/* ==========================================================================
   GLOBAL FLOATING NAV & OVERLAY MENU
   ========================================================================== */

:root {
    --color-marron: #5e372f;
    --color-marron-rgb: 94, 55, 47;
    --glass-blur: 14px;
    --nav-height: 54px;
}

/* -------------------------------------------------------------------------
   PÍLDORA FLOTANTE (CONTENEDOR)
   ------------------------------------------------------------------------- */
#floating-global-nav {
    position: fixed;
    top: 24px;
    right: 24px;
    height: var(--nav-height);
    padding: 0 8px 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    /* Z-index superior al del overlay */
    z-index: 2147483647 !important; 
    border-radius: 40px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.08);
    transition: top 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Enlace al Directorio (Siempre visible) */
#floating-global-nav .global-directory-link {
    color: #ffffff !important;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-decoration: none;
    transition: color 0.3s ease;
}

#floating-global-nav .global-directory-link:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* -------------------------------------------------------------------------
   ESTADO STICKY (Al hacer Scroll)
   ------------------------------------------------------------------------- */
#floating-global-nav.is-sticky {
    top: 16px;
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(var(--color-marron-rgb), 0.15);
    box-shadow: 0 10px 30px rgba(var(--color-marron-rgb), 0.08);
}

#floating-global-nav.is-sticky .global-directory-link {
    color: var(--color-marron) !important;
}

#floating-global-nav.is-sticky .global-directory-link:hover {
    opacity: 0.8;
}

/* -------------------------------------------------------------------------
   BOTÓN HAMBURGUESA INTERACTIVO
   ------------------------------------------------------------------------- */
.global-menu-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 0;
    position: relative;
    transition: background 0.3s ease;
}

/* Círculo de fondo al hacer hover en el botón */
#floating-global-nav:not(.is-sticky) .global-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
}
#floating-global-nav.is-sticky .global-menu-toggle:hover {
    background: rgba(var(--color-marron-rgb), 0.08);
}

/* Líneas del botón */
.global-menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: #ffffff;
    border-radius: 2px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}

/* Cambiar color de líneas en modo Sticky */
#floating-global-nav.is-sticky .global-menu-toggle span {
    background: var(--color-marron);
}

/* -------------------------------------------------------------------------
   BLOQUEO DE SCROLL EN EL BODY (Clase utilitaria para el JS)
   ------------------------------------------------------------------------- */
body.global-menu-open {
    overflow: hidden !important; /* Evita que el fondo se mueva y rompa el z-index */
    touch-action: none; /* Bloquea el scroll táctil en móviles */
}
/* Cuando se añade la clase de apertura */
body.global-menu-open #global-overlay-menu {
    opacity: 1 !important;
    pointer-events: auto !important;
}
/* Transformación a cruz (X) cuando está abierto */
body.global-menu-open .global-menu-toggle span:nth-child(1) {
    transform: translate3d(0, 3.5px, 0) rotate(45deg);
    background: #ffffff !important; /* Siempre blanca en el overlay */
}
body.global-menu-open .global-menu-toggle span:nth-child(2) {
    transform: translate3d(0, -3.5px, 0) rotate(-45deg);
    background: #ffffff !important;
}

/* -------------------------------------------------------------------------
   OVERLAY MENU (Pantalla Completa Elegante)
   ------------------------------------------------------------------------- */
#global-overlay-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #5e372f !important; /* Marrón corporativo */
    
    /* Justo un nivel por debajo del botón de cierre */
    z-index: 2147483646 !important; 
    
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: opacity;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Cuando se añade la clase de apertura */
body.global-menu-open #global-overlay-menu {
    opacity: 1;
    pointer-events: auto;
}

/* Contenedor de enlaces internos */
.global-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 40px;
    text-align: center;
}

/* Estilo premium de los enlaces del Menú */
.global-overlay-inner a {
    color: #ffffff !important;
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -0.02em;
    text-decoration: none;
    opacity: 0;
    transform: translate3d(0, 30px, 0);
    transition: 
        transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), 
        opacity 0.5s ease,
        color 0.3s ease;
}

.global-overlay-inner a:hover {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* Cascada de animación de aparición de enlaces */
body.global-menu-open .global-overlay-inner a {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}
body.global-menu-open .global-overlay-inner a:nth-child(1) { transition-delay: 0.15s; }
body.global-menu-open .global-overlay-inner a:nth-child(2) { transition-delay: 0.25s; }
body.global-menu-open .global-overlay-inner a:nth-child(3) { transition-delay: 0.35s; }

/* Destacar ligeramente el botón de actualización en móvil */
.global-overlay-inner a[href*="actualice"] {
    font-weight: 300;
    font-style: italic;
}

/* -------------------------------------------------------------------------
   RESPONSIVE OPTIMIZATIONS
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
    #floating-global-nav {
        top: 16px;
        right: 16px;
        height: 48px;
        padding: 0 6px 0 16px;
    }
    #floating-global-nav.is-sticky {
        top: 12px;
    }
    #floating-global-nav .global-directory-link {
        font-size: 13px;
    }
    .global-overlay-inner a {
        font-size: 24px;
        gap: 24px;
    }
}