/* Header Component Styles */
/* Consolidates all header-related styling across the application */

/* === BASE HEADER STYLES === */
.app-header {
    background-color: var(--color-ivey-green);
    color: var(--color-white);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
}

/* Header Navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-nav:first-child {
    justify-content: flex-start;
    min-width: 80px; /* Ensure space for logo */
}

/* Header Title */
.header-title {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: none;
    font-variant: normal;
    /* Always center the title relative to the header */
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

/* Make header title links invisible */
.header-title a {
    color: inherit;
    text-decoration: none;
}

.header-title a:hover,
.header-title a:focus {
    color: inherit;
    text-decoration: none;
}

/* Header Title Inline Logo Styles */
.header-title .inline-transformed-iv {
    display: inline-block;
    position: relative;
    line-height: 1;
    white-space: nowrap;
    font-family: var(--font-logo);
    font-weight: var(--font-weight-medium);
    color: inherit;
    font-size: 1em;
    vertical-align: baseline;
    margin: 0 0.1em;
}

.header-title .merged-initials-wrapper-inline {
    display: inline-block;
    transform-origin: center center;
    transform-style: preserve-3d;
    transform: rotateZ(-270deg) rotateX(180deg);
}

.header-title .initial-i-inline {
    display: inline-block;
    margin-right: -0.15em;
    opacity: 1;
    transform: none;
}

.header-title .initial-v-inline {
    display: inline-block;
    opacity: 1;
    transform: none;
}

/* Header Navigation Links */
.back-link, 
.graph-link {
    color: var(--color-white);
    text-decoration: none;
    text-transform: uppercase;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-link {
    visibility: visible;
}

.back-link:hover,
.back-link:focus,
.graph-link:hover,
.graph-link:focus {
    opacity: 0.85;
}

/* === USER MENU COMPONENT === */
.user-menu {
    display: flex;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.user-info span {
    color: var(--color-white);
    font-weight: 500;
    font-size: 0.9rem;
}

.account-link {
    background: transparent;
    border: none;
    color: var(--color-white);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    gap: 0.375rem;
}

.account-link:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-turquoise);
}

.sign-out-btn {
    background: transparent;
    border: none;
    color: var(--color-white);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sign-out-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-turquoise);
}


/* === USER PROGRESS COMPONENT === */
.user-progress {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--color-white);
}

/* === GRAPH-SPECIFIC HEADER OVERRIDES === */
/* Graph page uses standard header styling with minimal overrides */
.graph-page .header-nav:last-child {
    justify-content: flex-end;
    min-width: 0;
    flex-shrink: 0;
}

.graph-page .user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-shrink: 0;
}

.graph-page .user-progress {
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .app-header {
        padding: var(--space-3) var(--space-4);
    }
    
    .header-nav {
        gap: var(--space-4);
    }
    
    .header-title {
        font-size: var(--font-size-md);
        /* Allow the title to occupy remaining space and truncate safely */
        flex: 1 1 auto;
        text-align: center;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Hide the right-side header nav (user menu) on tablet and below */
    .app-header > .header-nav:last-child {
        display: none;
    }

    /* Hide first left-nav link (Home) when crowded; keep Learning Graph */
    .app-header > .header-nav:first-child .graph-link:first-child {
        display: none;
    }
    
    .user-info {
        padding: var(--space-1) var(--space-2);
        gap: var(--space-2);
    }
    
    .user-info span {
        font-size: var(--font-size-xs);
    }
}

/* Graph page uses standard responsive header styling */

@media (max-width: 480px) {
    .header-nav {
        gap: var(--space-2);
    }
    
    .user-info span {
        display: none; /* Hide username on very small screens */
    }
    
    /* Ensure graph page user progress stays visible on mobile */
    .graph-page .user-progress {
        font-size: var(--font-size-xs);
    }
}

/* Icon-only fallback for Learning Graph link when header collapses */
@media (max-width: 768px) {
    /* Convert second left-nav link (Learning Graph) to icon-only, keep accessible name in DOM */
    .app-header > .header-nav:first-child .graph-link:last-child {
        font-size: 0;      /* visually hide text */
        gap: 0;            /* remove space next to icon */
    }
    .app-header > .header-nav:first-child .graph-link:last-child i {
        font-size: 1.1rem; /* keep icon visible */
    }
}
