/* Encabezado: logo, píldora, menú */
:root {
  --logo-st0: #3d3d3b;
  --logo-st1: #575756;
  --logo-halo: #292823;
  --logo-sw-iso: 0.9px;
  --logo-sw-word: 1px;
}
:root[data-theme="dark"] {
  --logo-st0: #f0f0f0;
  --logo-st1: #f0f0f0;
  --logo-halo: #f1eee6;
}
.site-header__bar { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 1.5rem; min-height: 72px; padding-block: 0; }
.brand { display: inline-flex; align-items: center; flex: none; }
.brand__logo { display: block; width: clamp(140px, 12vw, 165px); height: auto; filter: drop-shadow(0 0 .35px var(--logo-halo)); }
.brand__logo path { vector-effect: non-scaling-stroke; }
.brand__logo .st0 { color: var(--logo-st0); fill: currentColor; stroke: currentColor; stroke-width: var(--logo-sw-iso); stroke-linejoin: round; transition: color var(--dur, 420ms) ease; }
.brand__logo .st1 { color: var(--logo-st1); fill: currentColor; stroke: currentColor; stroke-width: var(--logo-sw-word); stroke-miterlimit: 10; transition: color var(--dur, 420ms) ease; }
.site-header__right { display: flex; align-items: center; gap: 3.5rem; }
.site-nav ul { display: flex; align-items: center; gap: 1.5rem; margin: 0; padding: 0; list-style: none; }
.site-nav .eyebrow { font-size: 12px; letter-spacing: .16em; }
.menu-open, .menu-close, .menu-brand { display: none; }
.theme-toggle { position: relative; flex: none; width: 48px; height: 26px; padding: 0; border: 1px solid color-mix(in oklch, currentColor 55%, transparent); border-radius: 999px; background: transparent; color: inherit; cursor: pointer; }
.theme-toggle::before { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: currentColor; transition: transform var(--dur, 240ms) ease; }
:root[data-theme="dark"] .theme-toggle::before { transform: translateX(22px); }
.theme-toggle svg { position: absolute; top: 6px; width: 12px; height: 12px; z-index: 1; }
.theme-toggle__sun { left: 6px; color: var(--bg); }
.theme-toggle__moon { right: 6px; color: currentColor; }
:root[data-theme="dark"] .theme-toggle__sun { color: currentColor; }
:root[data-theme="dark"] .theme-toggle__moon { color: var(--bg); }
.theme-toggle:focus-visible, .menu-open:focus-visible, .menu-close:focus-visible, .menu-brand:focus-visible, .site-nav li a:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

/* Escritorio: el nav (popover) se muestra en línea */
@media (min-width: 821px) {
  .site-nav { display: block; position: static; inset: auto; width: auto; height: auto; margin: 0; padding: 0 0 0 2rem; border: 0; border-left: 1px solid var(--rule); background: none; color: inherit; overflow: visible; }
}

/* Móvil: logo | píldora + hamburguesa; menú a pantalla completa */
@media (max-width: 820px) {
  .site-header__bar { direction: ltr; flex-direction: row; flex-wrap: nowrap; gap: 1rem; }
  .brand { order: 1; margin-right: auto; }
  .brand__logo { width: clamp(132px, 38vw, 150px); }
  .site-header__right { order: 2; flex-direction: row; gap: 1rem; }
  .theme-toggle { order: 1; }
  .menu-open { order: 2; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 1px solid color-mix(in oklch, currentColor 55%, transparent); border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
  .menu-open svg, .menu-close svg { width: 20px; height: 20px; }
  .site-nav:popover-open { position: fixed; inset: 0; width: 100%; height: 100dvh; margin: 0; padding: 17dvh 2rem 3rem; border: 0; background: var(--bg); color: var(--fg); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 11dvh; overflow: auto; }
  .site-nav:popover-open .menu-brand { display: block; flex: none; }
  .menu-brand .brand__logo { width: clamp(150px, 52vw, 190px); }
  .menu-close { display: inline-flex; align-items: center; justify-content: center; position: absolute; top: 16px; right: 1.25rem; width: 40px; height: 40px; padding: 0; border: 1px solid color-mix(in oklch, currentColor 55%, transparent); border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
  .site-nav ul { flex-direction: column; align-items: center; gap: clamp(1rem, 3.2dvh, 1.75rem); }
  .site-nav li a { display: inline-flex; align-items: center; gap: 1.1em; padding: .5rem 1rem; font-size: 1.125rem; letter-spacing: .3em; text-decoration: none; color: color-mix(in oklch, currentColor 68%, transparent); transition: gap var(--dur, 300ms) ease, color var(--dur, 300ms) ease; }
  .site-nav li a::before { content: "[" / ""; opacity: .5; transition: opacity var(--dur, 300ms) ease; }
  .site-nav li a::after { content: "]" / ""; margin-left: -.3em; opacity: .5; transition: opacity var(--dur, 300ms) ease; }
  .site-nav li a:focus-visible, .site-nav li a[aria-current="page"] { color: var(--fg); gap: .45em; }
  .site-nav li a:focus-visible::before, .site-nav li a:focus-visible::after, .site-nav li a[aria-current="page"]::before, .site-nav li a[aria-current="page"]::after { opacity: 1; }
  @media (hover: hover) {
    .site-nav li a:hover { color: var(--fg); gap: .45em; }
    .site-nav li a:hover::before, .site-nav li a:hover::after { opacity: 1; }
  }
  :root:has(.site-nav:popover-open) { overflow: hidden; }
}

/* === Header fijo y anclas (js/scroll.js fija --header-h; 73px es el respaldo) === */
:root { --header-h: 73px; }
.site-header { position: sticky; top: 0; z-index: 50; background: var(--bg); }

/* Música de fondo */
.audio-toggle:not([hidden]) {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.audio-toggle svg { width: 20px; height: 20px; }
.audio-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.audio-toggle[aria-pressed="false"] .audio-toggle__on,
.audio-toggle[aria-pressed="true"] .audio-toggle__off { display: none; }

@media (min-width: 821px) {
  .audio-toggle:not([hidden]) { margin-inline-end: calc(8px - 3.5rem); }
}

@media (max-width: 360px) {
  .site-header__bar:has(.audio-toggle:not([hidden])) { gap: 8px; }
  .site-header__right:has(.audio-toggle:not([hidden])) { gap: 4px; }
}

/* Cabecera compacta con audio */
@media (821px <= width <= 1050px) {
  .site-header__bar:has(.audio-toggle:not([hidden])) { gap: .75rem; }
  .site-header__right:has(.audio-toggle:not([hidden])) { gap: 1rem; }
  .audio-toggle:not([hidden]) { margin-inline-end: -.5rem; }
  .site-header__right:has(.audio-toggle:not([hidden])) .site-nav { padding-inline-start: 1rem; }
  .site-header__right:has(.audio-toggle:not([hidden])) .site-nav ul { gap: .625rem; flex-wrap: nowrap; }
  .site-header__right:has(.audio-toggle:not([hidden])) .site-nav .eyebrow { white-space: nowrap; }
}

@media (821px <= width <= 900px) {
  .site-header__right:has(.audio-toggle:not([hidden])) .site-nav .eyebrow {
    font-size: 11px;
    letter-spacing: .12em;
  }
}

/* Ayuda de los controles */
.site-header .audio-toggle {
  position: relative;
}

.site-header :is(.audio-toggle, .theme-toggle)[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 2;
  inset-block-start: calc(50% + 30px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  padding: .35rem .55rem;
  border-radius: .3rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  font: 400 .75rem/1.25 system-ui, sans-serif;
  white-space: nowrap;
  pointer-events: none;
  visibility: hidden;
}

.site-header :is(.audio-toggle, .theme-toggle)[data-tooltip]:focus-visible::after {
  visibility: visible;
}

@media (hover: hover) and (pointer: fine) {
  .site-header :is(.audio-toggle, .theme-toggle)[data-tooltip]:hover::after {
    visibility: visible;
  }
}
