:root {
  --paper: #f5ead3;
  --paper-2: #fdf6e6;
  --ink: #2a1d16;
  --muted: #6f5a4a;
  --tomato: #d4472a; /* accent: rank numbers only */
  --mustard: #e8b23c;
  --highlight: rgba(232, 178, 60, .45);
  --line: rgba(42, 29, 22, .18);
  --grain-opacity: .35;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body-ink: var(--ink);       /* long-form text colour */
  --smoothing: antialiased;     /* fine for dark text on light paper */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1e1712;
    --paper-2: #2a2019;
    --ink: #f3e6cc;
    --muted: #bca78f;
    --tomato: #ff7b57;
    --mustard: #f0c65e;
    --highlight: rgba(240, 198, 94, .28);
    --line: rgba(243, 230, 204, .18);
    --grain-opacity: .12;
    --body-ink: #e9dfcf;        /* a touch softer than headline cream */
    --smoothing: auto;          /* antialiased thins light-on-dark text */
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #1e1712;
  --paper-2: #2a2019;
  --ink: #f3e6cc;
  --muted: #bca78f;
  --tomato: #ff7b57;
  --mustard: #f0c65e;
  --highlight: rgba(240, 198, 94, .28);
  --line: rgba(243, 230, 204, .18);
  --grain-opacity: .12;
  --body-ink: #e9dfcf;
  --smoothing: auto;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 18px/1.6 var(--display);
  /* SOFT 0 keeps body text crisp; headings set their own softer values. */
  font-variation-settings: "SOFT" 0, "WONK" 0;
  -webkit-font-smoothing: var(--smoothing);
  position: relative;
  overflow-x: clip;
}
/* Paper grain. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { mix-blend-mode: screen; } }
:root[data-theme="dark"] body::before { mix-blend-mode: screen; }
.masthead, main, .footer { position: relative; z-index: 1; }

a { color: var(--ink); text-decoration-color: var(--muted); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* ---------- Masthead ---------- */
.masthead { padding: 48px 0 20px; text-align: center; }
.masthead .wrap { position: relative; }

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
  /* 15% larger than the previous clamp(26px, 7vw, 52px). "What's Happening"
     fits on one line at these sizes from 320px phones up. */
  font-size: clamp(30px, 8.05vw, 60px);
  line-height: 1;
  letter-spacing: -.025em;
  white-space: nowrap;
}
.tagline {
  margin: 12px 0 6px;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--muted);
}
.dateline {
  margin: 0;
  font: 400 .9rem/1.4 var(--sans);
  color: var(--muted);
}
.dateline time { white-space: nowrap; }

.status {
  margin: 56px 0;
  text-align: center;
  font-style: italic;
  color: var(--muted);
}

/* ---------- Articles ---------- */
.articles { list-style: none; margin: 16px 0 0; padding: 0; }

/* Quiet divider used under the masthead and between articles: a short,
   faint squiggle, centred. Uses --muted so it follows light/dark mode. */
.articles::before,
.divider {
  content: "";
  display: block;
  width: 96px;
  height: 12px;
  margin: 28px auto 8px;
  background: var(--muted);
  opacity: .45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='12'%3E%3Cpath d='M0 6 Q5 3 10 6 T20 6' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x center / 20px 12px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='12'%3E%3Cpath d='M0 6 Q5 3 10 6 T20 6' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x center / 20px 12px;
}
.article { padding: 36px 0 0; min-width: 0; /* let carousels scroll instead of widening the page */ }

.divider { margin: 48px auto 0; }
.article:last-child .divider { display: none; }

.head {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 0 18px;
  align-items: start;
}

/* Plain coral numeral, vertically centred on the title's first line: it gets
   the same top offset and line height as the title, so both share a line box. */
.article { --title-size: 38px; }
.rank { padding-top: 2px; text-align: right; }
.rank-num {
  display: block;
  font: 600 1.95rem/calc(var(--title-size) * 1.05) var(--display);
  font-variant-numeric: lining-nums;
  color: var(--tomato);
}

.head-text { min-width: 0; padding-top: 2px; }
h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 800;
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 72;
  font-size: var(--title-size);
  line-height: 1.05;
  letter-spacing: -.015em;
}
h2 a { color: inherit; text-decoration: none; }
h2 a:hover { text-decoration: underline; text-decoration-thickness: 2px; }

.description { margin: 0 0 8px; color: var(--muted); }
.wiki-link {
  font: 600 14px/1.2 var(--sans);
  color: var(--ink);
  text-decoration: none;
}
.wiki-link:hover { text-decoration: underline; }

.thumb-wrap {
  width: 132px;
  height: 132px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.thumb-wrap.empty { display: none; }
.thumb { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb[hidden] { display: none; }

/* Everything below the headline lines up with the title. */
.why, .block { margin-left: 58px; }

h3 {
  margin: 0;
  font: 600 12px/1.2 var(--sans);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.why { margin-top: 26px; }
.why h3 { margin-bottom: 8px; color: var(--muted); }
.why p {
  margin: 0;
  max-width: 65ch;              /* about 65-75 characters per line */
  font-size: 19px;
  line-height: 1.65;
  color: var(--body-ink);
}

/* ---------- Carousels ---------- */
.block { margin-top: 30px; min-width: 0; }
.carousel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.block h3 {
  font: 800 24px/1.2 var(--display);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  letter-spacing: 0;
  text-transform: none;
  background: linear-gradient(transparent 55%, var(--highlight) 55%, var(--highlight) 92%, transparent 92%);
  padding: 0 4px;
  margin-left: -4px;
}

.carousel-nav { display: flex; gap: 8px; }
.carousel-nav[hidden] { display: none; }
.nav {
  position: relative;
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font: 500 18px/1 var(--sans);
  cursor: pointer;
}
.nav:hover:not(:disabled) { background: var(--paper-2); }
.nav:disabled { opacity: .3; cursor: default; }

.carousel {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  /* Room for the hover lift so cards aren't clipped. */
  margin: 0 -8px;
  padding: 14px 8px 16px;
  scroll-padding: 0 8px;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel:focus-visible { outline: 2px dashed var(--muted); outline-offset: 2px; }
.track { display: flex; gap: 16px; width: max-content; }

/* News tiles: index cards. */
.news { list-style: none; margin: 0; padding: 0; align-items: stretch; }
.news li { scroll-snap-align: start; flex: none; width: 250px; }
.news a.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  min-height: 160px;
  padding: 14px 16px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
.news a.card:hover { border-color: var(--muted); transform: translateY(-2px); }
.news .source {
  font: 600 12px/1.2 var(--sans);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.news .headline { font-size: 18px; font-weight: 600; line-height: 1.3; }
.news .date { margin-top: auto; padding-top: 6px; font: 400 13px/1.2 var(--sans); color: var(--muted); }

/* Discourse: embedded X posts. */
.discourse-block .track { align-items: flex-start; }
.slide { scroll-snap-align: start; width: 340px; flex: none; }
.slide iframe { max-width: 100% !important; border-radius: 12px; }
.slide .twitter-tweet-rendered { margin: 0 !important; }

/* Placeholder shown until (or if) the platform's embed script loads. */
.post {
  margin: 0;
  padding: 16px 18px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--sans);
}
.post .who { display: flex; align-items: baseline; gap: 8px; font-size: 14px; color: var(--muted); }
.badge {
  font: 600 11px/1 var(--sans);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--highlight);
  color: var(--ink);
}
.post .who strong { color: var(--ink); font-weight: 600; }
.post p { margin: 0; font: 500 16px/1.4 var(--display); }
.post .open { margin-top: auto; font: 600 13px/1 var(--sans); color: var(--ink); text-decoration: none; }
.post .open:hover { text-decoration: underline; }

.browse { margin: 6px 0 0; font: 400 14px/1.4 var(--sans); color: var(--muted); }
.empty { color: var(--muted); }

/* ---------- Footer ---------- */
.footer {
  margin-top: 56px;
  padding-top: 20px;
  padding-bottom: 64px;
  border-top: 1px solid var(--line);
  font: 400 14px/1.5 var(--sans);
  color: var(--muted);
}
.footer p { margin: 0 0 8px; }
.footer a { color: var(--ink); }

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  body { font-size: 17px; }
  .masthead { padding-top: 40px; }
  .article { --title-size: 28px; }
  .head { grid-template-columns: 28px 1fr auto; gap: 0 10px; }
  .rank-num { font-size: 1.69rem; }
  .thumb-wrap { width: 88px; height: 88px; }
  .why, .block { margin-left: 0; }
  .why p { font-size: 18px; }
  .news li { width: min(230px, calc(100vw - 96px)); }
  .slide { width: min(320px, calc(100vw - 48px)); }
}
