/* The public front page: the "Source ledger" design (ADR 0004). */

/* Dark is the design's own palette and the default. The system preference
   applies when the reader has not chosen; data-theme (set from the header
   toggle, remembered in localStorage) beats both. The two light blocks below
   are identical on purpose and must be kept in step. */
:root {
  --bg: #111315;
  --surface: #181b1e;
  --rule: #2a2e31;
  --rule-strong: #3a3f42;
  --rule-row: #24282b;
  --chip: #33383b;
  --text: #ebe8e2;
  --body: #d9d7d1;
  --lede: #c3c1bb;
  --quiet: #a9aba7;
  --muted: #8e928f;
  --accent: #e9b44c;
  --dot-off: #2c3134;
  --row-hover: #16191b;
  /* The toggle offers the theme you are not in. */
  --sun: inline-flex;
  --moon: none;
  --gutter: clamp(20px, 6.667vw, 96px);
  --mono: "IBM Plex Mono", Menlo, Consolas, monospace;
  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5f1;
    --surface: #ffffff;
    --rule: #e2e0d9;
    --rule-strong: #c7c4ba;
    --rule-row: #eceae3;
    --chip: #d7d3c9;
    --text: #1b1a17;
    --body: #2e2d29;
    --lede: #3b3a35;
    --quiet: #5c5a53;
    --muted: #6b6960;
    --accent: #96690a;
    --dot-off: #ded9cd;
    --row-hover: #f0eee7;
    --sun: none;
    --moon: inline-flex;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --rule: #e2e0d9;
  --rule-strong: #c7c4ba;
  --rule-row: #eceae3;
  --chip: #d7d3c9;
  --text: #1b1a17;
  --body: #2e2d29;
  --lede: #3b3a35;
  --quiet: #5c5a53;
  --muted: #6b6960;
  --accent: #96690a;
  --dot-off: #ded9cd;
  --row-hover: #f0eee7;
  --sun: none;
  --moon: inline-flex;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; text-wrap: pretty; }
ul, ol { list-style: none; margin: 0; padding: 0; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Masthead */

.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 22px var(--gutter);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
}
.wordmark { justify-self: start; font-weight: 600; letter-spacing: 0.14em; }
.sections { display: flex; gap: 28px; }
.sections a { color: var(--muted); }
.sections a:hover, .sections a[aria-current="page"] { color: var(--accent); }
.masthead-end { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 14px; }
.dateline { color: var(--muted); }

.theme-toggle {
  display: none; /* the toggle only does anything with scripting */
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.has-js .theme-toggle { display: inline-flex; }
.theme-toggle:hover { color: var(--text); border-color: var(--rule-strong); }
.theme-toggle .icon-sun { display: var(--sun); }
.theme-toggle .icon-moon { display: var(--moon); }

/* Hero */

.hero { display: flex; flex-direction: column; gap: 28px; padding: 72px var(--gutter) 56px; }
.kicker {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.hero h1 {
  max-width: 1180px;
  font-size: clamp(36px, 4.72vw, 68px);
  font-weight: 700;
  line-height: 1.03;
  letter-spacing: -0.025em;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 48px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
}
.stats strong { font-weight: 600; color: var(--text); }
.stats a { color: var(--accent); }

/* Lead story */

.lead {
  display: flex;
  gap: 56px;
  margin: 0 var(--gutter);
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--rule);
}
.lead-story { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.lead-story h2 {
  font-size: clamp(28px, 3.47vw, 50px);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.02em;
}
.lede { font-size: 19px; line-height: 1.55; color: var(--lede); }

.meta { font-family: var(--mono); font-size: 13px; letter-spacing: 0.1em; color: var(--muted); }
.rank { font-weight: 600; color: var(--accent); }

.reported-by { flex: 0 0 420px; display: flex; flex-direction: column; gap: 16px; }
.reported-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.reported-head strong { font-size: 28px; font-weight: 600; color: var(--accent); }

.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--chip);
  font-family: var(--mono);
  font-size: 13px;
}
a.chip:hover { border-color: var(--accent); color: var(--text); }
.chip svg { flex-shrink: 0; stroke: var(--muted); }
.note { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* Ledger */

.ledger { padding: 48px var(--gutter) 0; }
.ledger-head, .row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 150px 300px;
  gap: 24px;
}
.ledger-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule-strong);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.row {
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule-row);
  transition: background-color 120ms ease;
}
.row:hover { background: var(--row-hover); }
.row .rank { font-family: var(--mono); font-size: 15px; }
.row .story { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row h3 { font-size: 22px; font-weight: 500; line-height: 1.25; }
.outlet-names { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.section { font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; color: var(--muted); }
.dots { display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 14px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot-off); }
.dot.on { background: var(--accent); }
.dots b { margin-left: 10px; font-weight: 400; }

/* Story page */

.story-page { padding: 40px var(--gutter) 0; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.story-grid { display: flex; align-items: flex-start; gap: 56px; margin-top: 40px; }
.story-body { flex: 1 1 0; min-width: 0; max-width: 760px; display: flex; flex-direction: column; gap: 20px; }
.story-body h1 {
  font-size: clamp(32px, 3.6vw, 52px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.body p { margin: 0 0 1.1em; font-size: 19px; line-height: 1.65; color: var(--body); }
.provenance {
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.story-grid .reported-by { padding: 28px; background: var(--surface); border: 1px solid var(--rule); }
.source-list { display: flex; flex-direction: column; gap: 18px; }
.source-list .outlet {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.source-list ul { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.source-list li li { font-size: 15px; line-height: 1.4; }
.time { display: block; margin-top: 2px; font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* Footer */

.method {
  display: flex;
  gap: 56px;
  margin: 56px var(--gutter) 0;
  padding: 28px 0 72px;
  border-top: 1px solid var(--rule-strong);
}
.method .label {
  flex: 0 0 220px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--accent);
}
.method p { max-width: 820px; font-size: 16px; line-height: 1.6; color: var(--quiet); }

/* Phone: the ledger's columns collapse into stacked rows. */

@media (max-width: 860px) {
  .masthead { grid-template-columns: 1fr auto; row-gap: 12px; padding: 14px 0 0; font-size: 12px; }
  .wordmark { padding-left: 20px; }
  .masthead-end { grid-column: 2; grid-row: 1; gap: 6px; padding-right: 12px; }
  .theme-toggle { width: 44px; height: 44px; }
  .sections {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 22px;
    height: 44px;
    align-items: center;
    padding: 0 20px;
    overflow-x: auto;
    white-space: nowrap;
    border-top: 1px solid var(--rule);
  }

  .hero { gap: 18px; padding: 40px 20px 32px; }
  .stats { gap: 8px 20px; font-size: 13px; }

  .lead { flex-direction: column; gap: 16px; margin: 0; padding: 24px 20px; border-left: 0; border-right: 0; }
  .lede { font-size: 16px; }
  .reported-by { flex-basis: auto; }
  .chip { min-height: 44px; }

  .ledger { padding: 8px 20px 0; }
  .ledger-head { display: none; }
  .row {
    grid-template-columns: auto auto minmax(0, 1fr);
    grid-template-areas: "rank section dots" "story story story";
    gap: 8px 6px;
    padding: 18px 0;
  }
  .row .rank { grid-area: rank; font-size: 12px; }
  .row .section { grid-area: section; }
  .row .section::before { content: "· "; }
  .row .dots { grid-area: dots; justify-self: end; gap: 4px; font-size: 12px; }
  .row .dot { width: 8px; height: 8px; }
  .row .dots b { margin-left: 6px; }
  .row .story { grid-area: story; gap: 8px; }
  .row h3 { font-size: 19px; line-height: 1.3; }

  .story-page { padding: 24px 20px 0; }
  .story-grid { flex-direction: column; gap: 32px; margin-top: 24px; }
  .story-grid .reported-by { width: 100%; padding: 20px; }
  .body p { font-size: 17px; }

  .method { flex-direction: column; gap: 12px; margin: 40px 20px 0; padding: 24px 0 56px; }
  .method .label { flex-basis: auto; }
  .method p { font-size: 15px; }
}
