@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "DM Sans";
  src: url("assets/dm-sans.ttf") format("truetype");
  font-weight: 100 1000;
  font-display: swap;
}

:root {
  --display: "Oswald", "Arial Narrow", Impact, sans-serif;
  --text: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --rail: 320px;
  --r: 4px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark is the house theme. Light is a manual switch, stored in the browser. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171c;
  --rail-bg: #101318;
  --raised: #1d222a;
  --ink: #ebe8e1;
  --muted: #a4abb6;
  --line: #2c323c;
  --accent: #f4b942;
  --on-accent: #14171c;
  --accent-text: #f4b942;
  --shade: rgb(8 10 14 / 0.72);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eceff3;
  --rail-bg: #e1e6ec;
  --raised: #f8f9fb;
  --ink: #14171c;
  --muted: #4b5563;
  --line: #c4ccd6;
  --accent: #b45309;
  --on-accent: #fbfaf8;
  --accent-text: #9a4507;
  --shade: rgb(20 23 28 / 0.55);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; border-radius: var(--r); font-weight: 600;
}
.skip:focus { top: 12px; }

/* ---------- Layout shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100dvh; }

.rail {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 40px 32px 32px;
  background: var(--rail-bg);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.wordmark {
  font: 700 46px/0.95 var(--display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.rail-tag { margin-top: 10px; color: var(--muted); font-size: 15px; }

.controls { display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.field label {
  font: 500 13px/1 var(--display);
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted);
}
input[type="search"], select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--raised); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--r);
}
input::placeholder { color: var(--muted); opacity: 1; }
input[type="search"]:hover, select:hover { border-color: var(--muted); }
input[type="search"]:focus-visible, select:focus-visible { border-color: var(--accent); outline-offset: 2px; }
select { appearance: auto; cursor: pointer; }

.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 10px 14px; width: 100%;
  background: transparent; border: 1.5px solid var(--ink); border-radius: var(--r);
  font-weight: 600; cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}
.toggle:hover { background: var(--raised); }
.toggle:active { transform: translateY(1px); }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.toggle .count {
  min-width: 28px; padding: 2px 8px; text-align: center;
  font: 600 14px/1.4 var(--display); letter-spacing: 0.04em;
  border: 1.5px solid currentColor; border-radius: var(--r);
}

.rail-bottom { display: grid; gap: 14px; }
.link-btn {
  justify-self: start; padding: 6px 0; background: none; border: 0;
  color: var(--ink); font-weight: 600; text-decoration: underline;
  text-underline-offset: 4px; text-decoration-thickness: 1.5px; cursor: pointer;
}
.link-btn:hover { color: var(--accent-text); }
.note { color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 30ch; }

/* ---------- Main ---------- */
.main { padding: 56px 56px 40px; min-width: 0; }
.intro { max-width: 760px; margin-bottom: 56px; }
.intro h1 {
  font: 600 clamp(44px, 5.6vw, 76px)/1 var(--display);
  text-transform: uppercase; letter-spacing: -0.005em;
  text-wrap: balance;
}
.intro p { margin-top: 20px; max-width: 46ch; font-size: 20px; color: var(--muted); }

.status { margin-bottom: 20px; color: var(--muted); font-size: 15px; }

.grid {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 40px; row-gap: 64px; align-items: start;
}
.grid[hidden] { display: none; }
.loading { grid-column: 1 / -1; color: var(--muted); }

.card { position: relative; grid-column: span 6; display: grid; gap: 18px; }
.card.s7 { grid-column: span 7; }
.card.s5 { grid-column: span 5; }
.card.s7.drop, .card.s5.drop { margin-top: 56px; }

.media { overflow: hidden; border-radius: var(--r); background: var(--raised); aspect-ratio: 3 / 2; }
.card.s7 .media, .card.s5 .media { aspect-ratio: auto; height: 300px; }
.media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s var(--ease); }
.card:hover .media img { transform: scale(1.04); }

.kicker {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline;
  font: 500 14px/1.3 var(--display); text-transform: uppercase; letter-spacing: 0.12em;
}
.kicker .cat { color: var(--accent-text); }
.kicker .when { color: var(--muted); }
.kicker .saved-mark { color: var(--ink); border-bottom: 1.5px solid var(--accent); }

.card h3 { font: 500 30px/1.1 var(--display); letter-spacing: 0.005em; text-wrap: balance; }
.card .sum { color: var(--muted); max-width: 52ch; }
.byline { font-size: 14px; color: var(--muted); }
.byline strong { color: var(--ink); font-weight: 600; }

.open {
  all: unset; cursor: pointer; display: inline;
}
.open::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
.open:focus-visible { outline: none; }
.card:has(.open:focus-visible) .media { outline: 3px solid var(--accent); outline-offset: 4px; }
.card:has(.open:focus-visible) h3 { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 5px; }
.card:hover h3 { color: var(--accent-text); }

/* Lead story and the closing wide story share a horizontal layout */
.card.lead, .card.wide {
  grid-column: 1 / -1; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  column-gap: 40px; align-items: end;
}
.card.lead .media, .card.wide .media { aspect-ratio: auto; height: 440px; }
.card.wide .media { height: 340px; }
.card.lead .copy, .card.wide .copy { display: grid; gap: 18px; padding-bottom: 4px; }
.card.lead h3 { font-size: 52px; line-height: 1.02; }
.card.wide h3 { font-size: 40px; line-height: 1.05; }
.card.lead .sum, .card.wide .sum { font-size: 19px; }
.copy { display: grid; gap: 14px; }

/* ---------- Empty and error ---------- */
.empty {
  display: grid; justify-items: start; gap: 14px;
  padding: 48px 0; max-width: 520px;
  border-top: 2px solid var(--ink);
}
.empty[hidden] { display: none; }
.empty h3 { font: 600 36px/1.05 var(--display); text-transform: uppercase; }
.empty p { color: var(--muted); }

.btn {
  min-height: 48px; padding: 10px 20px; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  border: 1.5px solid var(--accent); border-radius: var(--r); font-weight: 700;
  transition: transform 0.15s var(--ease), filter 0.2s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }

.foot {
  margin-top: 96px; padding-top: 24px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 14px;
}
.foot p:first-child { font: 700 18px/1 var(--display); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink); }

/* ---------- Detail dialog ---------- */
dialog#detail {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0;
  width: min(820px, 100%); max-width: 100%; height: 100dvh; max-height: none;
  background: var(--bg); color: var(--ink);
  border: 0; border-left: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
}
dialog#detail:not([open]) { display: none; }
dialog#detail::backdrop { background: var(--shade); }

.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 32px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar .btn-ghost, .bar .save {
  min-height: 44px; padding: 8px 18px; cursor: pointer; border-radius: var(--r);
  font-weight: 600; background: transparent; border: 1.5px solid var(--ink);
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}
.bar .btn-ghost:hover, .bar .save:hover { background: var(--raised); }
.bar .btn-ghost:active, .bar .save:active { transform: translateY(1px); }
.bar .save[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.bar .save[aria-pressed="true"]:hover { filter: brightness(1.08); background: var(--accent); }

.article { padding: 0 32px 72px; }
.article .hero { margin: 32px 0 0; }
.article .hero img { width: 100%; height: 360px; object-fit: cover; border-radius: var(--r); }
.article figcaption { margin-top: 10px; font-size: 13px; color: var(--muted); }
.article .kicker { margin-top: 36px; }
.article h2 {
  margin-top: 14px; font: 600 clamp(38px, 5vw, 60px)/1.02 var(--display);
  text-transform: uppercase; text-wrap: balance;
}
.article .meta { margin-top: 20px; color: var(--muted); font-size: 15px; display: flex; flex-wrap: wrap; gap: 2px 20px; }
.article .meta strong { color: var(--ink); font-weight: 600; }
.article .lede { margin-top: 28px; max-width: 34em; font-size: 22px; line-height: 1.4; font-weight: 500; }
.article .body { margin-top: 32px; padding-top: 32px; border-top: 2px solid var(--ink); }
.article .body p { max-width: 36em; font-size: 19px; line-height: 1.7; }
.article .body p + p { margin-top: 1.2em; }
.article .end { margin-top: 48px; }

@media (prefers-reduced-motion: no-preference) {
  dialog#detail[open] { animation: slide-in 0.45s var(--ease); }
  dialog#detail[open]::backdrop { animation: fade-in 0.3s ease; }
  .intro-anim .card { animation: rise 0.7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
  .intro h1, .intro p { animation: rise 0.8s var(--ease) both; }
  .intro p { animation-delay: 0.1s; }
}
@keyframes slide-in { from { transform: translateX(48px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Tablet and mobile ---------- */
@media (max-width: 1100px) {
  .main { padding: 48px 32px 32px; }
  .grid { column-gap: 28px; }
  .card.lead h3 { font-size: 42px; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: static; height: auto; overflow: visible;
    display: grid; gap: 20px; padding: 20px 20px 24px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .rail-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
  .wordmark { font-size: 36px; }
  .rail-tag { margin: 0; font-size: 14px; }
  .controls { grid-template-columns: 1fr 1fr; gap: 14px; }
  .controls .field:first-child { grid-column: 1 / -1; }
  .controls .toggle { align-self: end; }
  .rail-bottom { order: 3; display: flex; align-items: center; justify-content: space-between; }
  .rail-bottom .note { display: none; }

  .main { padding: 36px 20px 28px; }
  .intro { margin-bottom: 36px; }
  .intro h1 { font-size: 44px; }
  .intro p { font-size: 18px; }

  .grid { grid-template-columns: minmax(0, 1fr); row-gap: 44px; }
  .card, .card.s7, .card.s5, .card.lead, .card.wide { grid-column: 1 / -1; }
  .card.s7.drop, .card.s5.drop { margin-top: 0; }
  .card.lead, .card.wide { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .media, .card.s7 .media, .card.s5 .media, .card.lead .media, .card.wide .media { height: auto; aspect-ratio: 3 / 2; }
  .card h3, .card.lead h3, .card.wide h3 { font-size: 30px; }
  .card.lead .sum, .card.wide .sum { font-size: 17px; }
  .foot { margin-top: 64px; flex-direction: column; }

  dialog#detail { width: 100%; border-left: 0; }
  .bar { padding: 10px 16px; }
  .article { padding: 0 20px 56px; }
  .article .hero { margin-top: 20px; }
  .article .hero img { height: 220px; }
  .article .kicker { margin-top: 28px; }
  .article .lede { font-size: 20px; }
  .article .body p { font-size: 18px; }
}
