/*
 * VSpanish Noticias — hoja de estilo única.
 *
 * The design brief this answers: a real news page, in Spanish, for eleven-to-fourteen year
 * olds, whose one distinguishing fact is that every story exists at three measured reading
 * levels and arrives from one of twenty-one countries.
 *
 * Two decisions carry the identity:
 *
 *   EL MEDIDOR. The level control is not a tab strip. It is an instrument that reports the
 *   actual measurements of the text you are reading — word count, mean sentence length,
 *   paragraph count, ACTFL sublevel. The pipeline computes those numbers to decide whether
 *   the text may be published at all, so the control tells the truth rather than decorating.
 *
 *   EL MATASELLOS. Every story carries a postmark: country, outlet, date, set in mono and
 *   slightly rotated, like something stamped on arrival. Stories genuinely do arrive from
 *   across the Spanish-speaking world every morning, so the device encodes a fact.
 *
 * Everything else stays quiet so those two can be loud.
 */

/* ------------------------------------------------------------------ tokens */

:root {
  --tinta:      #101a33;   /* ink navy — text, never pure black */
  --tinta-70:   #4a5570;
  --tinta-45:   #7d869c;
  --papel:      #fffdf8;   /* warm near-white */
  --papel-2:    #f6f2e9;   /* recessed panels */
  --niebla:     #e3ded1;   /* rules and hairlines */

  --sol:        #f2b705;   /* marigold — the authentic-quote block, active states */
  --sandia:     #e0405b;   /* watermelon — alerts, the "sin adaptar" mark */
  --jade:       #0e8f7e;   /* jade — audio, confirmations */

  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --lectura: "Newsreader", Georgia, "Times New Roman", serif;
  --dato:    "DM Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --medida: 34rem;         /* reading measure */
  --radio: 3px;            /* almost none — this is print, not an app */
}

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

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

body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--lectura);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-optical-sizing: auto;
}

a { color: inherit; }

img { max-width: 100%; display: block; }

/*
 * The browser's own [hidden] rule is `display: none` at the lowest possible specificity, so
 * ANY class that sets `display` beats it. `.medidor__lectura { display: flex }` did exactly
 * that, and the story page rendered all three level readouts and all three audio players
 * stacked on top of each other while the text below switched correctly. One line, and it has
 * to be !important, because the whole point is to outrank the layout rules.
 */
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--sandia);
  outline-offset: 3px;
}

.envoltorio {
  width: min(100% - 2.5rem, 68rem);
  margin-inline: auto;
}

/* ------------------------------------------------------------- cabecera */

.cabecera {
  border-bottom: 2px solid var(--tinta);
  padding: 1.1rem 0 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.marca {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.35rem, 1rem + 1.4vw, 1.9rem);
  letter-spacing: -0.03em;
  text-decoration: none;
  line-height: 1;
}
.marca em {
  font-style: normal;
  color: var(--sandia);
}

.fecha-hoy {
  font-family: var(--dato);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tinta-70);
}

.navegacion {
  display: flex;
  gap: 1.25rem;
  font-family: var(--dato);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.navegacion a { text-decoration: none; border-bottom: 2px solid transparent; padding-bottom: 2px; }
.navegacion a:hover, .navegacion a:focus-visible { border-bottom-color: var(--sol); }

/* --------------------------------------------------------------- portada */

.titulo-seccion {
  font-family: var(--display);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
  font-size: clamp(2.4rem, 1.3rem + 5vw, 4.5rem);
  margin: 2.2rem 0 0.4rem;
}

.subtitulo-seccion {
  font-family: var(--lectura);
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem);
  color: var(--tinta-70);
  max-width: 40ch;
  margin: 0 0 2.4rem;
}

.rejilla {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  margin-bottom: 3.5rem;
}

/* -------------------------------------------------------------- tarjetas */

.tarjeta {
  display: flex;
  flex-direction: column;
  background: var(--papel);
  border: 1.5px solid var(--tinta);
  border-radius: var(--radio);
  text-decoration: none;
  overflow: hidden;
  position: relative;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.tarjeta:hover, .tarjeta:focus-visible {
  transform: translateY(-3px);
  box-shadow: 6px 6px 0 var(--tinta);
}

.tarjeta__imagen {
  aspect-ratio: 3 / 2;
  object-fit: cover;
  width: 100%;
  border-bottom: 1.5px solid var(--tinta);
  background: var(--papel-2);
}

/* Typographic fallback when a story has no usable picture. The country initials become the
   image rather than a grey placeholder pretending a photograph is missing. */
.tarjeta__sinimagen {
  aspect-ratio: 3 / 2;
  border-bottom: 1.5px solid var(--tinta);
  background: var(--papel-2);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: -0.04em;
  color: var(--tinta);
  opacity: 0.14;
}

.tarjeta__cuerpo {
  padding: 1.1rem 1.15rem 1.3rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.55rem;
}

.tarjeta__titular {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.32rem;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0;
}

.tarjeta__entradilla {
  margin: 0;
  color: var(--tinta-70);
  font-size: 0.97rem;
  line-height: 1.45;
}

.tarjeta__pie {
  margin-top: auto;
  padding-top: 0.7rem;
  border-top: 1px solid var(--niebla);
  font-family: var(--dato);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tinta-45);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ------------------------------------------------------------ matasellos */

.matasellos {
  font-family: var(--dato);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.24rem 0.55rem;
  border: 1.5px solid var(--tinta);
  border-radius: 999px;
  background: var(--papel);
  align-self: flex-start;
}
.matasellos--ligera { background: var(--sol); }

.tema {
  font-family: var(--dato);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--sandia);
}

/* ---------------------------------------------------------- página historia */

.historia { max-width: var(--medida); margin: 2.5rem auto 0; }

.historia__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.historia__titular {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.1rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 0.6rem;
}

.historia__entradilla {
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--tinta-70);
  margin: 0 0 1.8rem;
}

.historia__imagen {
  width: 100%;
  border: 1.5px solid var(--tinta);
  border-radius: var(--radio);
  margin-bottom: 0.5rem;
}

.credito {
  font-family: var(--dato);
  font-size: 0.68rem;
  color: var(--tinta-45);
  letter-spacing: 0.04em;
  margin: 0 0 2rem;
}
.credito a { color: var(--tinta-70); }

/* ------------------------------------------------------------- el medidor */

.medidor {
  border: 1.5px solid var(--tinta);
  border-radius: var(--radio);
  background: var(--papel-2);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.medidor__etiqueta {
  font-family: var(--dato);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tinta-45);
  padding: 0.6rem 0.9rem 0.15rem;
}

.medidor__niveles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 0 0.55rem 0.55rem;
}

.medidor__boton {
  appearance: none;
  border: 1.5px solid var(--tinta);
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  padding: 0.55rem 0.4rem 0.6rem;
  cursor: pointer;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: background 120ms ease;
}
.medidor__boton + .medidor__boton { border-left: none; }
.medidor__boton:first-child { border-radius: var(--radio) 0 0 var(--radio); }
.medidor__boton:last-child  { border-radius: 0 var(--radio) var(--radio) 0; }
.medidor__boton:hover { background: var(--niebla); }
.medidor__boton[aria-selected="true"] {
  background: var(--tinta);
  color: var(--papel);
}
.medidor__boton small {
  font-family: var(--dato);
  font-weight: 400;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.75;
}

/* The readout. This is the part that makes the control an instrument: the numbers are the
   same ones the publishing gate measured, not adjectives. */
.medidor__lectura {
  font-family: var(--dato);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--tinta-70);
  border-top: 1.5px solid var(--tinta);
  padding: 0.55rem 0.9rem;
  background: var(--papel);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
}
.medidor__lectura b { font-weight: 500; color: var(--tinta); }

/* ----------------------------------------------------------------- audio */

.escucha {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.escucha audio { height: 2.4rem; flex: 1 1 16rem; min-width: 0; }
.escucha__voz {
  font-family: var(--dato);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tinta-45);
}
.escucha__voz b { color: var(--jade); font-weight: 500; }

/* ------------------------------------------------------------- el texto */

.texto { font-size: 1.16rem; line-height: 1.68; }
.texto p { margin: 0 0 1.15rem; }
.texto[hidden] { display: none; }

/* Novice prose is short sentences by design; a little extra leading keeps it from looking
   like a list of fragments. */
.texto[data-nivel="novicio"] { font-size: 1.24rem; line-height: 1.78; }

/* ------------------------------------------------------------- la cita */

.cita {
  border: 1.5px solid var(--tinta);
  border-left-width: 8px;
  border-radius: var(--radio);
  background: var(--sol);
  padding: 1.2rem 1.3rem 1rem;
  margin: 2.2rem 0;
}
.cita__marca {
  font-family: var(--dato);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.cita blockquote {
  margin: 0 0 0.6rem;
  font-family: var(--lectura);
  font-size: 1.25rem;
  line-height: 1.4;
  font-style: italic;
}
.cita figcaption {
  font-family: var(--dato);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

/* ------------------------------------------------------------ glosario */

.glosario { margin: 2.2rem 0; }
.glosario h2 {
  font-family: var(--dato);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tinta-45);
  margin: 0 0 0.7rem;
  font-weight: 400;
}
.glosario dl { margin: 0; display: grid; gap: 0.5rem; }
.glosario div {
  border-bottom: 1px solid var(--niebla);
  padding-bottom: 0.5rem;
}
.glosario dt { font-family: var(--display); font-weight: 700; display: inline; }
.glosario dd { display: inline; margin: 0 0 0 0.4rem; color: var(--tinta-70); }
.glosario dt::after { content: " ·"; color: var(--tinta-45); }

/* --------------------------------------------------------------- fuente */

.fuente {
  border-top: 2px solid var(--tinta);
  padding-top: 1rem;
  margin: 2.5rem 0 4rem;
  font-family: var(--dato);
  font-size: 0.76rem;
  line-height: 1.7;
  color: var(--tinta-70);
}
.fuente a { color: var(--tinta); }
.fuente strong { color: var(--tinta); font-weight: 500; }

/* -------------------------------------------------------------- archivo */

.lista-archivo { list-style: none; margin: 1.5rem 0 4rem; padding: 0; }
.lista-archivo li { border-bottom: 1px solid var(--niebla); }
.lista-archivo a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  padding: 0.85rem 0.25rem;
  text-decoration: none;
}
.lista-archivo a:hover { background: var(--papel-2); }
.lista-archivo time {
  font-family: var(--dato);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tinta-45);
  min-width: 11rem;
}
.lista-archivo .titulares { flex: 1; min-width: 14rem; }
.lista-archivo .banderas { font-size: 1.05rem; letter-spacing: 0.15em; }

/* ------------------------------------------------------------ pie de página */

.pie {
  border-top: 2px solid var(--tinta);
  padding: 1.5rem 0 3rem;
  font-family: var(--dato);
  font-size: 0.7rem;
  line-height: 1.8;
  color: var(--tinta-45);
  letter-spacing: 0.03em;
}
.pie a { color: var(--tinta-70); }

.aviso {
  border: 1.5px dashed var(--sandia);
  border-radius: var(--radio);
  padding: 1rem 1.15rem;
  margin: 2rem 0;
  font-family: var(--dato);
  font-size: 0.78rem;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .tarjeta:hover { transform: none; }
}

/* The site is read on school Chromebooks in a browser the school chose. Print is the other
   real delivery channel: teachers print stories. */
@media print {
  .cabecera, .navegacion, .medidor, .escucha, .pie { display: none; }
  body { background: #fff; font-size: 11pt; }
  .texto[hidden] { display: block !important; }
  .texto::before {
    content: "Nivel: " attr(data-nivel);
    font-family: var(--dato);
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: block;
    margin: 1.5rem 0 0.5rem;
    color: #666;
  }
}
