/* Afterglow — base: reset, tipografía, layout y los únicos componentes compartidos. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body, h1, h2, h3, p, figure, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

/* ---------- Tipografía ---------- */

.display {
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-display);
  font-weight: 400;
}
h2, .h2 {
  font-size: var(--fs-h2);
  line-height: var(--lh-heading);
  letter-spacing: -0.015em;
  font-weight: 400;
}
h3, .h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-heading);
  font-weight: 600;
}
.lead {
  font-size: var(--fs-lead);
  line-height: 1.45;
  color: var(--ink);
  max-width: 34ch;
}
p { max-width: var(--measure); color: var(--ink-2); }
em { font-style: italic; color: var(--ink); }
strong { font-weight: 600; color: var(--ink); }

.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-3);
}
.mono { font-family: var(--font-mono); font-feature-settings: "zero" 1; }
.figure-num {
  font-family: var(--font-serif);
  font-size: var(--fs-figure);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: lining-nums tabular-nums;
}

a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; text-decoration-thickness: 1px; transition: text-decoration-color var(--t-fast) var(--ease-out); }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

/* ---------- Layout ---------- */

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--section-y); border-top: 1px solid var(--rule); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--s-5); }
@media (max-width: 760px) { .grid { grid-template-columns: minmax(0, 1fr); row-gap: var(--s-6); } .grid > * { grid-column: 1 / -1 !important; } }

/* Encabezado de sección: número + título. Igual en todas las secciones. */
.section-head { display: grid; gap: var(--s-4); margin-bottom: var(--s-8); }
.section-head .label { display: flex; gap: var(--s-3); }
.section-head .label span:first-child { color: var(--ink-2); }

/* ---------- Componentes compartidos ---------- */

/* Botón único del sitio: rectángulo de 1px, sin radio, sin relleno de color. */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-3);
  padding: 0.875rem 1.375rem;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-mono); font-size: var(--fs-small); letter-spacing: 0.02em;
  text-decoration: none;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn .arrow { transition: transform var(--t-fast) var(--ease-out); }
.btn:hover .arrow { transform: translateX(3px); }
.btn-quiet { border-color: var(--rule-strong); color: var(--ink-2); }

.rule { height: 1px; background: var(--rule); border: 0; }

/* Figura estilo paper: "Fig. N — descripción" */
.fig { display: grid; gap: var(--s-3); }
.fig figcaption { font-size: var(--fs-small); color: var(--ink-3); max-width: 60ch; }
.fig figcaption b { font-weight: 600; color: var(--ink-2); }

/* ---------- Animación de entrada (core.js añade .is-in) ---------- */

[data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out); transition-delay: calc(var(--i, 0) * 90ms); }
[data-reveal].is-in { opacity: 1; transform: none; }
.no-js [data-reveal] { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* Campo de estrellas de fondo (js/space.js) */
.sky { position: fixed; top: 0; left: 0; z-index: -1; pointer-events: none; will-change: transform; }

/* Estados de datos: cargando, error, vacío. Mismo aspecto en todas las secciones. */
.state { border: 1px solid var(--rule); padding: var(--s-5); display: grid; gap: var(--s-2); }
.state p { color: var(--ink-2); }
.state .label { color: var(--ink-3); }
.state-loading .label::after { content: "▍"; margin-left: 0.4em; animation: state-blink 1s steps(2, start) infinite; }
@keyframes state-blink { to { visibility: hidden; } }
.state button { justify-self: start; background: none; border: 0; padding: 0; color: var(--ink); font: inherit; font-family: var(--font-mono); font-size: var(--fs-small); text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.2em; cursor: pointer; }

/* Skeletons: la forma del contenido que viene, en bloques sólidos y hairlines. Sin degradados; solo se anima opacity/transform.
   .sk envuelve el esqueleto. .sk-bar = una línea de texto (alto de línea real según .t-*; la barra ocupa ~62 %).
   .sk-block = rectángulo sólido. .sk-slow = la frase de espera larga. .sk-out / .sk-enter = fundido esqueleto → contenido. */
.sk { --sk-fill: var(--rule); display: grid; gap: var(--s-3); align-content: start; }
.sk-bar { --sk-lh: var(--lh-body); display: flow-root; height: calc(var(--sk-lh) * 1em); }
.sk-bar::before { content: ""; display: block; width: var(--w, 100%); max-width: 100%; height: 0.62em; margin-top: calc((var(--sk-lh) * 1em - 0.62em) / 2); background: var(--sk-fill); }
.sk-bar.t-label { font-size: var(--fs-label); }
.sk-bar.t-small { font-size: var(--fs-small); }
.sk-bar.t-h3 { font-size: var(--fs-h3); --sk-lh: var(--lh-heading); }
.sk-bar.t-lead { font-size: var(--fs-lead); --sk-lh: 1.45; }
.sk-block { display: block; background: var(--sk-fill); }
.sk-bar::before, .sk-block { opacity: 0.6; animation: sk-pulse 0.8s ease-in-out infinite alternate; }
.sk-bar:nth-child(2n)::before, .sk-block:nth-child(2n) { animation-delay: -0.4s; }
@keyframes sk-pulse { from { opacity: 0.4; } to { opacity: 0.8; } }
.sk-slow { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.02em; color: var(--ink-3); max-width: 46ch; animation: sk-in var(--t-base) var(--ease-out) both; }
.sk-out { position: absolute; top: 0; left: 0; right: 0; z-index: 1; pointer-events: none; animation: sk-out 200ms var(--ease-out) forwards; }
.sk-enter > :not(.sk-out) { animation: sk-in 200ms var(--ease-out) both; }
@keyframes sk-in { from { opacity: 0; } }
@keyframes sk-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sk-bar::before, .sk-block { animation: none; } }
