/* =============================================================
   ARTÍCULO INTERACTIVO — Estilos Base
   Periodismo de datos con visualizaciones D3
   ============================================================= */


/* ──────────────────────────────────────────────────────────────
   1. VARIABLES GLOBALES
   Los valores de color y fuente son sobreescritos por el
   bloque :root del <style> inline en index.html.
   ────────────────────────────────────────────────────────────── */
:root {
  /* Tipografía */
  --font-serif:   'Source Serif 4', Georgia, serif;
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;

  /* Escala tipográfica (base 16px) */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;
  --text-5xl:  3rem;
  --text-6xl:  3.75rem;
  --text-7xl:  4.5rem;

  /* Interlineado */
  --leading-tight:   1.15;
  --leading-snug:    1.375;
  --leading-normal:  1.6;
  --leading-relaxed: 1.8;

  /* Colores (tema por defecto; sobreescritos inline) */
  --color-bg:         #ffffff;
  --color-bg-alt:     #f7f8fa;
  --color-bg-card:    #ffffff;
  --color-bg-dark:    #0f1923;
  --color-text:       #1a1f2e;
  --color-text-muted: #5a6478;
  --color-text-light: #8b95a8;
  --color-text-inv:   #ffffff;
  --color-accent:     #1a56db;
  --color-accent-2:   #e3342f;
  --color-accent-3:   #10b981;
  --color-border:     #e2e6ef;
  --color-divider:    #cbd5e1;

  /* Paleta de datos */
  --data-1: #1a56db;
  --data-2: #e3342f;
  --data-3: #10b981;
  --data-4: #f59e0b;
  --data-5: #8b5cf6;
  --data-6: #06b6d4;

  /* Espaciado */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Bordes y sombras */
  --radius-sm:   4px;
  --radius:      8px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);

  /* Transiciones */
  --ease-fast:   0.15s ease-in-out;
  --ease-normal: 0.3s ease-in-out;
  --ease-slow:   0.6s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: 0.8s cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --max-w-text: 680px;
  --max-w-wide: 900px;
  --max-w-full: 1280px;
}


/* ──────────────────────────────────────────────────────────────
   2. RESET Y BASE
   ────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

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

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--ease-fast);
}

a:hover { color: var(--color-accent-2); }


/* ──────────────────────────────────────────────────────────────
   3. TIPOGRAFÍA BASE
   ────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: var(--leading-tight);
  color: var(--color-text);
  font-weight: 700;
}

.article-title {
  font-size: clamp(var(--text-4xl), 5vw, var(--text-7xl));
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.article-subtitle {
  font-size: clamp(var(--text-xl), 2.5vw, var(--text-3xl));
  font-weight: 400;
  font-family: var(--font-serif);
  line-height: var(--leading-snug);
  color: var(--color-text-muted);
}


/* ──────────────────────────────────────────────────────────────
   4. LAYOUT Y CONTENEDOR
   ────────────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w-full);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--text {
  max-width: var(--max-w-text);
}

.container--wide {
  max-width: var(--max-w-wide);
}

.section {
  padding-block: var(--space-24);
}

.section--alt {
  background-color: var(--color-bg-alt);
}


/* ──────────────────────────────────────────────────────────────
   5. CUERPO DEL ARTÍCULO
   ────────────────────────────────────────────────────────────── */
.article-body {
  max-width: var(--max-w-text);
  margin-inline: auto;
}

.article-body h2 {
  font-size: clamp(var(--text-2xl), 2.5vw, var(--text-4xl));
  margin-block: var(--space-10) var(--space-4);
}

.article-body h3 {
  font-size: clamp(var(--text-xl), 2vw, var(--text-3xl));
  margin-block: var(--space-8) var(--space-3);
}

.article-body p {
  font-family: var(--font-serif);
  font-size: clamp(var(--text-base), 1.2vw, var(--text-lg));
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-5);
}


/* ──────────────────────────────────────────────────────────────
   6. COMPONENTES DE TEXTO
   ────────────────────────────────────────────────────────────── */

/* Pullquote */
.pullquote {
  position: relative;
  margin-block: var(--space-16);
  padding: var(--space-10) var(--space-12);
  background: none;
  border-radius: var(--radius-xl);
  text-align: center;
}

.pullquote::before {
  content: '\201C';
  position: absolute;
  top: -0.1em;
  left: var(--space-8);
  font-size: 8rem;
  line-height: 1;
  font-family: var(--font-serif);
  color: var(--color-accent);
  opacity: 0.2;
  pointer-events: none;
}

.pullquote__text {
  font-family: var(--font-serif);
  font-size: clamp(var(--text-xl), 2.5vw, var(--text-3xl));
  font-style: italic;
  font-weight: 400;
  line-height: var(--leading-snug);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  text-align: center;
}

.pullquote .pullquote__text {
  text-align: center;
}

.pullquote__attribution {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-light);
}

/* Callout */
.callout {
  margin-block: var(--space-8);
  padding: var(--space-6) var(--space-8);
  border-left: 4px solid var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-bg));
  border-radius: 0 var(--radius) var(--radius) 0;
}

.callout p {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-muted);
}


/* ──────────────────────────────────────────────────────────────
   7. CONTENEDORES DE GRÁFICOS
   ────────────────────────────────────────────────────────────── */
.chart-card {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.chart-card__header {
  padding: var(--space-8) var(--space-8) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.chart-card__eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.chart-card__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.chart-card__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

.chart-card__body {
  padding: var(--space-6) var(--space-8) var(--space-8);
}

.chart-card__footer {
  padding: var(--space-4) var(--space-8);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.chart-card__body svg {
  width: 100%;
  overflow: visible;
}


/* ──────────────────────────────────────────────────────────────
   8. TOOLTIP
   ────────────────────────────────────────────────────────────── */
.chart-tooltip {
  position: absolute;
  z-index: 100;
  pointer-events: none;
  background: var(--color-bg-dark);
  color: var(--color-text-inv);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  box-shadow: var(--shadow-xl);
  max-width: 220px;
  opacity: 0;
  transition: opacity var(--ease-fast);
}

.chart-tooltip strong {
  display: block;
  font-weight: 700;
  margin-bottom: var(--space-1);
  color: #fff;
}

.chart-tooltip span {
  color: rgba(255,255,255,0.7);
}


/* ──────────────────────────────────────────────────────────────
   9. UTILIDADES
   ────────────────────────────────────────────────────────────── */

/* Animaciones de aparición en scroll */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Progress bar de lectura */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-border);
  z-index: 1000;
}

.reading-progress__bar {
  height: 100%;
  background: linear-gradient(to right, var(--color-accent), var(--color-accent-2));
  width: 0%;
  transition: width 0.1s linear;
}

/* Skip link (accesibilidad) */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-accent);
  color: white;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 700;
  z-index: 9999;
  transition: top var(--ease-fast);
}

.skip-link:focus {
  top: var(--space-4);
}


/* ──────────────────────────────────────────────────────────────
   10. RESPONSIVE
   ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --space-24: 4rem;
    --space-20: 3.5rem;
    --space-16: 3rem;
  }

  .container {
    padding-inline: var(--space-3);
  }

  .pullquote {
    padding: var(--space-8) var(--space-6);
  }

  .pullquote::before {
    font-size: 5rem;
  }

  .article-body p {
    text-align: left;
  }

  .pullquote .pullquote__text {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .chart-card__header,
  .chart-card__body {
    padding-inline: var(--space-4);
  }
}

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

  .reveal {
    opacity: 1;
    transform: none;
  }
}
