/*
  ─────────────────────────────────────────────────────────────
  BASE COMÚN — tokens, reset y patrones que comparten el índice
  y todos los juegos.

  Misma dirección de arte que diegojaureguisalvatierra.com:
  cero border-radius, cero sombras, cero gradientes; hairlines
  de 1px como único ornamento y ritmo vertical en múltiplos de 8px.

  Los colores en hex viven SOLO en :root / [data-theme='dark']
  (más el meta theme-color de cada página, que se pinta antes que
  este archivo). Los canvas los leen de las custom properties.
  ─────────────────────────────────────────────────────────────
*/

/* ── Tipografía: Fraunces Variable (SIL OFL), self-hosted ───── */
@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/Fraunces-Roman-VF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/Fraunces-Italic-VF.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* Fallback métrico sobre Georgia para CLS 0 mientras carga Fraunces */
@font-face {
  font-family: 'Fraunces-fallback';
  src: local('Georgia');
  size-adjust: 104%;
  ascent-override: 97%;
  descent-override: 25%;
  line-gap-override: 0%;
}

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  /* papel y tinta — tema claro (canónico) */
  --bg: #faf7f2;
  --surface: #f2ede4;
  --ink: #1c1917; /* 16.37:1 sobre --bg */
  --muted: #6b6459; /* 5.47:1 sobre --bg */
  --accent: #c43a2f; /* bermellón — 4.92:1 sobre --bg */
  --accent-text: #b33327; /* 5.75:1 sobre --bg, para texto <18px */

  --hairline-color: color-mix(in oklab, var(--ink) 18%, transparent);
  --hairline: 1px solid var(--hairline-color);

  --font-display: 'Fraunces', 'Fraunces-fallback', Georgia, serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', SFMono-Regular, Menlo, Consolas,
    'Liberation Mono', monospace;
}

html[data-theme='dark'] {
  /* la metáfora invertida: tinta como fondo, papel como texto */
  --bg: #121110;
  --surface: #1c1a18;
  --ink: #ede8e0; /* 15.47:1 sobre --bg */
  --muted: #a39a8c; /* 6.79:1 sobre --bg */
  --accent: #e86a5b; /* 5.97:1 sobre --bg */
  --accent-text: #e86a5b;
}

/* ── Reset mínimo ───────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  color-scheme: light;
}

html[data-theme='dark'] {
  color-scheme: dark;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: no-preference) {
  body {
    transition:
      background-color 200ms ease,
      color 200ms ease;
  }
}

canvas,
svg,
img {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ── Utilidades ─────────────────────────────────────────────── */
.container {
  max-width: 84rem;
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 5rem);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: clip;
  clip-path: inset(50%);
  white-space: nowrap;
}

.u-anim {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .u-anim {
    transition: background-size 250ms ease-out;
  }
}

.u-anim:hover,
.u-anim:focus-visible {
  background-size: 100% 2px;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--bg);
  color: var(--accent-text);
  border: var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-decoration: none;
  transform: translateY(calc(-100% - 2rem));
}

.skip-link:focus {
  transform: translateY(0);
}

/* ── Esqueleto de página ────────────────────────────────────── */
.pagina {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.5rem;
  border-bottom: var(--hairline);
}

.barra-izq {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.marca {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  color: inherit;
  text-decoration: none;
}

.barra .kicker {
  color: var(--muted);
}

main {
  padding-block: clamp(2.5rem, 8vh, 4.5rem);
}

.pie {
  border-top: var(--hairline);
  padding-block: 1rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  color: var(--muted);
}

.pie a {
  color: var(--ink);
}

/* ── Interruptor de tema ────────────────────────────────────── */
#tema {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: none;
  border: var(--hairline);
  color: var(--ink);
  cursor: pointer;
  flex: none;
}

#tema svg {
  grid-area: 1 / 1;
}

@media (prefers-reduced-motion: no-preference) {
  #tema svg {
    transition: opacity 150ms ease;
  }
}

.icono-sol {
  opacity: 0;
}

.icono-luna {
  opacity: 1;
}

html[data-theme='dark'] .icono-sol {
  opacity: 1;
}

html[data-theme='dark'] .icono-luna {
  opacity: 0;
}

/* ── Titulares ──────────────────────────────────────────────── */
.recreo {
  color: var(--accent-text);
  text-align: center;
  margin-bottom: 0.75rem;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 1.5rem + 5vw, 4.5rem);
  font-weight: 560;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 72;
  text-align: center;
}

.acento {
  font-style: italic;
  font-weight: 520;
  color: var(--accent); /* display ≥24px: acento pleno permitido */
}

.entrada {
  margin: 1rem auto 0;
  max-width: 48ch;
  text-align: center;
  color: var(--muted);
}

/* ── Capa de estado sobre el tablero (inicio, pausa, fin) ───── */
.capa {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
}

.capa[hidden] {
  display: none;
}

.capa-titulo {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.75rem;
  line-height: 1.1;
}

.capa-texto {
  max-width: 34ch;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.sin-js {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 1.5rem;
  text-align: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9375rem;
}

.boton {
  margin-top: 0.5rem;
  padding: 0.625rem 1.5rem;
  background: none;
  border: var(--hairline);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.boton:hover {
  color: var(--accent-text);
  border-color: var(--accent-text);
}

.ayuda {
  margin: 1.5rem auto 0;
  max-width: 52ch;
  text-align: center;
  color: var(--muted);
}

/* ── Movimiento reducido ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
