/*
 * Meridian — Navigation & Header/Footer CSS
 *
 * Covers: sticky header, transparent header variant, minimal header,
 * mega menu, search overlay, mobile drawer, footer newsletter form,
 * social links, and utility icon buttons.
 */

/* =========================================================================
 * CSS Custom Properties — header-specific tokens
 * ====================================================================== */
:root {
        --meridian-header-height: 72px;
        --meridian-header-bg: var(--wp--preset--color--surface);
        --meridian-header-bg-transparent: transparent;
        --meridian-header-border: 1px solid var(--wp--preset--color--neutral-100);
        --meridian-header-shadow: 0 1px 24px rgba(15, 15, 15, 0.08);
        --meridian-header-z: 900;
        --meridian-overlay-z: 890;
}

/* =========================================================================
 * Site Header — outer sticky wrapper
 * ====================================================================== */

header.site-header {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        z-index: var(--meridian-header-z);
        background-color: var(--meridian-header-bg);
        border-bottom: var(--meridian-header-border);
        transition:
                background-color 0.25s ease,
                box-shadow 0.25s ease,
                border-color 0.25s ease;
}

/* Scrolled state — JS adds .is-scrolled */
header.site-header.is-scrolled {
        box-shadow: var(--meridian-header-shadow);
        border-bottom-color: transparent;
}

/* Admin bar offset */
.admin-bar header.site-header {
        top: 32px;
}

@media (max-width: 782px) {
        .admin-bar header.site-header {
                top: 46px;
        }
}

/* =========================================================================
 * Transparent header variant (for hero/lookbook pages)
 *
 * Fixed-position so it overlays the full-viewport hero image from y=0.
 * A dark gradient provides enough contrast for white nav links over any
 * background image. On scroll the gradient is swapped for a solid fill.
 * ====================================================================== */

header.site-header--transparent {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to bottom, rgba(15,15,15,0.60) 0%, rgba(15,15,15,0) 100%);
        border-bottom-color: transparent;
        box-shadow: none;
        /* Promote the header to its own GPU compositing layer so mobile
         * Safari doesn't lag repainting it while the address bar
         * collapses/expands during scroll (it would otherwise visually
         * "ghost" mid-viewport). IMPORTANT: do this with `will-change`
         * only — do NOT put an actual `transform` value (e.g.
         * translateZ(0)/translate3d(0,0,0)) on this element. iOS Safari has
         * a long-standing bug where a `transform` on a `position:fixed`
         * element makes it position relative to the *layout* viewport
         * instead of the *visual* viewport, so once the address bar
         * collapses the header renders a gap above it (looks "dropped"
         * down the page instead of pinned to the very top). `will-change:
         * transform` alone still forces layer promotion without that side
         * effect. */
        will-change: transform, background;
}

/* Mobile nav open — clear will-change:transform from the transparent header.
 *
 * will-change:transform (required above to prevent iOS Safari GPU-compositing
 * lag during scroll) is a double-edged sword: it creates a NEW CONTAINING
 * BLOCK for every position:fixed descendant.  The mobile nav drawer uses
 * position:fixed to cover the viewport, but being inside this element it
 * is instead positioned relative to the header's own bounds — appearing as
 * a ~72px strip rather than a full-screen overlay.
 *
 * Clearing will-change while the overlay is open restores normal fixed
 * positioning semantics.  The `:has()` selector handles this in pure CSS
 * (Chrome 105+, Safari 15.4+, Firefox 121+); the `.is-nav-open` class is
 * toggled by a MutationObserver in functions.php for older browsers. */
@media (max-width: 781px) {
    header.site-header--transparent:has(
        .wp-block-navigation__responsive-dialog[open],
        .wp-block-navigation__responsive-dialog.is-menu-open,
        .wp-block-navigation__responsive-container.is-menu-open
    ),
    header.site-header--transparent.is-nav-open {
        will-change: auto;
    }
}

/* Admin bar offset — fixed, so must be explicit */
.admin-bar header.site-header--transparent {
        top: 32px;
}
@media (max-width: 782px) {
        .admin-bar header.site-header--transparent {
                top: 46px;
        }
}

/* Nav links + icons — white over the dark gradient */
header.site-header--transparent:not(.is-scrolled) .wp-block-navigation a,
header.site-header--transparent:not(.is-scrolled) .wp-block-navigation-item__label {
        color: var(--wp--preset--color--surface);
}

/* Restore dark colour on nav items when the mobile drawer is open.
 *
 * The rule above cascades into the open drawer: every <a> and label inside
 * .wp-block-navigation (the <nav> root, which is an ancestor of the dialog)
 * inherits white text and is invisible against the white drawer background.
 *
 * Selector strategy: add a :has() condition to the transparent-header rule
 * so this override has one extra pseudo-class and therefore HIGHER specificity
 * than the white-color rule — no !important needed.  The .is-nav-open class
 * is the JS MutationObserver fallback for browsers without :has() support
 * (pre-Chrome 105, pre-Safari 15.4, pre-Firefox 121). */
@media (max-width: 781px) {
        header.site-header--transparent:not(.is-scrolled):has(
                .wp-block-navigation__responsive-dialog[open],
                .wp-block-navigation__responsive-dialog.is-menu-open,
                .wp-block-navigation__responsive-container.is-menu-open
        ) .wp-block-navigation a,
        header.site-header--transparent:not(.is-scrolled):has(
                .wp-block-navigation__responsive-dialog[open],
                .wp-block-navigation__responsive-dialog.is-menu-open,
                .wp-block-navigation__responsive-container.is-menu-open
        ) .wp-block-navigation-item__label,
        header.site-header--transparent:not(.is-scrolled).is-nav-open .wp-block-navigation a,
        header.site-header--transparent:not(.is-scrolled).is-nav-open .wp-block-navigation-item__label {
                color: var(--wp--preset--color--ink);
        }
}

header.site-header--transparent:not(.is-scrolled) .search-toggle,
header.site-header--transparent:not(.is-scrolled) .account-toggle {
        color: var(--wp--preset--color--surface);
}

/* Logo — invert to white (only if a raster/SVG img is used as logo) */
header.site-header--transparent:not(.is-scrolled) .site-header__logo img {
        filter: brightness(0) invert(1);
}

/* Scrolled state — solid white header, restore dark colours */
header.site-header--transparent.is-scrolled {
        background: var(--meridian-header-bg);
        border-bottom-color: var(--wp--preset--color--neutral-100);
        box-shadow: var(--meridian-header-shadow);
}

header.site-header--transparent.is-scrolled .site-header__logo img {
        filter: none;
}

/* Transparent header — restore dark nav text once the header has scrolled
 * to its solid-background state.  The Navigation block is configured with
 * textColor:"surface" (white) so items read over the pre-scroll gradient;
 * that block-generated class keeps the text white after scroll unless we
 * override it here.
 *
 * !important is required: WordPress renders the block's configured text
 * colour as an inline style="color:#fff" on the nav element, which beats
 * any class-based selector regardless of specificity. */
header.site-header--transparent.is-scrolled .wp-block-navigation a,
header.site-header--transparent.is-scrolled .wp-block-navigation-item__label,
header.site-header--transparent.is-scrolled .wp-block-navigation__responsive-container-open {
        color: #816f49 !important;
}

/* =========================================================================
 * Minimal header (cart / checkout)
 * ====================================================================== */

header.site-header--minimal {
        border-bottom-color: var(--wp--preset--color--neutral-100);
}

.site-header__inner--minimal {
        justify-content: space-between;
}

.secure-badge {
        display: inline-flex;
        align-items: center;
        gap: var(--wp--preset--spacing--8);
        font-family: var(--wp--preset--font-family--body);
        font-size: var(--wp--preset--font-size--xs);
        font-weight: 500;
        color: var(--wp--preset--color--neutral-600);
}

/* =========================================================================
 * Header inner layout
 * ====================================================================== */

.site-header__inner {
        max-width: var(--wp--style--global--wide-size);
        margin-left: auto;
        margin-right: auto;
        padding-left: var(--wp--preset--spacing--32);
        padding-right: var(--wp--preset--spacing--32);
}

/* Navigation — center column */
.site-header__nav {
        flex: 1;
        display: flex;
        justify-content: center;
}

/* Shrink nav links to fit */
.site-header__nav .wp-block-navigation__container {
        display: flex;
        align-items: center;
        gap: var(--wp--preset--spacing--40);
}

.site-header__nav .wp-block-navigation-item__label {
        font-family: var(--wp--preset--font-family--body);
        font-size: var(--wp--preset--font-size--sm);
        font-weight: 400;
        letter-spacing: 0;
        white-space: nowrap;
}

.site-header__nav .wp-block-navigation-item > .wp-block-navigation-item__content {
        padding: var(--wp--preset--spacing--8) 0;
        transition: color var(--wp--custom--transition--base);
}

.site-header__nav .wp-block-navigation-item > .wp-block-navigation-item__content:hover,
.site-header__nav .wp-block-navigation-item.current-menu-item > .wp-block-navigation-item__content {
        color: var(--wp--preset--color--accent-deep);
}

/* Standard submenu dropdown */
.site-header__nav .wp-block-navigation__submenu-container {
        min-width: 220px;
        background-color: var(--wp--preset--color--surface);
        border: 1px solid var(--wp--preset--color--neutral-100);
        box-shadow: var(--meridian-header-shadow);
        padding: var(--wp--preset--spacing--8) 0;
        border-radius: 0;
}

.site-header__nav .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
        padding: var(--wp--preset--spacing--10) var(--wp--preset--spacing--24);
        font-size: var(--wp--preset--font-size--sm);
        color: var(--wp--preset--color--ink);
}

.site-header__nav .wp-block-navigation__submenu-container .wp-block-navigation-item__content:hover {
        background-color: var(--wp--preset--color--neutral-50);
        color: var(--wp--preset--color--ink);
}

/* =========================================================================
 * Mega Menu
 *
 * Usage: In the Site Editor, add class "mega-menu" to any top-level nav item
 * that has sub-items. The submenu becomes a full-width panel.
 * ====================================================================== */

/* Make the nav container non-clipping so mega panels can break out */
.site-header__nav .wp-block-navigation__container {
        overflow: visible;
}

/* Mega menu trigger item — position:static so submenu is relative to header */
.site-header__nav .wp-block-navigation-item.mega-menu {
        position: static;
}

/* The mega panel itself */
.site-header__nav .wp-block-navigation-item.mega-menu > .wp-block-navigation__submenu-container {
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 0;
        padding: var(--wp--preset--spacing--48) var(--wp--preset--spacing--64);
        border-top: 2px solid var(--wp--preset--color--neutral-100);
        box-shadow: 0 8px 32px rgba(15, 15, 15, 0.10);
}

/* Mega panel column headings */
.site-header__nav .wp-block-navigation-item.mega-menu .wp-block-navigation__submenu-container .wp-block-navigation-item:first-child > .wp-block-navigation-item__content {
        font-size: var(--wp--preset--font-size--xs);
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--wp--preset--color--neutral-600);
        cursor: default;
        padding: 0 0 var(--wp--preset--spacing--16);
        border-bottom: 1px solid var(--wp--preset--color--neutral-100);
        margin-bottom: var(--wp--preset--spacing--12);
        pointer-events: none;
}

/* Mega panel links */
.site-header__nav .wp-block-navigation-item.mega-menu .wp-block-navigation__submenu-container .wp-block-navigation-item__content {
        background: none;
        padding: var(--wp--preset--spacing--8) 0;
        color: var(--wp--preset--color--neutral-600);
        transition: color var(--wp--custom--transition--base);
}

.site-header__nav .wp-block-navigation-item.mega-menu .wp-block-navigation__submenu-container .wp-block-navigation-item__content:hover {
        background: none;
        color: var(--wp--preset--color--ink);
}

/* =========================================================================
 * Utility icon buttons (search toggle, account)
 * ====================================================================== */

.search-toggle,
.account-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        cursor: pointer;
        color: var(--wp--preset--color--ink);
        border-radius: 50%;
        transition:
                background-color var(--wp--custom--transition--base),
                color var(--wp--custom--transition--base);
        text-decoration: none;
        flex-shrink: 0;
}

.search-toggle:hover,
.account-toggle:hover {
        background-color: var(--wp--preset--color--neutral-50);
        color: var(--wp--preset--color--ink);
}

.search-toggle:focus-visible,
.account-toggle:focus-visible {
        outline: 2px solid var(--wp--preset--color--ink);
        outline-offset: 2px;
}

/* Mini cart icon sizing */
.site-header__mini-cart .wc-block-mini-cart__button {
        background: transparent;
        border: none;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: var(--wp--preset--spacing--8);
        padding: var(--wp--preset--spacing--8);
        color: var(--wp--preset--color--ink);
        font-family: var(--wp--preset--font-family--body);
        font-size: var(--wp--preset--font-size--sm);
        border-radius: 50%;
        transition: background-color var(--wp--custom--transition--base);
}

.site-header__mini-cart .wc-block-mini-cart__button:hover {
        background-color: var(--wp--preset--color--neutral-50);
}

/* =========================================================================
 * Dark mode toggle button
 * ====================================================================== */

.theme-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        cursor: pointer;
        color: var(--wp--preset--color--ink);
        border-radius: 50%;
        transition:
                background-color var(--wp--custom--transition--base),
                color var(--wp--custom--transition--base);
        flex-shrink: 0;
}

.theme-toggle:hover {
        background-color: var(--wp--preset--color--neutral-50);
}

.theme-toggle:focus-visible {
        outline: 2px solid var(--wp--preset--color--ink);
        outline-offset: 2px;
}

/* Sun icon — visible in light mode (default) */
.theme-toggle__sun  { display: block; }
/* Moon icon — hidden in light mode */
.theme-toggle__moon { display: none; }

/* Swap icons when dark mode is active */
.is-dark-mode .theme-toggle__sun  { display: none; }
.is-dark-mode .theme-toggle__moon { display: block; }

/* Transparent header — toggle inherits white colour before scroll */
header.site-header--transparent:not(.is-scrolled) .theme-toggle {
        color: var(--wp--preset--color--surface);
}

/* =========================================================================
 * Search overlay
 * ====================================================================== */

.search-overlay {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--wp--preset--color--surface);
        border-bottom: 1px solid var(--wp--preset--color--neutral-100);
        box-shadow: 0 8px 24px rgba(15, 15, 15, 0.08);
        z-index: var(--meridian-overlay-z);

        /* Hidden state */
        opacity: 0;
        transform: translateY(-8px);
        pointer-events: none;
        transition:
                opacity 0.2s ease,
                transform 0.2s ease;
}

.search-overlay.is-open {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
}

.search-overlay__inner {
        max-width: var(--wp--style--global--wide-size);
        margin: 0 auto;
        padding: var(--wp--preset--spacing--24) var(--wp--preset--spacing--32);
        display: flex;
        align-items: center;
        gap: var(--wp--preset--spacing--16);
}

.search-overlay__form {
        display: flex;
        align-items: center;
        flex: 1;
        border-bottom: 1.5px solid var(--wp--preset--color--neutral-200);
        transition: border-color var(--wp--custom--transition--base);
}

.search-overlay__form:focus-within {
        border-bottom-color: var(--wp--preset--color--ink);
}

.search-overlay__form input[type="search"] {
        flex: 1;
        border: none;
        background: transparent;
        font-family: var(--wp--preset--font-family--body);
        font-size: var(--wp--preset--font-size--lg);
        color: var(--wp--preset--color--ink);
        padding: var(--wp--preset--spacing--12) 0;
        outline: none;
        -webkit-appearance: none;
}

.search-overlay__form input[type="search"]::placeholder {
        color: var(--wp--preset--color--neutral-400);
}

.search-overlay__form input[type="search"]::-webkit-search-cancel-button {
        -webkit-appearance: none;
}

.search-overlay__form button[type="submit"] {
        background: transparent;
        border: none;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        color: var(--wp--preset--color--neutral-600);
        padding: var(--wp--preset--spacing--8);
        transition: color var(--wp--custom--transition--base);
}

.search-overlay__form button[type="submit"]:hover {
        color: var(--wp--preset--color--ink);
}

.search-overlay__close {
        background: transparent;
        border: none;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        color: var(--wp--preset--color--neutral-600);
        flex-shrink: 0;
        transition: color var(--wp--custom--transition--base);
}

.search-overlay__close:hover {
        color: var(--wp--preset--color--ink);
}

/* =========================================================================
 * Mobile navigation
 * ====================================================================== */

/*
 * Hamburger toggle button — styled to look unmistakably like a menu trigger,
 * not an account/person icon.  WordPress renders an SVG with three horizontal
 * lines; these rules ensure it is correctly sized and clearly visible so users
 * do not confuse it with the account icon in the utilities group.
 */
.site-header__nav .wp-block-navigation__responsive-container-open {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        background: var(--wp--preset--color--neutral-100);
        border: 1px solid var(--wp--preset--color--neutral-200);
        border-radius: 4px;
        cursor: pointer;
        color: var(--wp--preset--color--ink);
        transition: background-color var(--wp--custom--transition--base);
        flex-shrink: 0;
}

/* WordPress core toggles the `hidden` attribute on this button via JS based
 * on the current viewport width (it is only meant to be visible below the
 * navigation block's own responsive breakpoint). The UA default `[hidden] {
 * display: none }` rule has the same specificity as the class selector
 * above, so — depending on CSS source order — our rule can win the tie and
 * force the hamburger to stay visible at every width, producing a duplicate
 * desktop nav (row + hamburger both showing). Make the hidden state
 * explicit so it always wins regardless of source order, and add a hard
 * breakpoint guard as a second line of defense in case a WP version does
 * not toggle `hidden` for this button at all. */
.site-header__nav .wp-block-navigation__responsive-container-open[hidden] {
        display: none !important;
}

@media (min-width: 782px) {
        .site-header__nav .wp-block-navigation__responsive-container-open {
                display: none !important;
        }
}

.site-header__nav .wp-block-navigation__responsive-container-open:hover {
        background-color: var(--wp--preset--color--neutral-200);
}

/* Ensure the hamburger SVG is sized correctly and stroked, not filled */
.site-header__nav .wp-block-navigation__responsive-container-open svg {
        width: 20px;
        height: 20px;
        display: block;
        flex-shrink: 0;
        /* iOS Safari does not always inherit currentColor into SVG child
         * elements via the parent button's `color` property. Set fill and
         * stroke explicitly so the hamburger bars render on all browsers. */
        fill: currentColor;
        stroke: none;
}

/* Close button inside the open overlay */
.site-header__nav .wp-block-navigation__responsive-container-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        color: var(--wp--preset--color--ink);
        margin-left: auto;
}

/* Newer WordPress core (Gutenberg 17+ / WP 6.6+) renders ALL nav items
 * inside a native <dialog> element. Browsers apply UA styles to <dialog>
 * (width:fit-content, margin:auto, border, background:Canvas) that break
 * the desktop header bar layout.
 *
 * DESKTOP (≥782px): reset UA box model so nav items display inline in the
 *   header flex row. `all:unset` clears UA styles; explicit margin:0 covers
 *   the Chrome quirk where all:unset does not reset margin:auto; color:inherit
 *   restores the correct text colour (all:unset resets it to CanvasText/black
 *   on Safari and Firefox, making items invisible on the dark gradient).
 *
 * MOBILE (≤781px): dialog is hidden when closed; when WP sets [open] or
 *   is-menu-open the drawer is shown full-screen. The containing-block issue
 *   caused by will-change:transform on the transparent header is fixed above
 *   — see the :has()/.is-nav-open rule. No unconditional base rules with
 *   !important here to avoid cascade conflicts. */
@media (min-width: 782px) {
        .wp-block-navigation__responsive-dialog {
                all: unset;
                display: block;
                color: inherit;
                margin: 0; /* Chrome: all:unset alone does not reset margin:auto */
        }
}

@media (max-width: 781px) {
        /* Hide the dialog when genuinely closed — i.e. it has none of:
         *   • native [open] attribute (WP 6.4 native <dialog> behaviour)
         *   • .is-menu-open class on the dialog itself (some WP builds)
         *   • .is-menu-open/.has-modal-open on the inner container (:has())
         *   • .is-menu-open mirrored by the JS fallback below
         *
         * Without the :has() guard the rule hides the dialog even when WP has
         * opened the menu via the inner container — producing an empty white
         * panel with no items (the "menu open but nothing visible" bug). 
         .wp-block-navigation__responsive-dialog:not([open]):not(.is-menu-open):not(:has(.wp-block-navigation__responsive-container.is-menu-open, .wp-block-navigation__responsive-container.has-modal-open)) {
                display: none !important; */
        }

        /* Show dialog when it (or its inner container) is open.
         *
         * Three selectors cover three different WP rendering strategies:
         *
         * 1. dialog[open] — native <dialog> element, WP 6.4–6.6 style
         * 2. dialog.is-menu-open — older WP / Interactivity API puts the
         *    class on the dialog element itself
         * 3. dialog:has(container.is-menu-open / .has-modal-open) — WP 6.7+
         *    Interactivity API puts both classes on the INNER container only;
         *    the dialog element receives neither [open] nor .is-menu-open.
         *    The JS MutationObserver in navigation.js mirrors .is-menu-open
         *    onto the dialog as a :has()-free fallback for older browsers. */
        .wp-block-navigation__responsive-dialog[open],
        .wp-block-navigation__responsive-dialog.is-menu-open,
        .wp-block-navigation__responsive-dialog:has(
                .wp-block-navigation__responsive-container.is-menu-open,
                .wp-block-navigation__responsive-container.has-modal-open
        ) {
                display: block !important;
                position: fixed !important;
                top: 0 !important;
                right: 0 !important;
                bottom: 0 !important;
                left: 0 !important;
                width: 100% !important;
                height: 100% !important;
                max-width: none !important;
                max-height: none !important;
                margin: 0 !important;
                border: none !important;
                background-color: var(--wp--preset--color--surface) !important;
                padding: var(--wp--preset--spacing--32) !important;
                /* overflow: visible, NOT overflow-y:auto — in Chrome 114+ any
                 * ancestor with overflow != visible creates a new containing
                 * block for position:fixed descendants.  If the dialog has
                 * overflow-y:auto the inner container's position:fixed offsets
                 * become relative to the dialog's *padding box* rather than
                 * the viewport, constraining it to the dialog's content area
                 * (viewport minus padding on each side) instead of the full
                 * screen. */
                overflow: visible !important;
                z-index: 1000;
        }

        /* Show the inner container and content wrapper whenever the dialog is
         * open in any of the three ways above (same :has() / [open] logic). */
        .wp-block-navigation__responsive-dialog[open]
                .wp-block-navigation__responsive-container,
        .wp-block-navigation__responsive-dialog.is-menu-open
                .wp-block-navigation__responsive-container,
        .wp-block-navigation__responsive-dialog:has(
                .wp-block-navigation__responsive-container.is-menu-open,
                .wp-block-navigation__responsive-container.has-modal-open
        ) .wp-block-navigation__responsive-container {
                display: flex !important;
                flex-direction: column !important;
        }

        .wp-block-navigation__responsive-dialog[open]
                .wp-block-navigation__responsive-container-content,
        .wp-block-navigation__responsive-dialog.is-menu-open
                .wp-block-navigation__responsive-container-content,
        .wp-block-navigation__responsive-dialog:has(
                .wp-block-navigation__responsive-container.is-menu-open,
                .wp-block-navigation__responsive-container.has-modal-open
        ) .wp-block-navigation__responsive-container-content {
                display: flex !important;
                flex-direction: column !important;
        }
}

/* WordPress 7.0 manages the responsive container's open/closed state via
 * TWO classes toggled together by the Interactivity API: `.is-menu-open`
 * AND `.has-modal-open`. Older WP only toggles `.is-menu-open`.
 *
 * The container must be hidden when the menu is CLOSED (neither class
 * present) and visible when EITHER class is set — so we use chained
 * :not() selectors rather than :not(.is-menu-open.has-modal-open), which
 * would keep the container hidden on WP < 7.0 (only has is-menu-open). */
@media (max-width: 781px) {
        .wp-block-navigation__responsive-container:not(.is-menu-open):not(.has-modal-open) {
                display: none !important;
        }
}

@media (max-width: 781px) {
        .site-header__nav .wp-block-navigation__responsive-container,
        .wp-block-navigation__responsive-container {
                background-color: var(--wp--preset--color--surface);
        }

        /* Mobile overlay — full height slide-in.
         * Rules are duplicated WITHOUT the .site-header__nav ancestor because
         * WordPress core renders the open mobile overlay as a modal that is
         * appended outside the header's DOM subtree on some versions — the
         * scoped selector then fails to match, leaving the overlay transparent
         * with only its close button and an unstyled submenu heading visible
         * (the "floating ABOUT + X over the hero" bug).
         *
         * Also duplicated targeting `.wp-block-navigation__responsive-dialog`
         * directly (both `.is-menu-open` and the native `[open]` attribute):
         * depending on WP core version, the "open" state class can land on
         * the <dialog> wrapper itself rather than on the nested
         * `.wp-block-navigation__responsive-container`. If it lands on the
         * dialog and none of these selectors account for that, the drawer
         * never gets styled at all — it just sits there as an unstyled,
         * transparent, full-width block with no visible items (the "empty
         * gap, no menu" bug). */
        .site-header__nav .wp-block-navigation__responsive-container.is-menu-open,
        .wp-block-navigation__responsive-container.is-menu-open,
        .wp-block-navigation__responsive-dialog.is-menu-open,
        .wp-block-navigation__responsive-dialog[open] {
                background-color: var(--wp--preset--color--surface);
                padding: var(--wp--preset--spacing--32);
                position: fixed;
                /* `inset` shorthand is not supported in iOS Safari < 14.4 — use
                 * explicit top/right/bottom/left to cover all versions. */
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
                z-index: 1000;
                overflow-y: auto;
                /* Momentum scrolling on iOS Safari */
                -webkit-overflow-scrolling: touch;
        }

        /* The transparent-header hero variant forces nav links/icons to white
         * text (".site-header--transparent:not(.is-scrolled) ... { color:
         * surface }") so they read over the dark hero gradient. That rule has
         * no exception for the open mobile drawer, so once the drawer's
         * white background is visible, the inherited white text is invisible.
         *
         * SELECTOR NOTE: `.wp-block-navigation` is the <nav> root element —
         * the parent of the drawer, NOT a descendant of it. Selectors like
         * `dialog[open] .wp-block-navigation a` therefore never match any
         * element. Use direct descendant selectors instead (no intermediate
         * .wp-block-navigation class required). */

        /* 1. Set ink on the drawer elements themselves — covers any child that
         *    inherits and isn't explicitly targeted below. */
        .wp-block-navigation__responsive-container.is-menu-open,
        .wp-block-navigation__responsive-dialog[open] {
                color: var(--wp--preset--color--ink) !important;
        }

        /* 2. Explicit rules for links, labels, buttons, and SVGs so they win
         *    over any block-level or inline colour set on those elements directly
         *    (inheritance from rule 1 would lose to a directly-applied rule). */
        .wp-block-navigation__responsive-container.is-menu-open a,
        .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__label,
        .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content,
        .wp-block-navigation__responsive-container.is-menu-open button,
        .wp-block-navigation__responsive-dialog[open] a,
        .wp-block-navigation__responsive-dialog[open] .wp-block-navigation-item__label,
        .wp-block-navigation__responsive-dialog[open] .wp-block-navigation-item__content,
        .wp-block-navigation__responsive-dialog[open] button {
                color: var(--wp--preset--color--ink) !important;
        }

        .wp-block-navigation__responsive-container.is-menu-open svg,
        .wp-block-navigation__responsive-dialog[open] svg {
                color: var(--wp--preset--color--ink) !important;
                fill: var(--wp--preset--color--ink) !important;
        }

        .site-header__nav .wp-block-navigation__container,
        .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container,
        .wp-block-navigation__responsive-dialog[open] .wp-block-navigation__container {
                flex-direction: column !important;
                flex-wrap: nowrap !important;
                justify-content: flex-start !important;
                align-items: flex-start !important;
                width: 100% !important;
                gap: 0;
                overflow: hidden; /* override desktop overflow:visible; mega menu hidden on mobile */
        }

        /* The desktop layout config renders the nav as a centered, nowrap flex
         * row and WordPress applies that as an inline style on the container
         * (higher specificity than a plain class selector), so the row/center/
         * nowrap layout survives into the open mobile drawer even with the
         * column override above — the drawer then shows one item stretched
         * across the screen instead of a stacked list. The !important rules
         * above win over that inline style. Individual items must also be
         * forced to full width (not shrink-to-fit against a nowrap row) and
         * not grow past their own content. */
        .site-header__nav .wp-block-navigation-item,
        .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item,
        .wp-block-navigation__responsive-dialog[open] .wp-block-navigation-item {
                width: 100% !important;
                flex: 0 0 auto !important;
        }

        .site-header__nav .wp-block-navigation-item__content,
        .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content,
        .wp-block-navigation__responsive-dialog[open] .wp-block-navigation-item__content {
                font-size: var(--wp--preset--font-size--xl);
                font-family: var(--wp--preset--font-family--heading);
                font-weight: 400;
                letter-spacing: -0.01em;
                padding: var(--wp--preset--spacing--16) 0;
                border-bottom: 1px solid var(--wp--preset--color--neutral-100);
                width: 100%;
        }

        /* Mobile mega menu becomes stacked */
        .site-header__nav .wp-block-navigation-item.mega-menu > .wp-block-navigation__submenu-container,
        .wp-block-navigation-item.mega-menu > .wp-block-navigation__submenu-container {
                position: relative;
                display: flex;
                flex-direction: column;
                grid-template-columns: none;
                padding: 0;
                box-shadow: none;
                border: none;
                left: auto;
                right: auto;
                width: auto;
        }

        /* Hide mega panel headers on mobile */
        .site-header__nav .wp-block-navigation-item.mega-menu .wp-block-navigation__submenu-container .wp-block-navigation-item:first-child > .wp-block-navigation-item__content,
        .wp-block-navigation-item.mega-menu .wp-block-navigation__submenu-container .wp-block-navigation-item:first-child > .wp-block-navigation-item__content {
                display: none;
        }

        /* Close button — duplicated unscoped for the same portal-rendering reason */
        .wp-block-navigation__responsive-container-close {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                width: 40px;
                height: 40px;
                background: transparent;
                border: none;
                cursor: pointer;
                color: var(--wp--preset--color--ink);
                margin-left: auto;
        }
}

/* =========================================================================
 * Footer newsletter form
 * ====================================================================== */

.footer-newsletter .footer-newsletter__row {
        display: flex;
        border: 1px solid var(--wp--preset--color--neutral-700);
        background-color: rgba(255, 255, 255, 0.05);
        transition: border-color var(--wp--custom--transition--base);
}

.footer-newsletter .footer-newsletter__row:focus-within {
        border-color: var(--wp--preset--color--neutral-400);
}

.footer-newsletter input[type="email"] {
        flex: 1;
        background: transparent;
        border: none;
        outline: none;
        font-family: var(--wp--preset--font-family--body);
        font-size: var(--wp--preset--font-size--sm);
        color: var(--wp--preset--color--surface);
        padding: var(--wp--preset--spacing--12) var(--wp--preset--spacing--16);
}

.footer-newsletter input[type="email"]::placeholder {
        color: var(--wp--preset--color--neutral-600);
}

.footer-newsletter button[type="submit"] {
        background: transparent;
        border: none;
        border-left: 1px solid var(--wp--preset--color--neutral-700);
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        color: var(--wp--preset--color--neutral-400);
        transition: color var(--wp--custom--transition--base), background-color var(--wp--custom--transition--base);
        flex-shrink: 0;
}

.footer-newsletter button[type="submit"]:hover {
        color: var(--wp--preset--color--surface);
        background-color: rgba(255, 255, 255, 0.08);
}

.footer-newsletter .footer-newsletter__note {
        font-size: var(--wp--preset--font-size--xs);
        color: var(--wp--preset--color--neutral-600);
        margin-top: var(--wp--preset--spacing--8);
        margin-bottom: 0;
}

/* =========================================================================
 * Footer social icons
 * ====================================================================== */

.site-footer__social .wp-block-social-link a {
        background-color: transparent !important;
        padding: 6px;
        border-radius: 50%;
        transition: background-color var(--wp--custom--transition--base);
}

.site-footer__social .wp-block-social-link a:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
}

.site-footer__social .wp-block-social-link-anchor svg {
        fill: var(--wp--preset--color--neutral-400);
        transition: fill var(--wp--custom--transition--base);
        width: 18px;
        height: 18px;
}

.site-footer__social .wp-block-social-link a:hover svg {
        fill: var(--wp--preset--color--surface);
}

/* Footer nav links */
.site-footer__inner .wp-block-navigation-item a {
        color: var(--wp--preset--color--neutral-400);
        text-decoration: none;
        transition: color var(--wp--custom--transition--base);
}

.site-footer__inner .wp-block-navigation-item a:hover {
        color: var(--wp--preset--color--surface);
}

/* Responsive footer columns */
@media (max-width: 768px) {
        .site-footer__inner .wp-block-columns {
                flex-direction: column;
        }

        .site-footer__inner .wp-block-column {
                width: 100% !important;
                flex-basis: 100% !important;
        }
}
