/* ═══════════════════════════════════════════════════════════════════════════
   Meridian — the world, as it happens.
   Three voices: Newsreader (headlines) · Archivo (UI) · Spline Sans Mono (data).
   Two chromatic colors only: --accent (interactive) and --live (<1h + new pill).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1 · Tokens ─────────────────────────────────────────────────────────── */

/* SOLAR COSMIC is the design: deep space, and the sun as the one source
   of light. Meridian = solar noon — the wordmark sits on a solar disc and
   its plasma flows into the right-rail timescale. Amber is the single
   interactive accent; everything else stays void. A white "daylight"
   variant remains behind the theme toggle. */
:root {
  color-scheme: dark;
  --paper: #0A0B12;
  --surface: #12141F;
  --ink: #F2EFE9;
  --ink-2: #A29DAD;
  --accent: #F5A83C;   /* solar amber */
  --glow: #FFC46B;     /* gold flare */
  --live: #FF6B4A;     /* solar red */
  --hairline: #232436;
  --hairline-strong: rgb(245 168 60 / 0.45);
  /* text on accent fills (buttons, selection) and the new-stories pill —
     tuned per theme to clear WCAG AA on small mono text */
  --on-accent: #140D02;
  --pill-bg: #F5A83C;
  --pill-fg: #140D02;

  /* wire strip: void band, warm rule */
  --wire-bg: #0C0C15;
  --wire-ink: #A8A2B4;
  --wire-strong: #F7F3EA;
  --wire-rule: rgb(255 180 90 / 0.22);

  --shadow-card: 0 1px 2px rgb(0 0 0 / 0.35);
  --shadow-hover: 0 14px 34px rgb(0 0 0 / 0.5);
  --shadow-modal: 0 28px 80px rgb(0 0 0 / 0.65);
  --scrim: rgb(6 6 10 / 0.7);

  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-ui: "Archivo", system-ui, -apple-system, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --wire-h: 36px;
  --pad: clamp(16px, 4vw, 32px);
  --max-w: 1360px;
  --radius: 12px;
}

:root[data-theme="light"] {
  color-scheme: light;
  /* daylight is the EARTH theme: ocean blues instead of solar fire */
  --paper: #F7F8FA;
  --surface: #FFFFFF;
  --ink: #111927;
  --ink-2: #5D6675;
  --accent: #0C6DAD;   /* ocean blue */
  --glow: #1897CE;
  --live: #D33A4E;
  --hairline: #E7EAF0;
  --hairline-strong: rgb(12 109 173 / 0.4);
  --on-accent: #FFFFFF;
  --pill-bg: #111927;
  --pill-fg: #FFFFFF;

  /* daylight clocks band: light, airy, sky-tinted */
  --wire-bg: #FFFFFF;
  --wire-ink: #5D6675;
  --wire-strong: #111927;
  --wire-rule: rgb(17 25 39 / 0.10);

  --shadow-card: 0 1px 2px rgb(16 24 40 / 0.04);
  --shadow-hover: 0 12px 28px rgb(16 24 40 / 0.10);
  --shadow-modal: 0 24px 64px rgb(16 24 40 / 0.24);
  --scrim: rgb(17 25 39 / 0.46);
}

/* ── 2 · Base ───────────────────────────────────────────────────────────── */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Cosmic atmosphere: a faint solar corona bleeding from the logo corner
   and an ember glow at the far edge. Daylight theme stays clean paper. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40vw 30vh at 12% -4%, rgb(255 150 40 / 0.12), transparent 65%),
    radial-gradient(34vw 40vh at 103% 50%, rgb(255 120 50 / 0.07), transparent 70%);
}
:root[data-theme="light"] body::before { content: none; }

h1, h2, h3, h4, p { margin: 0; }

img { max-width: 100%; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

::selection { background: var(--accent); color: var(--on-accent); }

/* Safety net: author display rules (e.g. flex boxes) must never defeat the
   hidden attribute. */
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Data voice — every time, dateline, counter, label. */
.mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.noscript {
  display: block;
  max-width: 40rem;
  margin: 3rem auto;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--ink-2);
}
.noscript strong { display: block; color: var(--ink); margin-bottom: 0.25rem; }

/* ── 3 · Wire strip ─────────────────────────────────────────────────────── */

.wire {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--wire-h);
  background: linear-gradient(100deg, #0C0C15, #1C1020 34%, #2A1418 55%, #170F1B 78%, #0C0C15);
  color: var(--wire-ink);
  border-bottom: 1px solid var(--wire-rule);
  overflow: hidden;
}
:root[data-theme="light"] .wire {
  background: linear-gradient(100deg, #FDFEFF, #EFF6FC 38%, #E7F1FA 60%, #FDFEFF);
}
:root[data-theme="light"] .wire-clock { text-shadow: none; }

/* the plasma timeline renders behind the clocks */
.wire-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.wire-track {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  height: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad);
  overflow: hidden;
}

/* ── Right-rail plasma timescale ─────────────────────────────────────────
   The vertical line maps the loaded feed's time range, NOW on top. The
   cursor mirrors the scroll position; click/drag seeks the feed. */
.timescale {
  position: fixed;
  /* top reaches up to meet the plasma stream flowing from the logo */
  top: calc(var(--wire-h) + 52px);
  bottom: 26px;
  right: 12px;
  width: 56px;
  z-index: 60;
  cursor: ns-resize;
  user-select: none;
  touch-action: none;
}
.timescale.is-empty { display: none; }

.timescale-canvas {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 100%;
  display: block;
  border-radius: 7px;
  /* fallback when WebGL is unavailable */
  background: linear-gradient(180deg, #E86A1A, #7A2D0E 45%, #3A1408 80%, #170A05);
  box-shadow: 0 0 0 1px rgb(255 180 90 / 0.20), 0 0 18px rgb(255 196 107 / 0.10);
}
/* daylight: the rail is water, not lava — light channel, deep-blue flow */
:root[data-theme="light"] .timescale-canvas {
  background: linear-gradient(180deg, #CFE7F7, #9CC8E8 45%, #6FA9D4 80%, #4C89BC);
  box-shadow: 0 0 0 1px rgb(30 140 220 / 0.22), 0 0 14px rgb(80 180 240 / 0.15);
}

.timescale-end {
  position: absolute;
  top: -16px;
  right: 0;
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}

.timescale-tick {
  position: absolute;
  right: 20px;
  transform: translateY(-50%);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  white-space: nowrap;
  pointer-events: none;
}

.timescale-cursor {
  position: absolute;
  right: -2px;
  width: 18px;
  height: 2px;
  background: var(--glow);
  border-radius: 1px;
  box-shadow: 0 0 8px rgb(255 196 107 / 0.75);
  pointer-events: none;
  transition: top 0.12s linear;
}
.timescale-label {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.35);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--ink);
}

@media (max-width: 899px) {
  .timescale { display: none; }
}
@media (min-width: 900px) {
  /* keep cards clear of the rail (main.feed outranks the later .feed rule) */
  main.feed { padding-right: 76px; }
}
@media (prefers-reduced-motion: reduce) {
  .timescale-cursor { transition: none; }
}

.wire-clock {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5em;
  padding: 0 clamp(10px, 2vw, 22px);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  /* keeps the mono clocks crisp over bright plasma crests */
  text-shadow: 0 1px 6px rgb(4 3 14 / 0.85), 0 0 2px rgb(4 3 14 / 0.9);
  text-transform: uppercase;
  white-space: nowrap;
}

.wire-clock + .wire-clock { border-left: 1px solid var(--wire-rule); }

.wire-label { color: var(--wire-ink); }
.wire-time { color: var(--wire-strong); font-variant-numeric: tabular-nums; }

.wire-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  align-self: center;
  animation: pulse 2s ease-in-out infinite;
}

/* ── 4 · Masthead ───────────────────────────────────────────────────────── */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--max-w);
  margin: 0 auto;
  /* the sun burns centered ABOVE the wordmark; content sits on the
     bottom edge of the band — tight, no dead air */
  align-items: center;
  /* compact header: the sun is BACKGROUND behind the wordmark — the
     paddings give the disc exactly band-bottom → tabs-top to live in */
  padding: 34px var(--pad) 24px;
  position: relative;
}

.wordmark {
  position: relative;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--ink);
  text-decoration: none;
  padding: 2px 0;
  /* legible over the blazing core */
  text-shadow: 0 1px 8px rgb(8 6 4 / 0.85), 0 0 3px rgb(8 6 4 / 0.9);
}
/* daylight: the wordmark sits on the Earth globe — white where the globe
   renders (>=900px); below that there is no globe, so ink stays */
@media (min-width: 900px) {
  :root[data-theme="light"] .wordmark { color: #F7F8FA; }
}
/* the black hole wears the ocean's light in daylight */
:root[data-theme="light"] .wordmark .bh::before {
  box-shadow:
    0 0 2px 1px rgb(120 200 255 / 0.95),
    0 0 7px 2px rgb(60 160 230 / 0.55),
    0 0 16px 6px rgb(40 130 210 / 0.28);
  animation: none;
}
:root[data-theme="light"] .wordmark .bh::after {
  border-color: rgb(140 210 255 / 0.6);
  box-shadow: 0 0 6px rgb(60 160 230 / 0.5), inset 0 0 4px rgb(60 160 230 / 0.4);
}
.wordmark:hover { text-decoration: none; }

/* The living sun renders on a full-viewport layer BEHIND the content:
   visible in the header, in the page gutters and between the cards —
   the plasma literally flows under the news. */
.sun-scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* CSS solar-disc fallback where the 3D scene is off (small screens) */
@media (max-width: 899px) {
  .sun-scene { display: none; }
  .masthead { padding: 18px var(--pad) 14px; }
  .wordmark::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 150px;
    height: 150px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle,
      rgb(255 220 140 / 0.34) 0%,
      rgb(255 160 60 / 0.20) 34%,
      rgb(230 90 30 / 0.09) 58%,
      transparent 72%);
    pointer-events: none;
    z-index: -1;
    animation: sun-breathe 7s ease-in-out infinite;
  }
}
@keyframes sun-breathe {
  0%, 100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
}

/* The I of MERIDIAN is a thin black hole: the glyph becomes a void slit
   wrapped in a glowing accretion rim, with a faint photon ring at its
   heart. The one thing on the page that swallows the sun's light. */
.wordmark .bh {
  position: relative;
  color: transparent; /* the void replaces the glyph */
}
.wordmark .bh::before {
  content: "";
  position: absolute;
  left: 38%; /* wide letter-spacing: center on the glyph, not its advance */
  top: -0.18em;
  bottom: -0.12em;
  width: 0.17em;
  transform: translateX(-50%);
  border-radius: 0.1em;
  background: #000;
  box-shadow:
    0 0 2px 1px rgb(255 190 90 / 0.95),
    0 0 7px 2px rgb(255 150 55 / 0.55),
    0 0 16px 6px rgb(255 115 45 / 0.28);
  animation: bh-rim 4.5s ease-in-out infinite;
}
/* photon ring: light bending around the throat's midpoint */
.wordmark .bh::after {
  content: "";
  position: absolute;
  left: 38%;
  top: 50%;
  width: 0.62em;
  height: 0.62em;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgb(255 200 110 / 0.55);
  box-shadow:
    0 0 6px rgb(255 160 60 / 0.5),
    inset 0 0 4px rgb(255 160 60 / 0.4);
  animation: bh-ring 4.5s ease-in-out infinite;
}
@keyframes bh-rim {
  0%, 100% { box-shadow: 0 0 2px 1px rgb(255 190 90 / 0.95), 0 0 7px 2px rgb(255 150 55 / 0.55), 0 0 16px 6px rgb(255 115 45 / 0.28); }
  50%      { box-shadow: 0 0 2px 1px rgb(255 205 120 / 1),   0 0 9px 3px rgb(255 160 60 / 0.7),  0 0 22px 8px rgb(255 125 50 / 0.38); }
}
@keyframes bh-ring {
  0%, 100% { opacity: 0.75; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}


.masthead-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--ink-2);
  flex: none;
}
.icon-btn:hover { color: var(--accent); background: var(--surface); }
.icon-btn svg { width: 20px; height: 20px; }

/* theme toggle: sun on the (default) solar-cosmic theme, moon on daylight */
.icon-moon { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: none; }

/* Search: input expands from the icon */
.search { display: flex; align-items: center; }

.search-input {
  width: 0;
  opacity: 0;
  visibility: hidden;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  height: 36px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  transition: width 0.25s ease, opacity 0.2s ease, visibility 0s 0.25s, padding 0.25s ease;
}
.search.open .search-input {
  width: min(230px, 42vw);
  opacity: 1;
  visibility: visible;
  padding: 0 12px;
  margin-right: 6px;
  transition: width 0.25s ease, opacity 0.2s ease, visibility 0s, padding 0.25s ease;
}
.search-input::placeholder { color: var(--ink-2); }

/* Translate popover */
.lang { position: relative; }

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  width: 240px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.popover[hidden] { display: none; }

.popover-label { color: var(--ink-2); }

.popover-hint {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.88rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

/* ── 5 · Tabs ───────────────────────────────────────────────────────────── */

.tabs {
  position: sticky;
  top: var(--wire-h);
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}

.tabs-track {
  display: flex;
  gap: 2px;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.tabs-track::-webkit-scrollbar { display: none; }

.tab {
  scroll-snap-align: start;
  padding: 11px 12px 9px;
  color: var(--ink-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex: none;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab--saved { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; }
.tab-star { font-size: 0.8em; transform: translateY(-1px); }

/* ── 6 · Daily brief ────────────────────────────────────────────────────── */

.brief {
  max-width: var(--max-w);
  margin: 18px auto 0;
  padding: 0 var(--pad);
}

.brief-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.brief-label { color: var(--accent); flex: none; }

.brief-tagline {
  font-size: 0.85rem;
  color: var(--ink-2);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 7px 13px;
  background: none;
  white-space: nowrap;
  flex: none;
}
.btn:hover { background: var(--accent); color: var(--on-accent); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

.brief-panel {
  margin-top: 10px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}
.brief-panel[hidden] { display: none; }

.brief-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.brief-panel-head .icon-btn { margin-left: auto; width: 30px; height: 30px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  color: var(--ink-2);
  background: var(--paper);
}

.bullets {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.bullets li {
  position: relative;
  padding-left: 18px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.bullets li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 7px;
  height: 1.5px;
  background: var(--accent);
}

/* ── 7 · Banner · pill · toasts ─────────────────────────────────────────── */

.banner {
  position: sticky;
  top: calc(var(--wire-h) + 44px);
  z-index: 35;
  max-width: min(560px, calc(100vw - 2 * var(--pad)));
  margin: 10px auto 0;
  padding: 9px 14px;
  text-align: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--live);
  border-radius: 8px;
}
.banner[hidden] { display: none; }

.pill {
  position: fixed;
  top: calc(var(--wire-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  padding: 9px 18px;
  background: var(--pill-bg);
  color: var(--pill-fg);
  border-radius: 999px;
  box-shadow: var(--shadow-hover);
  /* entrance handled by Motion (js/motion.js) */
}
.pill[hidden] { display: none; }
.pill:hover { filter: brightness(1.12); }
/* live dot inside the pill — the red is a signal, not a background */
.pill::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--live);
  vertical-align: 1px;
  animation: pulse 1.6s ease-in-out infinite;
}

/* freshly loaded cards glow briefly so the eye finds them without any
   scroll movement */
.card--fresh {
  animation: fresh-glow 3.5s ease-out forwards;
}
@keyframes fresh-glow {
  0% { box-shadow: 0 0 0 1.5px var(--glow), 0 0 22px rgb(255 196 107 / 0.35); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
:root[data-theme="light"] .card--fresh { animation-name: fresh-glow-water; }
@keyframes fresh-glow-water {
  0% { box-shadow: 0 0 0 1.5px var(--glow), 0 0 22px rgb(60 170 230 / 0.35); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes pill-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.85rem;
  border-radius: 8px;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 100%;
}
.toast--in { opacity: 1; transform: translateY(0); }

/* ── 8 · Feed grid ──────────────────────────────────────────────────────── */

.feed {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px var(--pad) 40px;
}

/* Dynamic mosaic: card shapes follow their content (hero 2x2, wide 2x1,
   std, compact text) and dense flow packs the maximum onto each screen. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
}

/* text cards: no media, tight — a solar top-rule keeps them on-theme */
.card--text {
  border-top: 2px solid rgb(245 168 60 / 0.55);
}
.card--text .card-body { gap: 7px; padding: 12px 14px 11px; }
.card--text .card-title { font-size: 1rem; -webkit-line-clamp: 4; }
.card--text .card-desc { font-size: 0.84rem; -webkit-line-clamp: 2; }

@media (min-width: 700px) {
  /* wide cards: image beside text, double column.
     .card.card--wide outranks the later .card{flex-direction:column} */
  .card.card--wide { grid-column: span 2; flex-direction: row; }
  .card--wide .card-media {
    width: 44%;
    flex: none;
    aspect-ratio: auto;
    min-height: 100%;
  }
  .card--wide .card-media img { height: 100%; object-fit: cover; }
  .card--wide .card-body { flex: 1; min-width: 0; }
  .card--wide .card-title { font-size: 1.16rem; }
  /* wide cards are tall: let the standfirst FILL the column instead of
     cutting at two lines over empty space */
  .card--wide .card-desc { -webkit-line-clamp: 6; }
}

.sentinel { height: 2px; }

/* ── 9 · Card ───────────────────────────────────────────────────────────── */

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  animation: card-in 0.3s ease backwards;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-hover);
}
.card:hover .card-title { color: var(--accent); }

/* photos fade in once decoded instead of popping */
.card-media img {
  opacity: 0;
  transition: opacity 0.35s ease;
}
.card-media img.is-loaded { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .card-media img { opacity: 1; transition: none; }
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.card-media {
  aspect-ratio: 16 / 9;
  background: var(--paper);
  overflow: hidden;
  flex: none;
}
.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Fallback tile: duotone gradient from the source-id hue + serif initial. */
.tile {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* solar duotone: hues constrained to the ember→gold range in cards.js */
  background: linear-gradient(
    135deg,
    hsl(var(--tile-hue, 30) 62% 46%),
    hsl(calc(var(--tile-hue, 30) - 16) 68% 22%)
  );
}
.tile-letter {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(3.4rem, 9vw, 5rem);
  line-height: 1;
  color: rgb(255 255 255 / 0.82);
  transform: translateY(-0.04em);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 12px;
  flex: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  min-width: 0;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-2);
  flex: none;
}
.dot--live { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.dot--recent { background: var(--accent); }
.dot--stale { background: var(--ink-2); opacity: 0.55; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.card-time { color: var(--ink); font-variant-numeric: tabular-nums; flex: none; }

.card-src {
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s ease;
}

.card-desc {
  font-size: 0.87rem;
  line-height: 1.48;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.card-cat { color: var(--ink-2); }
.card-foot-l { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-cmt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 0.6rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.card-cmt svg { width: 12px; height: 12px; }
.card-cmt:hover { color: var(--accent); border-color: var(--hairline-strong); }
.card:hover .card-cat { color: var(--accent); }

.card-actions { display: flex; align-items: center; gap: 2px; }
.card-actions .icon-btn { width: 32px; height: 32px; }
.card-actions .icon-btn svg { width: 17px; height: 17px; }
.card-actions .icon-btn:hover { background: var(--paper); }

.icon-btn.is-saved { color: var(--accent); }
.icon-btn.is-saved svg { fill: currentColor; }

.icon-btn.is-translated { color: var(--accent); }

/* Hero card */
@media (min-width: 900px) {
  /* hero: double width; small-source images demote to the duotone tile,
     so no photo is ever upscaled into blur */
  .card--hero { grid-column: span 2; }
  .card--hero .card-media { aspect-ratio: 21 / 9; }
  .card--hero .card-body { gap: 11px; padding: 18px 22px 17px; }
  .card--hero .card-title {
    font-size: clamp(1.45rem, 2.4vw, 2rem);
    font-weight: 500;
    line-height: 1.16;
  }
  .card--hero .card-desc { -webkit-line-clamp: 2; font-size: 0.95rem; }
  .card--hero .tile-letter { font-size: clamp(4rem, 9vw, 6rem); }
}

@media (min-width: 1100px) {
  /* full editorial lead: 2x2 with a taller image and roomier text
     (og:image enrichment supplies real high-res photos) */
  .card--hero { grid-row: span 2; }
  .card--hero .card-media { aspect-ratio: 16 / 10; }
  .card--hero .card-title { font-size: clamp(1.7rem, 2.2vw, 2.15rem); }
  .card--hero .card-desc { -webkit-line-clamp: 5; font-size: 0.98rem; }
}

/* ── 10 · Skeletons ─────────────────────────────────────────────────────── */

.card--skeleton { cursor: default; pointer-events: none; animation: none; }

.skel {
  background: var(--hairline);
  border-radius: 5px;
  animation: skel-pulse 1.4s ease-in-out infinite;
}
.skel-media { aspect-ratio: 16 / 9; border-radius: 0; }
.skel-line { height: 0.85rem; }
.skel-line--meta { width: 55%; height: 0.7rem; margin-bottom: 4px; }
.skel-line--short { width: 65%; }

@keyframes skel-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ── 11 · Empty states ──────────────────────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 72px 20px;
  text-align: center;
}
.empty[hidden] { display: none; }

.empty-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  color: var(--ink);
}

.empty-hint {
  font-size: 0.92rem;
  color: var(--ink-2);
  max-width: 32rem;
}

.empty .btn { margin-top: 8px; }

/* ── 12 · Footer ────────────────────────────────────────────────────────── */

.site-foot {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 22px var(--pad) 34px;
  border-top: 1px solid var(--hairline);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  text-align: center;
}
.site-foot a { color: var(--accent); }
.site-foot-sep { color: var(--hairline); }

/* ── 13 · Preview modal ─────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 3vw, 32px);
}

.modal-dialog {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 2 * clamp(10px, 3vw, 32px));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  /* entrance handled by Motion (js/motion.js) */
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.modal-close {
  /* sticky, not absolute: stays reachable while a long article scrolls
     (the dialog itself is the scroll container) */
  position: sticky;
  top: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  margin: 10px 10px -46px auto;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--hairline);
}
.modal-close:hover { color: var(--ink); }
.modal-close svg { width: 18px; height: 18px; }

.modal-media {
  aspect-ratio: 16 / 9;
  background: var(--paper);
  overflow: hidden;
  border-radius: 14px 14px 0 0;
}
.modal-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-body {
  padding: clamp(18px, 4vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  flex-wrap: wrap;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: clamp(1.55rem, 3.6vw, 2.1rem);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.01em;
  max-width: 26ch;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--hairline);
}
.modal-actions .btn { padding: 6px 11px; }

.chip {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 5px 11px;
  align-self: flex-start;
}
.chip:hover { border-color: var(--accent); }

.modal-summary {
  padding: 15px 17px;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.modal-summary-head {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-2);
}

/* Article body: proper reading typography — serif, generous leading,
   bounded measure, a larger lede paragraph. */
.modal-text {
  display: flex;
  flex-direction: column;
  gap: 1.05em;
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 400;
  line-height: 1.72;
  letter-spacing: 0.005em;
  color: var(--ink);
  max-width: 64ch;
}
.modal-text p { overflow-wrap: break-word; }
.modal-text p:first-child {
  font-size: 1.22rem;
  line-height: 1.58;
  font-weight: 500;
}

.modal-note {
  font-size: 0.83rem;
  font-style: italic;
  color: var(--ink-2);
}

.skel-text { height: 0.8rem; }
.skel-text:nth-child(2n) { width: 92%; }
.skel-text:nth-child(3n) { width: 84%; }
.skel-text:last-child { width: 55%; }

/* ── 14 · Settings drawer ───────────────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--scrim);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.scrim.open { opacity: 1; }
.scrim[hidden] { display: none; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  width: min(360px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s ease;
}
.drawer.open { transform: translateX(0); }
.drawer[hidden] { display: none; }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
  flex: none;
}

.drawer-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 500;
}

.drawer-body {
  overflow-y: auto;
  padding: 6px 20px 28px;
  flex: 1;
}

.drawer-section { padding: 16px 0; }
.drawer-section + .drawer-section { border-top: 1px solid var(--hairline); }

.drawer-label { color: var(--ink-2); margin-bottom: 10px; }

.drawer-hint {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.drawer-cat {
  color: var(--accent);
  margin: 14px 0 6px;
}

.source-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  font-size: 0.88rem;
  cursor: pointer;
}
.source-row input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; flex: none; }
.source-row.off { opacity: 0.5; cursor: default; }

.source-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 5px;
  flex: none;
}

/* ── 15 · Responsive ────────────────────────────────────────────────────── */

/* Below 900px the six clocks would clip mid-digit: keep UTC + two cities. */
@media (max-width: 899px) {
  .wire-clock:not(.wire-clock--utc):not([data-priority]) { display: none; }
  .wire-clock { padding: 0 clamp(8px, 2.5vw, 18px); }
}

@media (max-width: 560px) {
  .masthead { padding-top: 14px; }
  .wordmark { font-size: 1rem; letter-spacing: 0.26em; }
  /* expanded search floats over the masthead so nothing is squeezed */
  .search.open .search-input {
    position: absolute;
    left: var(--pad);
    right: calc(var(--pad) + 44px);
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    z-index: 5;
    margin-right: 0;
  }
  /* keep the toggle itself tappable above the overlaying input so touch
     users can collapse the search again */
  .search.open > .icon-btn {
    position: relative;
    z-index: 6;
    background: var(--paper);
  }
  .brief-tagline { display: none; }
}

/* Comfortable touch targets on coarse pointers (cards' 32px actions and the
   36px masthead icons are below the 40px floor) */
@media (pointer: coarse) {
  .icon-btn,
  .card-actions .icon-btn,
  .brief-panel-head .icon-btn {
    width: 42px;
    height: 42px;
  }
}

/* ── Comments ───────────────────────────────────────────────────────────── */

.cmt-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px 22px;
  border-top: 1px solid var(--hairline);
}

.cmt-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.cmt-title { color: var(--ink); }
.cmt-count { color: var(--ink-2); }
.cmt-sorts { margin-left: auto; display: flex; gap: 4px; }
.cmt-sort {
  padding: 4px 9px;
  border-radius: 6px;
  color: var(--ink-2);
  border: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.cmt-sort:hover { color: var(--ink); }
.cmt-sort.is-active { color: var(--accent); border-color: var(--hairline); }

.cmt-composer { display: flex; flex-direction: column; gap: 8px; }
.cmt-input {
  width: 100%;
  resize: vertical;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.45;
}
.cmt-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cmt-composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cmt-me { color: var(--ink-2); font-size: 0.62rem; }

.cmt-status { color: var(--ink-2); font-size: 0.9rem; }

.cmt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cmt-item {
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 13px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.cmt-item:last-child { border-bottom: none; }

.cmt-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cmt-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.72rem;
  color: #fff;
  background: linear-gradient(
    135deg,
    hsl(var(--av-hue, 30) 62% 46%),
    hsl(calc(var(--av-hue, 30) - 24) 66% 30%)
  );
}
.cmt-name { font-weight: 600; font-size: 0.88rem; color: var(--ink); }
.cmt-time { color: var(--ink-2); font-size: 0.6rem; margin-left: auto; flex: none; }

.cmt-body {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink);
  overflow-wrap: break-word;
  white-space: pre-line;
}

.cmt-votes { display: flex; gap: 8px; }
.cmt-vote {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 0.72rem;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.cmt-vote svg { width: 14px; height: 14px; }
.cmt-vote:hover { color: var(--ink); border-color: var(--hairline-strong); }
.cmt-vote[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--hairline-strong);
  background: rgb(127 127 127 / 0.07);
}
.cmt-more { align-self: center; }

/* split layout: comments take the right column of the full-screen view */
@media (min-width: 1000px) {
  .modal-dialog.has-comments {
    width: min(1200px, 100%);
    height: calc(100vh - 2 * clamp(10px, 3vw, 32px));
    max-height: none;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  }
  .modal-dialog.has-comments .modal-article {
    overflow-y: auto;
    overscroll-behavior: contain;
    position: relative;
  }
  .modal-dialog.has-comments .modal-comments {
    overflow-y: auto;
    overscroll-behavior: contain;
    border-left: 1px solid var(--hairline);
    background: var(--surface);
  }
  .modal-dialog.has-comments .cmt-panel { border-top: none; }
}
@media (pointer: coarse) {
  .cmt-vote { padding: 8px 14px; }
}

/* ── 16 · Reduced motion ────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .card:hover { transform: none; }
  html { scroll-behavior: auto; }
}
