/* ============================================================
   CÁPSULAS GAMIFICADAS — BASE
   ------------------------------------------------------------
   Reset acotado, tipografía global, utilidades de accesibilidad
   y el fondo "bloque" de la app. Depende de tokens.css.
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd {
  margin: 0;
}

ul[role='list'],
ol[role='list'] {
  list-style: none;
  margin: 0;
  padding: 0;
}

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  /* El halo de arriba SÍ es un gradiente normal (no necesita ser
     bloques): se mantiene acá. El mosaico bento va en ::before —
     ver ahí por qué necesita ser un elemento aparte. */
  background-image: radial-gradient(ellipse 80% 60% at 50% 0%, var(--grid-glow), transparent 70%);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ─── Fondo "bento" ────────────────────────────────────────────
   Un mosaico de rectángulos de tamaño MIXTO (grande + medianos +
   chicos), no una grilla pareja — es lo que lo hace leer como
   bento y no como cuadriculado. Va en un ::before aparte, no en el
   `background-image` de `body`, porque `mask-image` enmascara TODO
   lo que pinta el elemento (colores y todo lo demás): si fuera el
   `body`, el halo de arriba y el color de fondo quedarían recortados
   por la máscara también. Achicando ::before a una capa propia,
   `background-color` (que SÍ seguimos pudiendo variar con
   `--grid-line`) es lo único que la máscara recorta.

   El SVG son 5 rectángulos redondeados de tres tamaños distintos,
   solo el TRAZO (sin relleno) — por eso la máscara los deja pasar
   como líneas finas y no como bloques sólidos. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--grid-line);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cg fill='none' stroke='white' stroke-width='2'%3E%3Crect x='8' y='8' width='140' height='140' rx='16'/%3E%3Crect x='156' y='8' width='76' height='66' rx='12'/%3E%3Crect x='156' y='82' width='76' height='66' rx='12'/%3E%3Crect x='8' y='156' width='100' height='76' rx='12'/%3E%3Crect x='116' y='156' width='116' height='76' rx='12'/%3E%3C/g%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cg fill='none' stroke='white' stroke-width='2'%3E%3Crect x='8' y='8' width='140' height='140' rx='16'/%3E%3Crect x='156' y='8' width='76' height='66' rx='12'/%3E%3Crect x='156' y='82' width='76' height='66' rx='12'/%3E%3Crect x='8' y='156' width='100' height='76' rx='12'/%3E%3Crect x='116' y='156' width='116' height='76' rx='12'/%3E%3C/g%3E%3C/svg%3E");
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  -webkit-mask-size: 240px 240px;
  mask-size: 240px 240px;
}

/* El atributo hidden lo pisa cualquier clase con display: flex/grid,
   porque el UA stylesheet tiene menos especificidad. Toda la app
   muestra y oculta con .hidden = true, así que esta regla es lo que
   hace que eso funcione en serio. */
[hidden] {
  display: none !important;
}

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

/* Las miniaturas son pixel art: nada de suavizado al escalar. */
img.pixelated,
.pixelated img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--diamond-ink);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--ink);
}

/* ─── Títulos ─────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-display);
  color: var(--ink);
}
h1 { font-size: var(--fs-display-lg); }
h2 { font-size: var(--fs-display); }
h3 { font-size: var(--fs-display-sm); }
h4 { font-size: var(--fs-display-xs); }

/* ─── Foco visible ────────────────────────────────────────────
   Doble anillo (negro + diamante) para que se vea sobre cualquier
   superficie, clara u oscura. Nunca se elimina el outline sin
   reemplazarlo por esto.
   ------------------------------------------------------------ */
:focus-visible {
  outline: var(--px) solid var(--diamond);
  outline-offset: var(--px);
}

/* ─── Utilidades ──────────────────────────────────────────── */

/* Texto solo para lectores de pantalla. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Salto al contenido: invisible hasta recibir foco por teclado. */
.skip-link {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  z-index: var(--z-toast);
  padding: var(--sp-2) var(--sp-4);
  background: var(--gold);
  color: var(--on-gold);
  font-family: var(--font-display);
  font-size: var(--fs-display-xs);
  text-decoration: none;
  box-shadow: var(--outline-ring), var(--bevel-out);
  transform: translateY(-200%);
}
.skip-link:focus-visible {
  transform: translateY(0);
}

.is-hidden {
  display: none !important;
}

.stack > * + * {
  margin-top: var(--gap, var(--sp-4));
}

/* ─── Preferencia de movimiento reducido ──────────────────────
   Se anulan animaciones y desplazamientos, pero se conservan los
   cambios de color: sin ellos se pierde el feedback de hover.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover,
  .btn:hover:not(:disabled) {
    transform: none !important;
  }
}
