/*
    Elevate custom navbar skin
    ————————————————————————
    Purpose:
        - Floating hamburger at top-right across all viewports
        - Full-screen overlay menu on small/medium screens
        - Compact panel at top-right on desktop (≥ 992px)

    Animation contract:
        - GSAP (in elevate-nav.js) owns all motion for open/close
            • Mobile: slide in/out using transform (xPercent)
            • Desktop: scale-pop (opacity + y + scale)
        - Avoid CSS transitions on properties animated by GSAP

    Accessibility contract:
        - The menu element uses the [hidden] attribute when closed
        - The toggle updates aria-expanded and aria-label between “Open menu”/“Close menu”
        - Escape key and outside click close the menu and restore focus to the toggle

    Notes:
        - Do not apply CSS-driven visibility/transform transitions for open/close
            (they will fight GSAP). Keep layout/positioning only.
        - Desktop overrides are in a min-width: 992px media query below.
*/

/* Global spacing token for page gutters */
:root {
    /* Collapsed floating nav: no reserved header height */
    --navbar-height: 0px;
    --page-gutter: clamp(12px, 3.5vw, 24px);
}

/* Navigation */
.navbar {
    /* Keep a fixed layer for positioning but make it non-blocking and invisible */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: transparent;
    box-shadow: none;
    z-index: 1000;
    transition: all 0.3s ease;
    padding: 0;
    /* Keep interactions enabled to avoid edge cases with children focus/AT */
}

/* Ensure the page content clears the fixed navbar height */
body { padding-top: var(--navbar-height); }

.nav-container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--navbar-height);
}

/* Hide the inline logo for the floating hamburger layout; re-enable later if desired */
.nav-logo { display: none; }


/* Universal mobile-style menu (base defaults) */
.nav-menu {
    position: fixed;
    left: 0; /* mobile baseline - overridden on desktop */
    top: 0;
    width: 100%;
    /* Less obtrusive: top-sheet style rather than full-screen */
    height: min(70vh, 520px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    background-color: #ffffff;
    text-align: center;
    /* No CSS transitions on properties animated by GSAP to avoid conflicts */
    box-shadow: 0 10px 27px rgba(0, 0, 0, 0.08);
    padding: max(64px, calc(16px + env(safe-area-inset-top, 0px))) 0 1rem 0; /* create top space */
    z-index: 1100;
    will-change: transform, opacity;
}

/* Ensure hidden attribute truly removes it for AT + layout when inactive */
.nav-menu[hidden] { display: none !important; }

/* Active state is handled by GSAP; class is retained for semantics */
/* .nav-menu.active { } */

.nav-link {
    text-decoration: none;
    color: #1a202c;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link:hover { color: #1e3a8a; }

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
    transition: width 0.3s ease;
}

.nav-link:hover::after { width: 100%; }

/* Floating hamburger toggle shown on all screen sizes */
.nav-toggle {
    position: fixed;
    top: max(24px, calc(env(safe-area-inset-top, 0px) + 24px));
    right: max(24px, calc(env(safe-area-inset-right, 0px) + 24px));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    padding: 14px;
    width: 64px;
    height: 64px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1101;
    pointer-events: auto; /* clickable despite navbar's pointer-events none */
}

.nav-toggle:focus-visible {
    outline: 3px solid #1e3a8a;
    outline-offset: 2px;
    border-radius: 6px;
}

.bar {
    width: 28px;
    height: 3px;
    background: #1a202c;
    margin: 4px 0;
    transition: 0.3s;
}

/* Active nav link styles */
.nav-link.active { color: #667eea !important; }
.nav-link.active::after { width: 100% !important; }

.nav-menu .nav-link {
        display: block;
        padding: 0.5rem 1rem;
}

/* Hamburger morph animation (always applies) */
.nav-toggle.active .bar:nth-child(2) { opacity: 0; }
.nav-toggle.active .bar:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav-toggle.active .bar:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

/* Desktop: compact menu panel at top-right */
@media screen and (min-width: 992px) {
    .nav-menu {
        /* hidden state off-canvas to the right */
        left: auto;
        right: 16px;
        top: 16px;
        width: min(360px, 90vw);
        height: auto;
        max-height: min(70vh, 720px);
        overflow-y: auto;
        border-radius: 16px;
        border: 1px solid rgba(0, 0, 0, 0.06);
        padding: 0.75rem;
        gap: 0.25rem;
        align-items: stretch;
        justify-content: flex-start;
        text-align: left;
        /* Ensure no off-canvas transform persists on desktop */
        transform: none;
    }

    .nav-menu[hidden] { display: none !important; }

    /* Active state visuals are animated by GSAP */
    /* .nav-menu.active { left: auto; right: 16px; } */

    .nav-menu .nav-link {
        border-radius: 8px;
        color: #0f172a;
    }

    .nav-menu .nav-link:hover {
        background: rgba(30, 58, 138, 0.08);
    }
}

/* On small/medium screens, keep the off-canvas initial state to avoid flash */
@media screen and (max-width: 991.98px) {
    .nav-menu {
        /* prepare for top-sheet slide-in from -100% Y (GSAP will own transforms) */
        min-height: 10vh;       /* floor */
        height: auto;           /* allow content to define height */
        max-height: 70vh;       /* ceiling */
        overflow-y: auto;       /* scroll if content exceeds */
        -webkit-overflow-scrolling: touch; /* smooth iOS scroll */
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* Backdrop to reduce obtrusiveness and focus content without covering fully */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.28); /* subtle slate overlay */
    backdrop-filter: blur(0px);
    z-index: 1099; /* just under the menu */
}

.nav-backdrop[hidden] { display: none !important; }
