/*
    LCC custom navbar skin
    ————————————————————————
    Ported from theelevate.network's elevate-nav.css and rethemed to the
    Lytham Chess Club gold palette (#ffbd21 / #b8860b) with Montserrat.

    Purpose:
        - Floating hamburger at top-right across all viewports
        - Top-sheet 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.
        - Users with prefers-reduced-motion get an instant toggle (the JS
          short-circuits its GSAP timeline; CSS transitions are also
          suppressed in the reduced-motion media query below).

    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 and outside-click close the menu and restore focus
          to the toggle.
        - `.skip-link` is visually hidden until focused.
        - `aria-current="page"` is styled identically to `.nav-link.active`.
*/

/* Skip link — visible only when keyboard-focused */
.skip-link {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.skip-link:focus {
    position: fixed;
    left: 1rem;
    top: 1rem;
    width: auto;
    height: auto;
    padding: 0.75rem 1rem;
    background: var(--lcc-gold);
    color: #000;
    font-family: "Montserrat", sans-serif;
    font-weight: 600;
    text-decoration: none;
    z-index: 2000;
    border-radius: 4px;
    outline: 3px solid var(--lcc-gold-dark);
    outline-offset: 2px;
}

/* 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 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: transparent;
    box-shadow: none;
    z-index: 1000;
    transition: all 0.3s ease;
    padding: 0;
    font-family: "Montserrat", sans-serif;
}

/* 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; }
.nav-logo-link {
    color: #1a202c;
    text-decoration: none;
    font-weight: 700;
}

/* Universal mobile-style menu (base defaults) */
.nav-menu {
    position: fixed;
    left: 0; /* mobile baseline - overridden on desktop */
    top: 0;
    width: 100%;
    height: min(70vh, 520px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    background-color: #ffffff;
    text-align: center;
    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;
    z-index: 1100;
    font-family: "Montserrat", sans-serif;
    will-change: transform, opacity;
}

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

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

.nav-link:hover,
.nav-link:focus-visible { color: var(--lcc-gold-dark); }

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

.nav-link:hover::after,
.nav-link:focus-visible::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;
}

.nav-toggle:focus-visible {
    outline: 3px solid var(--lcc-gold-dark);
    outline-offset: 2px;
    border-radius: 6px;
}

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

/* Active nav link styles (both class-based and aria-current="page") */
.nav-link.active,
.nav-link[aria-current="page"] { color: var(--lcc-gold-dark) !important; }
.nav-link.active::after,
.nav-link[aria-current="page"]::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 {
        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;
        transform: none;
    }

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

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

    .nav-menu .nav-link:hover,
    .nav-menu .nav-link:focus-visible {
        background: rgba(255, 189, 33, 0.18);
    }
}

/* On small/medium screens, keep the off-canvas initial state to avoid flash */
@media screen and (max-width: 991.98px) {
    .nav-menu {
        min-height: 10vh;
        height: auto;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateY(-100%);
        opacity: 0;
    }
}

/* Backdrop to focus content without fully covering it */
.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    backdrop-filter: blur(0px);
    z-index: 1099;
}

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

/* Suppress CSS transitions for users who prefer reduced motion.
   GSAP-driven motion is short-circuited separately in elevate-nav.js. */
@media (prefers-reduced-motion: reduce) {
    .navbar,
    .nav-link,
    .nav-link::after,
    .bar {
        transition: none !important;
    }
}
