/* ==========================================================================
   La decadencia del CGI — editorial longread (black, minimal)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
  --bg: #0a0a0a;
  --bg-deep: #070707;
  --bg-elevated: #111111;
  --bg-soft: #141414;

  --text: #e8e6e3;
  --text-bright: #f3f1ed;
  --text-muted: #9c9892;
  --text-faint: #6e6a64;
  --text-dim: #55514c;

  --border: #2c2c2c;
  --border-soft: #1c1c1c;
  --border-hair: rgba(255, 255, 255, 0.06);

  --accent: #c4a574;
  --accent-soft: rgba(196, 165, 116, 0.1);
  --accent-muted: rgba(196, 165, 116, 0.28);
  --accent-hover: #d4b98a;
  --link: #c4a574;
  --focus: #d4b98a;

  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino,
    "Times New Roman", Times, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;

  --measure: 40rem;
  --toc-width: 14rem;
  --gutter: clamp(1.15rem, 3.5vw, 1.75rem);
  --lh: 1.74;
  --lh-tight: 1.28;
  --lh-display: 1.12;

  --space-1: 0.35rem;
  --space-2: 0.65rem;
  --space-3: 1rem;
  --space-4: 1.35rem;
  --space-5: 1.85rem;
  --space-6: 2.5rem;
  --space-7: 3.25rem;
  --space-8: 4.5rem;

  --radius: 2px;
  --ease: 0.16s ease;
}

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

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

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.125rem;
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 18;
  line-height: var(--lh);
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1;
}

/* Bare film grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: 0.028;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 180px 180px;
}

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

/* --------------------------------------------------------------------------
   Accessibility
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  z-index: 10001;
  padding: 0.5rem 0.85rem;
  background: var(--accent);
  color: var(--bg-deep);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  border-radius: var(--radius);
  transition: top var(--ease);
}

.skip-link:focus {
  top: 0.85rem;
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

:focus {
  outline: none;
}

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

::selection {
  background: rgba(196, 165, 116, 0.38);
  color: #fffef9;
}

/* --------------------------------------------------------------------------
   Page shell: TOC rail + main column
   -------------------------------------------------------------------------- */

.page {
  /* Mobile / default: single column, no dead left void */
  display: block;
  padding-inline: var(--gutter);
  padding-block: 0 var(--space-6);
}

.toc-rail {
  display: none; /* desktop only */
}

.page-main {
  max-width: var(--measure);
  margin: 0 auto;
  min-width: 0;
}

/* Desktop: two-column shell */
@media (min-width: 1100px) {
  .page {
    display: grid;
    grid-template-columns: var(--toc-width) minmax(0, var(--measure));
    column-gap: 3rem;
    justify-content: center;
    padding-inline: 1.5rem;
    padding-block: 2rem var(--space-8);
    align-items: start;
  }

  .toc-rail {
    display: block;
    position: sticky;
    top: 2rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    padding-top: 0.25rem;
  }

  .page-main {
    max-width: none;
    margin: 0;
  }

  .toc-mobile {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Sticky TOC rail (desktop)
   -------------------------------------------------------------------------- */

.toc-kicker {
  margin: 0 0 0.65rem;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.toc-rail nav ol,
.toc-mobile nav ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
  font-family: var(--sans);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.toc-rail nav li,
.toc-mobile nav li {
  margin: 0;
  counter-increment: toc;
}

.toc-rail nav li + li,
.toc-mobile nav li + li {
  margin-top: 0.15rem;
}

.toc-rail a,
.toc-mobile a {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.35rem;
  align-items: baseline;
  padding: 0.3rem 0.15rem 0.3rem 0;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  transition: color var(--ease);
}

.toc-rail a::before,
.toc-mobile a::before {
  content: counter(toc, decimal-leading-zero);
  font-size: 0.6875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  transition: color var(--ease);
}

.toc-rail a:hover,
.toc-mobile a:hover {
  color: var(--text-bright);
}

.toc-rail a:hover::before,
.toc-mobile a:hover::before {
  color: var(--accent);
}

.toc-rail a.is-active,
.toc-mobile a.is-active {
  color: var(--accent);
}

.toc-rail a.is-active::before,
.toc-mobile a.is-active::before {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Mobile TOC (details)
   -------------------------------------------------------------------------- */

.toc-mobile {
  margin: 0 0 var(--space-5);
  padding: 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.toc-mobile > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 0;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  user-select: none;
}

.toc-mobile > summary::-webkit-details-marker {
  display: none;
}

.toc-mobile > summary::after {
  content: "+";
  float: right;
  font-weight: 400;
  color: var(--text-dim);
}

.toc-mobile[open] > summary::after {
  content: "−";
}

.toc-mobile nav {
  padding: 0 0 0.9rem;
}

/* --------------------------------------------------------------------------
   Site header (eyebrow only)
   -------------------------------------------------------------------------- */

.site-header {
  margin: 0 0 var(--space-4);
  padding: 1.1rem 0 0;
  border: 0;
  background: transparent;
}

.eyebrow {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Article
   -------------------------------------------------------------------------- */

.article {
  max-width: none;
  margin: 0;
  padding: 0 0 var(--space-6);
}

.section,
.uncertainty,
.source-list li,
#contenido {
  scroll-margin-top: 1.75rem;
}

.article-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-soft);
}

.article-header h1 {
  margin: 0 0 var(--space-4);
  font-family: var(--serif);
  font-size: clamp(2.05rem, 4.8vw, 2.85rem);
  font-weight: 700;
  font-variation-settings: "opsz" 48;
  line-height: var(--lh-display);
  letter-spacing: -0.022em;
  color: var(--text-bright);
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 38rem;
  font-size: 1.175rem;
  line-height: 1.7;
  font-weight: 400;
  font-variation-settings: "opsz" 20;
  color: var(--text);
  letter-spacing: -0.005em;
}

/* --------------------------------------------------------------------------
   Sections & body type
   -------------------------------------------------------------------------- */

.section {
  margin-bottom: var(--space-7);
}

.section h2 {
  margin: 0 0 var(--space-3);
  padding-bottom: 0.55rem;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.4vw, 1.5rem);
  font-weight: 600;
  font-variation-settings: "opsz" 28;
  line-height: var(--lh-tight);
  letter-spacing: -0.016em;
  color: var(--text-bright);
  text-wrap: balance;
  border-bottom: 1px solid var(--border-hair);
}

.section h3 {
  margin: var(--space-5) 0 var(--space-2);
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section p {
  margin: 0 0 1.2rem;
  max-width: 40rem;
}

.section p:last-child {
  margin-bottom: 0;
}

.section strong {
  font-weight: 600;
  color: var(--text-bright);
}

em {
  font-style: italic;
}

.section a:not(.cite a),
.source-list a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--accent-muted);
  transition: color var(--ease), text-decoration-color var(--ease);
}

.section a:not(.cite a):hover,
.source-list a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
}

/* --------------------------------------------------------------------------
   Citations
   -------------------------------------------------------------------------- */

.cite {
  font-family: var(--sans);
  font-size: 0.7em;
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 0;
  vertical-align: super;
}

.cite a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 0.08em;
  transition: color var(--ease);
}

.cite a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Pull quotes
   -------------------------------------------------------------------------- */

.pull-quote,
blockquote.pull-quote {
  margin: var(--space-6) 0;
  padding: 0.15rem 0 0.15rem 1.15rem;
  border: 0;
  border-left: 1.5px solid var(--accent);
  max-width: 34rem;
  font-family: var(--serif);
  font-size: clamp(1.2rem, 2.2vw, 1.4rem);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 24;
  line-height: 1.48;
  letter-spacing: -0.012em;
  color: var(--text-bright);
}

.pull-quote p,
blockquote.pull-quote p {
  margin: 0;
  max-width: none;
}

/* --------------------------------------------------------------------------
   Figures
   -------------------------------------------------------------------------- */

.figure {
  margin: 2rem 0;
}

.figure img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
  border-radius: 2px;
  background: var(--bg-elevated);
}

.figure figcaption {
  max-width: 100%;
  margin-top: 0.6rem;
  padding: 0;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: 0.01em;
  color: var(--text-faint);
}

.figure figcaption .credit {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.figure figcaption a,
figcaption a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 0.15em;
}

.figure figcaption .credit a {
  color: var(--text-faint);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  margin: var(--space-5) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  outline-offset: 2px;
}

.table-wrap:focus-visible {
  outline: 2px solid var(--focus);
}

table {
  width: 100%;
  min-width: 30rem;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.84375rem;
  line-height: 1.45;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 0.8rem 1rem 0.7rem;
  font-family: var(--sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-soft);
}

th,
td {
  padding: 0.7rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-hair);
}

th {
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
  border-bottom-color: var(--border-soft);
}

td {
  color: var(--text);
}

tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: rgba(196, 165, 116, 0.05);
}

td:nth-child(2) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 500;
  color: var(--accent-hover);
  letter-spacing: 0.01em;
}

td em {
  font-style: italic;
  color: var(--text-bright);
}

/* --------------------------------------------------------------------------
   Conclusion
   -------------------------------------------------------------------------- */

.conclusion {
  margin-top: var(--space-6);
  padding: var(--space-5) 0 0;
  border-top: 1px solid var(--border);
}

.conclusion h2 {
  color: var(--text-bright);
  margin-bottom: var(--space-3);
}

.conclusion p {
  font-size: 1.06rem;
  line-height: 1.72;
}

/* --------------------------------------------------------------------------
   Sources
   -------------------------------------------------------------------------- */

.sources h2 {
  margin-bottom: var(--space-4);
}

.source-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--sans);
  font-size: 0.84375rem;
  line-height: 1.5;
}

.source-list li {
  display: grid;
  grid-template-columns: 2.85rem minmax(0, 1fr);
  gap: 0.35rem 0.65rem;
  align-items: start;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.source-list li:last-child {
  border-bottom: none;
}

.source-list li:target {
  background: var(--accent-soft);
  outline: 1px solid var(--accent-muted);
  margin-inline: -0.5rem;
  padding-inline: 0.5rem;
  border-radius: var(--radius);
}

.sid {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  padding-top: 0.12rem;
}

.source-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.source-list a {
  color: var(--text);
  text-decoration-color: transparent;
  word-break: break-word;
}

.source-list a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-muted);
}

.source-pub {
  display: block;
  color: var(--text-faint);
  font-size: 0.75rem;
  line-height: 1.4;
}

/* --------------------------------------------------------------------------
   Uncertainty / limits
   -------------------------------------------------------------------------- */

.uncertainty {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-soft);
}

.uncertainty ul {
  margin: 0;
  padding: 0 0 0 1.05rem;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--text-faint);
  line-height: 1.62;
}

.uncertainty li {
  margin: 0.4rem 0;
  padding-left: 0.15rem;
}

.uncertainty li em {
  color: var(--text-muted);
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-soft);
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--text-faint);
}

.site-footer p {
  margin: 0 0 0.3rem;
}

.footer-note {
  margin-top: 0.5rem !important;
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   Scroll reveal
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* --------------------------------------------------------------------------
   Mobile tweaks
   -------------------------------------------------------------------------- */

@media (max-width: 560px) {
  body {
    font-size: 1.0625rem;
  }

  .site-header {
    padding-top: 0.9rem;
  }

  .lede {
    font-size: 1.08rem;
  }

  .section h2 {
    font-size: 1.28rem;
  }

  .section {
    margin-bottom: var(--space-6);
  }

  .source-list li {
    grid-template-columns: 2.5rem minmax(0, 1fr);
  }

  .toc-rail a,
  .toc-mobile a {
    grid-template-columns: 1.35rem 1fr;
  }

  th,
  td {
    padding: 0.6rem 0.75rem;
  }

  .pull-quote,
  blockquote.pull-quote {
    padding-left: 0.9rem;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

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

  body::before {
    display: none;
  }

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

@media (prefers-reduced-transparency: reduce) {
  body::before {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */

@media print {
  body {
    background: #fff;
    color: #111;
    font-size: 11pt;
    line-height: 1.5;
  }

  body::before {
    display: none;
  }

  .skip-link,
  .toc-rail,
  .toc-mobile {
    display: none !important;
  }

  .page {
    display: block;
    padding: 0;
  }

  .page-main {
    max-width: none;
  }

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

  h1,
  h2,
  h3 {
    color: #000;
    break-after: avoid;
  }

  a {
    color: #000;
    text-decoration: none;
  }

  .source-list a[href]::after,
  .section a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #444;
    word-break: break-all;
  }

  .cite a[href]::after {
    content: none;
  }

  .table-wrap {
    border-color: #ccc;
    background: transparent;
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  th,
  td {
    border-color: #ddd;
    color: #111;
  }

  tbody tr:nth-child(even) td {
    background: #f7f7f7;
  }

  td:nth-child(2) {
    color: #111;
  }

  .site-footer {
    border-top-color: #ccc;
    color: #444;
  }
}
