/* JDServer-Webs v6.8 — modules/header/header.css
   - BrandTitle (grande) con Apple-ish vibes
   - Nav bajo el título, responsive sin romper
   - Subtítulo + estación del año en la misma fila
   - Fila de chips: Estación / Idioma / Tema
   - Modo "hero-logo" por slug (cerdanyola_centre)
*/

#site-header {
  position: relative;
  z-index: 30; /* por si hay elementos con z-index altos debajo */
  backdrop-filter: blur(10px);
  background:
    radial-gradient(1200px 200px at 50% -40%, var(--brand-50, color-mix(in oklab, var(--brand, #10b981) 12%, transparent)), transparent 70%),
    linear-gradient(180deg, var(--brand-100, color-mix(in oklab, var(--brand, #10b981) 20%, transparent)), transparent 40%);
  box-shadow: var(--shadow-2);
  border-bottom: 1px solid var(--border);
}

/* ──────────────── Fila superior: logo + bloque brand + chips ──────────────── */
.header-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  flex-wrap: wrap; /* permite bajar acciones si no cabe */
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* ✅ PC: un poquito más pequeño aún */
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  overflow: hidden;
  object-fit: cover;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  flex: 0 0 auto;
}

.brand-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

/* Filas internas del título */
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

/* Fila del título principal + logos Sant Vicenç */
.brand-row.title-row { align-items: center; }

/* Fila subtítulo + estación del año */
.brand-row.sub-row {
  align-items: center;
  gap: 8px;
}

/* Título principal */
.brand-title strong {
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: .1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Subtítulo (por defecto: modo claro / neutro) */
.brand-title .brand-subtitle {
  color: var(--muted);
  font-size: 1.0rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logos inline para Sant Vicenç (a la derecha del título) */
.brand-partners-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  max-width: 100%;
  margin-left: 14px;
  flex-wrap: nowrap;
}

.brand-partners-inline img {
  height: 34px;
  max-width: 150px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--card);
  padding: 2px 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,.15);
}

/* Zona derecha: chips Estación / Idioma / Tema */
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ──────────────── Píldora de estación ──────────────── */
.season-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .26rem .60rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--card) 80%, var(--brand, #10b981) 20%);
  font-size: .84rem;
  color: var(--fg, var(--text));
  white-space: nowrap;
}

.season-pill .season-icon {
  font-size: 1rem;
  line-height: 1;
}

.season-pill .season-label { font-weight: 500; }

/* ──────────────── Chips resumen (Idioma/Tema/Estación) ──────────────── */
.header-actions .btn.ghost,
.header-actions .dropdown > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .20rem .55rem;
}

.header-actions .chip-current {
  font-size: .80rem;
  color: var(--muted);
}

/* ──────────────── Dropdowns accesibles con <details> ──────────────── */
.dropdown { position: relative; }

.dropdown > summary {
  list-style: none;
  cursor: pointer;
  outline: none;
}

.dropdown > summary::-webkit-details-marker { display: none; }

.dropdown > summary:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand, #10b981) 30%, transparent);
  border-radius: 10px;
}

/* ✅ Menú: desktop anclado a la derecha */
.dropdown .menu {
  position: absolute;
  right: 0;
  left: auto;
  top: calc(100% + 8px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
  padding: 6px;
  min-width: 180px;
  z-index: 60;

  /* extra robustez */
  max-width: 320px;
  overflow: auto;
  max-height: 60vh;
}

.menu a,
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--fg, var(--text));
  padding: .55rem .65rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: .95rem;
  outline: none;
}

.menu a.active,
.menu button.active,
.menu a:hover,
.menu button:hover {
  background: rgba(0,0,0,.05);
}

.menu a:focus-visible,
.menu button:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand, #10b981) 30%, transparent);
}

/* hover/active más suave en dark (esto sí puede seguir con prefers-color-scheme, no depende del "tema" del site) */
@media (prefers-color-scheme: dark) {
  .menu a.active,
  .menu button.active,
  .menu a:hover,
  .menu button:hover {
    background: rgba(255,255,255,.06);
  }
}

/* ──────────────── Etiquetas pequeñas tipo “badge” ──────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .30rem;
  padding: .16rem .42rem;
  font-size: .76rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
}

/* ──────────────── Segunda fila: navegación ──────────────── */
.header-nav {
  border-top: 1px solid var(--border);
  padding: 10px 0 14px;
}

.nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav a {
  padding: .45rem .7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg, var(--text));
  font-size: .92rem;
  transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
  outline: none;
}

.nav a:hover {
  background: var(--brand-50, color-mix(in oklab, var(--brand, #10b981) 12%, transparent));
  border-color: var(--brand-200, color-mix(in oklab, var(--brand, #10b981) 30%, transparent));
}

.nav a:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand, #10b981) 30%, transparent);
}

.nav a.active {
  background: linear-gradient(180deg, var(--brand-accent, var(--brand, #10b981)), var(--brand, #10b981));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* ──────────────── HERO LOGO (cerdanyola_centre + cerdanyola_montflorit) ──────────────── */
:root[data-site="cerdanyola_centre"] .header-bar,
:root[data-site="cerdanyola_montflorit"] .header-bar{
  gap: 22px;
  padding: 16px 0 12px;
}

:root[data-site="cerdanyola_centre"] .brand,
:root[data-site="cerdanyola_montflorit"] .brand{ gap: 16px; }

/* ✅ Hero PC un poquito más pequeño */
:root[data-site="cerdanyola_centre"] .brand-logo,
:root[data-site="cerdanyola_montflorit"] .brand-logo{
  width: 74px;
  height: 74px;
  border-radius: 20px;
  background: #fff;
  padding: 6px;
  border: 1px solid rgba(var(--brand-rgb), .25);
  box-shadow:
    0 18px 44px rgba(0,0,0,.22),
    0 0 0 10px rgba(var(--brand-rgb), .08);
  object-fit: contain;
}

:root[data-site="cerdanyola_centre"] .brand-title strong,
:root[data-site="cerdanyola_montflorit"] .brand-title strong{
  font-size: 1.60rem;
  letter-spacing: .2px;
}

:root[data-site="cerdanyola_centre"] .brand-title .brand-subtitle,
:root[data-site="cerdanyola_montflorit"] .brand-title .brand-subtitle{ font-size: 1.02rem; }

@media (max-width: 880px) {
  .brand-logo { width: 40px; height: 40px; border-radius: 12px; }
  .brand-title strong { font-size: 1.30rem; }
  .brand-title .brand-subtitle { font-size: .94rem; }

  .header-bar{
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header-actions{
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
  }

  .season-pill {
    font-size: .80rem;
    padding: .24rem .52rem;
  }

  .brand-partners-inline {
    margin-left: 10px;
    gap: 6px;
  }

  .brand-partners-inline img {
    height: 28px;
    max-width: 130px;
  }

  :root[data-site="cerdanyola_centre"] .brand-logo,
  :root[data-site="cerdanyola_montflorit"] .brand-logo{
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: #fff;
    box-shadow:
      0 16px 40px rgba(0,0,0,.22),
      0 0 0 9px rgba(var(--brand-rgb), .08);
  }

  .nav a { font-size: .9rem; padding: .42rem .62rem; }
}

@media (max-width: 520px) {
  .brand-logo { width: 36px; height: 36px; border-radius: 10px; }
  .brand-title strong { font-size: 1.22rem; }
  .brand-title .brand-subtitle { font-size: .90rem; }

  /* ✅ FIX iPhone: el menú NO se sale por la izquierda (se ancla al left)
     + respeta safe-area y limita ancho */
  .dropdown .menu{
    left: 0;
    right: auto;
    width: min(320px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }

  :root[data-site="cerdanyola_centre"] .brand-logo,
  :root[data-site="cerdanyola_montflorit"] .brand-logo{
    width: 66px;
    height: 66px;
    border-radius: 18px;
    background: #fff;
    box-shadow:
      0 14px 34px rgba(0,0,0,.22),
      0 0 0 8px rgba(var(--brand-rgb), .08);
  }

  .nav a { font-size: .86rem; }
}

/* ───────────────────────────────────────────────────────────────
   SUBTÍTULO: compatibilidad total (iOS/Android/mac/windows)
   - NO usamos prefers-color-scheme para forzar blanco, porque rompe cuando:
     sistema=dark pero tema de la web=light (caso Android).
   - En LIGHT: gris de siempre (var(--muted)).
   - En DARK: blanco suave.
   - En AUTO: si no hay "theme" forzado, el navegador decide; si theme.js fuerza,
     gana el atributo/clase.
─────────────────────────────────────────────────────────────── */

/* 1) Tema oscuro FORZADO por la web (recomendado) */
:root[data-theme="dark"] #site-header .brand-title .brand-subtitle,
html[data-theme="dark"]  #site-header .brand-title .brand-subtitle,
html.dark                #site-header .brand-title .brand-subtitle,
body.dark                #site-header .brand-title .brand-subtitle {
  color: rgba(255,255,255,.92);
}

/* 2) Tema claro FORZADO por la web (mantiene el gris "de siempre") */
:root[data-theme="light"] #site-header .brand-title .brand-subtitle,
html[data-theme="light"]  #site-header .brand-title .brand-subtitle {
  color: var(--muted);
}

/* 3) AUTO (solo si NO hay tema forzado): el navegador manda */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) #site-header .brand-title .brand-subtitle,
  html:not([data-theme])  #site-header .brand-title .brand-subtitle {
    color: rgba(255,255,255,.92);
  }
}


/* ───────────────────────────────────────────────────────────────
   CHIP-CURRENT (Centre / CA / Automàtic)
   - Solo los textos “de valor” al lado de los botones.
   - En LIGHT: muted normal.
   - En DARK (forzado): blanco suave.
   - En AUTO sin tema forzado: si el sistema está en dark, blanco suave.
─────────────────────────────────────────────────────────────── */

#site-header .header-actions .chip-current{
  color: var(--muted); /* default (light / neutro) */
}

/* 1) Tema oscuro FORZADO por la web */
:root[data-theme="dark"] #site-header .header-actions .chip-current,
html[data-theme="dark"]  #site-header .header-actions .chip-current,
html.dark                #site-header .header-actions .chip-current,
body.dark                #site-header .header-actions .chip-current{
  color: rgba(255,255,255,.92);
}

/* 2) Tema claro FORZADO por la web */
:root[data-theme="light"] #site-header .header-actions .chip-current,
html[data-theme="light"]  #site-header .header-actions .chip-current{
  color: var(--muted);
}

/* 3) AUTO (solo si NO hay tema forzado): el navegador manda */
@media (prefers-color-scheme: dark){
  :root:not([data-theme]) #site-header .header-actions .chip-current,
  html:not([data-theme])  #site-header .header-actions .chip-current{
    color: rgba(255,255,255,.92);
  }
}
