/* =========================================================
   Conflict Casualties — product theme
   Layered over styles.css. Every rule is scoped to html.rd, so only
   pages that opt in (currently index.html) change.

   System
   - One brand colour: graphite ink. On a page about two peoples'
     dead, any saturated UI hue risks reading as a side; colour is
     reserved for the data (olive = Palestinian, navy = Israeli).
   - Soft surfaces: white cards on a cool grey page, 24px radius,
     shadow instead of rules.
   - Pills for every control; badges for labels and status.
   - Frosted sticky chrome. Subtle lift on hover, press on active.
   - Full dark theme; motion removed under reduced-motion.
   - Casualty figures are never animated.
   ========================================================= */

/* ---------- Tokens ---------- */
.rd {
  /* The interface and data face (see the Faces block at the top of styles.css). Alegreya and
     Alegreya Sans are one designed family: x-heights 0.456 and 0.461, cap heights 0.637 and 0.641. */
  --font-ui: "Alegreya Sans LF", "Alegreya Sans Fallback", Arial, sans-serif;

  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef1;
  --fill:      rgba(118, 122, 132, 0.12);
  --fill-2:    rgba(118, 122, 132, 0.18);
  --hair:      rgba(16, 19, 23, 0.07);
  --text:      #111317;
  --text-2:    #3b3f46;
  --text-3:    #666b73;
  --text-4:    #8b9098;
  --brand:     #16181b;
  --on-brand:  #ffffff;
  --thumb:     #ffffff;
  --glass:     rgba(248, 249, 251, 0.72);
  --glass-edge: rgba(16, 19, 23, 0.06);
  --focus:     #2f6fdf;
  --sheet-scrim: rgba(10, 12, 15, 0.36);

  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;
  --pill: 999px;

  --e1: 0 1px 2px rgba(16, 19, 23, 0.04), 0 4px 14px -6px rgba(16, 19, 23, 0.06);
  --e2: 0 1px 2px rgba(16, 19, 23, 0.05), 0 14px 32px -14px rgba(16, 19, 23, 0.16);
  --e3: 0 2px 6px rgba(16, 19, 23, 0.06), 0 30px 60px -20px rgba(16, 19, 23, 0.28);
  --e-thumb: 0 1px 2px rgba(16, 19, 23, 0.10), 0 2px 8px -2px rgba(16, 19, 23, 0.12);

  --rd-head: 68px;

  /* Re-point the existing system tokens at the new ones */
  --paper: var(--bg);
  --paper-2: var(--surface-3);
  --paper-3: var(--fill-2);
  --card: var(--surface);
  --card-2: var(--surface-2);
  --ink: var(--text);
  --ink-2: var(--text-2);
  --ink-3: var(--text-3);
  --ink-4: var(--text-4);
  --ink-5: #b3b8bf;
  --rule: var(--hair);
  --rule-2: rgba(16, 19, 23, 0.12);
  --rule-3: rgba(16, 19, 23, 0.2);
  --radius: var(--r-sm);
  --radius-md: var(--r-sm);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);
  --shadow-pop: var(--e3);
  --head-h: var(--rd-head);
  color-scheme: light;
}
@media (max-width: 640px) {
  .rd { --rd-head: 104px; }
}

/* Dark theme — follows the system, or a forced data-theme */
@media (prefers-color-scheme: dark) {
  .rd:not([data-theme="light"]) {
    --bg:        #0a0b0d;
    --surface:   #141619;
    --surface-2: #1b1d21;
    --surface-3: #22252a;
    --fill:      rgba(160, 166, 178, 0.14);
    --fill-2:    rgba(160, 166, 178, 0.22);
    --hair:      rgba(255, 255, 255, 0.07);
    --text:      #f1f3f5;
    --text-2:    #cfd3d9;
    --text-3:    #a0a6af;
    --text-4:    #7d838c;
    --brand:     #f1f3f5;
    --on-brand:  #0a0b0d;
    --thumb:     #3a3d44;
    --glass:     rgba(20, 22, 25, 0.66);
    --glass-edge: rgba(255, 255, 255, 0.08);
    --focus:     #7aa7ff;
    --sheet-scrim: rgba(0, 0, 0, 0.55);
    --e1: 0 0 0 1px rgba(255, 255, 255, 0.05);
    --e2: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 16px 32px -16px rgba(0, 0, 0, 0.6);
    --e3: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 30px 60px -20px rgba(0, 0, 0, 0.8);
    --e-thumb: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ink-5: #5b6068;
    --rule-2: rgba(255, 255, 255, 0.12);
    --rule-3: rgba(255, 255, 255, 0.2);
    --pal: #aebd86; --pal-soft: #6b7650; --pal-deep: #c4d19e;
    --isr: #93b3d3; --isr-soft: #5a7690;
    --pal-bg: rgba(174, 189, 134, 0.1); --isr-bg: rgba(147, 179, 211, 0.1);
    --accent-children: #d9a45c; --accent-women: #c2a980; --accent-press: #86b58f;
    --accent-medical: #b69ad0; --accent-civdef: #7fbcc7;
    color-scheme: dark;
  }
}

/* Forced dark (the story pages) */
.rd[data-theme="dark"] {
    --bg:        #0a0b0d;
    --surface:   #141619;
    --surface-2: #1b1d21;
    --surface-3: #22252a;
    --fill:      rgba(160, 166, 178, 0.14);
    --fill-2:    rgba(160, 166, 178, 0.22);
    --hair:      rgba(255, 255, 255, 0.07);
    --text:      #f1f3f5;
    --text-2:    #cfd3d9;
    --text-3:    #a0a6af;
    --text-4:    #7d838c;
    --brand:     #f1f3f5;
    --on-brand:  #0a0b0d;
    --thumb:     #3a3d44;
    --glass:     rgba(20, 22, 25, 0.66);
    --glass-edge: rgba(255, 255, 255, 0.08);
    --focus:     #7aa7ff;
    --sheet-scrim: rgba(0, 0, 0, 0.55);
    --e1: 0 0 0 1px rgba(255, 255, 255, 0.05);
    --e2: 0 0 0 1px rgba(255, 255, 255, 0.07), 0 16px 32px -16px rgba(0, 0, 0, 0.6);
    --e3: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 30px 60px -20px rgba(0, 0, 0, 0.8);
    --e-thumb: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ink-5: #5b6068;
    --rule-2: rgba(255, 255, 255, 0.12);
    --rule-3: rgba(255, 255, 255, 0.2);
    --pal: #aebd86; --pal-soft: #6b7650; --pal-deep: #c4d19e;
    --isr: #93b3d3; --isr-soft: #5a7690;
    --pal-bg: rgba(174, 189, 134, 0.1); --isr-bg: rgba(147, 179, 211, 0.1);
    --accent-children: #d9a45c; --accent-women: #c2a980; --accent-press: #86b58f;
    --accent-medical: #b69ad0; --accent-civdef: #7fbcc7;
    color-scheme: dark;
}

/* ---------- Base ---------- */
.rd body { background: var(--bg); color: var(--text); }
.rd ::selection { background: rgba(47, 111, 223, 0.18); }
.rd :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.rd .wrap { max-width: var(--container); }

/* ---------- Header: frosted glass, sticky ---------- */
.rd .site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-ui) var(--ease-out), box-shadow var(--dur-ui) var(--ease-out);
}
.rd .site-head.is-scrolled { border-bottom-color: var(--glass-edge); }
.rd .site-head .wrap { padding-top: var(--s-12); padding-bottom: var(--s-12); min-height: var(--rd-head); }
.rd .site-head .brand { color: var(--text); text-decoration: none; }
.rd .site-head .brand-mark { color: var(--text); }
.rd .site-head .brand-title { color: var(--text); font-weight: 600; }
.rd .site-head .brand-sub { color: var(--text-4); }
.rd .site-nav { gap: var(--s-4); }
.rd .site-nav a {
  padding: var(--s-8) var(--s-16);
  border-radius: var(--pill);
  color: var(--text-2);
  font-weight: 500;
  font-size: var(--text-sm);
  border: 0;
  box-shadow: none;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .site-nav a::after { display: none; }
.rd .site-nav a:hover { background: var(--fill); color: var(--text); }
.rd .site-nav a:active { transform: scale(var(--press-scale)); }
.rd .site-nav a.active { background: var(--brand); color: var(--on-brand); font-weight: 600; border: 0; }
@media (max-width: 640px) {
  .rd .site-head .wrap { flex-direction: column; align-items: stretch; gap: var(--s-8); padding-top: var(--s-12); padding-bottom: var(--s-12); }
  .rd .site-nav {
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 calc(-1 * var(--page-margin));
    padding: 0 var(--page-margin);
    border: 0;
  }
  .rd .site-nav::-webkit-scrollbar { display: none; }
  .rd .site-nav a { white-space: nowrap; padding: var(--s-8) var(--s-12); font-size: var(--text-note); }
}
.rd .read-progress { top: auto; bottom: -1px; position: absolute; height: 2px; background: var(--text); opacity: 0.5; } /* floor-ignore: hairline offset */

/* ---------- Kickers: quiet sentence-case text above a heading, never a chip ---------- */
.rd .eyebrow,
.rd .era-years,
.rd .step-when,
.rd .part-num {
  display: block;
  width: auto;
  padding: 0;
  border-radius: 0;
  background: none;
  color: var(--text-3);
  font: 500 0.9375rem/var(--lh-label) var(--font-ui);
  letter-spacing: var(--track-snug);
  text-transform: none;
  margin-bottom: var(--stack-related);
}
.rd .eyebrow--isr { background: none; color: var(--text-3); }   /* both sides at equal weight */
.rd .era--now .era-years { background: none; color: var(--pal); }

/* ---------- Surfaces: every chapter is a soft card ---------- */
.rd .panel .card,
.rd .tracker .card,
.rd .foot-meta .card,
.rd .context-card .card,
.rd .context-card:not(.tracker + .context-card) .card {
  background: var(--surface);
  border: 0;
  border-radius: var(--r-xl);   /* the key figures' tile radius, so every card reads as one family */
  box-shadow: var(--e1);
  padding: var(--pad-card);
  overflow: visible;
}
.rd .panel--scrolly .card { overflow: visible; }
.rd .context-card--band { width: auto; margin-left: 0; margin-right: 0; background: none; padding: 0; }
.rd .context-card--band .card { background: var(--surface) !important; }

.rd .panel-head h2,
.rd .context-lede h2 { letter-spacing: var(--track-display); font-weight: 500; }
.rd .dek, .rd .context-dek { color: var(--text-3); }

/* Part openers breathe, no rules */
.rd .part-head { border: 0; padding-top: clamp(var(--s-64), 9vw, var(--s-128)); padding-bottom: var(--s-8); margin-inline: auto; }
.rd .part-head::before, .rd .part-head::after { display: none; }
.rd .part-head h2 { letter-spacing: var(--track-display); }

/* Lede: the story sits on its own card */
.rd .story--lede {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--e1);
  padding: var(--pad-card);
  max-width: none;
}
.rd .story--lede > * { max-width: 680px; margin-left: auto; margin-right: auto; }
.rd .story-map { border: 0; padding: var(--s-24) var(--s-24); background: var(--surface-2); border-radius: var(--r-md); }

/* Contents: tappable rows */
.rd .contents { border: 0; padding-top: var(--s-8); }
.rd .contents > .eyebrow { margin-left: 0; }
.rd .contents-groups a {
  border-radius: var(--r-xs);
  padding: var(--s-8) var(--s-12);
  margin: 0 calc(-1 * var(--s-12));
  text-decoration: none;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .contents-groups a:hover { background: var(--fill); }
.rd .contents-groups a:active { transform: scale(var(--press-scale)); }

/* ---------- Segmented controls: iOS-style pill track ---------- */
.rd .segmented {
  display: inline-flex;
  gap: var(--s-4);
  padding: var(--s-4);
  border: 0;
  border-radius: var(--pill);
  background: var(--fill);
  box-shadow: none;
}
.rd .segmented button {
  border: 0;
  border-radius: var(--pill);
  padding: var(--s-8) var(--s-16);
  min-height: 34px;
  background: transparent;
  color: var(--text-2);
  font: 600 0.86rem/var(--lh-figure) var(--font-body);
  box-shadow: none;
  transition: background-color var(--dur-ui) var(--ease-out), color var(--dur-ui) var(--ease-out), box-shadow var(--dur-ui) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .segmented button + button { border-left: 0; }
.rd .segmented button:hover:not(.active) { color: var(--text); background: var(--fill); }
.rd .segmented button:active { transform: scale(var(--press-scale)); }
.rd .segmented button.active {
  background: var(--thumb);
  color: var(--text);
  box-shadow: var(--e-thumb);
}
.rd .segmented--night { background: rgba(255, 255, 255, 0.1); }
.rd .segmented--night button { color: rgba(255, 255, 255, 0.72); }
.rd .segmented--night button.active { background: rgba(255, 255, 255, 0.95); color: #111317; }

/* ---------- Chart controls ---------- */

/* Legend chips */

/* Chart surfaces */
.rd .chart-foot { color: var(--text-4); }

/* ---------- "More" disclosures: text and a chevron, like the key figures' control ---------- */
.rd .more { border: 0; padding: 0; margin-top: var(--s-24); }
.rd .more > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  min-height: 32px;
  margin-left: calc(-1 * var(--s-8));
  padding: 0 var(--s-8);
  border-radius: var(--r-xs);
  background: none;
  color: var(--text-2);
  font: 500 0.875rem/var(--lh-figure) var(--font-ui);
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-ui) var(--ease-out), color var(--dur-ui) var(--ease-out);
}
.rd .more > summary::-webkit-details-marker { display: none; }
.rd .more > summary::before { content: none; }
.rd .more > summary::after {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-1px) rotate(45deg);
  transition: transform var(--dur-ui) var(--ease-in-out);
}
.rd .more[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.rd .more > summary:hover { background: var(--fill); color: var(--text); }
.rd .more > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rd .more > :not(summary) { margin-top: var(--s-16); }
.rd .more--night > summary { color: #d9dce1; }
.rd .more--night > summary:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ---------- Stat tiles ---------- */
.rd .oct7-grid, .rd .who-grid { gap: var(--s-12); border: 0; }
.rd .oct7-grid .cell, .rd .who-grid .cell {
  background: var(--surface-2);
  border: 0 !important;
  border-radius: var(--r-md);
  padding: var(--s-16) var(--s-16) var(--s-16);
  transition: transform var(--dur-ui) var(--ease-in-out), box-shadow var(--dur-ui) var(--ease-out);
}
.rd .oct7-grid .cell .lbl, .rd .who-grid .cell .lbl { color: var(--text-3); text-transform: none; letter-spacing: 0; font-weight: 500; }
.rd .who-grid .cell .val, .rd .oct7-grid .cell .val { color: var(--text); }

/* Stacked bars: rounded, gapped segments */
.rd .stackbar { gap: var(--s-4); height: 14px; border-radius: var(--pill); overflow: hidden; background: transparent; }
.rd .stackbar .seg { border-radius: 3px; }
.rd .stackbar .seg:first-child { border-radius: var(--pill) 3px 3px var(--pill); }
.rd .stackbar .seg:last-child { border-radius: 3px var(--pill) var(--pill) 3px; }
.rd .stack-key .sw { border-radius: 50%; }

/* Ceasefire rates */
.rd .rate-moment { gap: var(--s-12); border: 0; }
.rd .rm-col { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s-24); }
.rd .rm-rule { display: none; }

/* Scrollytelling steps as floating cards */
.rd .step-card {
  background: var(--surface);
  border: 0;
  border-radius: var(--r-md);
  box-shadow: var(--e2);
  padding: var(--s-24) var(--s-24);
}
.rd .step:not(.is-active) .step-card { box-shadow: var(--e1); }

/* ---------- History ---------- */
.rd .century-wrap {
  top: calc(var(--rd-head) + var(--s-8));
  width: auto;
  margin: var(--s-24) 0 0;
  border-radius: var(--r-md);
  background: var(--glass) !important;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--e2);
  border: 0;
}
.rd .century-wrap.is-dark { background: rgba(20, 22, 26, 0.6) !important; }
/* The timeline's kicker: sentence case, like every other kicker */
.rd .century-kicker { font: 500 0.8125rem/var(--lh-label) var(--font-ui); letter-spacing: var(--track-snug); text-transform: none; }
.rd .century-btn {
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  width: 34px; height: 34px;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .century-btn:hover { background: var(--fill-2); }
.rd .century-btn:active { transform: scale(var(--press-scale)); }

.rd .era:not(.era--feature) { padding-top: clamp(var(--s-48), 6vw, var(--s-96)); }
.rd .era-fig img { border-radius: var(--r-lg); }
.rd .era-fig--doc img { box-shadow: var(--e2); }
.rd .era-stats { border: 0; gap: var(--s-12); }
.rd .era-stats > div { background: var(--surface); border-radius: var(--r-md); padding: var(--s-16) var(--s-16); box-shadow: var(--e1); border: 0; }
.rd .era--feature {
  width: auto;
  margin-left: 0;
  margin-right: 0;
  margin-top: clamp(var(--s-48), 6vw, var(--s-96));
  border-radius: var(--r-xl);
  overflow: clip; /* clip, not hidden: hidden makes a scroll container, which captures scroll-driven timelines */
  isolation: isolate;
}
.rd .era--feature .era-stats > div { background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.rd .era--feature .era-years { background: rgba(255, 255, 255, 0.12); color: #e7ebd9; }
.rd .era--now { border-top: 0; }
.rd .century-chart { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--e1); padding: var(--s-24); }
.rd .cc-bar i { border-radius: var(--pill); }

.rd .pullquote { border: 0; }

/* ---------- Table ---------- */
.rd .table-scroll { border-radius: var(--r-md); background: var(--surface-2); padding: var(--s-4) var(--s-8); }
.rd .tracker-table { border-collapse: separate; border-spacing: 0; }
.rd .tracker-table thead th {
  border: 0;
  border-bottom: 1px solid var(--hair);
  text-transform: none;
  letter-spacing: var(--track-ui);
  color: var(--text-3);
  font-weight: 600;
  background: transparent;
}
.rd .tracker-table td { border: 0; border-bottom: 1px solid var(--hair); }
.rd .tracker-table tbody tr:last-child td { border-bottom: 0; }
.rd .tracker-table tbody tr { transition: background-color var(--dur-micro) var(--ease-out); }
.rd .tracker-table tbody tr:hover td { background: var(--fill); }
.rd .tracker-table tbody tr:hover td:first-child { border-radius: 12px 0 0 12px; }
.rd .tracker-table tbody tr:hover td:last-child { border-radius: 0 12px 12px 0; }

/* ---------- Coda: an inset memorial surface ---------- */
.rd .coda {
  width: auto;
  border-radius: var(--r-xl);
  background: #0e1013;
  overflow: clip; /* clip, not hidden: hidden makes a scroll container, which captures scroll-driven timelines */
  margin-inline: 0;
}
.rd .names-more {
  min-height: 44px;
  border: 0;
  border-radius: var(--pill);
  background: rgba(255, 255, 255, 0.95);
  color: #111317;
  padding: var(--s-12) var(--s-24);
  font-weight: 600;
  transition: transform var(--dur-micro) var(--ease-press), box-shadow var(--dur-micro) var(--ease-out);
}
.rd .names-more:hover { box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6); }
.rd .names-more:active { transform: scale(var(--press-scale)); }
.rd .coda-links { gap: var(--s-8); border: 0; }
.rd .coda-links a {
  padding: var(--s-12) var(--s-16);
  border-radius: var(--pill);
  background: rgba(255, 255, 255, 0.08);
  color: #f1f3f5;
  text-decoration: none;
  font-weight: 600;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .coda-links a:hover { background: rgba(255, 255, 255, 0.16); }
.rd .coda-links a:active { transform: scale(var(--press-scale)); }

/* ---------- Footer: quiet ---------- */
.rd .site-foot {
  background: transparent;
  color: var(--text-3);
  border-top: 0;
  margin-top: clamp(var(--s-48), 6vw, var(--s-96));
}
.rd .site-foot a { color: var(--text-2); }
.rd .site-foot .foot-title { color: var(--text); }
.rd .site-foot .foot-h { color: var(--text-3); text-transform: none; letter-spacing: var(--track-ui); }
.rd .foot-brand .brand-mark { color: var(--text); }
.rd .foot-base { border-top: 1px solid var(--hair); color: var(--text-4); }

/* ---------- Fixes from the first review pass ---------- */
.rd .eyebrow { align-self: flex-start; }
.rd .coda .eyebrow { background: none; color: #c9d0b4; }
.rd .site-foot, .rd .site-foot span, .rd .site-foot p, .rd .foot-col { color: var(--text-3); }
.rd .era--now::before, .rd .era--now::after { display: none; }
.rd .era--now { border-top: 0 !important; }
@media (max-width: 640px) {
  .rd .site-nav { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .rd .dots-controls .segmented { display: flex; width: 100%; }
  .rd .dots-controls .segmented button { flex: 1 1 auto; padding: var(--s-8); white-space: nowrap; }   /* sized to their labels, never wrapped */
  /* Horizontal, swipeable rows instead of tall stacks */
}

/* ---------- Links ---------- */
.rd main a:not([class]) { text-decoration-color: var(--rule-3); text-underline-offset: 3px; transition: text-decoration-color var(--dur-micro) var(--ease-out); }
.rd main a:not([class]):hover { text-decoration-color: currentColor; }

/* =========================================================
   Mobile: filters live in a bottom sheet (redesign.js)
   ========================================================= */
@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
  @keyframes rd-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
  @keyframes rd-fade { from { opacity: 0; } to { opacity: 1; } }
}

/* ---------- Hover lift for interactive surfaces (pointer devices) ---------- */

/* ---------- Reduced motion: no transforms, no transitions ---------- */
@media (prefers-reduced-motion: reduce) {
  .rd .segmented button:active,
  .rd .more > summary:active,
  .rd .site-nav a:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .rd .site-head, .rd .century-wrap { background: var(--surface) !important; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* =========================================================
   Refinement pass — one edge, one rhythm, every breakpoint
   Breakpoints: phone ≤640 · tablet 641–1023 · desktop ≥1024 · wide ≥1440
   Gutter  12 · 20 · 24 · 24      (page edge → card edge; the opening shares it)
   Pad     20 · 32 · 48 · 56      (card edge → content)
   Gap     12 · 16 · 24 · 24      (card → card)
   Inside a card everything shares one left edge; prose is capped
   by measure, never re-centred.
   ========================================================= */
.rd .wrap { padding-left: var(--page-margin); padding-right: var(--page-margin); }

/* Header: brand and nav on the content edge, 36px pills */
.rd .site-head .wrap { min-height: 64px; padding-top: var(--s-12); padding-bottom: var(--s-12); }
.rd .site-nav a { min-height: 36px; display: inline-flex; align-items: center; padding: 0 var(--s-16); }
@media (max-width: 1023px) and (min-width: 641px) {
  .rd .site-head .brand-sub { display: none; }
  .rd .site-nav a { padding: 0 var(--s-12); font-size: var(--text-note); }
}
@media (max-width: 640px) {
  .rd { --rd-head: 100px; }
  .rd .site-head .wrap { gap: var(--s-8); padding-top: var(--s-8); padding-bottom: var(--s-8); min-height: 0; }
  .rd .site-head .brand-sub { font-size: var(--text-3xs); }
  .rd .site-nav { margin: 0 calc(-1 * var(--page-margin)); padding: 0 var(--page-margin); }
  .rd .site-nav a { min-height: 34px; padding: 0 var(--s-12); }
}

/* Sections: identical spacing between every card */
.rd .story--lede { padding: var(--pad-card); }

/* Inside a card: one left edge */
.rd .panel-head,
.rd .context-lede,
.rd .context-inner > .viz-block,
.rd .context-inner > .more,
.rd .rate-moment { max-width: none; margin-left: 0; margin-right: 0; width: auto; }
.rd .panel-head { margin-bottom: var(--s-32); }
.rd .panel-head .dek, .rd .context-dek, .rd .viz-sub { max-width: var(--measure); }
.rd .panel-head .eyebrow, .rd .context-lede .eyebrow { margin-bottom: var(--stack-related); }
.rd .panel-head h2, .rd .context-lede h2 {
  font-size: var(--fs-panel-head-h2-ui);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  margin: 0 0 var(--stack-block);
}
.rd .panel-head .dek, .rd .context-dek { font-size: var(--fs-panel-head-dek-ui); line-height: var(--lh-caption); margin: 0; }
.rd .context-inner { gap: var(--s-32); }
.rd .viz-title { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.rd .chart-foot { font-size: var(--text-xs); line-height: var(--lh-caption); margin-top: var(--s-16); max-width: var(--measure); }
.rd .card > .more:last-child, .rd .more { margin-top: var(--s-24); padding-top: 0; }

/* Lede card: reading column centred as a unit, badges on its edge */
.rd .story--lede { --lede-column: 640px; }   /* the reading column, ~60 characters at the lede size */
.rd .story--lede > *, .rd .story--lede > .eyebrow { max-width: var(--lede-column); margin-left: auto; margin-right: auto; }
.rd .story--lede > .eyebrow { display: block; width: fit-content; margin-left: max(0px, calc((100% - var(--lede-column)) / 2)); }
.rd .story--lede .contents { margin-top: var(--s-32); }
.rd .story--lede .contents > .eyebrow { margin-left: 0; }
.rd .story-map { margin-top: var(--s-32); padding: var(--s-16) var(--s-24); font-size: var(--text-sm); }

/* Controls row: labels and pills on a shared baseline */
.rd .segmented { min-height: 40px; align-items: center; }
.rd .segmented button { min-height: 34px; }

/* Turning points: an even grid, never a ragged 4 + 2 */

/* Dots */
.rd .dots-controls { margin-bottom: var(--s-24); gap: var(--s-12) var(--s-16); align-items: center; }

/* Ceasefire rates: two equal tiles */
.rd .rate-moment { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-12); max-width: 640px; }
.rd .rm-col { padding: var(--s-24) var(--s-24); }
.rd .rm-num { font-size: var(--fs-rm-num-ui); line-height: var(--lh-figure); color: var(--text); }
.rd .rm-col--now .rm-num { color: var(--text-3); }
.rd .rm-lbl { margin-top: var(--s-12); font-size: var(--text-sm); }
.rd .viz-block { max-width: none; }
.rd .context-inner > .viz-block { max-width: 640px; }

/* Stat tiles: fill the row, no orphans */
.rd .who-grid, .rd .oct7-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-8); }
.rd .who-grid .cell:last-child:nth-child(odd) { grid-column: 1 / -1; }
.rd .oct7-grid .cell .val, .rd .who-grid .cell .val { font-size: var(--fs-oct7-grid-cell-val); margin-top: var(--s-8); line-height: var(--lh-figure); }
.rd .oct7-grid .cell .lbl, .rd .who-grid .cell .lbl { font-size: var(--text-xs); line-height: var(--lh-label); }
.rd .people { gap: clamp(var(--s-32), 4vw, var(--s-64)); }
@media (max-width: 1023px) { .rd .people { grid-template-columns: 1fr; } }

/* Scrollytelling: cards track the graphic's edge */
.rd .step-card { max-width: 400px; }

/* History: eras on the page grid, same gutter as cards */
.rd .century-wrap { margin-top: 0; }   /* the page stack spaces .history; the bar sits at its top edge */
.rd .century-bar { padding-left: var(--s-24); padding-right: var(--s-12); }
.rd .era--feature .era-body { padding: var(--pad-card); }
.rd .era-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 640px) {
  .rd .century-wrap { top: calc(var(--rd-head) + var(--s-8)); border-radius: var(--r-sm); }
  .rd .era--feature { border-radius: var(--r-lg); }
}

/* Table: tighter cells, numerals aligned */
.rd .tracker-table th, .rd .tracker-table td { padding: var(--s-16) var(--s-12); vertical-align: top; }
.rd .tracker-table td { font-size: var(--text-sm); }

/* Coda and footer */
.rd .coda-inner { padding-left: var(--pad-card); padding-right: var(--pad-card); }
@media (max-width: 640px) { .rd .coda { border-radius: var(--r-lg); } }
.rd .site-foot { margin-top: var(--gap-section); }
.rd .foot-grid { padding-top: 0; }
.rd .foot-base { margin-top: var(--s-32); }
.rd .context-card--band .card { padding: var(--pad-card); max-width: none; }
.rd .chart-foot { max-width: 72ch; }

/* Phone: swipe rows run edge to edge of the card (re-asserted after the rhythm rules) */

/* ---------- Final spacing fixes ---------- */

@media (max-width: 640px) {
  /* Prose that sits on the page (no card) lines up with text inside cards */
  .rd .history-intro, .rd .era:not(.era--feature) .era-body, .rd .era-fig figcaption, .rd .pullquote, .rd .site-foot .wrap { padding-left: var(--s-8); padding-right: var(--s-8); }
  .rd .site-foot .wrap { padding-left: calc(var(--page-margin) + var(--s-8)); padding-right: calc(var(--page-margin) + var(--s-8)); }
  .rd .era-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-8); }
  .rd .era-stats > div { padding: var(--s-16); }

  /* Sources: one rounded card per source instead of one long block */
  .rd .table-scroll { background: none; padding: 0; border-radius: 0; overflow: visible; }
  .rd .tracker-table tr {
    background: var(--surface-2);
    border: 0;
    border-radius: var(--r-md);
    padding: var(--s-16) var(--s-16);
    margin-bottom: var(--s-8);
  }
  .rd .tracker-table td { border: 0 !important; padding: var(--s-4) 0; font-size: var(--text-note); }
  .rd .tracker-table td.tracker-name { padding-bottom: var(--s-8); margin-bottom: var(--s-8); border-bottom: 1px solid var(--hair) !important; }
  .rd .tracker-table tbody tr:hover td { background: none; }
}
/* Ceasefire card uses the width on desktop: headline left, rates right */
@media (min-width: 1024px) {
  .rd .context-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--s-48); row-gap: var(--s-48); align-items: end; }
  .rd .context-inner > .context-lede { grid-column: 1; }
  .rd .context-inner > .rate-moment { grid-column: 2; max-width: none; }
  .rd .context-inner > .viz-block, .rd .context-inner > .more { grid-column: 1 / -1; max-width: none; }
  .rd .context-inner > .viz-block .stack-key { display: flex; flex-wrap: wrap; gap: var(--s-8) var(--s-24); }
}
@media (max-width: 640px) {
  .rd .tracker-table td:not(.tracker-name) { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); column-gap: var(--s-12); }
}
@media (min-width: 1024px) { .rd .context-inner > .more { margin-top: calc(-1 * var(--s-16)); } }
@media (max-width: 640px) {
  .rd .tracker-table td::before { font: 600 0.78rem/var(--lh-ui) var(--font-body) !important; letter-spacing: var(--track-ui); text-transform: none; color: var(--text-3); }
}

/* ---------- Month by month: tighter scrollytelling ---------- */
.rd .scrolly { gap: clamp(var(--s-32), 4vw, var(--s-64)); }
.rd .scrolly-steps { padding: 8vh 0 24vh; }
.rd .step { min-height: 46vh; }
.rd .scrolly-graphic { top: calc(var(--rd-head) + max(var(--s-24), 50vh - var(--rd-head) / 2 - 300px)); } /* floor-ignore: pin position derived from the chart height, not spacing */
@media (max-width: 900px) {
  /* Chart pins under the header; cards pass beneath it and activate at 74% of the screen */
  .rd .scrolly-graphic {
    top: var(--rd-head);
    margin: 0 calc(-1 * var(--pad-card));
    padding: var(--s-12) var(--pad-card) var(--s-16);
    background: var(--surface);
    border-radius: 0 0 var(--r-md) var(--r-md);
    box-shadow: 0 12px 16px -12px rgba(16, 19, 23, 0.12);
  }
  .rd .scrolly-steps { padding: 32vh 0 18vh; }
  .rd .step { min-height: 52vh; justify-content: center; }
  .rd .step-card { max-width: none; box-shadow: var(--e2); }
}
@media (max-width: 900px) and (prefers-color-scheme: dark) {
  .rd:not([data-theme="light"]) .scrolly-graphic { box-shadow: 0 12px 16px -12px rgba(0, 0, 0, 0.6); }
}
@media (max-width: 900px) {
  .rd .scrolly-graphic { z-index: 4; }
  .rd .scrolly-steps { z-index: 1; }
}

/* The content edge: where page text sits, in line with the logo. Full-bleed
   elements (the opening plate) use it to line their insides up with the page. */
.rd { --edge: max(var(--page-margin), calc((100vw - var(--container)) / 2 + var(--page-margin))); }

/* Open section heads on these pages: same scale as chapter heads */
.rd .section-head,
.rd .gallery-head,
.rd .lists-section > h2,
.rd .note-panel > h2 { border: 0; }
.rd .section-head h2,
.rd .gallery-head h2 {
  font-size: var(--fs-gallery-head-h2-ui);
  font-weight: 500;
  letter-spacing: var(--track-display);
  line-height: var(--lh-title);
  margin: 0 0 var(--stack-block);
}
.rd .section-head p, .rd .gallery-head p { color: var(--text-3); max-width: var(--measure); margin: 0; }
.rd .section-head::before, .rd .section-head::after { display: none; }

/* =========================================================
   Reading list
   ========================================================= */
.rd .jump-nav {
  position: sticky;
  top: calc(var(--rd-head) + var(--s-8));
  z-index: 20;
  display: flex;
  gap: var(--s-4);
  width: fit-content;
  max-width: 100%;
  padding: var(--s-4);
  border: 0;
  border-radius: var(--pill);
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--e2);
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: 0;
}
.rd .jump-nav::-webkit-scrollbar { display: none; }
.rd .jump-nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--s-16);
  border: 0;
  border-radius: var(--pill);
  color: var(--text-2);
  font: 600 0.86rem/var(--lh-figure) var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .jump-nav a::after { display: none; }
.rd .jump-nav a:hover { background: var(--fill); color: var(--text); }
.rd .jump-nav a:active { transform: scale(var(--press-scale)); }
@media (max-width: 640px) {
  .rd .jump-nav { width: auto; border-radius: var(--r-sm); margin-left: calc(-1 * var(--page-margin) + var(--s-4)); margin-right: calc(-1 * var(--page-margin) + var(--s-4)); }
}

.rd .book-section { padding-top: 0; border: 0; scroll-margin-top: calc(var(--rd-head) + var(--s-64)); }
.rd .section-head { margin-bottom: var(--s-24); padding: 0; }
.rd .book-grid { gap: var(--gap-card); }
.rd .book {
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 0;
  padding: var(--s-12);
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--e1);
  overflow: hidden;
  transition: transform var(--dur-ui) var(--ease-in-out), box-shadow var(--dur-ui) var(--ease-out);
}
.rd .book-featured { grid-template-columns: 240px minmax(0, 1fr); }
.rd .book-cover { border-radius: var(--r-sm); overflow: hidden; min-height: 196px; }
.rd .book-featured .book-cover { min-height: 300px; }
.rd .book-body { padding: var(--s-8) var(--s-12) var(--s-8) var(--s-24); border: 0; }
.rd .book-body h3 { letter-spacing: var(--track-snug); }
.rd .book-author { text-transform: none; letter-spacing: var(--track-ui); color: var(--text-3); font-weight: 600; }
.rd .book-body p { color: var(--text-2); }
.rd .book-pill { border-radius: var(--pill); background: var(--fill); color: var(--text-2); border: 0; padding: var(--s-4) var(--s-12); text-transform: none; letter-spacing: var(--track-ui); }
.rd .book-links { border: 0; padding-top: var(--s-12); gap: var(--s-8); }
.rd .book-links a {
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  min-height: 32px;
  padding: 0 var(--s-12);
  border: 0;
  border-radius: var(--pill);
  background: var(--fill);
  color: var(--text);
  font: 600 0.8rem/var(--lh-figure) var(--font-body);
  text-decoration: none;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .book-links a:hover { background: var(--fill-2); }
.rd .book-links a:active { transform: scale(var(--press-scale)); }
@media (max-width: 900px) { .rd .book-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .rd .book, .rd .book-featured { grid-template-columns: 96px minmax(0, 1fr); padding: var(--s-12); border-radius: var(--r-md); }
  .rd .book-cover, .rd .book-featured .book-cover { min-height: 140px; border-radius: 10px; }
  .rd .book-featured .book-cover .title-cover { font-size: var(--text-sm); }
  .rd .book-body { padding: var(--s-4) var(--s-8) var(--s-4) var(--s-16); }
}

.rd .lists-section {
  padding: var(--pad-card);
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--e1);
}
.rd .lists-section .note { background: var(--surface-2); border: 0; border-radius: var(--r-md); padding: var(--s-16) var(--s-16); }
.rd .source-lists li { border-color: var(--hair); }

/* =========================================================
   Destruction
   ========================================================= */
.rd .gallery-head { padding: 0; }
.rd .gallery-head .eyebrow { margin-bottom: var(--stack-related); }
.rd .gallery { gap: var(--gap-card); }
.rd .photo { background: transparent; border: 0; border-radius: 0; }
.rd .photo img { border-radius: var(--r-lg); }
.rd .photo figcaption { padding: var(--s-16) var(--s-4) 0; }
.rd .photo.wide { width: auto; margin-left: 0; margin-right: 0; }
.rd .photo.wide img { border-radius: var(--r-xl); }
.rd .photo.wide figcaption { padding-left: var(--s-4); padding-right: var(--s-4); }
.rd .cap-loc { font-weight: 600; }
.rd .cap-date {
  display: inline-flex;
  margin: var(--s-8) 0 var(--s-8);
  padding: var(--s-4) var(--s-12);
  border-radius: var(--pill);
  background: var(--fill);
  color: var(--text-2);
  font: 600 0.74rem/var(--lh-label) var(--font-body);
}
.rd .cap-credit { color: var(--text-4); }
@media (max-width: 640px) {
  .rd .photo img, .rd .photo.wide img { border-radius: var(--r-md); }
}
.rd .note-panel {
  padding: var(--pad-card);
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--e1);
}

/* Content-warning gate: a sheet-style dialog */
.rd .cw-gate { background: var(--sheet-scrim); backdrop-filter: blur(18px) saturate(120%); -webkit-backdrop-filter: blur(18px) saturate(120%); }
.rd .cw-card {
  border: 0;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--e3);
  padding: clamp(var(--s-32), 4vw, var(--s-48));
}
.rd .cw-mark { border-radius: 50%; background: var(--fill); color: var(--text); }
.rd .cw-eyebrow {
  display: inline-flex;
  padding: var(--s-4) var(--s-12);
  border-radius: var(--pill);
  background: var(--fill);
  color: var(--text-2);
  font: 600 0.78rem/var(--lh-title) var(--font-body);
  letter-spacing: var(--track-ui);
  text-transform: none;
}
.rd .cw-actions { gap: var(--s-8); }
.rd .btn-primary, .rd .btn-ghost {
  min-height: 48px;
  padding: 0 var(--s-24);
  border: 0;
  border-radius: var(--pill);
  font: 600 0.95rem/var(--lh-figure) var(--font-body);
  transition: transform var(--dur-micro) var(--ease-press), box-shadow var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.rd .btn-primary { background: var(--brand); color: var(--on-brand); }
.rd .btn-primary:hover { box-shadow: var(--e2); }
.rd .btn-ghost { background: var(--fill); color: var(--text); }
.rd .btn-ghost:hover { background: var(--fill-2); }
.rd .btn-primary:active, .rd .btn-ghost:active { transform: scale(var(--press-scale)); }
@media (max-width: 640px) {
  .rd .cw-actions { flex-direction: column; align-items: stretch; }
}

/* =========================================================
   Donate
   ========================================================= */
.rd .donate-grid { gap: var(--gap-card); }
.rd .donate-card {
  display: flex;
  flex-direction: column;
  padding: clamp(var(--s-24), 3vw, var(--s-32));
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--e1);
  transition: transform var(--dur-ui) var(--ease-in-out), box-shadow var(--dur-ui) var(--ease-out);
}
.rd .donate-card::before { display: none; }
.rd .donate-head { align-items: flex-start; gap: var(--s-12); }
.rd .donate-head h3 { letter-spacing: var(--track-title); }
.rd .donate-rating {
  flex: none;
  padding: var(--s-4) var(--s-12);
  border-radius: var(--pill);
  background: var(--pal-bg);
  color: var(--pal);
  font: 600 0.74rem/var(--lh-label) var(--font-body);
  white-space: nowrap;
}
.rd .donate-tags { gap: var(--s-8); }
.rd .donate-tag { border: 0; border-radius: var(--pill); background: var(--fill); color: var(--text-2); padding: var(--s-4) var(--s-12); font-weight: 600; }
.rd .donate-card > p { color: var(--text-2); flex: 1; }
.rd .donate-foot { border: 0; padding-top: var(--s-8); align-items: center; gap: var(--s-12); flex-wrap: wrap; }
.rd .donate-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  min-height: 42px;
  padding: 0 var(--s-16);
  border-radius: var(--pill);
  background: var(--brand);
  color: var(--on-brand);
  font: 600 0.88rem/var(--lh-figure) var(--font-body);
  text-decoration: none;
  transition: transform var(--dur-micro) var(--ease-press), box-shadow var(--dur-micro) var(--ease-out);
}
.rd .donate-link:hover { box-shadow: var(--e2); color: var(--on-brand); }
.rd .donate-link:active { transform: scale(var(--press-scale)); }
.rd .donate-meta { color: var(--text-4); font-family: var(--font-body); font-size: var(--text-xs); }
@media (max-width: 640px) {
  .rd .donate-head { flex-direction: column; gap: var(--s-8); }
  .rd .donate-link { width: 100%; justify-content: center; min-height: 46px; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .rd .book:hover, .rd .donate-card:hover { box-shadow: var(--e2); }
}
.rd .cap-date { width: fit-content; }
/* Phone: covers collapse to a slim colour spine; the text gets the width */
@media (max-width: 640px) {
  .rd .book, .rd .book-featured { grid-template-columns: 6px minmax(0, 1fr); padding: var(--s-16) var(--s-16) var(--s-16) var(--s-12); }
  .rd .book-cover, .rd .book-featured .book-cover { min-height: 0; height: auto; border-radius: 3px; padding: 0; }
  .rd .book-cover > *, .rd .book-cover::before, .rd .book-cover::after { display: none; }
  .rd .book-body { padding: var(--s-4) 0 0 var(--s-16); }
}
.rd .btn-primary, .rd .btn-ghost { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* =========================================================
   Many conflicts: switcher in the header
   Graphite only, like the rest of the chrome; colour stays with
   the data.
   ========================================================= */
.rd .head-id { display: flex; align-items: center; gap: var(--s-16); min-width: 0; }

/* Switcher button: a pill naming the conflict on screen */
.rd .conflict-switch { position: relative; }
.rd .cs-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--s-8);
  min-height: 36px;
  padding: 0 var(--s-12) 0 var(--s-16);
  border-radius: var(--pill);
  background: var(--fill);
  color: var(--text);
  font: 600 0.88rem/var(--lh-figure) var(--font-body);
  white-space: nowrap;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-press);
}
.rd .cs-btn:hover { background: var(--fill-2); }
.rd .cs-btn:active { transform: scale(var(--press-scale)); }
.rd .cs-label { font-weight: 500; color: var(--text-3); }
.rd .cs-chev { width: 14px; height: 14px; color: var(--text-3); transition: transform var(--dur-ui) var(--ease-in-out); }
.rd .cs-btn[aria-expanded="true"] { background: var(--fill-2); }
.rd .cs-btn[aria-expanded="true"] .cs-chev { transform: rotate(180deg); }

/* Menu: one card per conflict */
.rd .cs-menu {
  position: absolute;
  top: calc(100% + var(--s-12));
  left: 0;
  z-index: 60;
  width: min(380px, calc(100vw - 2 * var(--page-margin)));
  padding: var(--s-8);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--e3);
}
.rd .cs-menu[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .rd .cs-menu:not([hidden]) { animation: cs-in var(--dur-ui) var(--ease-out); }
}
@keyframes cs-in { from { opacity: 0; transform: translateY(-4px); } }
.rd .cs-head { padding: var(--s-8) var(--s-12) var(--s-8); font-size: var(--text-xs); font-weight: 600; color: var(--text-3); }
.rd .cs-item {
  position: relative;
  display: grid;
  gap: var(--s-4);
  padding: var(--s-12);
  border-radius: var(--r-sm);
  color: var(--text);
  text-decoration: none;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.rd .cs-item + .cs-item { margin-top: var(--s-4); }
.rd .cs-item:hover, .rd .cs-item:focus-visible { background: var(--fill); }
.rd .cs-item.is-current { background: var(--surface-2); }
.rd .cs-row { display: flex; align-items: center; gap: var(--s-8); padding-right: var(--s-64); }
.rd .cs-item-name { font: 600 1.06rem/var(--lh-label) var(--font-display); letter-spacing: var(--track-snug); }
.rd .cs-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 var(--s-8);
  border-radius: var(--pill);
  font: 600 0.68rem/var(--lh-figure) var(--font-body);
  letter-spacing: var(--track-label);
  background: var(--fill);
  color: var(--text-2);
}
.rd .cs-badge--featured { background: var(--brand); color: var(--on-brand); }
.rd .cs-period { font-size: var(--text-xs); color: var(--text-3); }
.rd .cs-toll { font-size: var(--text-note); color: var(--text-2); }
.rd .cs-toll strong { font-variant-numeric: tabular-nums; color: var(--text); }
.rd .cs-here { position: absolute; top: var(--s-16); right: var(--s-12); font-size: var(--text-micro); font-weight: 600; color: var(--text-3); }
.rd .cs-foot { margin: var(--s-8) var(--s-12) var(--s-8); font-size: var(--text-xs); color: var(--text-3); }

/* Jumps land below the header */
.rd [data-chapter], .rd .part-head { scroll-margin-top: calc(var(--rd-head) + var(--s-16)); }

/* Footer: a second heading inside a column */
.rd .foot-h--sub { margin-top: var(--s-16); }

/* Tablet: the switcher drops its label; the wordmark goes before the nav wraps */
@media (max-width: 1023px) {
  .rd .cs-label { display: none; }
}
@media (max-width: 900px) and (min-width: 641px) {
  .rd .site-head .brand-text { display: none; }
}

/* Phone: brand and switcher share the top row. */
@media (max-width: 640px) {
  .rd .head-id { justify-content: space-between; gap: var(--s-8); }
  .rd .site-head .brand-title { font-size: var(--text-ui); }
  .rd .site-head .brand-mark { width: 26px; height: 26px; }
  .rd .cs-btn { min-height: 32px; padding: 0 var(--s-8) 0 var(--s-12); font-size: var(--text-xs); }
  .rd .cs-menu { left: auto; right: 0; width: calc(100vw - 2 * var(--page-margin)); }
}
@media (prefers-reduced-transparency: reduce) {
  .rd .cs-menu { background: var(--surface); }
}

/* =========================================================
   Display numerals: every big data number reads one token, so
   the face can change in one place. The closing memorial
   number stays in the serif on purpose: it is a tribute, not
   a statistic.
   ========================================================= */
.rd { --font-num: var(--font-ui); }
/* Data figures that were set in the mono face keep column alignment with tabular numerals */
.rd :is(.rate-val, .stack-key strong, .dots-readout strong, .tl-when, .yr-x, .contents a b, .toc-list a b) { font-variant-numeric: tabular-nums lining-nums; }
.rd .rm-num { font-family: var(--font-num); font-weight: 600; letter-spacing: var(--track-display); }
.rd .era-stats strong,
.rd .cell .val,
.rd .yr-facts strong,
.rd .us-grid .val,
.rd .yr-readout strong { font-family: var(--font-num); font-weight: 600; letter-spacing: var(--track-display); }

/* =========================================================
   Layout primitives — spacing is owned by parents.
   Tokens live at the top of styles.css; rules in docs/spacing.md.
   ========================================================= */

/* Page stack: <main> spaces its top-level blocks. Blocks carry no outer margins.
   Cards sit --gap-card apart; anything that changes the subject gets --gap-section. */
.rd main.wrap > * { margin-block: 0; }
.rd main.wrap > * + * { margin-block-start: var(--gap-card); }
.rd main.wrap > :is(.opening + *, .stats, .story--lede, .part-head, .history, .pullquote, .pullquote + *, .tracker, .coda, .gallery-head, .note-panel, .donate-grid + .foot-meta, .book-section, .lists-section) { margin-block-start: var(--gap-section); }
.rd main.wrap > :first-child { margin-block-start: 0; }
.rd main.wrap { padding-block-end: 0; }

/* Space is measured to the visible text: each text block's first line is trimmed to its
   cap height and its last line to its baseline, so padding and gaps are ink to ink.
   Browsers without text-box (Firefox, for now) keep the leading: slightly looser, never cramped.
   Excluded: the opening headline (its lines are clip boxes for the entrance) and figures
   painted with background-clip: text (trimming would clip the paint under a comma's tail). */
@supports (text-box: trim-both cap alphabetic) {
  :where(.rd main, .rd .site-foot) :where(h1, h2, h3, h4, p, dt, dd, figcaption, blockquote, li, .eyebrow, .viz-title, .lbl, .val, .rm-num, .rm-lbl) {
    text-box: trim-both cap alphabetic;
  }
  :where(.rd) :where(.opening-title, .opening-title *, .stats-num, .stats-more, .coda-num, li:has(> ol, > ul)) { text-box: normal; }
}

/* Long-form measure */
.rd :is(.era-body > p, .step p) { max-width: var(--measure); }   /* the In brief column sets its own 640px, ~60 characters at its size */

/* Touch targets: at least 44 × 44 on coarse pointers, without changing how controls look.
   Text controls grow their own box (they have no background); pills get an invisible hit area. */
.rd { --touch: 44px; }
@media (pointer: coarse) {
  .rd :is(.stats-info, .more > summary, .skip-link) { min-height: var(--touch); }
  .rd :is(.site-nav a, .segmented button, .cs-btn, .century-btn, .coda-links a, .brand, .contents-groups a, .names-more) { position: relative; }
  /* (.century-mark is already absolutely positioned, so its hit area anchors to it as is) */
  .rd :is(.site-nav a, .segmented button, .cs-btn, .century-btn, .coda-links a, .brand, .contents-groups a, .names-more, .century-mark)::before {
    content: "";
    position: absolute;
    inset-block: min(0px, calc((100% - var(--touch)) / 2));
    inset-inline: min(0px, calc((100% - var(--touch)) / 2));
  }
}

/* Debug overlay: ?debug=space, or Alt+Shift+G, toggles it (ui.js).
   Blue outlines every box, a 4px baseline grid runs down the page, and the
   12-column grid shows the container's content edge. */
.debug-space :where(main, .site-foot) * { outline: 1px solid rgba(47, 111, 223, 0.28); outline-offset: -1px; }
.debug-space body {
  background-image: linear-gradient(to bottom, rgba(47, 111, 223, 0.1) 1px, transparent 1px);
  background-size: 100% var(--s-4);
}
.debug-space body::after {
  content: "";
  position: fixed;
  inset: 0 var(--edge);
  z-index: 999;
  pointer-events: none;
  background: repeating-linear-gradient(to right, rgba(255, 0, 80, 0.07) 0 calc((100% - 11 * var(--s-24)) / 12), transparent 0 calc((100% - 11 * var(--s-24)) / 12 + var(--s-24)));
}

/* Touch: header and footer links reach 44px */
@media (max-width: 640px) { .rd .site-nav a { min-height: 44px; } }
@media (pointer: coarse) { .rd .site-foot .foot-col a { display: inline-flex; align-items: center; min-height: 44px; } }

/* Phones: the rate figures stack, so a range never clips */
@media (max-width: 600px) {
  .rd .rate-moment { grid-template-columns: 1fr; }
  .rd .rate-moment .rm-rule { display: none; }
}
/* Footer conflict headings: the name, then the years on their own line */
.rd .site-foot .foot-h .foot-when { display: block; color: var(--text-3); font-weight: 400; }

.rd .site-nav.at-end { -webkit-mask-image: none; mask-image: none; }
@media (pointer: coarse) { .rd .site-foot .foot-base a { position: relative; } .rd .site-foot .foot-base a::before { content: ""; position: absolute; inset: calc(var(--s-12) * -1) calc(var(--s-4) * -1); } }
#main-content { scroll-margin-top: var(--rd-head); }
#main-content:focus { outline: none; }
