/* =========================================================================
   SOPHIA STEM · Base — reset, tipografía, layout primitives
   ========================================================================= */

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

/* El navegador oculta [hidden] con display:none, pero cualquier componente que
   declare su propio display (flex, grid…) gana por especificidad y lo deja
   visible. Pasó de verdad: el filtro por módulo de la biblioteca marcaba bien
   las tarjetas y no se ocultaba ninguna. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  color: var(--heading);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-display);
  font-weight: 400;              /* Fredoka One solo tiene este grosor */
  margin: 0 0 var(--sp-4);
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

p  { margin: 0 0 var(--sp-4); max-width: var(--measure); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--link); text-decoration: none; transition: color var(--dur-fast) var(--ease-out); }
a:hover { color: var(--accent); }

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.15rem; }
/* <figure> trae 40 px de margen lateral del navegador: dentro de una rejilla
   estrecha se come la mitad del hueco. */
figure, figcaption { margin: 0; }
li { margin-bottom: var(--sp-2); }
li:last-child { margin-bottom: 0; }

strong, b { font-weight: 700; color: var(--heading); }
small { font-size: var(--fs-xs); }

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: var(--sp-12) 0;
}

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

::selection { background: var(--yellow-400); color: var(--navy-900); }

/* ---- Utilidades de layout ----------------------------------------------- */
.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: 820px; }

.section { padding-block: var(--section-y); position: relative; }
.section--tint { background: var(--bg-alt); }
.section--cream { background: var(--bg-cream); }
.section--navy { background: var(--band); color: var(--band-text); }
.section--navy h1, .section--navy h2, .section--navy h3, .section--navy h4 { color: #FFFFFF; }
.section--flush-top { padding-top: 0; }

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

.grid { display: grid; gap: clamp(1.25rem, 2.5vw, 2rem); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }

.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }

.text-center { text-align: center; }
.text-center p { margin-inline: auto; }
.muted { color: var(--text-muted); }
.lead { font-size: var(--fs-lg); color: var(--text); }

.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;
}

.skip-link {
  position: absolute; top: 0; left: 50%;
  transform: translate(-50%, -120%);
  z-index: var(--z-modal);
  background: var(--band); color: #FFFFFF;
  padding: var(--sp-3) var(--sp-5);
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-weight: 700;
  transition: transform var(--dur) var(--ease-out);
}
.skip-link:focus { transform: translate(-50%, 0); color: #FFFFFF; }

/* ---- Movimiento reducido ------------------------------------------------ */
@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;
  }
}

/* Rejilla de tres columnas de verdad: .grid-3 usa auto-fit y en pantallas anchas
   se va a cuatro, lo que deja filas huérfanas cuando hay seis tarjetas. */
@media (min-width: 1080px) {
  .grid-3--strict { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
