/* ============================================================================
   BASE — reset, elementos y ritmo tipográfico.
   Consume solo la capa semántica de tokens.css. Cero literales de color.
   ============================================================================ */

/* --------------------------------------------------------------- TIPOGRAFÍAS --
   Autohospedadas, todas OFL. Fuentes variables: un solo archivo por familia cubre
   todos los pesos, así que no hay una petición por peso. `swap` evita el texto
   invisible mientras carga — el fallback del sistema se ve al instante y la web-font
   entra sin bloquear el render. Nada de Google Fonts: cada host externo hay que
   meterlo en la CSP. Solo Raleway: el contraste lo da el peso, no una segunda familia.
   Fredoka, Nunito, Inter, Fraunces y Space Grotesk se declaraban aquí sin que ningún
   token las aplicara; se han quitado del repositorio (siguen en el historial de git). */

@font-face {
  font-family: "Raleway";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/raleway-latin-wght-normal.woff2") format("woff2-variations");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  /* scroll-padding evita que el header fijo tape el destino de un ancla. */
  scroll-padding-top: calc(var(--header-height, 4.5rem) + var(--space-4));
}

/* Solo aquí, no en `html`: en html fuerza el comportamiento incluso cuando el salto
   lo dispara JavaScript, y eso interfiere con el foco de teclado. */
@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--color-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Corta el scroll horizontal por accidente sin ocultar overflow vertical
     (overflow-x: hidden en body rompe position: sticky en varios navegadores). */
  overflow-wrap: break-word;
}

/* --------------------------------------------------------------- TITULARES -- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  color: var(--text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); letter-spacing: var(--tracking-wide); text-transform: uppercase; }

p {
  text-wrap: pretty;
}

/* ------------------------------------------------------------------ ENLACES -- */

a {
  color: var(--text-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--duration-fast) var(--ease-standard);
}

a:hover {
  color: var(--text-link-hover);
}

/* Foco visible solo para teclado. `:focus` a secas dibujaba el anillo también al
   hacer clic con ratón, y el equipo acababa quitándolo del todo — que es peor. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ------------------------------------------------------------------ MEDIOS -- */

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Reserva la caja mientras carga: sin esto hay CLS en cuanto la imagen llega tarde.
   Las plantillas emiten width/height y aquí se mantiene la proporción. */
img[width][height] {
  height: auto;
}

/* `:not([fill])` para no pisar al SVG que ya declara el suyo. Los iconos de
   partials/icon.php son de trazo (`fill="none" stroke="currentColor"`), y una regla
   `svg { fill: currentColor }` a secas los rellenaba en sólido: el euro salía como un
   bloque y el reloj como un círculo macizo. Cada bloque que los usaba lo tapaba con su
   propio `fill: none`, así que el fallo aparecía solo donde nadie se había acordado. */
svg:not([fill]) {
  fill: currentColor;
}

/* ------------------------------------------------------------ FORMULARIOS -- */

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

textarea {
  resize: vertical;
}

/* --------------------------------------------------------------- UTILIDADES -- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--wide { max-width: var(--container-wide); }
.container--narrow { max-width: var(--container-narrow); }

.section {
  padding-block: var(--section-y);
}

.section--lg { padding-block: var(--section-y-lg); }
/* Sin `.section--alt`: las bandas grises troceaban la página en franjas y competían con
   el panel de cifras. La separación la dan ahora el aire y los filetes. La clase se ha
   quitado también del marcado — un gancho sin estilo solo confunde al siguiente. */
.section--inverse {
  background-color: var(--color-surface-inverse);
  color: var(--text-inverse);
}

.section--inverse :where(h1, h2, h3, h4, h5, h6) {
  color: var(--text-inverse);
}

/* Entradilla bajo un titular de sección o de modal. Estaba repetida en cinco `style=""`
   inline por las plantillas, con tres márgenes distintos. */
.section-lead { margin-top: var(--space-3); color: var(--text-secondary); }

.measure { max-width: var(--measure); }
.measure--narrow { max-width: var(--measure-narrow); }

/* Oculto visualmente pero legible por lector de pantalla. Para el enlace de salto
   y para etiquetas que el diseño no muestra pero el formulario necesita. */
.visually-hidden:not(:focus):not(:active) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transform: translateY(-150%);
  transition: transform var(--duration-base) var(--ease-out);
}

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

/* ====================================================== CUERPO DE ARTÍCULO ====
   Los 446 posts migrados del WordPress traen su HTML tal cual y NO se edita: el
   ritmo tipográfico se define aquí, por etiqueta. Tocar los artículos a mano es
   como se pierde el SEO de golpe.
   ============================================================================ */

.article-body {
  max-width: var(--measure);
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.article-body > * + * {
  margin-block-start: var(--space-5);
}

.article-body :where(h2, h3, h4) {
  margin-block-start: var(--space-7);
  color: var(--text-primary);
}

.article-body h2 { font-size: var(--text-2xl); }
.article-body h3 { font-size: var(--text-xl); }
.article-body h4 { font-size: var(--text-lg); font-family: var(--font-sans); font-weight: var(--weight-semibold); }

.article-body :where(ul, ol) {
  padding-inline-start: var(--space-5);
}

.article-body li + li {
  margin-block-start: var(--space-2);
}

.article-body img {
  border-radius: var(--radius-md);
  margin-block: var(--space-6);
}

.article-body blockquote {
  padding-inline-start: var(--space-5);
  border-inline-start: 3px solid var(--color-accent);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

.article-body a {
  text-decoration: underline;
}

/* Las tablas del contenido histórico no tienen ancho controlado: si desbordan,
   scrollan dentro de su caja en vez de romper el layout de la página. */
.article-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.article-body :where(th, td) {
  padding: var(--space-3);
  border: var(--border-width) solid var(--color-border);
  text-align: start;
}

.article-body th {
  background-color: var(--color-surface-alt);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
