.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--color-white) 90%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    border-bottom: var(--border-width) solid var(--color-border);
    transition: background-color 250ms ease, border-color 250ms ease;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .site-header { background: var(--color-white); }
}

.navbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-4);
    max-width: var(--container-max);
    min-height: var(--header-h);
    margin: 0 auto;
    padding: var(--space-2) var(--space-6);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    justify-self: start;
    border-radius: var(--radius);
    color: var(--color-text);
}

/* base.css gives img max-width: 100%, which drops the logo from the brand's
   minimum width; without this the name slides under the header buttons. */
.navbar-logo {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    object-fit: contain;
}

/* A wordmark, so fixed px: the accessibility text slider would otherwise
   push the header wider than a small phone. */
.brand__name {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.brand__sub {
    display: block;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--color-text-soft);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* The header links and buttons are fixed px like the wordmark: at the larger
   accessibility text sizes the row would run into the logo and Sign in. The
   phone menu still grows with the text. */
.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 15.68px;
    font-weight: 500;
    color: var(--color-text-mid);
    white-space: nowrap;
    transition: color 180ms ease, background-color 180ms ease;
}

.nav-link:hover {
    background: color-mix(in srgb, var(--color-text) 6%, transparent);
    color: var(--color-text);
}

.nav-link.active {
    color: var(--color-primary-dark);
    font-weight: 600;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    right: 12px;
    bottom: 6px;
    left: 12px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.nav-watch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    margin-left: var(--space-2);
    padding: 0 14px 0 8px;
    border-radius: 999px;
    color: var(--color-primary-dark);
    font-size: 15.68px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 180ms ease;
}

/* A plain link with a small play disc, like the links beside it; only the
   hover and the current page get the same faint wash as a nav link. */
.nav-watch:hover,
.nav-watch.active { background: color-mix(in srgb, var(--color-text) 6%, transparent); }

.nav-watch__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary-dark);
    color: var(--color-white);
    transition: transform 220ms var(--ease-out);
}

.nav-watch:hover .nav-watch__icon { transform: scale(1.08); }

/* No nudge: the triangle's centroid already sits on the viewBox centre, so a
   margin only pushes it off the middle of the disc. */
.nav-watch__icon svg {
    width: 10px;
    height: 10px;
}

.site-header--overlay:not(.is-scrolled) .nav-watch {
    color: var(--color-white);
    text-shadow: 0 1px 3px rgba(12, 26, 18, 0.6);
}

.site-header--overlay:not(.is-scrolled) .nav-watch:hover { background: rgba(255, 255, 255, 0.16); }

@media (max-width: 1080px) {
    .nav-watch {
        min-height: 60px;
        margin: var(--space-5) 0 0;
        padding: 0 var(--space-5) 0 10px;
        border-radius: var(--radius-card);
        font-size: var(--text-base);
    }

    .nav-watch__icon {
        width: 40px;
        height: 40px;
    }

    /* Keeps the glyph at the same share of the disc as on desktop. */
    .nav-watch__icon svg {
        width: 17px;
        height: 17px;
    }
}

.nav-dropdown { position: relative; }

.nav-dropdown__caret {
    width: 10px;
    height: 6px;
    transition: transform 220ms var(--ease-out);
}

.nav-dropdown.is-open .nav-dropdown__caret { transform: rotate(180deg); }

.nav-dropdown__menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    z-index: 120;
    display: flex;
    flex-direction: column;
    min-width: 210px;
    padding: var(--space-2);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-white);
    box-shadow: var(--shadow-lift);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -6px);
    transition: opacity 180ms ease, transform 220ms var(--ease-out), visibility 0s linear 220ms;
}

.nav-dropdown__menu::before {
    content: '';
    position: absolute;
    inset: -10px 0 auto;
    height: 10px;
}

.nav-dropdown.is-open .nav-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition-delay: 0s;
}

.nav-dropdown__link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 var(--space-4);
    border-radius: var(--radius);
    font-size: 15.68px;
    font-weight: 500;
    color: var(--color-text-mid);
    white-space: nowrap;
    transition: background-color 150ms ease, color 150ms ease;
}

.nav-dropdown__link:hover {
    background: var(--color-primary-tint);
    color: var(--color-primary-dark);
}

.nav-dropdown__link.active {
    color: var(--color-primary-dark);
    font-weight: 600;
}

.navbar-right {
    display: flex;
    align-items: center;
    justify-self: end;
    gap: var(--space-2);
}

.nav-signin {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px 0 12px;
    border: 1.5px solid color-mix(in srgb, var(--color-primary-dark) 45%, transparent);
    border-radius: 999px;
    font-size: 15.68px;
    font-weight: 600;
    color: var(--color-primary-dark);
    white-space: nowrap;
    transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.nav-signin:hover {
    border-color: var(--color-primary-dark);
    background: var(--color-primary-dark);
    color: var(--color-white);
}

.nav-signin svg {
    width: 18px;
    height: 18px;
}

.nav-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    color: var(--color-text-mid);
    transition: background-color 180ms ease, color 180ms ease;
}

.nav-icon-btn:hover {
    background: color-mix(in srgb, var(--color-text) 7%, transparent);
    color: var(--color-text);
}

.nav-icon-btn svg {
    width: 20px;
    height: 20px;
}

.nav-toggle {
    display: none;
    align-items: center;
    gap: var(--space-2);
    min-height: 42px;
    padding: 0 var(--space-4);
    border: 1.5px solid var(--color-border-strong);
    border-radius: 999px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
}

.nav-toggle__icon {
    position: relative;
    width: 18px;
    height: 12px;
}

.nav-toggle__icon span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 260ms var(--ease-out), opacity 150ms ease;
}

.nav-toggle__icon span:nth-child(1) { top: 0; }
.nav-toggle__icon span:nth-child(2) { top: 5px; }
.nav-toggle__icon span:nth-child(3) { top: 10px; }

.nav-toggle[aria-expanded="true"] .nav-toggle__icon span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle__icon span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.site-header--overlay {
    position: fixed;
    right: 0;
    left: 0;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom-color: transparent;
}

.site-header--overlay::before {
    content: '';
    position: absolute;
    inset: 0 0 auto;
    height: 190px;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(12, 26, 18, 0.7) 0%,
        rgba(12, 26, 18, 0.42) 32%,
        rgba(12, 26, 18, 0.14) 64%,
        rgba(12, 26, 18, 0) 100%
    );
    transition: opacity 250ms ease;
}

.site-header--overlay .navbar {
    position: relative;
    z-index: 1;
}

.site-header--overlay.is-scrolled {
    background: color-mix(in srgb, var(--color-white) 90%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    border-bottom-color: var(--color-border);
}

.site-header--overlay.is-scrolled::before { opacity: 0; }

.site-header--overlay:not(.is-scrolled) :is(.brand, .nav-link, .nav-signin, .nav-icon-btn, .nav-toggle) {
    color: var(--color-white);
    text-shadow: 0 1px 3px rgba(12, 26, 18, 0.6);
}

.site-header--overlay:not(.is-scrolled) .brand__sub { color: rgba(255, 255, 255, 0.88); }
.site-header--overlay:not(.is-scrolled) .navbar-logo { filter: drop-shadow(0 1px 4px rgba(12, 26, 18, 0.45)); }

.site-header--overlay:not(.is-scrolled) :is(.nav-link, .nav-icon-btn):hover { background: rgba(255, 255, 255, 0.16); }

.site-header--overlay:not(.is-scrolled) .nav-signin,
.site-header--overlay:not(.is-scrolled) .nav-toggle { border-color: rgba(255, 255, 255, 0.75); }

.site-header--overlay:not(.is-scrolled) .nav-signin:hover {
    border-color: var(--color-white);
    background: var(--color-white);
    color: var(--color-primary-dark);
    text-shadow: none;
}

@media (max-width: 1080px) {
    .navbar {
        display: flex;
        gap: var(--space-2);
    }

    .brand { margin-right: auto; }

    .nav-toggle { display: inline-flex; }

    /* A backdrop filter would make the header the box the fixed menu sizes against. */
    .nav-open .site-header,
    .nav-open .site-header--overlay.is-scrolled {
        background: var(--color-white);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .nav-links {
        position: fixed;
        top: var(--header-h);
        right: 0;
        bottom: 0;
        left: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: var(--space-2) var(--space-5) var(--space-8);
        overflow-y: auto;
        overscroll-behavior: contain;
        border-top: var(--border-width) solid var(--color-border);
        background: var(--color-white);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity 220ms ease, transform 300ms var(--ease-out), visibility 0s linear 300ms;
    }

    .nav-links.is-open {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition-delay: 0s;
    }

    /* Every destination is one row of the same list, whether or not it sits
       under a group. */
    /* No rules between rows: the section labels and the row rhythm carry the
       grouping, and a line under every item only added noise. */
    .nav-links > .nav-link,
    .nav-dropdown__link {
        width: 100%;
        min-height: 52px;
        padding: 0 var(--space-3);
        border-bottom: 0;
        border-radius: 10px;
        font-size: var(--text-base);
    }

    .nav-link.active::after { display: none; }

    /* A single, unmistakable "you are here": a tinted pill, no extra indent so
       the label does not shift when it becomes current. */
    .nav-links > .nav-link.active,
    .nav-dropdown__link.active {
        background: var(--color-primary-tint);
        color: var(--color-primary-dark);
        font-weight: 600;
    }

    /* Group names are not tappable, so they read as quiet section labels
       rather than links the same size as the real destinations. */
    .nav-dropdown__trigger,
    .nav-dropdown__trigger.active {
        width: 100%;
        min-height: 0;
        margin-top: var(--space-5);
        padding: 0 var(--space-3) var(--space-2);
        border-bottom: 0;
        border-radius: 0;
        font-size: var(--text-xs);
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--color-text-soft);
        pointer-events: none;
    }

    /* A small step after a group so its last link does not run into the next row. */
    .nav-dropdown + .nav-link { margin-top: var(--space-2); }

    .nav-dropdown__caret { display: none; }

    .nav-dropdown .nav-dropdown__menu,
    .nav-dropdown.is-open .nav-dropdown__menu {
        position: static;
        min-width: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: none;
        box-shadow: none;
        opacity: 1;
        /* Not visible: that would keep the links clickable under a closed menu. */
        visibility: inherit;
        transform: none;
        transition: none;
    }

    .nav-dropdown__menu::before { display: none; }
}

@media (max-width: 560px) {
    .navbar { padding: var(--space-2) var(--space-4); }
    .navbar-logo { width: 38px; height: 38px; }
    .brand { gap: var(--space-2); }
    .brand__name { font-size: 15px; }
    .brand__sub { font-size: 12px; }

    .nav-signin {
        width: 42px;
        padding: 0;
        justify-content: center;
    }

    .nav-signin span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .nav-toggle { padding: 0 var(--space-3); }
}

/* Set by layout.js when the full header does not fit. */
.navbar--compact .nav-toggle {
    width: 42px;
    padding: 0;
    justify-content: center;
}

.navbar--compact .nav-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
