/* ========================================================================
  HEADER - RunArt Base Theme (Blanco y Rojo)
  UI/UX Improvements 2025-11:
    - Spacing nav desktop 2rem→3rem, tablet 1rem→1.5rem
    - Gap menú desktop 0.5rem→0.75rem; tablet 0.25rem→0.5rem
    - Active state con background rgba(195,0,0,.15) + font-weight 600
    - Focus-visible accesible en logo, nav links y language switcher
    - Language switcher mantiene fixes Chrome en responsive.overrides.css
  ======================================================================== */

/* Header Container */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 2px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Branding */
.site-branding {
  flex-shrink: 0;
  margin-right: 0.5rem; /* Separación entre logo y nav */
}

.site-title {
  color: var(--color-text);
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

.site-title:hover {
  color: var(--color-primary);
}

.site-title:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
  border-radius: 4px;
}

.custom-logo {
  max-height: 50px;
  width: auto;
  display: block;
}

.site-logo {
  display: inline-block;
  border-radius: 4px;
  transition: opacity 0.2s;
}

.site-logo:hover {
  opacity: 0.85;
}

.site-logo:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
}

/* Navigation */
.site-nav {
  flex: 1;
  display: flex;
  justify-content: center;
  margin: 0 3rem; /* Aumentado de 2rem a 3rem para más espacio en desktop */
}

/* Mobile social block - oculto por defecto en desktop */
.mobile-menu-social {
  display: none;
}

.site-nav .menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.75rem; /* Aumentado de 0.5rem a 0.75rem para mejor separación */
  align-items: center;
}

.site-nav .menu-item {
  margin: 0;
  position: relative;
}

.site-nav .menu-item a {
  color: var(--color-text);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  display: block;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.site-nav .menu-item a:hover {
  background: rgba(195, 0, 0, 0.08);
  color: var(--color-primary);
}

.site-nav .menu-item a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  background: rgba(195, 0, 0, 0.08);
}

/* Estado activo: más contraste visual */
.site-nav .menu-item.current-menu-item a,
.site-nav .menu-item.current_page_parent a {
  background: rgba(195, 0, 0, 0.15);
  color: var(--color-primary);
  font-weight: 600;
}

.site-nav .menu-item a:active {
  transform: scale(0.98);
}

/* Language Switcher */
.site-lang-switcher {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.site-lang-switcher ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0.5rem;
}

.site-lang-switcher li {
  margin: 0;
}

.site-lang-switcher a {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
  opacity: 0.7;
}

.site-lang-switcher a:hover {
  background: rgba(195, 0, 0, 0.1);
  opacity: 1;
}

.site-lang-switcher a img {
  display: block;
  width: 24px;
  height: auto;
  border-radius: 2px;
}

/* Hamburger toggle (hidden by default on desktop) */
.nav-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
}

.site-menu-toggle {
  display: none; /* visible solo en móvil */
  flex-direction: column; /* CRÍTICO: apilar las líneas verticalmente */
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
  gap: 5px; /* Espacio entre las 3 líneas */
  cursor: pointer;
  transition: background 0.2s ease;
  padding: 8px;
  box-sizing: border-box;
}

.site-menu-toggle:hover { background: rgba(195, 0, 0, 0.08); }
.site-menu-toggle:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.site-menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text, #1a1a1a);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Responsive: Mobile */
@media (max-width: 768px) {
  .site-header .container {
    flex-wrap: wrap;
    padding: 1rem;
    gap: 0.5rem; /* Espacio entre elementos */
  }

  .site-branding {
    order: 1;
    flex: 0 0 auto;
    margin-right: 0;
  }

  .site-lang-switcher {
    order: 2;
    flex: 0 0 auto;
    /* Asegurar que las banderas siempre sean visibles */
    min-width: 80px;
    margin-left: auto; /* Empujar a la derecha */
  }

  .site-menu-toggle {
    order: 3;
    display: inline-flex;
    flex: 0 0 auto;
  }

  .site-nav {
    order: 4;
    width: 100%;
    margin: 0.5rem 0 0 0; /* Reducido de 1rem a 0.5rem */
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Prevenir que el menú empuje elementos fuera */
    max-width: 100%;
    display: none; /* Oculto por defecto en móvil; se muestra con toggle */
  }

  .site-nav .menu {
    flex-wrap: nowrap;
    gap: 0.25rem;
    /* Asegurar que el scroll horizontal funcione correctamente */
    padding-right: 1rem;
  }

  .site-nav .menu-item a {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* Mostrar nav cuando el toggle está activo (via JavaScript class on body) */
@media (max-width: 768px) {
  /* Reset completo para el menú abierto */
  body.nav-open .site-nav {
    /* Posicionamiento */
    display: flex;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(100vh - 60px);

    /* Apariencia */
    background: #ffffff;
    border-top: 1px solid #e0e0e0;

    /* Layout */
    flex-direction: column;
    padding: 1rem;
    margin: 0;
    box-sizing: border-box;

    /* Scroll */
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;

    /* Anular reglas de responsive.overrides.css */
    max-inline-size: 100%;
    max-width: 100%;
    contain: none;

    /* Z-index */
    z-index: 9998;
  }

  body.nav-open .site-nav .menu,
  body.nav-open .site-nav > ul {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.5rem;
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
    white-space: normal;
    inline-size: auto;
  }

  body.nav-open .site-nav .menu-item,
  body.nav-open .site-nav li {
    width: 100%;
    margin: 0;
    list-style: none;
    flex: none;
  }

  body.nav-open .site-nav .menu-item a,
  body.nav-open .site-nav li a {
    display: block;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    background: #f5f5f5;
    color: #1a1a1a;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s ease;
  }

  body.nav-open .site-nav .menu-item a:hover,
  body.nav-open .site-nav li a:hover {
    background: rgba(195, 0, 0, 0.1);
    color: #C30000;
  }

  body.nav-open .site-nav .menu-item.current-menu-item a,
  body.nav-open .site-nav .menu-item.current_page_item a,
  body.nav-open .site-nav .current-menu-item a {
    background: #C30000;
    color: #fff;
  }

  /* Header fijo cuando menú está abierto */
  body.nav-open .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  }

  /* Animación hamburguesa a X */
  body.nav-open .site-menu-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  body.nav-open .site-menu-toggle span:nth-child(2) {
    opacity: 0;
  }
  body.nav-open .site-menu-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* Bloque de redes sociales en menú móvil */
  .mobile-menu-social {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1rem;
    margin-top: auto;
    border-top: 1px solid var(--color-border, #e0e0e0);
  }

  .mobile-menu-social__label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
}

/* Responsive: Tablet - Protección language switcher */
@media (max-width: 1200px) {
  .site-header .container {
    /* Asegurar que language switcher nunca se pierda */
    gap: 0.5rem;
    /* Prevenir overflow horizontal */
    overflow: visible;
  }

  .site-branding {
    flex-shrink: 0;
  }

  .site-nav {
    margin: 0 1rem;
    /* Permitir que el nav se comprima pero no empuje al switcher */
    flex: 1 1 auto;
    min-width: 0; /* Permite que flex-shrink funcione */
    /* Prevenir overflow del contenedor padre */
    max-width: calc(100% - 280px); /* Espacio para logo + switcher + gaps */
  }

  .site-nav .menu {
    gap: 0.4rem;
    flex-wrap: nowrap;
  }

  .site-nav .menu-item a {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .site-lang-switcher {
    /* Forzar que el switcher siempre sea visible */
    flex-shrink: 0;
    min-width: 80px; /* Espacio mínimo garantizado para banderas */
    margin-left: auto; /* Asegurar posición a la derecha */
  }
}

/* Responsive: Tablet medio */
@media (max-width: 1024px) {
  .site-nav {
    margin: 0 0.75rem;
  }

  .site-nav .menu {
    gap: 0.3rem;
  }

  .site-nav .menu-item a {
    padding: 0.5rem 0.65rem;
    font-size: 0.875rem;
  }
}

/* Responsive: Tablet pequeño - wrap antes de perder switcher */
@media (max-width: 900px) {
  .site-header .container {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .site-branding {
    order: 1;
    flex: 0 0 auto;
  }

  .site-lang-switcher {
    order: 2;
    flex: 0 0 auto;
    min-width: 80px;
    margin-left: auto; /* Mantener a la derecha */
  }

  .site-nav {
    order: 3;
    width: 100%;
    margin: 0.75rem 0 0 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%; /* Prevenir overflow */
  }

  .site-nav .menu {
    gap: 0.5rem;
    flex-wrap: nowrap;
    padding-right: 1rem; /* Espacio para scroll */
  }
}

/* Responsive: Móvil reducido */
@media (max-width: 480px) {
  .site-header .container {
    padding: 0.5rem 0.75rem;
    gap: 0.4rem;
  }

  .site-lang-switcher a {
    padding: 0.25rem;
  }

  .site-lang-switcher a img {
    width: 20px; /* Reducir bandera en móviles pequeños */
  }

  .site-nav .menu-item a {
    padding: 0.45rem 0.6rem;
    font-size: 0.875rem;
  }
  .site-menu-toggle {
    display: inline-flex;
    flex-direction: column;
    width: 40px;
    height: 40px;
  }
  .site-menu-toggle span { width: 22px; }
}

/* Responsive: Móvil muy pequeño (ajuste fino a ~400px) */
@media (max-width: 400px) {
  .site-header .container {
    padding: 0.5rem; /* Compactar aún más */
  }

  .site-lang-switcher {
    min-width: 64px; /* Asegura espacio mínimo para dos banderas */
  }

  .site-lang-switcher a img {
    width: 18px; /* Banderas más compactas */
  }

  .site-nav {
    margin-top: 0.5rem;
  }

  .site-nav .menu {
    gap: 0.25rem;
  }
  .site-menu-toggle {
    width: 36px;
    height: 36px;
    gap: 4px;
  }
  .site-menu-toggle span { width: 18px; }
}
