/* Base del sistema «cristal»: reset, fondo ambiental, tipografía, tema, movimiento y foco. Solo usa tokens. */

/* Reset breve */
*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body, h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* Tema: oscuro por defecto; claro si lo pide la marca (data-tema) o el sistema, salvo que se fije oscuro */
:root { color-scheme: dark; }
:root[data-tema="claro"] { color-scheme: light; }
@media (prefers-color-scheme: light) {
  :root:not([data-tema="oscuro"]) { color-scheme: light; }
}

/* Tema claro: el cristal recupera el borde luminoso (teñido con el acento, porque el blanco sobre claro no se ve), el reflejo y una sombra de profundidad visible.
   Dos selectores por el mismo motivo que arriba (data-tema o, sin elegir, el sistema); el ámbito de submarca (`data-marca` en :root) queda fuera. */
:root[data-tema="claro"]:not([data-marca]) {
  --vol-fuerza: 100%;
  --cristal-brillo: 26%;
  --luz-borde: color-mix(in srgb, var(--acento) 45%, var(--luz));
  --tinte-acento: 16%;
  --tinte-acento-fuerte: 22%;
}
@media (prefers-color-scheme: light) {
  :root:not([data-tema]):not([data-marca]) {
    --vol-fuerza: 100%;
    --cristal-brillo: 26%;
    --luz-borde: color-mix(in srgb, var(--acento) 45%, var(--luz));
    --tinte-acento: 16%;
    --tinte-acento-fuerte: 22%;
  }
}

/* Superficie de fondo del documento */
html,
body { background: var(--sup-0); }

/* Cuerpo: tipografía base de la marca */
body {
  min-height: 100svh;
  color: var(--texto);
  font-family: var(--f-texto);
  font-size: var(--t-cuerpo);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Capa ambiental fija: no participa del flujo, no cambia de tamaño con la barra del navegador y no recibe toques */
#fondo {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100lvh;
  z-index: var(--z-fondo);
  overflow: hidden;
  pointer-events: none;
  contain: strict;
  background: var(--sup-0);
}

/* El contenido va por encima de la capa de fondo */
body > :where(:not(#fondo)) { position: relative; z-index: var(--z-base); }

/* Títulos: carácter por tokens de marca */
h1, h2, h3, h4, .t-hero, .t-pagina, .t-seccion, .t-sub {
  font-family: var(--f-titulo);
  font-weight: var(--peso-titulo);
  font-style: var(--estilo-titulo);
  font-variation-settings: var(--var-titulo);
  letter-spacing: var(--track-titulo);
  text-transform: var(--caja-titulo);
  line-height: var(--lh-titulo);
  text-wrap: balance;
}
h1, .t-pagina { font-size: var(--t-pagina); }
h2, .t-seccion { font-size: var(--t-seccion); }
h3, h4, .t-sub { font-size: var(--t-sub); }
.t-hero { font-size: var(--t-hero); }
.t-nota { font-size: var(--t-apoyo); color: var(--texto-2); }
.t-datos { font-family: var(--f-datos); font-variant-numeric: tabular-nums; }
p { text-wrap: pretty; }

/* Enlaces de texto */
a:not([class]) {
  color: var(--acento-ink);
  text-underline-offset: var(--subrayado-desfase);
  text-decoration-thickness: 1px;
}

/* Selección con el acento de la marca */
::selection { background: color-mix(in srgb, var(--acento) 45%, transparent); }

/* Foco visible accesible: contorno de 2 px con separación, legible sobre cualquier superficie */
:focus-visible {
  outline: 2px solid var(--acento-ink);
  outline-offset: 3px;
}
:focus:not(:focus-visible) { outline: none; }

/* Movimiento reducido: todas las duraciones a cero (especificidad alta para ganar a los tokens de marca y de ámbito) */
@media (prefers-reduced-motion: reduce) {
  :root:root:root,
  [data-marca][data-marca][data-marca] {
    --mov-rapido: 0ms;
    --mov-base: 0ms;
    --mov-lento: 0ms;
  }
  html { scroll-behavior: auto; }
}

/* Utilidades mínimas */
.oculto { display: none; }
.solo-lector {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.col {
  width: 100%;
  max-width: var(--col);
  margin-inline: auto;
  padding-inline: var(--e-4);
}
