/* Selector de idioma único en cabecera (ES | VA). */
.header-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.32em;
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--porcelana);
  white-space: nowrap;
}
.header-lang a {
  color: inherit;
  text-decoration: none;
  opacity: 0.62;
  padding-block: 0.15em;
  border-bottom: 1px solid transparent;
}
.header-lang a:hover,
.header-lang a:focus-visible {
  opacity: 1;
}
.header-lang a[aria-current="page"] {
  opacity: 1;
  font-weight: 600;
  border-bottom-color: currentColor;
}
.header-lang .sep {
  opacity: 0.35;
}
.header-inner > .header-lang {
  margin-left: 0.35rem;
}
.bar > .header-lang {
  margin-left: 1rem;
}
.legal-header-home + .header-lang {
  margin-left: 0.8rem;
}
@media (max-width: 960px) {
  .header-lang {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
  }
}

/* Banderas junto a ES y VA (retoque 2026-11-23).
   Solo actúan en las páginas cuyo selector lleva los spans .lang-flag;
   en el resto quedan inertes y la cabecera no cambia.
   Geometría de la senyera según el modelo oficial: franja blava de un
   terzo y nueve bandas iguales de groc y roig. */
.header-lang a:has(.lang-flag) {
  display: inline-flex;
  align-items: center;
  gap: 0.34em;
  min-height: 24px;
  opacity: 1;
}
.header-lang a:has(.lang-flag) .lang-code {
  /* Atenuada respecto al idioma activo, con margen sobre el AA (≥ 4,5:1). */
  opacity: 0.72;
  transition: opacity 0.2s ease;
}
.header-lang a:has(.lang-flag):hover .lang-code,
.header-lang a:has(.lang-flag):focus-visible .lang-code,
.header-lang a[aria-current="page"] .lang-code {
  opacity: 1;
}
.header-lang .lang-flag {
  flex: 0 0 auto;
  width: 1.2667rem;
  height: 0.8444rem;
  box-shadow: 0 0 0 1px rgba(38, 10, 25, 0.2);
}
.header-lang .lang-flag-es {
  background: linear-gradient(to bottom, #aa151b 0 25%, #f1bf00 25% 75%, #aa151b 75% 100%);
}
.header-lang .lang-flag-va {
  background:
    linear-gradient(to right, #0072bc 0 33.333%, rgba(0, 0, 0, 0) 33.333%),
    repeating-linear-gradient(to bottom, #fcdd09 0 11.111%, #da121a 11.111% 22.222%);
}
@media (max-width: 420px) {
  .header-lang a:has(.lang-flag) {
    gap: 0.26em;
  }
  .header-lang .lang-flag {
    width: 0.84375rem;
    height: 0.5625rem;
  }
}

/* Ajuste de cabecera para las páginas con banderas.
   Con las banderas el selector ocupa más y la marca, que antes iba fija,
   empujaba fuera de pantalla el menú (360-430 px) o el propio selector
   (820-1024 px). La marca pasa a ser el único elemento que cede espacio:
   se encoge solo lo necesario, de forma fluida y nunca por debajo de un
   mínimo. Los controles (idioma, reserva y menú) no se recortan nunca.
   En las páginas sin banderas estas reglas no aplican. */
.header-inner:has(.header-lang .lang-flag) .brand {
  flex: 0 1 auto;
  min-width: 96px;
}
.header-inner:has(.header-lang .lang-flag) .brand img {
  flex: 0 1 auto;
  min-width: 0;
}
.header-inner:has(.header-lang .lang-flag) .desktop-nav,
.header-inner:has(.header-lang .lang-flag) .mobile-header-actions,
.header-inner:has(.header-lang .lang-flag) .header-lang {
  flex-shrink: 0;
}
@media (min-width: 761px) and (max-width: 1180px) {
  .header-inner:has(.header-lang .lang-flag) {
    gap: clamp(12px, 2vw, 20px);
    padding-inline: clamp(20px, 3.4vw, 40px);
  }
  .header-inner:has(.header-lang .lang-flag) .desktop-nav {
    gap: clamp(12px, 1.7vw, 22px);
  }
}
@media (min-width: 761px) and (max-width: 900px) {
  /* Igual que en el resto de páginas: a este ancho el teléfono no cabe
     junto a la navegación y las banderas; la llamada sigue en el cierre. */
  .header-inner:has(.header-lang .lang-flag) .desktop-nav .header-phone {
    display: none;
  }
}
@media (max-width: 520px) {
  .header-inner:has(.header-lang .lang-flag) > .header-lang {
    margin-left: 0;
  }
  .header-lang:has(.lang-flag) {
    gap: 0.6em;
  }
  .header-lang:has(.lang-flag) .sep {
    display: none;
  }
  .header-inner:has(.header-lang .lang-flag) .mobile-header-actions .button-small {
    padding-inline: 8px;
    font-size: 10px;
  }
}
@media (max-width: 374px) {
  /* Con banderas no cabe el botón junto a la marca: la reserva sigue en el menú. */
  .header-inner:has(.header-lang .lang-flag) .mobile-header-actions .button-small {
    display: none;
  }
}
@media (max-width: 350px) {
  .mobile-header-actions .button-small {
    display: none !important;
  }
}
@media (min-width: 381px) and (max-width: 420px) {
  .header-inner .brand img {
    max-width: 160px !important;
    height: 44px !important;
  }
  .mobile-header-actions .button-small {
    padding: 6px 8px !important;
    font-size: 10px !important;
  }
}
