/* =========================================
   HEADER / NAVBAR
========================================= */
.header {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: min(1320px, calc(100% - 40px));
    z-index: 100;
    border-radius: 50px;
    overflow: hidden;
    color: #1a1a1a;

    background: transparent;
    border: none;

    box-shadow:
        0 8px 28px rgba(0, 0, 0, 0.10),
        0 1px 2px rgba(0, 0, 0, 0.06);

    transition:
        box-shadow 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.header:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.14),
        0 2px 6px rgba(0, 0, 0, 0.06);
}

.header-glass {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.header-glass-effect {
    position: absolute;
    z-index: 0;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    isolation: isolate;
    backdrop-filter: blur(16px) saturate(160%);
    -webkit-backdrop-filter: blur(16px) saturate(160%);
}

@supports (backdrop-filter: url(#glass-distortion)) {
    .header-glass-effect {
        backdrop-filter: blur(12px) saturate(160%) url(#glass-distortion);
        -webkit-backdrop-filter: blur(12px) saturate(160%) url(#glass-distortion);
    }
}

.header-glass-tint {
    position: absolute;
    z-index: 1;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.01) 0%,
        rgba(255, 255, 255, 0.01) 42%,
        rgba(255, 255, 255, 0.01) 100%
    );
}

.header-glass-shine {
    position: absolute;
    z-index: 2;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.01) 0%,
        transparent 22%
    );
}

.header-glass-svg {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Canto fino y neutro: no pinta un aro blanco sobre fondos de color. */
.header::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.10);
    pointer-events: none;
    z-index: 2;
}

.header::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 2;
    background: linear-gradient(
        105deg,
        transparent 36%,
        rgba(255, 255, 255, 0.55) 48%,
        transparent 60%
    );
    background-size: 220% 100%;
    background-position: 140% 0;
    opacity: 0;
}

@keyframes glass-sweep {
    0%   { background-position: 140% 0; opacity: 0; }
    18%  { opacity: 0.85; }
    100% { background-position: -50% 0; opacity: 0; }
}

.header-container {
    width: 100%;
    min-height: 64px;
    margin: 0 auto;
    padding: 10px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 3;
}


/* Logo */
.brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    width: 70px;
    display: block;
    transition: filter 0.25s ease;
}

.header.logo-invert .logo {
    filter: brightness(0) invert(1);
}


/* Nav */
.nav {
    display: flex;
    align-items: center;
    gap: 26px;
}

.nav-link {
    position: relative;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 500;
    padding: 10px 0;
    white-space: nowrap;
    transition:
        color 0.25s ease,
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-link:hover {
    color: var(--verde-oscuro);
    transform: translateY(-2px);
}

.nav-link:active {
    transform: translateY(0);
}

.nav-link.active {
    color: #000;
    font-weight: 600;
}

.header.logo-invert .nav-link,
.header.logo-invert .nav-link.active {
    color: #fff;
}

.header.logo-invert .nav-link:hover {
    color: var(--verde-claro);
}

/* La línea vive en el enlace activo. left/right contra un ancestro
   más ancho la dibujaba debajo de todos los items. */
.nav-link.active::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 3px;
    border-radius: 3px;
    background: #AEE318;
    transform-origin: center;
    animation: line-grow 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

@keyframes line-grow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}


/* Botón Ingresar */
.login-button {
    position: relative;
    overflow: hidden;
    padding: 11px 26px;
    border: none;
    border-radius: 50px;
    background: var(--verde-oscuro);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    transition:
        background 0.3s ease,
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.3s ease;
}

.login-button::after {
    content: "";
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        100deg,
        transparent 0%,
        rgba(255, 255, 255, 0.55) 50%,
        transparent 100%
    );
    transform: skewX(-20deg);
    transition: left 0.6s ease;
}

.login-button:hover {
    background: #024d28;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 22px rgba(3, 102, 53, 0.35);
}

.login-button:hover::after {
    left: 125%;
}

.login-button:active {
    transform: translateY(0) scale(0.98);
}


/* Botón hamburguesa (solo visible en móvil) */
.menu-button {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;

    width: 40px;
    height: 40px;
    flex-shrink: 0;

    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;

    transition:
        background 0.3s ease,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.menu-button:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.06);
}

.menu-button:active {
    transform: scale(0.92);
}

.menu-button span {
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: #1a1a1a;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease, background 0.25s ease;
}

.header.logo-invert .menu-button span {
    background: #fff;
}

.menu-button[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-button[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.menu-button[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

body.nav-scroll-lock {
    overflow: hidden;
}


/* =========================================
   RESPONSIVE — LAPTOP (<= 1280px)
========================================= */

@media (max-width: 1280px) {

    .header {
        width: min(1200px, calc(100% - 36px));
    }

    .nav {
        gap: 18px;
    }

    .nav-link {
        font-size: 15px;
    }

    .login-button {
        padding: 10px 20px;
        font-size: 16px;
    }

}


/* =========================================
   RESPONSIVE — TABLET / MÓVIL (<= 1024px)
   Menú hamburguesa + panel desplegable
========================================= */

@media (max-width: 1024px) {

    .header {
        overflow: visible;
        top: max(12px, env(safe-area-inset-top, 0px));
        width: min(100%, calc(100% - 24px));
        border-radius: 28px;
        z-index: 250;
    }

    .header:hover {
        transform: translateX(-50%);
    }

    .header.nav-open {
        border-radius: 24px;
        z-index: 120;
    }

    .header-container {
        min-height: 56px;
        padding: 8px 16px;
        gap: 12px;
    }

    .logo {
        width: 64px;
    }

    .menu-button {
        display: flex;
        position: relative;
        z-index: 5;
    }

    .nav {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        right: 0;
        z-index: 40;

        flex-direction: column;
        align-items: stretch;
        gap: 2px;

        max-height: min(520px, calc(100dvh - 120px));
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;

        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(20px) saturate(160%);
        -webkit-backdrop-filter: blur(20px) saturate(160%);
        border: 1px solid rgba(0, 0, 0, 0.08);
        border-radius: 20px;
        padding: 8px 12px 12px;

        box-shadow:
            0 16px 40px rgba(0, 0, 0, 0.14),
            0 2px 8px rgba(0, 0, 0, 0.06);

        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-10px);

        transition:
            opacity 0.28s ease,
            transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
            visibility 0.32s;
    }

    .nav.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .header.logo-invert .nav {
        background: rgba(18, 22, 20, 0.94);
        border-color: rgba(255, 255, 255, 0.12);
    }

    .nav-link {
        font-size: 15px;
        font-weight: 500;
        padding: 12px 12px;
        border-radius: 12px;
        border-bottom: none;
        white-space: normal;
    }

    .nav-link:hover {
        transform: none;
        background: rgba(3, 102, 53, 0.08);
    }

    .nav-link.active {
        background: rgba(174, 227, 24, 0.22);
        font-weight: 600;
    }

    .header.logo-invert .nav-link {
        color: #f5f5f5;
    }

    .header.logo-invert .nav-link:hover {
        background: rgba(255, 255, 255, 0.08);
        color: var(--verde-claro);
    }

    .header.logo-invert .nav-link.active {
        background: rgba(174, 227, 24, 0.18);
        color: #ffffff;
    }

    .nav-link.active::after {
        display: none;
    }

    .login-button {
        display: block;
        width: 100%;
        margin-top: 8px;
        padding: 13px 20px;
        text-align: center;
        box-sizing: border-box;
    }

    .login-button:hover {
        transform: none;
    }

}

@media (max-width: 480px) {

    .header {
        width: calc(100% - 16px);
        border-radius: 22px;
    }

    .header-container {
        padding: 8px 12px;
    }

    .logo {
        width: 58px;
    }

    .nav {
        padding: 6px 8px 10px;
        border-radius: 18px;
    }

    .nav-link {
        font-size: 16px;
        padding: 11px 10px;
    }

}


/* =========================================
   ACCESIBILIDAD — respeta "reducir movimiento"
========================================= */

@media (prefers-reduced-motion: reduce) {

    .header,
    .header::before,
    .header::after,
    .header-glass-effect,
    .nav,
    .nav-link,
    .nav-link.active::after,
    .login-button,
    .login-button::after,
    .logo,
    .menu-button,
    .menu-button span {
        animation: none !important;
        transition: none !important;
    }

    .header-glass-effect {
        backdrop-filter: blur(16px) saturate(160%);
        -webkit-backdrop-filter: blur(16px) saturate(160%);
    }

}


@media screen and (max-width: 600px) {
    .header .nav,
    .header.logo-invert .nav {
        background: rgba(255, 255, 255, 0.97) !important;
        border-color: rgba(0, 0, 0, 0.08) !important;
    }

    .header .nav-link,
    .header.logo-invert .nav-link,
    .header.logo-invert .nav-link.active {
        color: #1a1a1a !important;
    }

    .header .nav-link:hover,
    .header.logo-invert .nav-link:hover {
        color: var(--verde-oscuro) !important;
        background: rgba(3, 102, 53, 0.08) !important;
    }

    .header .nav-link.active,
    .header.logo-invert .nav-link.active {
        color: #1a1a1a !important;
        background: rgba(174, 227, 24, 0.22) !important;
    }
}
