/**
 * Sticky Sub-navigation Component
 *
 * Sits immediately after the hero section in the DOM. CSS position:sticky
 * causes it to adhere to the viewport top once the hero scrolls fully away —
 * no JavaScript required for the sticky behaviour itself.
 *
 * JavaScript (script.js) handles:
 *   - Building nav links from [data-subnav-section] elements
 *   - Active-section highlighting via IntersectionObserver
 */

/* ── Base ─────────────────────────────────────────────────────────────────── */

.sticky-subnav {
    display: none;
    position: sticky;
    top: 0;
    z-index: var(--z-index-sticky-subnav, 200);
    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.06);
}

/* Hide entirely when JS hasn't populated any links */
.sticky-subnav:has(.sticky-subnav__list:empty) {
    display: none;
}

/* ── Inner scroll wrapper (allows horizontal scroll on narrow viewports) ──── */

.sticky-subnav__inner {
    max-inline-size: var(--container-max-width, 80rem);
    margin-inline: auto;
    padding-inline: var(--spacing-6, 1.5rem);
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sticky-subnav__inner::-webkit-scrollbar {
    display: none;
}

/* ── Link list ────────────────────────────────────────────────────────────── */

.sticky-subnav__list {
    display: flex;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.sticky-subnav__list:empty {
    display: none;
}

.sticky-subnav__item {
    flex-shrink: 0;
}

/* ── Links ────────────────────────────────────────────────────────────────── */

.sticky-subnav__link {
    display: block;
    padding-block: var(--spacing-4, 1rem);
    padding-inline: var(--spacing-5, 1.25rem);
    font-family: var(--font-family-sans);
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    text-decoration: none;

    /* Active indicator — bottom border, matches the element height */
    border-block-end: 3px solid transparent;
    transition:
        color 0.2s ease,
        border-color 0.2s ease;
}

.sticky-subnav__link:hover {
    color: var(--color-primary);
}

.sticky-subnav__link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
    border-radius: 2px;
    color: var(--color-primary);
}

/* Active state — set by JS via IntersectionObserver */
.sticky-subnav__link.is-active,
.sticky-subnav__link[aria-current="location"] {
    color: var(--color-primary);
    border-block-end-color: var(--color-primary);
}

/* ── Reduced-motion: disable transitions ─────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .sticky-subnav__link {
        transition: none;
    }
}
