/* ============================================
   TICKER BAR
   ============================================ */
.ticker-bar {
    background: var(--charcoal);
    color: var(--ink-light);
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    overflow: hidden;
    height: 32px;
    display: flex;
    align-items: center;
    position: relative;
}

.ticker-bar__label {
    background: var(--sage);
    color: #fff;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    font-weight: 600;
    white-space: nowrap;
    z-index: 2;
    position: relative;
}

.ticker-bar__track {
    display: flex;
    animation: ticker 40s linear infinite;
    white-space: nowrap;
}

.ticker-bar__item {
    padding: 0 40px;
    white-space: nowrap;
    opacity: 0.85;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
}

a.ticker-bar__item:hover {
    opacity: 1;
    color: var(--sage);
}

.ticker-bar__item::before {
    content: '\25C6';
    margin-right: 12px;
    color: rgba(255,255,255,0.4);
    font-size: 0.5em;
    vertical-align: middle;
}

@keyframes ticker {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ============================================
   TOP NAV
   ============================================ */
.top-nav {
    background: transparent;
    border-bottom: none;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    padding: 10px 0;
}

.top-nav .container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.top-nav__date {
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

.top-nav__links {
    display: flex;
    gap: 20px;
    list-style: none;
}

.top-nav__links a {
    color: var(--ink-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.top-nav__links a:hover { color: var(--accent); }

/* Hide Advertise from top nav — it belongs in the main nav CTA only */
.top-nav__links li:has(a[href*="advertise"]) { display: none; }

/* ============================================
   MASTHEAD
   ============================================ */
.masthead {
    text-align: center;
    padding: 5px 0 12px;
    background: transparent;
    position: relative;
}

.masthead__subtitle {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: var(--ink-muted);
    margin-bottom: 8px;
}

.masthead__logo {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.masthead__logo-img {
    width: 80px;
    height: auto;
    opacity: 0.9;
}

.masthead__title {
    font-family: var(--font-masthead);
    font-size: clamp(2.2rem, 6vw, 3.8rem);
    font-weight: 700;
    line-height: 1;
    color: var(--ink-light);
    margin-bottom: 6px;
    cursor: default;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.masthead__tagline {
    font-family: var(--font-headline);
    font-style: italic;
    font-size: 1rem;
    color: var(--ink-muted);
    letter-spacing: 0.02em;
}

/* Mobile: hide masthead and top-nav — brand lives in the nav bar instead */
@media (max-width: 768px) {
    .top-nav,
    .masthead,
    .masthead + .rule,
    hr.rule--thick { display: none !important; }
}

.masthead__edition {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    font-family: var(--font-ui);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-muted);
}

.masthead__edition span { white-space: nowrap; }
.masthead__edition .dot { color: var(--sage); }

/* ============================================
   MAIN NAV
   ============================================ */
.main-nav {
    background: var(--paper);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow 0.3s, background 0.3s;
    height: 52px;
}

.main-nav .container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 100%;
}

.main-nav.is-scrolled {
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    background: rgba(255, 255, 255, 0.98);
}

.main-nav__list {
    display: flex;
    align-items: center;
    list-style: none;
    gap: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.main-nav__link {
    display: block;
    padding: 14px 16px;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink);
    position: relative;
    transition: color 0.2s;
    white-space: nowrap;
}

.main-nav__link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: var(--sage);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform: translateX(-50%);
}

.main-nav__link:hover { color: var(--accent); }
.main-nav__link:hover::after { width: 100%; }

.main-nav .current-menu-item .main-nav__link,
.main-nav .current_page_item .main-nav__link { color: var(--accent); }
.main-nav .current-menu-item .main-nav__link::after,
.main-nav .current_page_item .main-nav__link::after { width: 100%; }

/* Nav advertise CTA — right side */
.main-nav__cta {
    position: absolute;
    right: var(--gutter);
    font-family: var(--font-ui);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fff;
    background: var(--sage-dark);
    padding: 6px 16px;
    border-radius: 3px;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.main-nav__cta:hover {
    background: var(--charcoal);
    color: #fff;
}

/* Nav brand — invisible on desktop until compact mode (masthead serves as brand above) */
.main-nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    position: absolute;
    left: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.main-nav__brand-icon {
    height: 28px;
    width: auto;
    opacity: 0.85;
}

.main-nav__brand-name {
    font-family: var(--font-masthead);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-light);
    white-space: nowrap;
}

/* ============================================
   COMPACT HEADER ON SCROLL
   ============================================ */
body.header-compact .ticker-bar,
body.header-compact .top-nav,
body.header-compact .masthead,
body.header-compact .masthead + .rule {
    display: none;
}


/* Show brand in compact mode — masthead is hidden so nav carries the identity */
body.header-compact .main-nav__brand {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* Single posts: always show brand (no masthead above on single) */
.single .main-nav__brand {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

body.header-compact .main-nav {
    border-top: 1px solid var(--rule);
    transition: border-top 0.3s ease;
}

/* ============================================
   DROPDOWN SUB-MENUS
   ============================================ */
.main-nav__list .menu-item-has-children {
    position: relative;
}

.main-nav__list .menu-item-has-children > a::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid currentColor;
    margin-left: 6px;
    vertical-align: middle;
    opacity: 0.5;
}

.main-nav__list .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    min-width: 200px;
    padding: 8px 0;
    list-style: none;
    z-index: 200;
}

.main-nav__list .menu-item-has-children:hover > .sub-menu {
    display: block;
}

.main-nav__list .sub-menu .main-nav__link {
    padding: 10px 20px;
    font-size: 0.75rem;
    display: block;
    white-space: nowrap;
}

.main-nav__list .sub-menu .main-nav__link::after {
    display: none;
}

.main-nav__list .sub-menu .main-nav__link:hover {
    background: var(--paper-dark);
}

/* ============================================
   MOBILE NAV TOGGLE
   ============================================ */
/* Desktop: hidden by default; only shown at the mobile breakpoint below. */
.nav-toggle--mobile { display: none; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    padding: 12px;
    cursor: pointer;
}

.nav-toggle__bar {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--ink);
    margin: 5px 0;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.2s ease;
    transform-origin: center;
}

/* ============================================
   RESPONSIVE HEADER
   ============================================ */
@media (max-width: 768px) {
    /* Prevent horizontal scroll — use clip not hidden to avoid breaking position:sticky */
    html { overflow-x: clip; }
    body { overflow-x: clip; max-width: 100vw; }

    /* Hide ticker bar on mobile */
    .ticker-bar { display: none; }

    .main-nav {
        padding: 0;
        height: 56px;
        border-top: none;
        border-bottom: 1px solid var(--rule);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 500;
        transform: none;
        will-change: auto;
        background: var(--paper);
    }

    /* Push page content below the fixed nav bar */
    body { padding-top: 56px; }

    .main-nav .container {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        height: 56px;
    }

    /* Hide the desktop nav-toggle stub that lives inside .main-nav */
    .main-nav .nav-toggle { display: none; }

    /* ---------- Hamburger / close toggle ---------- */
    .nav-toggle--mobile {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 6px;
        right: 16px;
        width: 44px;
        height: 44px;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        z-index: 501;
        -webkit-tap-highlight-color: transparent;
    }

    .nav-toggle--mobile:focus-visible {
        outline: 2px solid var(--ink);
        outline-offset: 2px;
    }

    /* Animate three bars into an X when expanded */
    .nav-toggle--mobile[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .nav-toggle--mobile[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
        opacity: 0;
    }
    .nav-toggle--mobile[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* ---------- Slide-in panel ---------- */
    .main-nav__list {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        top: 56px;
        right: 0;
        left: auto;
        width: 300px;
        max-width: 85vw;
        height: calc(100vh - 56px);
        background-color: #ffffff;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
        padding: 0;
        margin: 0;
        list-style: none;
        z-index: 499;
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        overflow-x: hidden;
    }

    .main-nav__list.is-open {
        transform: translateX(0);
    }

    /* ---------- Backdrop ---------- */
    .nav-backdrop {
        display: block;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 498;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    }

    .nav-backdrop.is-open {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.3s ease, visibility 0s linear 0s;
    }

    /* ---------- Menu links ---------- */
    .main-nav__link {
        padding: 16px 24px;
        border-bottom: 1px solid var(--rule);
        text-align: left;
    }

    .main-nav__link:focus-visible {
        outline: 2px solid var(--ink);
        outline-offset: -2px;
    }

    .main-nav__link::after { display: none; }

    /* Reset desktop centering — mobile panel is a slide-in column */
    .main-nav__list {
        justify-content: flex-start;
        width: 300px;
        max-width: 85vw;
        left: auto;
    }

    /* Sub-menus on mobile */
    .main-nav__list .sub-menu {
        position: static;
        transform: none;
        display: block;
        border: none;
        box-shadow: none;
        min-width: auto;
        padding: 0;
        background: var(--paper-dark);
    }

    .main-nav__list .sub-menu .main-nav__link {
        padding-left: 40px;
        font-size: 0.75rem;
    }

    .main-nav__list .menu-item-has-children > a::after {
        display: none;
    }

    .main-nav__cta { display: none; }

    /* Brand always visible on mobile, in-flow (overrides desktop absolute + hidden) */
    .main-nav__brand {
        opacity: 1 !important;
        visibility: visible !important;
        transition: none !important;
        position: static !important;
        left: auto !important;
        margin-right: auto;
        order: -1;
        gap: 8px;
        align-items: center;
    }
    .main-nav__brand-icon { height: 22px; width: auto; opacity: 0.85; }
    .main-nav__brand-name { font-size: 0.9rem; letter-spacing: 0.15em; line-height: 1; }

    /* Hide the thick rule under masthead to prevent double line */
    hr.rule--thick {
        display: none !important;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .main-nav__list,
    .nav-backdrop,
    .nav-toggle__bar {
        transition: none;
    }
}
