/* ── Contenedor fijo (evita que backdrop-filter del header rompa position:fixed del menú) ── */
.site-header-shell {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
}

.site-header-shell .site-header {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    z-index: auto;
}

.site-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.header__spacer {
    min-width: 0;
    justify-self: end;
}

.logo-link {
    justify-self: start;
}

/* ── Navegación desktop ── */
.nav__links {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vw, 1.5rem);
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav__links a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-weight: 500;
    font-size: clamp(0.82rem, 1.4vw, 0.92rem);
    white-space: nowrap;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background 0.22s ease, border-color 0.22s ease, color 0.22s ease;
}

.nav__links a:hover,
.nav__links a:focus-visible,
.nav__links a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}

@media (min-width: 769px) {
    .nav {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        z-index: 2;
        margin: 0;
        padding: 0;
        width: max-content;
        max-width: calc(100% - 12rem);
        pointer-events: auto;
    }

    .menu-toggle {
        display: none !important;
    }
}

/* ── Botón hamburger ── */
.menu-toggle {
    display: none;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.menu-toggle__icon {
    display: block;
    position: relative;
    width: 1.375rem;
    height: 0.625rem;
}

.menu-toggle__line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition:
        transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        top 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease;
}

.menu-toggle__line:nth-child(1) {
    top: 0;
}

.menu-toggle__line:nth-child(2) {
    top: 50%;
    transform: translateY(-50%);
}

.menu-toggle__line:nth-child(3) {
    bottom: 0;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__line:nth-child(1) {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__line:nth-child(2) {
    opacity: 0;
    transform: translateY(-50%) scaleX(0);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__line:nth-child(3) {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%) rotate(-45deg);
}

/* ── Backdrop ── */
.nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 198;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    -webkit-tap-highlight-color: transparent;
}

.nav-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

body.nav-open {
    overflow: hidden;
}

body.nav-open .site-header-shell {
    z-index: 203;
}

body.nav-open .site-header {
    background: rgba(8, 8, 8, 0.98) !important;
    border-bottom-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important;
}

/* ── Menú móvil ── */
@media (max-width: 768px) {
    .site-header-shell .site-header {
        position: relative;
        z-index: 3;
    }

    .site-header__inner {
        display: flex !important;
        grid-template-columns: unset !important;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        width: 100%;
        position: relative;
        z-index: 1;
    }

    .logo-link {
        position: relative;
        z-index: 1;
    }

    .header__spacer {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        margin-left: auto;
        min-width: 2.75rem;
        position: relative;
        z-index: 1;
    }

    .menu-toggle {
        display: inline-flex;
        position: relative;
        z-index: 1;
    }

    .nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        margin: 0;
        padding: calc(var(--header-height, 4.5rem) + 1.5rem) clamp(1.25rem, 4vw, 2.5rem) 2.5rem;
        background: #0a0a0a;
        transform: none;
        width: auto;
        max-width: none;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.28s ease, visibility 0.28s ease;
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }

    .nav.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .nav__links {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
    }

    .nav__links li {
        margin: 0;
        padding: 0;
        border: 0;
        list-style: none;
    }

    .nav__links a {
        display: block;
        padding: 1.125rem 0;
        text-align: left;
        font-size: 1.0625rem;
        font-weight: 500;
        letter-spacing: 0.02em;
        text-transform: none;
        color: rgba(255, 255, 255, 0.9);
        white-space: normal;
        border: 0 !important;
        border-radius: 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        background: transparent !important;
        transition: color 0.2s ease;
    }

    .nav__links li:last-child a {
        border-bottom: 0 !important;
    }

    .nav__links a:hover,
    .nav__links a:focus-visible,
    .nav__links a[aria-current="page"] {
        color: #fff;
        background: transparent !important;
        border-color: rgba(255, 255, 255, 0.1) !important;
        padding-left: 0;
    }

    .nav__links a[aria-current="page"] {
        color: #fff;
    }
}

@media (prefers-reduced-motion: reduce) {
    .menu-toggle__line,
    .nav,
    .nav-backdrop {
        transition: none;
    }
}
