/* Drug News Roundup — Nocturne
   Drop-in replacement for site/assets/style.css.
   No build.py or HTML changes needed: every rule targets the markup
   build.py already emits. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap");

:root {
  --bg: #161826;
  --surface: #232532;
  --text: #e9e9ed;
  --accent: #9184d9;
  --accent-200: #e7e5fe;
  --accent-300: #d2cefd;
  --accent-400: #b5abfc;
  --accent-500: #968ae0;
  --accent-800: #423a6a;
  --accent-900: #2b2741;
  --n-300: #b8b9c0;
  --n-400: #9a9ba4;
  --n-500: #7d7e88;
  --n-800: #3a3c44;
  --n-900: #292b31;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --radius: 8px;
  --rule: linear-gradient(to right, var(--n-800) 0%, rgba(41, 43, 49, 0.6) 70%, transparent 100%);
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-800); }

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

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 32px 96px; }

/* ---------- masthead ---------- */

.masthead {
  position: relative;
  margin: 0 -32px 0;
  padding: 76px 32px 48px;
  border-bottom: 1px solid var(--n-900);
  overflow: hidden;
}
.masthead::before {
  content: "";
  position: absolute;
  top: -260px; left: -120px;
  width: 720px; height: 520px;
  background: radial-gradient(closest-side, rgba(145, 132, 217, 0.2), transparent);
  pointer-events: none;
}
.masthead > * { position: relative; }

.kicker {
  margin: 0 0 22px;
  font: 500 11px/1 var(--font);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-400);
}

.masthead h1 {
  margin: 0;
  font: 300 clamp(44px, 6.4vw, 80px)/0.98 var(--font);
  letter-spacing: -0.035em;
  max-width: 16ch;
}

.dateline {
  margin: 26px 0 0;
  font: 500 15px/1 var(--font);
  color: var(--text);
}

.window {
  margin: 14px 0 0;
  font: 400 17px/1.6 var(--font);
  color: var(--n-400);
  max-width: 60ch;
  text-wrap: pretty;
}

nav.top { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 30px; }
nav.top a {
  padding: 8px 14px;
  border: 1px solid var(--n-900);
  border-radius: var(--radius);
  background: var(--surface);
  font: 400 13px/1 var(--font);
  color: var(--n-300);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
nav.top a:hover { color: var(--text); border-color: var(--n-800); }
nav.top a:active { background: var(--accent-800); }
nav.top a[aria-current] {
  background: var(--accent-900);
  border-color: var(--accent-800);
  color: var(--accent-200);
  font-weight: 500;
}

/* ---------- contents ---------- */

.toc { margin: 48px 0 0; }
.toc h2 {
  margin: 0 0 18px;
  font: 500 11px/1 var(--font);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--n-500);
}
.toc ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
  border-radius: var(--radius);
  overflow: hidden;
}
.toc li { counter-increment: toc; position: relative; }
.toc li a {
  display: grid;
  gap: 10px;
  height: 100%;
  padding: 16px;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--n-900);
  font: 400 14px/1.35 var(--font);
  color: var(--n-300);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.toc li a::before {
  content: "0" counter(toc);
  font: 500 10.5px/1 var(--font);
  letter-spacing: 0.2em;
  color: var(--accent-500);
}
.toc li.toc-tally a::before { content: "↓"; letter-spacing: 0; }
.toc li a:hover { background: var(--surface); color: var(--text); }
.toc .count {
  position: absolute;
  top: 16px;
  right: 16px;
  font: 400 11.5px/1 var(--font);
  color: var(--n-500);
}

/* ---------- sections ---------- */

.block { margin-top: 64px; }

.block > h2 {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 0 0 4px;
  font: 500 13px/1 var(--font);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text);
}
.block > h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.block > h2 .num {
  order: -1;
  font: 500 11px/1 var(--font);
  letter-spacing: 0.2em;
  color: var(--accent-500);
}
.block > h2 .num::before { content: "0"; }

/* ---------- stories ---------- */

.story {
  display: grid;
  gap: 12px;
  padding: 28px 0;
  border-top: 1px solid var(--n-900);
}
.story h3 {
  margin: 0;
  font: 400 22px/1.3 var(--font);
  letter-spacing: -0.015em;
  max-width: 34ch;
  text-wrap: pretty;
}
.story p {
  margin: 0;
  font: 400 15.5px/1.7 var(--font);
  color: var(--n-400);
  max-width: 70ch;
  text-wrap: pretty;
}

/* the lead story of the edition carries the edition */
#federal .story:first-of-type { padding: 34px 0 32px; gap: 14px; }
#federal .story:first-of-type h3 {
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  max-width: 26ch;
}
#federal .story:first-of-type p { font-size: 16px; color: var(--n-300); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 4px 9px;
  border: 1px solid var(--n-800);
  border-radius: 999px;
  font: 400 12px/1.4 var(--font);
  color: var(--n-300);
}
.chip.qty {
  border-color: transparent;
  background: var(--accent-900);
  color: var(--accent-200);
  font-weight: 500;
}

.source { display: flex; }
.source .label { display: none; }
.source a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--accent-800);
  font: 500 11px/1 var(--font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-300);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.source a::after { content: "↗"; letter-spacing: 0; }
.source a:hover { color: var(--accent-200); border-color: var(--accent-500); }
.source a:active { color: var(--accent-400); }

.empty {
  margin: 0;
  padding: 28px 0;
  border-top: 1px solid var(--n-900);
  font: 400 15px/1.7 var(--font);
  color: var(--n-500);
}

/* background/analysis items read as cards, not as breaking stories */
#ongoing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}
#ongoing > h2 { grid-column: 1 / -1; margin-bottom: 20px; }
#ongoing .story {
  padding: 18px;
  border: 1px solid var(--n-900);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  align-content: start;
  gap: 11px;
}
#ongoing .story h3 { font-size: 19px; max-width: none; }
#ongoing .story p { font-size: 14.5px; line-height: 1.65; }
#ongoing .chip { font-size: 11.5px; }

/* ---------- running tally ---------- */

.block.tally {
  margin-top: 80px;
  padding: 38px 32px 8px;
  border: 1px solid var(--n-900);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface), var(--bg) 70%);
}
.block.tally > h2 {
  display: block;
  margin: 0 0 14px;
  font: 500 11px/1 var(--font);
  letter-spacing: 0.2em;
  color: var(--accent-400);
}
.block.tally > h2::after { display: none; }

.tally-note {
  margin: 0;
  font: 400 15px/1.7 var(--font);
  color: var(--n-400);
  max-width: 56ch;
  text-wrap: pretty;
}

.tally-headline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 18px;
  margin: 4px 0 34px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--n-900);
}
.tally-headline .big {
  font: 300 clamp(52px, 7vw, 84px)/0.9 var(--font);
  letter-spacing: -0.04em;
}
.tally-headline .meta {
  font: 400 13px/1.5 var(--font);
  color: var(--n-500);
}

.block.tally h3 {
  margin: 0 0 14px;
  font: 500 12px/1 var(--font);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--n-400);
}
.block.tally .scroll-x + h3 { margin-top: 40px; }

.scroll-x { overflow-x: auto; margin-bottom: 8px; }

.tally-table { width: 100%; border-collapse: collapse; }
.tally-table th,
.tally-table td {
  padding: 13px 0;
  border-bottom: 1px solid var(--n-900);
  text-align: left;
  vertical-align: baseline;
}
.tally-table tr:last-child th,
.tally-table tr:last-child td { border-bottom: 0; }
.tally-table th[scope="row"] {
  font: 500 15px/1.3 var(--font);
  color: var(--text);
  white-space: nowrap;
  padding-right: 24px;
}
.tally-table .brk {
  font: 400 12.5px/1.5 var(--font);
  color: var(--n-500);
  padding-right: 24px;
}
.tally-table .amt {
  font: 500 15px/1.3 var(--font);
  color: var(--accent-200);
  text-align: right;
  white-space: nowrap;
}

/* ---------- story photographs ---------- */

/* Only stories carrying a public-domain photo get this treatment; every
   other story keeps the plain full-width layout above, so a sparse
   edition still reads as deliberate. */

.story.has-shot {
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 12px 30px;
  align-items: start;
}
.story.has-shot .story-text { display: grid; gap: 12px; min-width: 0; }

figure.shot { margin: 0; display: grid; gap: 8px; }

figure.shot img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--n-900);
  border-radius: var(--radius);
  background: var(--surface);
}

figure.shot figcaption {
  font: 400 11px/1.45 var(--font);
  letter-spacing: 0.04em;
  color: var(--n-500);
  text-wrap: pretty;
}

/* the lead story earns a larger photo */
#federal .story.has-shot:first-of-type { grid-template-columns: minmax(0, 1fr) 300px; }

/* inside the ongoing cards the column is already narrow — stack instead */
#ongoing .story.has-shot { grid-template-columns: 1fr; gap: 11px; }
#ongoing figure.shot { order: -1; }

@media (max-width: 780px) {
  .story.has-shot,
  #federal .story.has-shot:first-of-type { grid-template-columns: 1fr; gap: 12px; }
  figure.shot { order: -1; }
  figure.shot img { aspect-ratio: 16 / 9; }
}

/* ---------- previous years ---------- */

.prior-years { margin-top: 44px; padding-bottom: 24px; }
.prior-years > h3 { margin-bottom: 10px; }

details.year {
  border-top: 1px solid var(--n-900);
}
details.year:last-of-type { border-bottom: 1px solid var(--n-900); }

details.year > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  padding: 15px 0;
  list-style: none;
  cursor: pointer;
  transition: color 0.15s;
}
details.year > summary::-webkit-details-marker { display: none; }
details.year > summary::before {
  content: "＋";
  order: 3;
  margin-left: auto;
  font: 400 13px/1 var(--font);
  color: var(--n-500);
}
details.year[open] > summary::before { content: "－"; }
details.year > summary:hover .y { color: var(--accent-200); }

details.year .y {
  font: 500 15px/1.3 var(--font);
  color: var(--text);
  min-width: 4ch;
}
details.year .t {
  font: 500 15px/1.3 var(--font);
  color: var(--accent-200);
  white-space: nowrap;
}
details.year .m { font: 400 12.5px/1.4 var(--font); color: var(--n-500); }

.year-body {
  margin: 0 0 6px 2px;
  padding: 4px 0 18px 18px;
  border-left: 1px solid var(--n-900);
}
.year-body h3 { margin-top: 22px; }
.year-body h3:first-child { margin-top: 0; }

.all-time {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--n-800);
}
.all-time .label {
  font: 500 12px/1 var(--font);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--n-400);
}
.all-time .v {
  font: 500 20px/1.2 var(--font);
  letter-spacing: -0.02em;
  color: var(--accent-200);
  white-space: nowrap;
}

/* ---------- archive index ---------- */

ul.archive {
  display: grid;
  gap: 1px;
  margin: 48px 0 0;
  padding: 0;
  list-style: none;
  border-radius: var(--radius);
  overflow: hidden;
}
ul.archive a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--n-900);
  text-decoration: none;
  transition: background 0.15s;
}
ul.archive a:hover { background: var(--surface); }
ul.archive .d { font: 400 17px/1.3 var(--font); color: var(--text); }
ul.archive .n { font: 400 12.5px/1 var(--font); color: var(--n-500); }

/* ---------- footer ---------- */

footer {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--n-900);
  display: grid;
  gap: 10px;
  max-width: 74ch;
}
footer p {
  margin: 0;
  font: 400 13.5px/1.7 var(--font);
  color: var(--n-500);
}

/* ---------- links, generally ---------- */

a { color: var(--accent-300); }
a:hover { color: var(--accent-200); }

/* ---------- narrow screens ---------- */

@media (max-width: 640px) {
  .wrap { padding: 0 20px 64px; }
  .masthead { margin: 0 -20px; padding: 52px 20px 36px; }
  .block.tally { padding: 28px 20px 8px; }
  .tally-table .brk { display: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .masthead::before, nav.top, .toc { display: none; }
}

/* ---------- tally: expandable place rows ---------- */
/* Replaces the old three-column .tally-table, whose breakdown column was
   hidden below 640px. Each place is a <details>: total always visible,
   per-drug detail one tap away. No JavaScript. */

.places { border-top: 1px solid var(--n-900); }

details.place { border-bottom: 1px solid var(--n-900); }

details.place > summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 4px 14px;
  padding: 13px 0;
  list-style: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
details.place > summary::-webkit-details-marker { display: none; }

details.place .p {
  font: 500 15px/1.3 var(--font);
  color: var(--text);
  min-width: 0;
}
details.place .n {
  font: 400 12px/1.3 var(--font);
  color: var(--n-500);
  white-space: nowrap;
}
details.place .t {
  font: 500 15px/1.3 var(--font);
  color: var(--accent-200);
  white-space: nowrap;
  text-align: right;
  border-bottom: 1px dotted var(--accent-800);
  padding-bottom: 1px;
}

details.place > summary:hover .p,
details.place > summary:hover .t { color: var(--accent-200); }
details.place > summary:hover .t { border-bottom-color: var(--accent-500); }
details.place[open] > summary .t { border-bottom-color: transparent; }

details.place > summary::after {
  content: "＋";
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  font: 400 11px/1 var(--font);
  color: var(--n-500);
}
details.place[open] > summary::after { content: "－"; }

ul.drugs {
  margin: 0 0 14px;
  padding: 2px 0 0 14px;
  list-style: none;
  border-left: 1px solid var(--n-900);
  display: grid;
  gap: 7px;
}
ul.drugs li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
}
ul.drugs .d { font: 400 13.5px/1.4 var(--font); color: var(--n-300); }
ul.drugs .w {
  font: 400 13.5px/1.4 var(--font);
  color: var(--n-400);
  white-space: nowrap;
}

/* wider screens: the substance count and the +/- fit on one line */
@media (min-width: 560px) {
  details.place > summary { grid-template-columns: 1fr auto auto auto; gap: 14px; }
  details.place > summary::after { grid-column: 4; grid-row: 1; }
}
