/*
 * advocacy.html — the essay with figures.
 *
 * Builds on site.css: same tokens, same plates and rules, same Barlow
 * figures. Everything here is layout for the four figure blocks (the strip,
 * the closures timeline, the bar ledgers, the six cards) and the resting and
 * arrived states of each. The script toggles `.is-in`; the motion is CSS.
 *
 * Motion rules: transforms and opacity only, so nothing here forces layout
 * while it runs; every transition is behind prefers-reduced-motion, where the
 * arrived state is simply the resting state.
 */

/* ── Page head ─────────────────────────────────────────────────────────── */

.essay-head { padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(1.75rem, 3vw, 2.5rem); border-bottom: 2px solid var(--ink); }
.essay-head h1 {
  font-size: clamp(2.5rem, 6.2vw, 4.75rem);
  line-height: 0.98;
  max-width: 24ch;
  margin: 0.9rem 0 1rem;
  letter-spacing: -0.01em;
}
.essay-head h1 em { font-style: normal; color: var(--accent); }
.essay-head .lede { font-size: clamp(1.0625rem, 1.5vw, 1.25rem); color: var(--ink-2); max-width: var(--measure); }
.essay-head .lede b { color: var(--ink); font-weight: 600; }

/* The essay body uses the section grid from site.css; the prose column is measured. */
.essay-prose { max-width: var(--measure); }
.essay-prose p { color: var(--ink-2); font-size: 1.0625rem; margin-bottom: 1rem; }
.essay-prose p b { color: var(--ink); font-weight: 600; }
.essay-prose p:last-child { margin-bottom: 0; }

/* A citation at the end of a figure: mono, small, linked. */
.src { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); line-height: 1.5; }
.src a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.src a:hover { text-decoration-color: currentColor; }

/* ── 01 The figure strip ───────────────────────────────────────────────── */

.figstrip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 2rem;
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  border-top: 2px solid var(--ink);
}
@media (min-width: 820px) { .figstrip { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.figstrip .figure { padding-left: 1rem; border-left: 4px solid var(--ink); min-width: 0; }
.figstrip .figure .v { font-size: clamp(2.4rem, 4.2vw, 3.6rem); }
.figstrip .figure .k { font-family: var(--display); font-weight: 600; font-size: 0.9375rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.figstrip .figure .c { font-size: 0.875rem; color: var(--ink-2); line-height: 1.45; }
.figstrip .figure .c b { color: var(--ink); font-weight: 600; }

/* Arrival: each figure rises in as it is counted. */
[data-reveal] > [data-row] { opacity: 0; transform: translateY(0.5rem); transition: opacity 420ms cubic-bezier(0.2, 0.7, 0.2, 1), transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: calc(var(--i, 0) * 40ms); }
[data-reveal].is-in > [data-row] { opacity: 1; transform: none; }

/* ── 01 The closures timeline ──────────────────────────────────────────── */

.timeline {
  --from: 1938;
  --to: 1968;
  --rail: 3px;
  position: relative;
  margin: 3rem 0 0.5rem;
  list-style: none;
  padding: 0;
}
/* Desktop: a horizontal rail across the column, years below, cities above
   and below alternately. Each stop is positioned by --x (0..1) along it. */
@media (min-width: 820px) {
  .timeline { height: 15rem; }
  .timeline::before {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 50%;
    height: var(--rail);
    background: var(--ink);
    transform: translateY(-50%);
  }
  .timeline li {
    position: absolute;
    left: calc(var(--x) * 100%);
    top: 50%;
    width: 0;
  }
  .timeline li .dot {
    position: absolute;
    left: 0;
    top: 0;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--ink);
    transform: translate(-50%, -50%) scale(0.6);
    transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1), background-color 260ms ease, border-color 260ms ease;
  }
  .timeline li .lbl {
    position: absolute;
    left: 0;
    white-space: nowrap;
    font-family: var(--display);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--ink-3);
    line-height: 1.05;
    transform: translateX(-50%);
    text-align: center;
    opacity: 0.55;
    transition: opacity 260ms ease, color 260ms ease;
  }
  .timeline li .lbl .yr { display: block; font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); margin-top: 0.15rem; }
  /* Odd stops hang below the rail, even stops stand above it. */
  .timeline li:nth-child(odd) .lbl { top: 1.1rem; }
  .timeline li:nth-child(even) .lbl { bottom: 1.1rem; }
  .timeline li:nth-child(even) .lbl .yr { margin: 0 0 0.15rem; }
  /* Stops that share a year nudge apart so the labels do not collide. */
  .timeline li[data-shift="1"] .lbl { transform: translateX(-50%) translateY(2.3rem); }
  .timeline li[data-shift="2"] .lbl { transform: translateX(-50%) translateY(4.6rem); }
  .timeline li:nth-child(even)[data-shift="1"] .lbl { transform: translateX(-50%) translateY(-2.3rem); }
  .timeline li:nth-child(even)[data-shift="2"] .lbl { transform: translateX(-50%) translateY(-4.6rem); }
}
/* Narrow: a vertical rail down the left, one stop per row. */
@media (max-width: 819.98px) {
  .timeline { padding-left: 1.6rem; }
  .timeline::before {
    content: "";
    position: absolute;
    left: 0.45rem;
    top: 0.3rem;
    bottom: 0.3rem;
    width: var(--rail);
    background: var(--ink);
  }
  .timeline li { position: relative; padding: 0.3rem 0; }
  .timeline li .dot {
    position: absolute;
    left: -1.6rem;
    top: 0.65rem;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--ink);
    transform: translateX(0.12rem) scale(0.6);
    transition: transform 260ms cubic-bezier(0.2, 0.7, 0.2, 1), background-color 260ms ease, border-color 260ms ease;
  }
  .timeline li .lbl { font-family: var(--display); font-size: 1.05rem; font-weight: 500; color: var(--ink-3); opacity: 0.55; transition: opacity 260ms ease, color 260ms ease; }
  .timeline li .lbl .yr { font-family: var(--mono); font-size: 0.8rem; margin-right: 0.6rem; color: var(--ink-3); }
}
/* The line has closed here: the stop fills with the line's own red and the name comes up to ink. */
.timeline li.is-lit .dot { background: var(--line-red-lit); border-color: var(--line-red-lit); transform: translate(-50%, -50%) scale(1); }
@media (max-width: 819.98px) { .timeline li.is-lit .dot { transform: translateX(0.12rem) scale(1); } }
.timeline li.is-lit .lbl { opacity: 1; color: var(--ink); }

/* The last car. A pale body with the red rim, as the hero draws its trains,
   running the rail from 1940 to 1966 once as the section arrives. */
.timeline li.timeline__car {
  position: absolute;
  width: 1.9rem;
  height: 0.8rem;
  padding: 0;
  border-radius: 0.4rem;
  background: #FFFFFF;
  border: 2px solid var(--line-red-lit);
  box-shadow: 0 0 0 1.5px #12161B;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}
.timeline.is-in li.timeline__car { opacity: 1; }
@media (max-width: 819.98px) { .timeline li.timeline__car { display: none; } }

/* ── 02 The ledgers with bars ──────────────────────────────────────────── */

.ledgers { display: grid; gap: 2.5rem 3rem; margin-top: 1rem; }
@media (min-width: 900px) { .ledgers { grid-template-columns: 1fr 1fr; } }
.lbars { min-width: 0; }
.lbars h3 { font-size: 1.5rem; margin: 0 0 0.25rem; }
.lbars .unit { font-size: 0.875rem; color: var(--ink-3); margin: 0 0 0.75rem; }
.lbars ol { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); }
.brow {
  display: grid;
  grid-template-columns: minmax(7.5rem, 11rem) 1fr auto;
  align-items: center;
  gap: 0 0.9rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.brow .nm { font-size: 0.9375rem; color: var(--ink-2); line-height: 1.2; }
.brow .nm small { display: block; font-family: var(--mono); font-size: 0.7rem; color: var(--ink-3); }
.brow .val { font-family: var(--display); font-weight: 600; font-size: 1.25rem; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 3.5ch; text-align: end; }
.brow .val small { font-size: 0.65em; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
/* The bar: ink, a hairline tall, grows from the left when the ledger arrives. */
.bar { height: 0.8rem; background: var(--ink); transform-origin: left center; transform: scaleX(var(--v, 0)); transition: transform 700ms cubic-bezier(0.2, 0.7, 0.2, 1); transition-delay: calc(var(--i, 0) * 40ms); }
.lbars:not(.is-in) .bar { transform: scaleX(0); }
/* American rows carry the one accent so the comparison reads at a glance. */
.brow--us .bar { background: var(--accent); }
.brow--us .nm { color: var(--ink); font-weight: 500; }
.brow--us .val { color: var(--accent); }
.lbars .src { margin-top: 0.6rem; }
.lbars .note { font-size: 0.875rem; color: var(--ink-2); margin: 0.6rem 0 0; }

/* ── 03 Six figure cards ───────────────────────────────────────────────── */

.figs {
  display: grid;
  gap: 0 2.5rem;
  margin-top: 1rem;
}
@media (min-width: 680px) { .figs { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .figs { grid-template-columns: 1fr 1fr 1fr; } }
.fig {
  position: relative;
  padding: 1.5rem 0 1.5rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  min-width: 0;
}
.fig::before { content: ""; position: absolute; inset-block: 1.65rem; inset-inline-start: 0; inline-size: 4px; background: var(--ink); }
.fig .v { font-family: var(--display); font-weight: 600; font-size: clamp(2.6rem, 4vw, 3.4rem); line-height: 0.95; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.fig .v .unit { font-size: 0.45em; font-weight: 500; color: var(--ink-2); margin-left: 0.15em; letter-spacing: 0; }
.fig h3 { font-size: 1.35rem; margin: 0.5rem 0 0.4rem; }
.fig p { font-size: 0.9375rem; color: var(--ink-2); margin: 0 0 0.6rem; }
.fig p b { color: var(--ink); font-weight: 600; }
.fig .src { padding-top: 0.5rem; border-top: 1px solid var(--rule); }

/* ── 04 What you can do ────────────────────────────────────────────────── */

.steps4 { display: grid; gap: 1.25rem 2rem; margin-top: 1rem; }
@media (min-width: 760px) { .steps4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .steps4 { grid-template-columns: repeat(4, 1fr); } }
.step { padding-top: 0.9rem; border-top: 2px solid var(--ink); }
.step .plate { margin-bottom: 0.75rem; }
.step h3 { font-size: 1.5rem; margin: 0 0 0.4rem; }
.step p { font-size: 0.9375rem; color: var(--ink-2); margin: 0; }
.step p b { color: var(--ink); font-weight: 600; }

.orgs { list-style: none; margin: 2.5rem 0 0; padding: 0; border-top: 2px solid var(--ink); }
.orgs li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.1rem 1.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
@media (min-width: 680px) { .orgs li { grid-template-columns: minmax(14rem, 18rem) 1fr auto; } }
.orgs .nm { font-family: var(--display); font-weight: 600; font-size: 1.15rem; color: var(--ink); }
.orgs .nm a { color: inherit; text-decoration: none; }
.orgs .nm a:hover { color: var(--accent); }
.orgs .sc { font-size: 0.9375rem; color: var(--ink-2); }
.orgs .url { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); }
.orgs .url a { color: var(--accent); text-decoration: none; }
.orgs .url a:hover { text-decoration: underline; }

/* ── The closing plate ─────────────────────────────────────────────────── */

.plate-close {
  margin: 0;
  padding: clamp(2rem, 5vw, 3.5rem) 0;
  background: var(--ink);
  color: var(--ground);
  border-left: 10px solid var(--plate-accent);
}
.plate-close .wrap { display: grid; gap: 1.25rem; align-items: center; }
@media (min-width: 900px) { .plate-close .wrap { grid-template-columns: auto 1fr auto; gap: 2.5rem; } }
.plate-close .ten { font-family: var(--display); font-weight: 700; font-size: clamp(4rem, 9vw, 7rem); line-height: 0.85; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.plate-close p { font-family: var(--display); font-weight: 500; font-size: clamp(1.35rem, 2.4vw, 1.9rem); line-height: 1.15; margin: 0; max-width: 30ch; }
.plate-close p b { font-weight: 700; }
.plate-close .btn { background: var(--ground); color: var(--ink); border-color: var(--ground); }
.plate-close .btn:hover { background: var(--plate-accent); border-color: var(--plate-accent); color: #07121C; }
/* A plate wipe as it arrives: the ink slides in from the left over its own ground. */
.plate-close { clip-path: inset(0 100% 0 0); transition: clip-path 640ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.plate-close.is-in { clip-path: inset(0 0 0 0); }

/* ── Sources ───────────────────────────────────────────────────────────── */

.sources ol { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-2); line-height: 1.55; padding-left: 1.5rem; margin: 0; max-width: 80ch; }
.sources li { margin-bottom: 0.45rem; }
.sources a { color: var(--accent); }
.sources p { font-size: 0.875rem; color: var(--ink-3); margin: 1rem 0 0; }

/* ── Motion refused ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  [data-reveal] > [data-row], .bar, .timeline li .dot, .timeline li .lbl, .plate-close { transition: none; }
  [data-reveal] > [data-row] { opacity: 1; transform: none; }
  .lbars:not(.is-in) .bar { transform: scaleX(var(--v, 0)); }
  .plate-close { clip-path: none; }
  .timeline__car { display: none; }
  /* Every closure shown at once; the still frame carries the same information. */
  .timeline li .dot { background: var(--line-red-lit); border-color: var(--line-red-lit); }
  .timeline li .lbl { opacity: 1; color: var(--ink); }
}
/* And without JavaScript at all, the same still frame. */
.no-js [data-reveal] > [data-row] { opacity: 1; transform: none; }
.no-js .lbars:not(.is-in) .bar { transform: scaleX(var(--v, 0)); }
.no-js .plate-close { clip-path: none; }
.no-js .timeline li .dot { background: var(--line-red-lit); border-color: var(--line-red-lit); }
.no-js .timeline li .lbl { opacity: 1; color: var(--ink); }
