:root {
  --bg: #10120e;
  --bg-raise: #171a13;
  --ink: #efe7d6;
  --muted: #a39880;
  --soft: #ddd4c4;
  --line: #2e3428;
  --orange: #f38020;
  --link: #f3d2b0;
  --link-hover: #ffffff;
  --nav-bg: rgba(16, 18, 14, 0.92);
  --sticky-bg: rgba(16, 18, 14, 0.94);
  --control-bg: #12150f;
  --control-border: #3c4134;
  --tray-bg: #14170f;
  --tooltip-bg: #1b1e16;
  --tooltip-border: #3c4134;
  --slider-bg: #141710;
  --slider-border: #3c4033;
  --split: rgba(239, 231, 214, 0.06);
  --heat-min: #2c3324;
  --calendar-bg: #141710;
  --calendar-border: #10120e;
  --glow-orange: rgba(243, 128, 32, 0.18);
  --glow-blue: rgba(126, 182, 201, 0.08);
  --paper: #f4efe4;
  --paper-ink: #1c1914;
  --critical: #ff5c39;
  --major: #f38020;
  --minor: #7eb6c9;
  --none: #8d8878;
  --good: #9dbe7c;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: ui-serif, "Iowan Old Style", Palatino, Georgia, serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f3efe4;
  --bg-raise: #fffaf2;
  --ink: #1c1914;
  --muted: #5c564c;
  --soft: #3f392f;
  --line: #ddd4c4;
  --orange: #9a4d12;
  --link: #9a4d12;
  --link-hover: #6e3208;
  --nav-bg: rgba(243, 239, 228, 0.92);
  --sticky-bg: rgba(243, 239, 228, 0.94);
  --control-bg: #fffaf2;
  --control-border: #d4cbb8;
  --tray-bg: #f7f1e6;
  --tooltip-bg: #fffaf2;
  --tooltip-border: #d4cbb8;
  --slider-bg: #fffaf2;
  --slider-border: #d4cbb8;
  --split: rgba(28, 25, 20, 0.08);
  --heat-min: #efe6d4;
  --calendar-bg: #fffaf2;
  --calendar-border: #e4dccb;
  --glow-orange: rgba(154, 77, 18, 0.1);
  --glow-blue: transparent;
  --paper: #f4efe4;
  --paper-ink: #1c1914;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 0% -10%, var(--glow-orange), transparent 55%),
    radial-gradient(700px 480px at 100% 0%, var(--glow-blue), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--link-hover); }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand, .logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.28rem;
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1;
}
.brand .logo-mark, .logo .logo-mark {
  display: block;
  width: 1.85rem;
  height: 1.85rem;
  flex: 0 0 auto;
}
.brand:hover { color: var(--link-hover); }

.nav nav, .nav-actions { display: flex; gap: 0.75rem; align-items: center; }

.nav a[aria-current="page"] { color: var(--orange); text-decoration: none; }

button, .select, input[type="search"], input[type="text"] {
  font: inherit;
  color: var(--ink);
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
}

button { cursor: pointer; }
button:hover, .nav button:hover { border-color: var(--orange); }

.wrap {
  width: min(1440px, calc(100% - 2.5rem));
  margin: 0 auto 4rem;
  container-type: inline-size;
  container-name: atlas;
}

.hero { padding: 2.2rem 0 1rem; }
.hero h1, .card h2, .essay-body h1, .dossier h1 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.hero h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); margin: 0 0 0.8rem; max-width: 16ch; }
.lede { max-width: 68ch; font-size: 1.12rem; color: var(--soft); }
.hero-links { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.status { color: var(--critical); min-height: 1.2em; }

.grade-switch {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0.15rem;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-bg);
  white-space: nowrap;
}
.grade-switch button {
  border: 0;
  background: transparent;
  border-radius: 999px;
}
.grade-switch button[aria-pressed="true"] {
  background: var(--orange);
  color: #1a1006;
}
.grade-hint { margin: 0.35rem 0 1rem; color: var(--muted); max-width: 68ch; }
.grade-band {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.85rem 1.75rem;
  align-items: start;
  margin: 0 0 1rem;
  padding: 1rem 1.15rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-raise);
}
.grade-band .grade-field {
  border: 0;
  margin: 0;
  padding: 0;
}
.grade-why p { margin: 0 0 0.7rem; color: var(--soft); max-width: 68ch; }
.grade-why .kicker { margin: 0 0 0.4rem; }
.grade-why ul {
  margin: 0 0 0.7rem;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.4rem;
  color: var(--soft);
}
.grade-why li { max-width: 68ch; }
.checks label.is-disabled { opacity: 0.4; }

.kpis, .filters, .split, .stack { display: grid; gap: 0.9rem; }
.kpis { grid-template-columns: repeat(6, 1fr); margin: 1.2rem 0 1rem; }
.kpi {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.8rem 0.9rem 0.7rem;
}
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.kpi b { display: block; margin-top: 0.25rem; font-family: var(--serif); font-size: 1.55rem; font-weight: 560; }

.filters {
  grid-template-columns: 1.4fr auto auto auto;
  align-items: end;
  margin-bottom: 0.8rem;
}
fieldset { border: 1px solid var(--line); border-radius: 16px; margin: 0; padding: 0.55rem 0.8rem 0.7rem; }
legend, .field span, label.field { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.checks { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.checks label { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 0.92rem; }
.field { display: grid; gap: 0.3rem; }
.select, #year-from, #year-to, #calendar-year { border-radius: 12px; padding: 0.45rem 0.6rem; }

.drill {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: rgba(243, 128, 32, 0.12);
  border: 1px solid rgba(243, 128, 32, 0.45);
  margin-bottom: 0.9rem;
}
.drill[hidden] { display: none; }

.subnav {
  position: sticky;
  top: var(--nav-height, 3.6rem);
  z-index: 25;
  display: flex;
  gap: 0.9rem;
  overflow-x: auto;
  padding: 0.55rem 0;
  background: var(--sticky-bg);
  border-bottom: 1px solid transparent;
}
.subnav a { color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 0.92rem; }
.subnav a:hover { color: var(--ink); }

.present-bar {
  display: none;
  position: sticky;
  top: var(--nav-height, 3.6rem);
  z-index: 24;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.2rem;
  background: var(--sticky-bg);
  border-bottom: 1px solid var(--line);
}
.present-bar p {
  margin: 0;
  text-align: center;
  flex: 1;
  color: var(--muted);
  font-size: 0.95rem;
}
body.presenting .present-bar { display: flex; }
body.presenting .hero,
body.presenting .kpis,
body.presenting .grade-band,
body.presenting .filters,
body.presenting .grade-hint,
body.presenting .subnav,
body.presenting .methods { display: none; }
body.presenting .wrap > section[id]:not(.kpis),
body.presenting .split { display: contents; }
body.presenting article.card {
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
body.presenting article.card.is-current {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
body.presenting article.card.is-leaving {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
body.presenting article.card.is-enter {
  opacity: 0;
  pointer-events: none;
}
body.presenting .plot,
body.presenting .plot.tall,
body.presenting .plot.short,
body.presenting .plot.calendar,
body.presenting .split .plot {
  height: min(58vh, 540px);
}
body.presenting .wrap { margin-bottom: 2rem; }
body.presenting .site-foot { display: none; }

.muted { color: var(--muted); }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 28%), var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.15rem 1.15rem 0.9rem;
  margin: 0.9rem 0;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.35rem;
}
.card h2 { margin: 0 0 0.35rem; font-size: 1.7rem; }
.card-head h2 { margin: 0; flex: 1 1 12rem; }
.chart-grade { flex: 0 0 auto; font-size: 0.78rem; }
.chart-grade button { padding: 0.2rem 0.55rem; }
.kicker { margin: 0 0 0.8rem; color: var(--orange); font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; }
.note { display: grid; gap: 0.55rem; max-width: 78ch; margin-bottom: 0.8rem; }
.note p { margin: 0; color: var(--soft); }
.note p:last-child { color: var(--ink); }
.plot { height: 380px; }
.plot.tall { height: 460px; }
.plot.short { height: 320px; }
.plot.calendar { height: 280px; }
.plot-help { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; color: var(--muted); font-size: 0.88rem; }

.split { grid-template-columns: 1fr; }
.split .plot { height: 340px; }

@container atlas (min-width: 800px) {
  .card:has(> .plot) {
    display: grid;
    grid-template-columns: minmax(18rem, 28rem) minmax(0, 1fr);
    column-gap: 1.35rem;
    align-items: start;
  }
  .card:has(> .plot) > .card-head {
    grid-column: 1 / -1;
  }
  .card:has(> .plot) > .kicker,
  .card:has(> .plot) > .note,
  .card:has(> .plot) > .field {
    grid-column: 1;
  }
  .card:has(> .plot) > .note {
    max-width: none;
    margin-bottom: 0;
  }
  .card:has(> .plot) > .plot {
    grid-column: 2;
    grid-row: 2 / 8;
    width: 100%;
    min-height: 0;
    height: 440px;
    align-self: start;
  }
  .card:has(> .plot) > .plot.tall { height: 520px; }
  .card:has(> .plot) > .plot.short { height: 380px; }
  .card:has(> .plot) > .plot.calendar { height: 320px; }
  .card:has(> .plot) > .plot-help,
  .card:has(> .plot) > table.ledger {
    grid-column: 1 / -1;
  }
}

body.presenting article.card:not(.is-current):not(.is-leaving):not(.is-enter) {
  display: none;
}

table.ledger { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.ledger th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.4rem;
}
table.ledger td { border-top: 1px solid var(--line); padding: 0.55rem 0.4rem; vertical-align: baseline; }
table.ledger .impact { text-transform: capitalize; }
.impact.critical { color: var(--critical); }
.impact.major { color: var(--major); }
.impact.minor { color: var(--minor); }
.impact.none { color: var(--none); }
.row-links { display: flex; gap: 0.7rem; white-space: nowrap; }

.methods { color: var(--muted); font-size: 0.92rem; max-width: 78ch; }
.methods summary { cursor: pointer; color: var(--ink); }

.site-foot {
  border-top: 1px solid var(--line);
  padding: 1.1rem 1.25rem 1.5rem;
}
.site-foot-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem 0.8rem;
  flex-wrap: wrap;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-foot a { color: inherit; text-decoration: none; }
.site-foot a:hover { color: var(--ink); }
.site-foot img { display: block; width: auto; }
.site-foot .logo {
  font-size: 1.55rem;
  color: var(--ink);
}
.site-foot .logo .logo-mark {
  width: 2.5rem;
  height: 2.5rem;
}
.site-foot .logo-revisit { height: 18px; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}
.tray {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(440px, 100%);
  background: var(--tray-bg);
  border-left: 1px solid var(--line);
  z-index: 50;
  transform: translateX(104%);
  display: flex;
  flex-direction: column;
  padding: 1rem 1rem 1.4rem;
}
.tray.open { transform: none; }
.tray-head, .neighbors { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; }
.tray h2 { font-family: var(--serif); font-size: 1.4rem; margin: 0; }
#tray-search { width: 100%; border-radius: 12px; margin: 0.4rem 0; }
#tray-list { list-style: none; padding: 0; margin: 0; overflow: auto; display: grid; gap: 0.85rem; }
#tray-list li { border-top: 1px solid var(--line); padding-top: 0.7rem; }
#tray-list p { margin: 0.2rem 0; color: var(--muted); font-size: 0.88rem; }
#tray-count {
  background: var(--orange);
  color: #1a1006;
  border-radius: 999px;
  padding: 0 0.4rem;
  font-style: normal;
}

.dossier { padding-top: 1.6rem; max-width: 760px; }
.dossier h1 { font-size: clamp(2rem, 4.4vw, 3.2rem); margin: 0.15rem 0 0.7rem; max-width: 22ch; }
.dossier .kicker { margin-bottom: 0.35rem; }
.grade-read {
  margin: 0 0 1.1rem;
  max-width: 62ch;
  color: var(--soft);
  font-size: 1.05rem;
}
.grade-read b { color: var(--ink); font-weight: 640; }
.grade-read b.critical { color: var(--critical); }
.grade-read b.major { color: var(--major); }
.grade-read b.minor { color: var(--minor); }
.grade-read b.none { color: var(--none); }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem 1.2rem; margin: 0 0 1.2rem; }
.facts div { border-top: 1px solid var(--line); padding-top: 0.4rem; }
.facts span { display: block; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; }
.brief { max-width: 70ch; font-size: 1.05rem; }
.brief p { color: var(--soft); }
.dossier-actions { margin: 0 0 1.4rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0; list-style: none; }
.chips a, .chips span {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  text-decoration: none;
  color: var(--ink);
}
.linked-list { list-style: none; padding: 0; display: grid; gap: 0.55rem; }
.linked-list li { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: 0.45rem; }

.essay-body { width: min(760px, calc(100% - 2rem)); margin: 0 auto 4rem; padding-top: 2rem; }
.essay-body h1 { font-size: clamp(2.5rem, 6vw, 4.6rem); margin: 0.3rem 0 0.6rem; }
.dek { font-size: 1.25rem; line-height: 1.45; }
.essay-body p, .essay-body li { font-family: var(--serif); font-size: 1.18rem; line-height: 1.6; }
.essay-body h2 { font-family: var(--serif); font-size: 1.7rem; margin-top: 2rem; }
.essay-body h3 { font-family: var(--serif); font-size: 1.25rem; margin: 1.4rem 0 0.4rem; }
.pull {
  border-left: 3px solid var(--orange);
  margin: 1.5rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  font-family: var(--serif);
  font-size: 1.55rem;
  line-height: 1.35;
}
.sources { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); }
.sources a { color: var(--link); }
.essay-body table.compare {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.98rem;
  margin: 1.2rem 0 0.4rem;
}
.essay-body table.compare th,
.essay-body table.compare td {
  text-align: right;
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid var(--line);
}
.essay-body table.compare th:first-child,
.essay-body table.compare td:first-child { text-align: left; }
.essay-body table.compare th {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.essay-body .caption { font-family: var(--sans); font-size: 0.92rem; color: var(--muted); margin-top: 0.35rem; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .filters, .split, .grade-band { grid-template-columns: 1fr; }
  .grade-switch { flex-wrap: wrap; white-space: normal; }
  .linked-list li { flex-direction: column; gap: 0.15rem; }
}

@media (max-width: 640px) {
  .kpis, .facts { grid-template-columns: 1fr 1fr; }
  .nav { align-items: flex-start; }
  .hero h1 { max-width: none; }
  .plot, .plot.tall, .plot.short { height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tray { transition: none; }
  body.presenting article.card.is-current,
  body.presenting article.card.is-leaving,
  body.presenting article.card.is-enter { transition: none; }
}
