/* Navbar styles
   The site header: a navy bar in both themes with a brand-red cap on top
   and a thinner red rule along the bottom. Desktop shows two rows (brand
   and account pills, then the module pills); at 960px and below the rows
   collapse into the hamburger and its full-screen slide-out. Spliced into
   <head> after every other stylesheet by init.php, so equal-specificity
   rules here win over Bootstrap and includes/styles.css. */

/* Header height. The navbar script measures the header with a
   ResizeObserver and overwrites this on <html>; these are only the
   one-row heights (168px desktop, 84px collapsed) used before it runs
   or without JS. */
:root {
    --nav-h: 10.5rem;
}
@media (max-width: 960px) {
    :root {
        --nav-h: 5.25rem;
    }
}

/* Skip link: the first focusable element on every page with the navbar
   (navbar.php, also tagged .visually-hidden-focusable for Bootstrap).
   Hidden until focused, then a primary-fill tab at the top-left above
   everything, with a white-and-navy ring that reads on the navy chrome
   and on light content. It jumps to #content-start, the empty anchor
   right after the header. */
.skip-link {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: calc(var(--z-toast, 1090) + 10);
    padding: 0.65rem 1.1rem;
    border-radius: var(--r-sm, 8px);
    background: var(--primary-fill, #3A6FA8);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--elev-3, 0 10px 30px rgba(40, 50, 75, 0.12));
    /* Appear at once: the global 'a { transition: all }' would grow it out
       of the 1px clip. */
    transition: none;
}
.skip-link:not(:focus):not(:focus-within) {
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    box-shadow: none;
}
.skip-link:focus,
.skip-link:focus-visible {
    color: #fff;
    text-decoration: underline;
    outline: 2px solid #fff;
    outline-offset: 0;
    box-shadow: 0 0 0 4px var(--brand-navy, #0c1929), var(--elev-3, 0 10px 30px rgba(40, 50, 75, 0.12));
}
/* Embedded iframe views hide the header; the skip link goes with it. */
body.admin-embedded .skip-link,
body.sched-embedded .skip-link {
    display: none;
}
@media print {
    .skip-link {
        display: none;
    }
}
/* The skip target is an empty, script-focusable anchor: no ring. */
.skip-target {
    display: block;
    height: 0;
}
.skip-target:focus {
    outline: none;
}

/* Header container: the one stickiness rule for the whole site. The
   header sits in normal flow at the top of the document and scrolls
   away with the page (the class name is historical; navbar.php's
   scripts and init.php's footer injector look for it). */
.sticky-header {
    position: relative;
    flex-shrink: 0;
    z-index: 1000;
    background: transparent;
}

/* ---------- The bar ----------
   Near-black shades of the brand navy in BOTH themes (the owner wanted
   the light-mode bar to match dark mode, 2026-10-16), with the brand-red
   cap (--brand-red-deep follows the admin site colour) and a thinner red
   rule where the bar meets the page. */
.navbar {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--brand-navy, #0c1929) 15%, #000) 0%,
        color-mix(in srgb, var(--brand-navy, #0c1929) 45%, #000) 70%,
        color-mix(in srgb, var(--brand-navy, #0c1929) 90%, #000) 100%);
    border-top: 5px solid color-mix(in srgb, var(--brand-red-deep, #902B20) 90%, transparent);
    border-bottom: 2px solid color-mix(in srgb, var(--brand-red-deep, #902B20) 55%, transparent);
    padding: 1rem 0;
    margin-bottom: 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
}

/* Measured with every module visible to an admin (11 links), the row
   needs a 1504px content box at the current pill size, so it fits on
   one row from a 1568px viewport up (1536px and 1600px with a Tasks
   count badge; the same thresholds as before the even padding). A
   1400px cap (1336px content, the page column) would wrap it at every
   width, so the bar keeps 1600px. */
.navbar-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.navbar-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1rem;
}

.navbar-top-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-bottom {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 2rem;
    width: 100%;
    padding: 0.35rem 0;
}

/* Brand: the site icon (coloured inline from the admin setting) and the
   site name. The name ellipsizes rather than pushing the hamburger off a
   narrow screen; the link keeps the full name as its accessible text. */
.navbar-brand {
    font-size: 2.1rem;
    font-weight: 700;
    /* The bar is navy in both themes, so the name is always light. */
    color: #F0F4FA;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    margin-right: 0;
    transition: all 0.3s ease;
}

/* Bootstrap turns a focused .navbar-brand black (its light-navbar
   default); keep the name light on the navy bar. */
.navbar-brand:focus {
    color: #F0F4FA;
}

/* Hover: the site colour lifted 55% toward white, like the hamburger
   glyph (the raw colour measured 2.7-3.0:1 on the light bar). */
.navbar-brand:hover {
    color: color-mix(in srgb, var(--site-color, #c0392b) 45%, #FFFFFF);
    text-decoration: none;
    transform: translateX(2px);
}

.navbar-brand i {
    font-size: 2.9rem;
    flex-shrink: 0;
}

.navbar-brand-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navbar-controls {
    display: none;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* The slide-out panel (shown at 960px and below). It is navy chrome
   too, and the toggle script moves it to <body> while it is open, out
   from under .navbar, so it re-declares the gold chrome focus ring. */
.navbar-nav {
    display: none;
    --focus-color: var(--focus-color-chrome);
    --focus-outline: 2px solid var(--focus-color-chrome);
    --focus-ring: 0 0 0 2px var(--brand-navy), 0 0 0 4px var(--focus-color-chrome);
}

.navbar-nav-desktop {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

/* ---------- Links (shared base) ----------
   Every navbar entry is a .nav-link. This base is the white pill with a
   slate label; the desktop rows and the slide-out refine it below. */
.nav-link {
    position: relative;
    color: #1A2740;
    background-color: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(26, 39, 64, 0.55);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1.1rem;
}

.nav-link i {
    font-size: 1.15rem;
}

.nav-link:hover {
    text-decoration: none;
}

.nav-link.active {
    font-weight: 600;
}

/* ---------- Desktop pills ----------
   Module row and account row share the .seg-tab shape (radius --r-md,
   even padding) and the active fill. Module pills: white in light,
   translucent primary in dark. Account pills (Admin/Manage, Profile,
   Logout, or Login / Sign Up): solid --primary-fill in both themes,
   white label at 5.2:1. */
.navbar-nav-desktop .nav-link,
.auth-buttons-desktop .nav-link {
    border-radius: var(--r-md, 12px);
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease,
                transform 0.2s ease, box-shadow 0.2s ease;
}

.navbar-nav-desktop .nav-link:hover {
    background: #F4F7FC;
    border-color: #FFFFFF;
    color: var(--primary-text);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] .navbar-nav-desktop .nav-link {
    background: color-mix(in srgb, var(--primary-soft) 26%, transparent);
    color: #E8F0FA;
    border-color: color-mix(in srgb, var(--primary-soft) 45%, transparent);
}
[data-theme="dark"] .navbar-nav-desktop .nav-link:hover {
    background: color-mix(in srgb, var(--primary-soft) 38%, transparent);
    border-color: color-mix(in srgb, var(--primary-soft) 65%, transparent);
    color: #FFFFFF;
}

.auth-buttons-desktop .nav-link {
    display: inline-flex;
    padding: 0.7rem 1.4rem;
    background: var(--primary-fill, #3A6FA8);
    color: #FFFFFF;
    border: 1.5px solid var(--primary-fill, #3A6FA8);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.005em;
    box-shadow: 0 4px 14px color-mix(in srgb, var(--primary-fill) 28%, transparent), 0 1px 3px rgba(0, 0, 0, 0.08);
}
.auth-buttons-desktop .nav-link:hover {
    background: var(--primary-fill-hover, #315E8F);
    border-color: var(--primary-fill-hover, #315E8F);
    color: #FFFFFF;
    transform: translateY(-2px);
    box-shadow: 0 10px 28px color-mix(in srgb, var(--primary-fill) 40%, transparent), 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* Active (aria-current="page"): the --primary-fill gradient with a white
   label, raised. Listed after the hover rules, with :hover variants, so
   hovering the current page's pill keeps it filled in both themes. */
.navbar-nav-desktop .nav-link.active,
.navbar-nav-desktop .nav-link.active:hover,
.auth-buttons-desktop .nav-link.active,
.auth-buttons-desktop .nav-link.active:hover {
    background: linear-gradient(135deg, var(--primary-fill, #3A6FA8) 0%, var(--primary-fill-hover, #315E8F) 100%);
    color: #FFFFFF;
    border-color: var(--primary-fill-hover, #315E8F);
    transform: translateY(-2px);
    box-shadow: 0 6px 14px color-mix(in srgb, var(--primary-soft) 22%, transparent),
                0 1px 3px color-mix(in srgb, var(--primary-soft) 12%, transparent);
}
/* The account pills already sit on the fill, so the current one also
   gets an inset white ring to tell it apart. */
.auth-buttons-desktop .nav-link.active,
.auth-buttons-desktop .nav-link.active:hover {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85),
                0 6px 14px color-mix(in srgb, var(--primary-soft) 22%, transparent);
}

.navbar-nav-desktop .nav-link i,
.auth-buttons-desktop .nav-link i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Account pills - desktop */
.auth-buttons-desktop {
    display: flex;
    gap: 0.5rem;
}

/* Account links - mobile (inside the slide-out) */
.auth-buttons-mobile {
    display: none;
}

/* ---------- Hamburger ----------
   The glyph is the site colour lifted 55% toward white: the raw colour
   measured 2.0-2.3:1 on its tint over the light bar, under the 3:1 a
   control's only glyph needs; the tint clears 5:1 in both themes for
   the live #E01B24 and the default #c0392b. */
.navbar-toggler {
    display: none;
    background: color-mix(in srgb, var(--site-color) 12%, transparent);
    border: 2px solid color-mix(in srgb, var(--site-color) 45%, transparent);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: color-mix(in srgb, var(--site-color, #c0392b) 45%, #FFFFFF);
    font-size: 1.25rem;
    transition: all 0.3s ease;
    /* 44px touch target (the padded icon alone measured about 37px). */
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}

.navbar-toggler:hover {
    background: color-mix(in srgb, var(--site-color) 20%, transparent);
    border-color: rgba(140, 170, 210, 0.6);
    color: color-mix(in srgb, var(--site-color, #c0392b) 45%, #FFFFFF);
}

/* ============================================================
   960px and below: brand + hamburger, links in the slide-out
   ============================================================ */
@media (max-width: 960px) {
    .navbar-container {
        flex-direction: column;
        gap: 0;
        padding: 0 1rem;
    }

    .navbar-controls {
        display: flex;
    }

    .navbar-toggler {
        /* grid centres the icon in the 44px minimum box */
        display: grid;
        place-items: center;
    }

    .navbar-top {
        margin-bottom: 0;
        width: 100%;
    }

    .navbar-bottom,
    .navbar-top-right,
    .navbar-nav-desktop {
        display: none;
    }

    .navbar-brand {
        font-size: 1.45rem;
    }

    .navbar-brand i {
        font-size: 2rem;
    }

    /* Full-screen overlay menu. Anchored below the navbar (top offset is
       set inline by the toggler script — measured live so it tracks any
       navbar height change), extends to the viewport bottom, and locks
       body scroll while open. Internal overflow handled by FLScrollbar
       (the same big-blue track used elsewhere on the site) — the toggler
       script calls FLScrollbar.init(navbarNav) on open, which wraps the
       children in .fl-scroll and adds .fl-scrollbar-track. */
    .navbar-nav.show {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: var(--mobile-menu-top, 64px);
        z-index: 999;
        margin-top: 0;
        /* Narrow side padding so the menu buttons (width: 100%) extend
           nearly edge-to-edge on a phone screen. */
        padding: 1rem 0.6rem 1.5rem;
        border-top: 1px solid rgba(120, 140, 180, 0.25);
        background: linear-gradient(180deg, rgba(70, 85, 110, 0.98) 0%, rgba(55, 70, 95, 0.97) 100%);
        backdrop-filter: blur(16px) saturate(1.3);
        -webkit-backdrop-filter: blur(16px) saturate(1.3);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
        /* FLScrollbar will swap this to overflow: hidden + an inner
           .fl-scroll once init runs. Pre-init, native scrolling still
           works so the menu is usable even if FLScrollbar fails to load. */
        overflow-y: auto;
    }

    [data-theme="dark"] .navbar-nav.show {
        background: linear-gradient(180deg, #02040A 0%, #060A16 100%);
        border-top-color: #1A2038;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    }

    /* Once FLScrollbar wraps the children, give the inner .fl-scroll the
       full height of the panel and reserve a gutter so the track doesn't
       sit on top of the last button. */
    .navbar-nav.show.fl-scrolled {
        overflow: hidden;
    }
    .navbar-nav.show.fl-scrolled > .fl-scroll {
        height: 100%;
        /* No side padding of its own: the panel's 0.6rem is the gap on
           both sides. When the track is showing (.fl-has-track, toggled by
           custom-scrollbar.js) a 26px right gutter clears it, so the space
           between a button and the track matches the space on the left.
           Mirroring the gutter on the left kept the pills geometrically
           centered but read as a fat empty margin next to the scrollbar. */
        padding-left: 0;
        padding-right: 0;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .navbar-nav.show.fl-scrolled.fl-has-track > .fl-scroll {
        padding-right: 26px;
    }

    /* Force every layer of the mobile menu hierarchy to stretch full
       width. Every selector here is !important + scoped to the overlay
       so it can't possibly leak into desktop styling. Without these
       overrides the buttons rendered at their content width and looked
       centered in the panel. */
    .navbar-nav.show,
    .navbar-nav.show > .fl-scroll,
    .navbar-nav.show ul,
    .navbar-nav.show li,
    .navbar-nav.show .auth-buttons-mobile {
        width: 100% !important;
        max-width: none !important;
        box-sizing: border-box !important;
        align-self: stretch !important;
    }
    .navbar-nav.show li {
        list-style: none;
        display: block;
    }
    .navbar-nav.show .nav-link {
        display: flex !important;
        width: 100% !important;
        max-width: none !important;
        box-sizing: border-box !important;
        align-self: stretch !important;
        /* Center icon + label horizontally so the button content sits in
           the middle on a tall, full-width pill. */
        justify-content: center;
        text-align: center;
    }

    /* The Learn / Schedule / Tools list lives in an unclassed <ul> inside
       .navbar-nav. Make it a flex column so the <li>s pick up the same
       gap as the auth-buttons-mobile row below them. */
    .navbar-nav > ul,
    .navbar-nav.show.fl-scrolled > .fl-scroll > ul {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav-link {
        width: 100%;
        text-align: left;
        justify-content: flex-start;
        padding: 0.65rem 1rem 0.65rem 1.25rem;
        font-size: 1rem;
    }

    /* Left-edge indicator: a site-colour bar, half height on hover and
       full height on the current page. */
    .nav-link::after {
        content: '';
        position: absolute;
        left: 0;
        top: 0.4rem;
        bottom: 0.4rem;
        width: 4px;
        background: var(--site-color);
        border-radius: 4px;
        transform: scaleY(0);
        transform-origin: center;
        opacity: 0;
        transition: transform 0.25s ease, opacity 0.2s ease;
    }

    .nav-link:hover::after {
        transform: scaleY(0.5);
        opacity: 0.55;
    }

    .nav-link.active::after {
        transform: scaleY(1);
        opacity: 1;
        transition: none; /* don't animate the indicator on initial render */
    }

    /* Active item gets the desktop active-pill treatment: the primary
       fill gradient and a white label in BOTH themes. Scoped to
       .navbar-nav (0,3,0) so it beats Bootstrap's `.navbar-nav
       .nav-link.active { color: var(--bs-navbar-active-color) }` (black)
       on source order — navbar.css is spliced in last in <head>. A bare
       .nav-link.active loses that. */
    .navbar-nav .nav-link.active {
        background: linear-gradient(135deg, var(--primary-fill, #3A6FA8) 0%, var(--primary-fill-hover, #315E8F) 100%);
        border-color: var(--primary-fill-hover, #315E8F);
        color: #FFFFFF;
    }

    /* Slide-out hover — light mode: the desktop light hover (pale pill,
       --primary-text label at 6.1:1). A site-colour label on a site-colour
       tint measured under 2:1. The half-height site-colour bar above
       stays as the hover cue. */
    .navbar-nav .nav-link:hover {
        background-color: #F4F7FC;
        border-color: rgba(26, 39, 64, 0.7);
        color: var(--primary-text);
        transform: translateY(-1px);
    }

    /* Slide-out hover — dark mode */
    [data-theme="dark"] .navbar-nav .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: #FFFFFF;
    }

    /* Keep the active pill filled on hover — both hover rules above would
       otherwise swap it back to a tint. Listed after them to win the tie. */
    .navbar-nav .nav-link.active:hover {
        background: var(--primary-fill-hover, #315E8F);
        border-color: var(--primary-fill-hover, #315E8F);
        color: #FFFFFF;
    }

    /* Slide-out tap feedback. Listed AFTER the :hover rules above —
       on touch devices both :hover and :active fire on tap, and identical
       specificity means later-in-source-order wins. Putting :active last
       guarantees the blue tap-highlight beats the hover sticky-state in
       both light and dark mode. */
    .navbar-nav .nav-link:active {
        background-color: var(--primary-light);
        color: var(--primary-soft);
    }
    [data-theme="dark"] .navbar-nav .nav-link:active {
        background-color: color-mix(in srgb, #5A8BC4 35%, transparent);
        color: #ffffff;
    }

    /* Hide desktop auth buttons on mobile */
    .auth-buttons-desktop {
        display: none;
    }

    /* Show mobile auth buttons in navbar */
    .auth-buttons-mobile {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-soft);
    }
}

/* Small phones: the site name scales with the screen (about 19.7px at
   375px, 15.4px at 320px) so the 44px hamburger always fits beside it;
   a longer name ellipsizes. vw counts a classic 15px scrollbar, so the
   slope leaves a few px of slack for narrow desktop windows. Above
   400px the 1.45rem name already fits. */
@media (max-width: 400px) {
    .navbar-top {
        gap: 0.75rem;
    }

    .navbar-brand {
        font-size: clamp(0.95rem, 7.8vw - 0.6rem, 1.45rem);
    }
}

/* Notification badge inside the Tasks nav-link */
.nav-task-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    margin-left: 0.25rem;
    border-radius: 999px;
    background: var(--danger-fill, #B03A2E);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

/* Trophy next to Profile: an unlocked achievement the user has not seen. */
.nav-ach-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; margin-left: 0.35rem; border-radius: 50%;
    background: linear-gradient(145deg, #ffe08a, #d4a017); color: #4a3300;
    font-size: 0.8rem; line-height: 1; vertical-align: middle;
    box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
    animation: navAchPulse 2.4s ease-in-out infinite;
}
.nav-ach-badge i { font-size: 0.8rem; margin: 0; }
@keyframes navAchPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .nav-ach-badge { animation: none; } }


/* ── Two-factor nudge (one-time banner under the navbar) ────────── */
.tfa-nudge {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    margin: 0.75rem auto 0; padding: 0.7rem 1rem; max-width: 1200px; width: calc(100% - 2rem);
    border-radius: 12px; background: var(--card-bg, #fff); color: var(--text-primary, #1f2937);
    border: 1px solid var(--border-soft, #e5e7eb); border-left: 4px solid var(--site-color, #c0392b);
    box-shadow: var(--shadow-medium, 0 4px 14px rgba(0,0,0,0.08)); font-size: 0.92rem; line-height: 1.4;
}
.tfa-nudge-icon { font-size: 1.5rem; color: var(--site-color, #c0392b); flex: none; }
.tfa-nudge-text { flex: 1 1 18rem; min-width: 0; }
.tfa-nudge-btn {
    display: inline-flex; align-items: center; gap: 0.35rem; flex: none;
    padding: 0.45rem 0.9rem; border-radius: 8px; font-weight: 700; text-decoration: none;
    background: var(--site-color, #c0392b); color: #fff;
}
.tfa-nudge-btn:hover { filter: brightness(1.08); color: #fff; }
.tfa-nudge-x {
    flex: none; width: 2rem; height: 2rem; border-radius: 8px; border: 1px solid var(--border-soft, #e5e7eb);
    background: transparent; color: var(--text-muted, #6b7280); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.tfa-nudge-x:hover { color: var(--text-primary, #1f2937); }
