/* ============================================================================
   NAVBAR - Barra superior + menú móvil (hamburguesa que crece a pantalla
   completa, secuencia tipo "bandera" con paleta COFIN).
   ============================================================================ */

/* ---- Barra superior (sticky, blur) ---- */
.site-nav {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    width: 100%;
    z-index: 100;
}

/* Inputs radio que controlan apertura/cierre del menú móvil */
.site-nav > #nav-toggle,
.site-nav > #nav-close {
    display: none;
}

.nav-inner {
    margin: 0 auto;
    padding: 1.1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo-mark { background: transparent; display: inline-block; }
.logo-mark img { display: block; height: 56px; width: auto; }

.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 2.4rem;
}

.nav-links li {
    position: relative;
}

.nav-links a {
    font-size: 0.92rem;
    color: var(--color-text-soft);
    font-weight: 500;
    text-decoration: none;
    transition: color .2s ease;
    padding-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Línea animada debajo de cada link */
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--color-primary);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s cubic-bezier(.4, 0, .2, 1);
}

.nav-links a:hover {
    color: var(--color-primary);
}

.nav-links a:hover::after {
    transform: scaleX(1);
}

/* Link activo */
.nav-links a.active {
    color: var(--color-primary);
    font-weight: 600;
}

.nav-links a.active::after {
    transform: scaleX(1);
}

.nav-cta {
    background: var(--color-primary);
    color: #fff;
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s ease, transform .2s ease;
}
.nav-cta:hover { background: #0a1f33; }

/* En escritorio el menú móvil completo NO se ve */
.site-nav > .nav-toggle-mobile,
.site-nav > .nav-close-mobile,
.site-nav > .mobile-nav {
    display: none;
}


/* ============================================================================
   MENÚ MÓVIL  (max-width: 1150px)
   La hamburguesa CRECE hasta llenar toda la pantalla, luego entran las
   columnas de colores COFIN como una bandera cayendo.
   ============================================================================ */
@media (max-width: 1150px) {

    /* Ocultar enlaces de escritorio + CTA */
    .nav-inner > .nav-links,
    .nav-inner > .nav-cta { display: none; }

    /* ---- HAMBURGUESA ---- */
    /* En reposo: cuadradito en la esquina superior derecha.
       Al activarse: crece hasta cubrir toda la pantalla (degradado COFIN). */
    .site-nav > .nav-toggle-mobile {
        position: fixed;
        /* Centrado vertical dentro de la barra superior:
           barra ≈ 1.1rem padding + 56px logo + 1.1rem padding ≈ 91px,
           por lo que el centro está en ~45px y el botón (30px) arranca en ~30px. */
        top: 30px;
        right: 18px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        width: 36px;
        height: 30px;
        padding: 4px;
        z-index: 300;
        background: transparent;
        border-radius: 6px;
        transition:
            width  0.55s cubic-bezier(.7, 0, .3, 1) 0.15s,
            height 0.55s cubic-bezier(.7, 0, .3, 1) 0.15s,
            top    0.55s cubic-bezier(.7, 0, .3, 1) 0.15s,
            right  0.55s cubic-bezier(.7, 0, .3, 1) 0.15s,
            background 0.5s ease 0.55s,
            border-radius 0.4s ease 0.15s;
    }
    .site-nav > .nav-toggle-mobile > figure {
        width: 100%;
        height: 3px;
        margin: 0;
        border-radius: 2px;
        transition: all 0.3s ease-in-out;
    }
    /* Tres barras COFIN: verde claro / verde / azul */
    .site-nav > .nav-toggle-mobile > figure:nth-child(2) { background: #2cd236; }
    .site-nav > .nav-toggle-mobile > figure:nth-child(3) { background: #18c020; }
    .site-nav > .nav-toggle-mobile > figure:nth-child(4) { background: #082c50; }

    .site-nav > .nav-toggle-mobile > label {
        position: absolute;
        inset: 0;
        cursor: pointer;
    }
    .site-nav > .nav-toggle-mobile:hover { transform: scale(1.06); }
    .site-nav > .nav-toggle-mobile:active { transform: scale(0.96); }

    /* ---- ABIERTO: la hamburguesa crece hasta tapar la pantalla ---- */
    #nav-toggle:checked ~ .nav-toggle-mobile {
        top: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        background: linear-gradient(
            160deg,
            #2cd236 0%,
            #18c020 35%,
            #0a4a82 75%,
            #082c50 100%
        );
        cursor: default;
        pointer-events: none;   /* deja pasar clicks a la X y a las columnas */
        animation: cofin-pulse 0.6s ease-in-out 0.7s 1;
    }
    /* Pequeño "respiro" cuando la hamburguesa termina de crecer */
    @keyframes cofin-pulse {
        0%, 100% { filter: brightness(1); }
        50%      { filter: brightness(1.08); }
    }

    /* Las 3 barras se expanden y se difuminan al crecer la hamburguesa */
    #nav-toggle:checked ~ .nav-toggle-mobile > figure {
        height: 33%;
        opacity: 0.18;
        transition: all 0.7s ease-in-out 0.2s;
    }


    /* ---- BOTÓN CERRAR (X) ---- */
    .site-nav > .nav-close-mobile {
        display: block;
        position: fixed;
        top: 18px;
        right: 18px;
        width: 46px;
        height: 46px;
        padding: 10px;
        background: rgba(0, 0, 0, 0.35);
        border-radius: 50%;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
        z-index: 700;
        opacity: 0;
        transform: scale(0.5) rotate(-90deg);
        pointer-events: none;
        /* Importante: pointer-events sin delay para que al cerrar se
           desactive YA y al reabrir entre limpio. La opacidad/transform
           pueden retrasarse para el efecto visual. */
        transition:
            opacity 0.4s ease,
            transform 0.4s cubic-bezier(.34, 1.56, .64, 1),
            background 0.2s ease;
    }
    .site-nav > .nav-close-mobile > svg {
        width: 100%;
        height: 100%;
        fill: #fff;
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
        transition: transform 0.35s ease, fill 0.2s ease;
        pointer-events: none;       /* evita que el SVG robe el clic al label */
    }
    .site-nav > .nav-close-mobile > label {
        position: absolute;
        inset: -8px;                /* área de toque ampliada (62×62 aprox) */
        cursor: pointer;
        border-radius: 50%;
        z-index: 1;
    }

    /* Hover SOLO en dispositivos con puntero real (no se queda "pegado"
       en pantallas táctiles) */
    @media (hover: hover) and (pointer: fine) {
        .site-nav > .nav-close-mobile:hover {
            background: rgba(220, 30, 30, 0.65);
        }
        .site-nav > .nav-close-mobile:hover > svg {
            transform: rotate(90deg);
        }
    }
    /* Feedback al tocar (en táctil): pulse rápido */
    .site-nav > .nav-close-mobile:active {
        background: rgba(220, 30, 30, 0.65);
        transform: scale(0.92) rotate(0deg) !important;
    }

    /* Aparece poco después de que entran las columnas */
    #nav-toggle:checked ~ .nav-close-mobile {
        opacity: 1;
        transform: scale(1) rotate(0deg);
        pointer-events: auto;       /* clickeable inmediatamente */
        transition-delay: 0s, 2.4s, 0s;  /* opacity, transform, background */
    }


    /* ---- MENÚ DE COLUMNAS ---- */
    .site-nav > .mobile-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        display: block;
        z-index: 500;
        pointer-events: none;
        background: transparent;
    }
    .site-nav > .mobile-nav > ul {
        position: relative;
        display: block;
        width: 100%;
        height: 100%;
        list-style: none;
        margin: 0;
        padding: 0;
    }
    .site-nav > .mobile-nav > ul > li {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 20%;
        height: 100%;
        bottom: 100%;       /* Empieza fuera de pantalla por arriba */
        overflow: hidden;
    }
    .site-nav > .mobile-nav > ul > li > a {
        position: relative;
        color: #fff;
        text-decoration: none;
        font-size: 1.1rem;
        font-weight: 700;
        text-align: center;
        padding: 18px 14px;
        background: rgba(0, 0, 0, 0.28);
        border-radius: 10px;
        box-shadow:
            rgba(0, 0, 0, 0.40) 0px 2px 4px,
            rgba(0, 0, 0, 0.30) 0px 7px 13px -3px,
            rgba(0, 0, 0, 0.20) 0px -3px 0px inset;
        transition: transform 0.35s cubic-bezier(.215, .61, .355, 1),
                    color 0.25s ease,
                    background 0.25s ease;
        line-height: 1.15;
        pointer-events: auto;
    }
    .site-nav > .mobile-nav > ul > li > a:hover {
        color: #082c50;
        background: #fff;
    }
    .site-nav > .mobile-nav > ul > li > a:active {
        transform: scale(0.92);
    }

    /* Posiciones + colores de fondo (paleta COFIN como bandera) */
    .site-nav > .mobile-nav > ul > li:nth-child(1) { left:  0%; background: #2cd236; }
    .site-nav > .mobile-nav > ul > li:nth-child(2) { left: 20%; background: #18c020; }
    .site-nav > .mobile-nav > ul > li:nth-child(3) { left: 40%; background: #0e8a18; }
    .site-nav > .mobile-nav > ul > li:nth-child(4) { left: 60%; background: #0a4a82; }
    .site-nav > .mobile-nav > ul > li:nth-child(5) { left: 80%; background: #082c50; }

    /* Cada columna entra en cascada DESPUÉS de que la hamburguesa cubrió
       la pantalla (~1.4s) — efecto bandera cayendo */
    #nav-toggle:checked ~ .mobile-nav > ul > li {
        bottom: 0;
        transition: bottom 0.65s cubic-bezier(.215, .61, .355, 1);
    }
    #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(1) { transition-delay: 1.4s; }
    #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(2) { transition-delay: 1.6s; }
    #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(3) { transition-delay: 1.8s; }
    #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(4) { transition-delay: 2.0s; }
    #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(5) { transition-delay: 2.2s; }

    /* Bloquear scroll de fondo */
    body:has(#nav-toggle:checked) { overflow: hidden; }

    /* En pantallas estrechas: filas en lugar de columnas */
    @media (max-width: 600px) {
        .site-nav > .mobile-nav > ul > li {
            width: 100% !important;
            height: 20% !important;
            left: 0 !important;
        }
        #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(1) { bottom: 80%; }
        #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(2) { bottom: 60%; }
        #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(3) { bottom: 40%; }
        #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(4) { bottom: 20%; }
        #nav-toggle:checked ~ .mobile-nav > ul > li:nth-child(5) { bottom:  0%; }

        .site-nav > .mobile-nav > ul > li > a {
            font-size: 1.25rem;
            padding: 14px 24px;
        }
    }
}

/* Accesibilidad: usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
    .site-nav *,
    .site-nav *::before,
    .site-nav *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        animation-delay: 0s !important;
        transition-delay: 0s !important;
    }
}
