/* ==========================================================================
   HEADER.CSS
   Estilos globales para la cabecera principal y la barra de navegación.
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. FIX CONTEXTO GLOBAL (Safari iOS WebKit)
   Previene el desbordamiento sin romper posiciones fijas/sticky
   -------------------------------------------------------------------------- */
html, 
body {
    overflow-x: clip !important;
    overscroll-behavior-y: none;
}

/* --------------------------------------------------------------------------
   0.1 FIX MENÚ EXTENDIDO: neutraliza el stabilizer de .site-header
   mientras el menú está abierto, para que el botón (X) quede anclado
   estrictamente al viewport (evita el bug de WebKit sticky+transform+fixed)
   -------------------------------------------------------------------------- */
body:has(.fullscreen-overlay.active) .site-header {
    transform: none !important;
    -webkit-transform: none !important;
}

/* --------------------------------------------------------------------------
   1. BASE Y CONTENEDORES
   -------------------------------------------------------------------------- */
.site-header {
    background: var(--color-white);
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 9999;
    border-bottom: 1px solid var(--color-grey-light);
    box-shadow: 0 4px 20px rgba(0,0,0,0.03); 
    
    /* FIX ANIMACIÓN FANTASMA: Quitamos 'all' y animamos solo colores/sombras. 
       Así el transform (capa 3D) cambia en 0ms y la X no salta */
    transition: background-color 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    border-bottom: 3px solid var(--color-red); 

    /* STABILIZER: Fuerza aceleración por GPU para evitar el salto en scroll de iOS.
       Neutralizado mientras el menú extendido está activo (ver sección 0.1). */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.header-fluid {
    width: 100%;
    padding: 15px 4vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --------------------------------------------------------------------------
   2. ESTRUCTURA DE DISTRIBUCIÓN (FLEXBOX)
   -------------------------------------------------------------------------- */
.header-left, 
.header-right {
    flex: 1;
    display: flex;
    align-items: center;
    height: 100%; 
}

.header-left { 
    justify-content: flex-start; 
}

.header-right { 
    justify-content: flex-end; 
}

/* --------------------------------------------------------------------------
   3. LOGOTIPO
   -------------------------------------------------------------------------- */
.site-logo {
    flex: 0 0 150px; 
    display: flex;
    justify-content: center;
    align-items: center;
}

.site-header .site-logo img {
    max-width: 200px;
    max-height: 85px;
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* --------------------------------------------------------------------------
   4. BOTÓN DE CONTACTO RÁPIDO
   -------------------------------------------------------------------------- */
.btn-quick-contact {
    display: inline-flex;  
    align-items: center;   
    text-decoration: none;
    color: var(--color-darker);
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    padding: 6px 0;
    line-height: 1;
    
    /* Mantenemos el 'all' solo aquí, porque el botón sí requiere animar su pseudo-elemento */
    transition: all 0.3s ease;
}

.btn-quick-contact::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 30%;
    height: 2px;
    background-color: var(--color-red);
    transition: width 0.3s ease;
}

.btn-quick-contact:hover { 
    color: var(--color-red); 
}

.btn-quick-contact:hover::after { 
    width: 100%; 
}

/* --------------------------------------------------------------------------
   5. BOTÓN HAMBURGUESA Y ESTADOS DEL MENÚ
   -------------------------------------------------------------------------- */
.header-left button,
.header-left .menu-toggle,
.header-left .hamburger,
.header-left a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    height: auto;
    line-height: 1;
    
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.header-left svg {
    display: block;
    margin: 0;
}

.site-header.menu-open {
    z-index: 10000; 
    background-color: transparent; 
    border-bottom-color: transparent;
    box-shadow: none;

    /* Al matar el transform instantáneamente sin transición, la "X" nace en su lugar exacto */
    -webkit-transform: none !important;
    transform: none !important;
}

/* Ocultamos el logo y el botón de contacto para dejar solo la "X" visible */
.site-header.menu-open .site-logo,
.site-header.menu-open .header-right {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

/* Pintamos las barras de la X de color rojo para que destaquen */
.site-header.menu-open .hamburger-bar {
    background-color: var(--color-red);
}

/* ==========================================================================
   6. MEDIA QUERIES (Responsividad para Móviles y Tablets)
   ========================================================================== */
@media (max-width: 768px) {
    .header-fluid {
        padding: 10px 5vw; 
    }

    .site-logo {
        flex: 0 0 120px; 
    }

    .site-header .site-logo img {
        max-width: 130px;
        max-height: 55px;
    }

    .btn-quick-contact {
        font-size: 0.75rem;
        letter-spacing: 0.5px;
    }
}