/* ==========================================================================
   Sofía México — hoja de estilos compartida
   Cuaderno editorial: papel cálido, tinta oscura, un solo acento.
   Sin dependencias. Sin JS. Sin seguimiento.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Papel y tinta */
  --paper:       #faf7f1;
  --paper-2:     #f3eee5;
  --paper-3:     #ece5d8;
  --ink:         #191512;
  --ink-soft:    #4c443b;
  --ink-faint:   #8a7f71;
  --hair:        #ded5c6;
  --hair-strong: #c9bda9;

  /* Acento único */
  --accent:      #0f5563;
  --accent-ink:  #0b3f4a;
  --accent-wash: #e6f0f2;

  /* Tipografía */
  --display: "Newsreader", Georgia, "Times New Roman", serif;
  --ui: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Medidas */
  --measure: 63ch;
  --pad: clamp(1.25rem, 5vw, 2.5rem);
  --rhythm: clamp(1.6rem, 3vw, 2.2rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #14110d;
    --paper-2:     #1c1813;
    --paper-3:     #241f18;
    --ink:         #ece5d9;
    --ink-soft:    #b6ac9c;
    --ink-faint:   #837868;
    --hair:        #2e271f;
    --hair-strong: #443a2e;

    --accent:      #74bccb;
    --accent-ink:  #9ed3de;
    --accent-wash: #142f35;
  }
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: clamp(1.0625rem, 0.98rem + 0.38vw, 1.1875rem);
  line-height: 1.66;
  font-weight: 380;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Grano de papel: textura muy tenue, puramente decorativa */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.028;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  body::after { mix-blend-mode: screen; opacity: 0.035; }
}

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

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.014em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: clamp(2.15rem, 1.5rem + 3.1vw, 3.9rem); }
h2 { font-size: clamp(1.5rem, 1.22rem + 1.3vw, 2.1rem); margin-top: calc(var(--rhythm) * 1.5); }
h3 { font-size: clamp(1.18rem, 1.06rem + 0.55vw, 1.4rem); margin-top: var(--rhythm); font-weight: 560; }

p { margin: 0 0 1.15em; text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, transparent);
  transition: text-decoration-color 160ms ease, color 160ms ease;
}
a:hover { text-decoration-color: var(--accent); }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

strong { font-weight: 620; }
em { font-style: italic; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--paper-3);
  border: 1px solid var(--hair);
  border-radius: 3px;
  padding: 0.1em 0.36em;
  word-break: break-word;
}

hr {
  border: 0;
  border-top: 1px solid var(--hair);
  margin: var(--rhythm) 0;
}

/* Etiquetas y metadatos: la "carpintería" va en grotesca */
.label {
  font-family: var(--ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------------------
   Estructura
   -------------------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 68rem;
  margin: 0 auto;
  padding-inline: var(--pad);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--paper);
  font-family: var(--ui);
  font-size: 0.85rem;
  padding: 0.7rem 1.1rem;
  z-index: 200;
}
.skip:focus {
  left: 0.75rem;
  top: 0.75rem;
}

/* --------------------------------------------------------------------------
   Cabecera de sitio
   -------------------------------------------------------------------------- */

.site-head {
  border-bottom: 1px solid var(--hair);
  background: var(--paper);
}

.site-head-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 1.15rem;
}

.wordmark {
  font-family: var(--display);
  font-size: 1.22rem;
  font-weight: 560;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--accent); }
.wordmark .dot { color: var(--accent); }

.site-nav {
  display: flex;
  gap: clamp(0.9rem, 2.5vw, 1.6rem);
  font-family: var(--ui);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  padding-block: 0.15rem;
  border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--hair-strong); }

/* --------------------------------------------------------------------------
   Portada
   -------------------------------------------------------------------------- */

.masthead {
  padding-block: clamp(3rem, 9vw, 6.5rem) clamp(2rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--hair);
  max-width: 44rem;
}

.masthead .label { display: block; margin-bottom: 1.4rem; }

.masthead h1 {
  font-size: clamp(2.4rem, 1.5rem + 4.2vw, 4.6rem);
  font-weight: 420;
  letter-spacing: -0.025em;
}
.masthead h1 em {
  font-style: italic;
  color: var(--accent);
  font-weight: 380;
}

.standfirst {
  margin-top: 1.5rem;
  font-size: clamp(1.1rem, 1.02rem + 0.4vw, 1.32rem);
  line-height: 1.58;
  color: var(--ink-soft);
  max-width: 38rem;
}

/* --------------------------------------------------------------------------
   Índice numerado de artículos
   -------------------------------------------------------------------------- */

.index {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--hair);
}

.index li { border-bottom: 1px solid var(--hair); }

.index-item {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0.4rem 1.4rem;
  align-items: start;
  padding-block: clamp(1.5rem, 3.2vw, 2.3rem);
  text-decoration: none;
  color: inherit;
  transition: background-color 220ms ease;
}
.index-item:hover { background: var(--paper-2); }
.index-item:focus-visible { outline-offset: -3px; }

.index-num {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 300;
  font-style: italic;
  color: var(--accent);
  line-height: 1.1;
  transition: transform 260ms cubic-bezier(.2,.8,.2,1);
}
.index-item:hover .index-num { transform: translateX(4px); }

.index-title {
  font-family: var(--display);
  font-size: clamp(1.3rem, 1.1rem + 0.95vw, 1.85rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
  text-wrap: balance;
}
.index-item:hover .index-title { color: var(--accent); }

.index-dek {
  margin: 0 0 0.75rem;
  color: var(--ink-soft);
  max-width: 58ch;
  font-size: 1.02rem;
  line-height: 1.58;
}

.index-meta {
  font-family: var(--ui);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

@media (max-width: 34rem) {
  .index-item { grid-template-columns: 2.4rem 1fr; gap: 0.3rem 0.9rem; }
  .index-num { font-size: 1.15rem; }
}

/* Entrada escalonada, sólo una vez al cargar */
@media (prefers-reduced-motion: no-preference) {
  .index li {
    animation: rise 620ms cubic-bezier(.2,.8,.2,1) backwards;
  }
  .index li:nth-child(1) { animation-delay: 60ms; }
  .index li:nth-child(2) { animation-delay: 130ms; }
  .index li:nth-child(3) { animation-delay: 200ms; }
  .index li:nth-child(4) { animation-delay: 270ms; }
  .index li:nth-child(5) { animation-delay: 340ms; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Secciones de portada
   -------------------------------------------------------------------------- */

.section {
  padding-block: clamp(2.6rem, 6vw, 4.5rem);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.8rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--hair);
}
.section-head h2 { margin: 0; font-size: clamp(1.3rem, 1.15rem + 0.7vw, 1.7rem); }

/* --------------------------------------------------------------------------
   Artículo
   -------------------------------------------------------------------------- */

.article-head {
  padding-block: clamp(2.4rem, 6vw, 4.2rem) clamp(1.8rem, 4vw, 2.8rem);
  border-bottom: 1px solid var(--hair);
  max-width: 46rem;
}

.article-kicker {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: 1.25rem;
}
.article-kicker .num {
  font-family: var(--display);
  font-style: italic;
  font-weight: 300;
  font-size: 1.35rem;
  color: var(--accent);
  line-height: 1;
}

.article-head h1 {
  font-weight: 440;
  font-size: clamp(2rem, 1.4rem + 2.7vw, 3.4rem);
}

.article-dek {
  margin-top: 1.25rem;
  font-size: clamp(1.06rem, 1rem + 0.35vw, 1.25rem);
  line-height: 1.56;
  color: var(--ink-soft);
  max-width: 40rem;
}

.article-meta {
  margin-top: 1.6rem;
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
}

/* Rejilla de cuerpo: la columna central manda, los .wide se desbordan */
.article-body {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    min(var(--measure), 100%)
    minmax(0, 1fr);
  padding-block: clamp(2rem, 5vw, 3.4rem) clamp(3rem, 7vw, 5rem);
}
.article-body > * { grid-column: 2; }
.article-body > .wide { grid-column: 1 / -1; }

.article-body > h2:first-child,
.article-body > p:first-child { margin-top: 0; }

/* Capitular */
.article-body > p.lead {
  font-size: 1.16em;
  line-height: 1.55;
  color: var(--ink);
}
.article-body > p.lead::first-letter {
  float: left;
  font-family: var(--display);
  font-size: 3.5em;
  line-height: 0.82;
  font-weight: 420;
  padding: 0.06em 0.09em 0 0;
  color: var(--accent);
}

/* Listas */
.article-body ul, .article-body ol {
  margin: 0 0 1.3em;
  padding-left: 1.3em;
}
.article-body li { margin-bottom: 0.55em; padding-left: 0.2em; }
.article-body li::marker { color: var(--accent); }

/* Cita destacada */
.pull {
  margin: calc(var(--rhythm) * 1.1) 0;
  padding-left: 1.3rem;
  border-left: 2px solid var(--accent);
  font-size: clamp(1.2rem, 1.05rem + 0.7vw, 1.55rem);
  line-height: 1.36;
  font-style: italic;
  font-weight: 380;
  color: var(--ink);
  text-wrap: balance;
}

/* Recuadro de nota */
.note {
  margin: var(--rhythm) 0;
  padding: 1.2rem 1.35rem;
  background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 4px;
  font-size: 0.96rem;
  line-height: 1.58;
}
.note p:last-child { margin-bottom: 0; }
.note .label { display: block; margin-bottom: 0.5rem; color: var(--accent-ink); }

/* Figuras y diagramas */
figure {
  margin: calc(var(--rhythm) * 1.2) 0;
}
figure svg { display: block; width: 100%; height: auto; }
figcaption {
  margin-top: 0.85rem;
  font-family: var(--ui);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-faint);
  max-width: 44ch;
}
.wide figcaption { margin-inline: auto; }

/* Tabla comparativa */
.table-scroll { overflow-x: auto; margin: var(--rhythm) 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  min-width: 30rem;
}
th, td {
  text-align: left;
  padding: 0.72rem 0.9rem 0.72rem 0;
  border-bottom: 1px solid var(--hair);
  vertical-align: top;
}
th {
  font-family: var(--ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom-color: var(--hair-strong);
}

/* Fuentes citadas */
.sources {
  margin-top: calc(var(--rhythm) * 1.4);
  padding-top: 1.3rem;
  border-top: 1px solid var(--hair);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.sources .label { display: block; margin-bottom: 0.8rem; }
.sources ol { padding-left: 1.2em; margin: 0; }
.sources li { margin-bottom: 0.5em; }

/* Navegación entre artículos */
.article-nav {
  border-top: 1px solid var(--hair);
  padding-block: clamp(2rem, 4vw, 3rem);
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.article-nav a {
  text-decoration: none;
  color: inherit;
  display: block;
}
.article-nav .label { display: block; margin-bottom: 0.5rem; }
.article-nav .t {
  font-family: var(--display);
  font-size: 1.16rem;
  font-weight: 500;
  line-height: 1.25;
}
.article-nav a:hover .t { color: var(--accent); }

/* --------------------------------------------------------------------------
   Fichas de recursos
   -------------------------------------------------------------------------- */

.res-group { margin-bottom: clamp(2.2rem, 5vw, 3.2rem); }

.res-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--hair);
}
.res-list li {
  border-bottom: 1px solid var(--hair);
  padding-block: 1.25rem;
  display: grid;
  gap: 0.35rem;
}
.res-list .r-name {
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 560;
  line-height: 1.3;
}
.res-list .r-url {
  font-family: var(--ui);
  font-size: 0.74rem;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  word-break: break-all;
}
.res-list .r-why {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.97rem;
  line-height: 1.55;
  max-width: 52ch;
}

/* --------------------------------------------------------------------------
   Perfil
   -------------------------------------------------------------------------- */

.bio {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: var(--rhythm);
}

.monogram {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-wash);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  font-family: var(--display);
  font-size: 2.4rem;
  font-style: italic;
  font-weight: 380;
  color: var(--accent);
  flex-shrink: 0;
}

@media (max-width: 30rem) {
  .bio { grid-template-columns: 1fr; gap: 1rem; }
}

/* --------------------------------------------------------------------------
   Pie
   -------------------------------------------------------------------------- */

.site-foot {
  border-top: 1px solid var(--hair);
  background: var(--paper-2);
  padding-block: clamp(2.2rem, 5vw, 3.4rem);
  margin-top: auto;
  font-family: var(--ui);
  font-size: 0.82rem;
  line-height: 1.65;
  color: var(--ink-soft);
}
.foot-grid {
  display: grid;
  gap: 1.6rem 2.5rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.site-foot a { color: var(--ink-soft); }
.site-foot a:hover { color: var(--accent); }
.foot-note {
  margin-top: 2rem;
  padding-top: 1.3rem;
  border-top: 1px solid var(--hair);
  font-size: 0.76rem;
  color: var(--ink-faint);
  max-width: 52ch;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}
main { flex: 1 0 auto; }
