/* Tufte-dark · One Hundred Years */
@import url("https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@300;400;500&family=Playfair+Display:wght@400;700;900&family=Space+Mono:wght@400;700&display=swap");

:root {
  --ink:        #13110d;
  --ink-2:      #1a1812;
  --ink-3:      #221f17;
  --rule:       #2a261d;
  --vellum:     #e8e0cf;
  --vellum-dim: #c4bda9;
  --muted:      #8a8270;
  --muted-2:    #5e5849;
  --amber:      #d4a64a;
  --amber-2:    #f0c878;
  --oxblood:    #a14545;
  --moss:       #8fa05a;
  --slate:      #6f8aa8;
  --bronze:     #b96f4a;
  --tan:        #a08456;

  --era-classic:       #a08456;
  --era-hollywood:     #b96f4a;
  --era-suburban:      #d4a64a;
  --era-individuality: #8fa05a;
  --era-unique:        #6f8aa8;
  --era-flash:         #a14545;
  --era-killed:        #6f5a4a;
  --era-steady:        #c4bda9;

  --serif: "EB Garamond", "Iowan Old Style", Georgia, serif;
  --mono:  "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--ink);
  color: var(--vellum);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.45;
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
body { min-height: 100vh; }

/* Subtle paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(rgba(232,224,207,0.012) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  z-index: 100;
}

a { color: var(--amber); text-decoration: none; border-bottom: 1px solid rgba(212,166,74,0.3); }
a:hover { color: var(--amber-2); border-bottom-color: var(--amber-2); }

::selection { background: rgba(212,166,74,0.3); color: var(--vellum); }

/* === Layout shell === */
.shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 36px 56px 96px;
  position: relative;
}

/* === Masthead === */
.masthead {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 22px;
  margin-bottom: 28px;
}
.masthead .series {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.masthead .series .sep { color: var(--muted-2); margin: 0 8px; }
.masthead h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 56px;
  line-height: 0.95;
  margin: 0;
  letter-spacing: -0.012em;
}
.masthead h1 em { color: var(--amber); font-style: italic; font-weight: 400; }
.masthead .sub {
  font-family: var(--serif);
  font-style: italic;
  color: var(--vellum-dim);
  font-size: 19px;
  margin-top: 10px;
  max-width: 720px;
}
.masthead .meta {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-align: right;
  line-height: 1.7;
}
.masthead .meta .k { color: var(--muted-2); }
.masthead .meta .v { color: var(--vellum-dim); }

/* === Tab strip === */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tab {
  padding: 12px 18px 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms;
  user-select: none;
  display: flex; align-items: baseline; gap: 9px;
  white-space: nowrap;
}
.tab:hover { color: var(--vellum-dim); }
.tab.active { color: var(--vellum); border-bottom-color: var(--amber); }
.tab .num { color: var(--muted-2); font-size: 9.5px; }
.tab.active .num { color: var(--amber); }

/* === Section headers === */
.section { margin-top: 44px; }
.section-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 18px;
}
.section-head .label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
}
.section-head .rule {
  height: 1px;
  background: var(--rule);
}
.section-head .aside {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.05;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}
.section-lede {
  font-family: var(--serif);
  font-style: italic;
  color: var(--vellum-dim);
  font-size: 17px;
  max-width: 680px;
  margin: 0 0 22px;
}

/* === Stat row === */
.statrow {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.stat {
  padding: 16px 20px 18px;
  border-right: 1px solid var(--rule);
  position: relative;
}
.stat:last-child { border-right: none; }
.stat .label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.stat .value {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--vellum);
}
.stat .value .unit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
  letter-spacing: 0.06em;
  vertical-align: 2px;
}
.stat .foot {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  margin-top: 8px;
  letter-spacing: 0.04em;
}
.stat .spark {
  margin-top: 8px;
  display: block;
}

/* === Hero landscape === */
.hero {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 36px;
  margin-top: 28px;
}
.hero-chart {
  background: transparent;
  position: relative;
}
.hero-aside {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--vellum-dim);
}
.hero-aside p { margin: 0 0 14px; }
.hero-aside .pull {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--vellum);
  border-left: 1px solid var(--amber);
  padding-left: 14px;
  margin: 12px 0;
}
.hero-aside .cite {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

/* === Era ribbon === */
.ribbon {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  margin-top: 24px;
  border-top: 1px solid var(--rule);
}
.ribbon .era {
  padding: 14px 18px 18px;
  border-right: 1px solid var(--rule);
  position: relative;
}
.ribbon .era:last-child { border-right: none; }
.ribbon .era .bar {
  height: 3px;
  margin-bottom: 12px;
  background: var(--era-classic);
}
.ribbon .era .yr {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.ribbon .era .name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  margin-bottom: 6px;
}
.ribbon .era .desc {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--vellum-dim);
}
.ribbon .era .keys {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-top: 8px;
}

/* === Featured triple === */
.triple {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 28px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.feat {
  padding: 22px 26px 24px;
  border-right: 1px solid var(--rule);
}
.feat:last-child { border-right: none; }
.feat .tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 8px;
}
.feat .name {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 500;
  line-height: 1;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.feat .by {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--vellum-dim);
  margin-bottom: 14px;
}
.feat .nums {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}
.feat .nums div { font-family: var(--mono); font-size: 10.5px; }
.feat .nums .k { color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-size: 9px; }
.feat .nums .v { color: var(--vellum); font-size: 15px; font-family: var(--serif); margin-top: 2px; }

/* === Pipeline stepper === */
.pipeline {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0;
  margin-top: 22px;
  border-top: 1px solid var(--rule);
}
.pipe-step {
  padding: 12px 12px 14px;
  border-right: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
  position: relative;
}
.pipe-step:last-child { border-right: none; }
.pipe-step .id {
  color: var(--amber);
  font-size: 9px;
  letter-spacing: 0.16em;
  margin-bottom: 4px;
}
.pipe-step .nm {
  color: var(--vellum);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: -0.002em;
  margin-bottom: 4px;
}
.pipe-step .ds { color: var(--muted); line-height: 1.4; font-size: 9.5px; }
.pipe-step .rt { margin-top: 6px; color: var(--vellum-dim); font-size: 9.5px; }
.pipe-step .rt .sep { color: var(--muted-2); margin: 0 5px; }

/* === Heatmap === */
.heatmap-wrap {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 32px;
  margin-top: 16px;
}
.heatmap {
  font-family: var(--mono);
  font-size: 10px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.heatmap-row {
  display: grid;
  align-items: center;
  height: 16px;
}
.heatmap-row .lbl {
  padding-right: 10px;
  color: var(--vellum-dim);
  font-family: var(--serif);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}
.heatmap-row.head .lbl { color: transparent; }
.heatmap-row .cells { display: flex; height: 100%; gap: 1px; }
.heatmap-row .cell { flex: 1; }
.heatmap-row.head .cell {
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-align: center;
  padding-top: 2px;
}
.heatmap-row .yr-tick {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
}
.heatmap-row.selected .lbl { color: var(--amber); }
.heatmap-legend {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  letter-spacing: 0.08em;
}
.heatmap-legend .grad {
  width: 180px; height: 8px;
  background: linear-gradient(to right, #211d14, #6b4a1a, var(--amber), #f6dc9c);
}

/* === Filters === */
.filter-row {
  display: flex;
  gap: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 10px 0 18px;
  border-bottom: 1px solid var(--rule);
}
.filter-row .pill {
  padding: 8px 14px 10px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
}
.filter-row .pill.active { color: var(--vellum); border-bottom-color: var(--amber); }
.filter-row .pill:hover { color: var(--vellum-dim); }
.filter-row .pill .dot {
  display: inline-block; width: 7px; height: 7px;
  margin-right: 7px;
  vertical-align: middle;
}

/* === Detail panel === */
.detail {
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--vellum-dim);
  border-left: 1px solid var(--rule);
  padding-left: 22px;
}
.detail h3 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--vellum);
  letter-spacing: -0.01em;
}
.detail .meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.detail .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
}
.detail .stats div .k { font-family: var(--mono); font-size: 9.5px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.detail .stats div .v { font-family: var(--serif); font-size: 22px; color: var(--vellum); }
.detail p { margin: 8px 0; }

/* === Suffix small multiples === */
.smallmult {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  margin-top: 18px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.smallmult .panel {
  padding: 12px 14px 14px;
  border-right: 1px solid var(--rule);
}
.smallmult .panel:last-child { border-right: none; }
.smallmult .panel .sx {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.smallmult .panel .ex {
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.smallmult .panel .pk {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--amber);
  letter-spacing: 0.1em;
  margin-top: 4px;
}

/* === Search === */
.search-shell {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  margin-top: 18px;
}
.search-input-wrap {
  position: relative;
  margin-bottom: 8px;
}
.search-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  color: var(--vellum);
  font-family: var(--serif);
  font-size: 48px;
  letter-spacing: -0.015em;
  padding: 14px 0 16px;
  outline: none;
  font-weight: 500;
}
.search-input::placeholder { color: var(--muted-2); font-style: italic; font-weight: 400; }
.search-input:focus { border-bottom-color: var(--amber); }
.search-prefix {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.search-suggest {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 12px;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--vellum-dim);
}
.search-suggest .pick {
  cursor: pointer;
  font-style: italic;
  border-bottom: 1px dotted var(--muted-2);
}
.search-suggest .pick:hover { color: var(--amber); border-bottom-color: var(--amber); }
.search-result {
  margin-top: 32px;
}
.search-result .wavebox {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 14px 0 0;
}
.search-narrative {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  color: var(--vellum-dim);
  max-width: 620px;
  margin: 18px 0 0;
}
.search-narrative em { color: var(--vellum); font-style: italic; }
.search-aside {
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--vellum-dim);
}
.search-aside h4 {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0 0 10px;
  font-weight: 400;
}
.search-aside .rel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 7px 0;
  border-top: 1px dotted var(--rule);
  font-size: 14px;
}
.search-aside .rel .nm { color: var(--vellum); cursor: pointer; }
.search-aside .rel .nm:hover { color: var(--amber); }
.search-aside .rel .v { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }
.search-aside section { margin-bottom: 22px; }

/* === Validation table === */
.valid-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-family: var(--serif);
  font-size: 15px;
}
.valid-table th, .valid-table td {
  text-align: left;
  padding: 10px 14px 10px 0;
  border-bottom: 1px dotted var(--rule);
  vertical-align: baseline;
}
.valid-table th {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
  border-bottom: 1px solid var(--rule);
}
.valid-table td.num { font-family: var(--mono); font-size: 12px; color: var(--vellum-dim); }
.valid-table td.delta { font-family: var(--mono); font-size: 12.5px; color: var(--amber); letter-spacing: 0.02em; }
.valid-table td.check { font-family: var(--mono); color: var(--moss); font-size: 13px; }

/* === Waves cards === */
.waves-list { display: grid; gap: 0; border-top: 1px solid var(--rule); margin-top: 14px; }
.wave-card {
  display: grid;
  grid-template-columns: 110px 1fr 280px;
  gap: 24px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}
.wave-card .yr {
  font-family: var(--serif);
  font-size: 38px;
  color: var(--amber);
  font-weight: 500;
  line-height: 1;
}
.wave-card .yr .sub { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: 0.1em; margin-top: 6px; }
.wave-card .body .ttl { font-family: var(--serif); font-size: 22px; margin-bottom: 4px; }
.wave-card .body .nm { font-family: var(--serif); font-style: italic; color: var(--vellum-dim); font-size: 14.5px; }
.wave-card .body .note { font-family: var(--serif); font-size: 13.5px; color: var(--muted); margin-top: 6px; }

/* === Two-column page === */
.twocol { display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; margin-top: 18px; }

/* === Stub note === */
.stub {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  border: 1px dashed var(--rule);
  padding: 38px 32px;
  text-align: center;
  font-size: 16px;
  letter-spacing: 0.01em;
}
.stub strong { color: var(--vellum-dim); font-style: normal; }

/* === Footnote / colophon === */
.colophon {
  margin-top: 80px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-size: 13.5px;
  color: var(--muted);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
}
.colophon .mono { font-family: var(--mono); font-style: normal; letter-spacing: 0.06em; font-size: 10px; }

/* SVG helpers */
.axis-text { fill: var(--muted); font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; }
.axis-tick { stroke: var(--rule); stroke-width: 1; }
.grid-line { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 1 3; }
.note-text { fill: var(--vellum-dim); font-family: var(--serif); font-style: italic; font-size: 12px; }
.note-line { stroke: var(--muted-2); stroke-width: 1; }
.peak-dot { fill: var(--amber); }

/* ===== Light theme ===== */
[data-theme="light"] {
  --ink:        #EDE8DC;
  --ink-2:      #E5DFD0;
  --ink-3:      #DDD7C6;
  --rule:       #C4BDA9;
  --vellum:     #1C1C18;
  --vellum-dim: #3A3830;
  --muted:      #6B6558;
  --muted-2:    #9A9486;
  --amber:      #C9A84C;
  --amber-2:    #A68A30;
  --oxblood:    #a14545;
  --moss:       #6B8A3A;
  --slate:      #4A6E8A;
  --bronze:     #9A5A30;
  --tan:        #7A6440;

  --era-classic:       #7A6440;
  --era-hollywood:     #9A5A30;
  --era-suburban:      #B89430;
  --era-individuality: #6B8A3A;
  --era-unique:        #4A6E8A;
  --era-flash:         #a14545;
  --era-killed:        #6B5440;
  --era-steady:        #8A8270;
}
[data-theme="light"],
[data-theme="light"] body {
  background: #EDE8DC;
  color: #1C1C18;
}
[data-theme="light"] body::before {
  background-image:
    radial-gradient(rgba(28,28,24,0.02) 1px, transparent 1px);
}
[data-theme="light"] ::selection {
  background: rgba(201,168,76,0.3);
  color: #1C1C18;
}
[data-theme="light"] .stat,
[data-theme="light"] .feat,
[data-theme="light"] .pipe-step,
[data-theme="light"] .smallmult .panel {
  background: #F5F0E3;
}

/* Light theme — SVG overrides */
[data-theme="light"] .tl text        { fill: var(--muted); }
[data-theme="light"] .tl .nl-bar     { stroke: var(--nl-track); }
[data-theme="light"] .tl .ml-pre-bar { stroke: var(--ml-pre); }
[data-theme="light"] .tl .ml-post-bar{ stroke: var(--ml-post); }

/* === Splash screen === */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #1C1C18;
  transition: opacity 500ms;
}
.splash.out { opacity: 0; pointer-events: none; }
.splash-ruler {
  position: fixed; top: 28px; left: 28px;
}
.splash-number {
  font-variant-numeric: tabular-nums;
  animation: splashIn 800ms ease both;
}
.splash-label {
  animation: splashIn 600ms ease 2s both;
}
.splash-title {
  animation: splashIn 600ms ease 3.5s both;
}
.splash-thesis {
  animation: splashIn 600ms ease 4s both;
}
.splash-enter {
  animation: splashIn 600ms ease 5.5s both;
  cursor: pointer;
}
@keyframes splashIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
