/*
 * Navigation and recovery resilience layer.
 *
 * Compact navigation is opt-in only after the JavaScript controller declares
 * readiness. Without that class, the primary menu remains visible in normal
 * document flow and the inoperable toggle stays hidden.
 */

body.admin-bar .skip-link:focus,
body.admin-bar .skip-link:focus-visible {
    top: calc(var(--wp-admin--admin-bar--height, 32px) + 0.75rem);
}

.footer-nav {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.footer-menu {
    flex-wrap: wrap;
    justify-content: center;
}

.footer-menu--invariant {
    padding-top: 1rem;
    border-top: 1px solid var(--td-border-subtle);
}

.footer-disclaimer__risk {
    display: inline-block;
    margin-left: 0.3em;
    color: #d9e0e7;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.14em;
}

.footer-disclaimer__risk:hover,
.footer-disclaimer__risk:focus-visible {
    color: #ffffff;
}

@media (min-width: 992px) {
    .header-inner {
        flex-wrap: wrap;
    }

    .site-nav {
        flex: 1 1 22rem;
        min-width: 0;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

@media (max-width: 991px) {
    html:not(.mobile-nav-ready) .mobile-menu-toggle {
        display: none;
    }

    html:not(.mobile-nav-ready) .header-inner {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    html:not(.mobile-nav-ready) .site-nav {
        position: static;
        inset: auto;
        display: block;
        flex: 1 0 100%;
        width: 100%;
        padding: 0;
        overflow: visible;
        border-top: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        pointer-events: auto;
        z-index: auto;
    }

    html:not(.mobile-nav-ready) .nav-menu {
        width: 100%;
        margin: 0.35rem 0 0;
    }

    html.mobile-nav-ready .mobile-menu-toggle {
        display: inline-flex;
    }

    html.mobile-nav-ready .site-nav {
        overscroll-behavior: contain;
    }

    /*
     * A tiny head preflight reserves the final compact header geometry before
     * footer JavaScript initializes. If the controller never becomes ready,
     * the preflight is removed and the fail-open document-flow menu above
     * returns automatically.
     */
    html.js-preflight:not(.mobile-nav-ready) .mobile-menu-toggle {
        display: inline-flex;
        visibility: hidden;
        pointer-events: none;
    }

    html.js-preflight:not(.mobile-nav-ready) .header-inner {
        flex-wrap: nowrap;
        gap: var(--td-space-md);
    }

    html.js-preflight:not(.mobile-nav-ready) .site-nav {
        position: fixed;
        inset: var(--mobile-nav-top) 0 0;
        display: flex;
        flex: 0 1 auto;
        width: auto;
        align-items: flex-start;
        justify-content: center;
        padding:
            clamp(1rem, 3vw, 1.35rem)
            max(14px, calc((100vw - var(--td-max-width)) / 2 + 20px))
            max(1.5rem, env(safe-area-inset-bottom));
        overflow-y: auto;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        background:
            radial-gradient(90% 60% at 50% 0%, rgba(216, 180, 106, 0.08), transparent 65%),
            rgba(10, 11, 13, 0.82);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        opacity: 0;
        visibility: hidden;
        transform: translate3d(0, -10px, 0);
        pointer-events: none;
        z-index: 40;
    }

    html.js-preflight:not(.mobile-nav-ready) .nav-menu {
        width: min(100%, 26rem);
        margin: 0 0 0 auto;
    }
}

@media (max-width: 782px) {
    body.admin-bar .skip-link:focus,
    body.admin-bar .skip-link:focus-visible {
        top: calc(var(--wp-admin--admin-bar--height, 46px) + 0.75rem);
    }
}
