/* infinitenews - one stylesheet for one rendered DOM.
 *
 * There used to be two front ends: a client-rendered SPA and these server-rendered pages,
 * each with its own CSS and its own idea of what an event card looks like. That is the same
 * trap as the coverage boundary living in four files, and it drifts the same way. The server
 * renders the markup; JavaScript only enhances it. Search and filter hide and show nodes
 * that already exist rather than rebuilding them.
 *
 * Visual language: newspaper. Serif for editorial voice, monospace for metadata, and colour
 * reserved almost entirely for evidence quality, because on a war board the confidence label
 * is the most important thing on the card after the sentence itself.
 */

/* ---------------------------------------------------------------- tokens -- */
:root {
  color-scheme: light dark;

  --paper:      #f6f3ea;
  --sheet:      #fffdf7;
  --ink:        #14130d;
  --ink-soft:   #4a4739;
  --muted:      #6d6a5b;
  --rule:       #ded7c4;
  --rule-firm:  #14130d;
  --accent:     #9c1717;
  --focus:      #1c5fd0;

  --confirmed:  #2c6a1c;
  --official:   #1b4d69;
  --reported:   #7a570b;
  --unverified: #8a2f2f;

  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans:  system-ui, -apple-system, "Segoe UI", sans-serif;

  --step--1: clamp(0.75rem, 0.72rem + 0.15vw, 0.82rem);
  --step-0:  clamp(1rem, 0.97rem + 0.15vw, 1.06rem);
  --step-1:  clamp(1.15rem, 1.08rem + 0.35vw, 1.35rem);
  --step-2:  clamp(1.4rem, 1.25rem + 0.75vw, 1.9rem);
  --step-3:  clamp(1.9rem, 1.5rem + 2vw, 3.1rem);

  --gutter: clamp(1rem, 4vw, 2rem);
  --measure: 42rem;
  --wide: 68rem;
}

:root[data-theme="dark"], :root:not([data-theme="light"]) {
  /* placeholder so the selector exists for the toggle; real values below */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:    #100f0b;
    --sheet:    #17160f;
    --ink:      #eee9d9;
    --ink-soft: #b8b3a1;
    --muted:    #97927f;
    --rule:     #322f24;
    --rule-firm:#eee9d9;
    --accent:   #e0605a;
    --focus:    #7fb0ff;
    --confirmed:#8dc276;
    --official: #7db4d6;
    --reported: #d6b062;
    --unverified:#d98d8d;
  }
}
:root[data-theme="dark"] {
  --paper:    #100f0b;
  --sheet:    #17160f;
  --ink:      #eee9d9;
  --ink-soft: #b8b3a1;
  --muted:    #97927f;
  --rule:     #322f24;
  --rule-firm:#eee9d9;
  --accent:   #e0605a;
  --focus:    #7fb0ff;
  --confirmed:#8dc276;
  --official: #7db4d6;
  --reported: #d6b062;
  --unverified:#d98d8d;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--step-0)/1.62 var(--serif);
  font-synthesis-weight: none;
}

:where(a):focus-visible,
:where(button, input, select, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: var(--gutter); top: 0.75rem; z-index: 40;
  background: var(--sheet); color: var(--ink);
  padding: 0.6rem 0.9rem; border: 1px solid var(--rule-firm);
}

/* --------------------------------------------------------------- masthead -- */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--sheet);
}
.masthead-in {
  max-width: var(--wide); margin: 0 auto;
  padding: 0.85rem var(--gutter);
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand {
  display: flex; flex-direction: column; gap: 0.24rem;
  color: var(--ink); text-decoration: none;
  margin-right: auto;
}
.brand-name {
  font: 700 1.12rem/1 var(--mono);
  letter-spacing: -0.035em;
}
.brand-tagline {
  font: 500 var(--step--1)/1 var(--sans);
  color: var(--muted);
  letter-spacing: 0.01em;
}
.livedot {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font: 600 var(--step--1)/1 var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent);
}
.livedot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}
.masthead nav { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; }
.masthead nav a, .themetoggle {
  font: 500 var(--step--1)/1 var(--sans);
  color: var(--muted); text-decoration: none;
}
.themetoggle { background: none; border: 0; cursor: pointer; padding: 0; }
.masthead nav a:hover, .themetoggle:hover { color: var(--ink); }

/* --------------------------------------------------------------- week bar -- */
.weekbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--sheet);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.03);
}
.weekbar-in {
  max-width: var(--wide); margin: 0 auto;
  padding: 0.55rem var(--gutter);
  display: flex; align-items: center; gap: 0.5rem;
  overflow-x: auto;
  /* Hidden rather than thin. A visible horizontal scrollbar under a pill rail reads as a
     rendering fault; the pills are self-evidently swipeable and keyboard scroll still works. */
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
}
.weekbar-in::-webkit-scrollbar, .filters::-webkit-scrollbar { display: none; }
.weekbar a, .weekbar span.wk {
  flex: 0 0 auto;
  font: 500 var(--step--1)/1 var(--sans);
  padding: 0.42rem 0.7rem;
  min-height: 34px; display: inline-flex; align-items: center; gap: 0.35rem;
  border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink-soft); text-decoration: none;
  white-space: nowrap;
}
.weekbar a:hover { border-color: var(--ink-soft); color: var(--ink); }
.weekbar [aria-current="page"] {
  border-color: var(--rule-firm); color: var(--ink); font-weight: 700;
  background: var(--paper);
}
.weekbar .n { color: var(--muted); font: 500 0.72rem/1 var(--mono); }

/* ------------------------------------------------------------------ shell -- */
main { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: var(--measure); }

/* ------------------------------------------------------------------- lead -- */
.lead { padding: clamp(1.75rem, 5vw, 3rem) 0 1.25rem; }
.kicker {
  margin: 0 0 0.7rem;
  font: 600 var(--step--1)/1.3 var(--mono);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
}
.kicker .sep { color: var(--rule); margin: 0 0.4rem; }
.lead h1 {
  margin: 0 0 0.75rem;
  font-size: var(--step-3); line-height: 1.02;
  letter-spacing: -0.028em; font-weight: 700;
  max-width: 20ch;
}
.standfirst {
  margin: 0 0 1rem; max-width: var(--measure);
  font-size: var(--step-1); line-height: 1.45; color: var(--ink-soft);
}

/* strip of the newest few, for scanning before reading */
.latest {
  display: grid; gap: 0 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  border-top: 1px solid var(--rule);
  padding-top: 0.9rem; margin-top: 1.25rem;
}
.latest a {
  display: block; padding: 0.5rem 0; color: var(--ink); text-decoration: none;
  border-bottom: 1px solid transparent;
}
.latest a:hover { border-bottom-color: var(--rule); }
.latest time { display: block; font: 500 0.7rem/1 var(--mono); color: var(--accent); margin-bottom: 0.3rem; }
.latest span { font-size: 0.92rem; line-height: 1.3; display: block; }

/* --------------------------------------------------------------- stat bar -- */
.stats {
  display: grid; gap: 0.75rem 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  border-top: 1px solid var(--rule-firm);
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 0; margin-bottom: 1.5rem;
}
.stats dt {
  font: 600 0.66rem/1 var(--mono); letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 0.3rem;
}
.stats dd { margin: 0; font: 600 0.95rem/1.2 var(--sans); }

/* ------------------------------------------------------------------- desk -- */
.desk {
  background: var(--sheet); border: 1px solid var(--rule);
  padding: 1.1rem 1.25rem; margin-bottom: 1.75rem;
}
.desk h2 {
  margin: 0 0 0.5rem;
  font: 600 var(--step--1)/1 var(--mono); letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--muted);
}
.desk p { margin: 0; max-width: var(--measure); color: var(--ink-soft); }

/* --------------------------------------------------------------- controls -- */
.controls { margin-bottom: 0.5rem; }
.searchrow { display: flex; gap: 0.5rem; margin-bottom: 0.6rem; }
.searchrow input {
  flex: 1 1 auto; min-height: 44px;
  padding: 0.5rem 0.8rem;
  font: var(--step-0)/1.2 var(--sans);
  color: var(--ink); background: var(--sheet);
  border: 1px solid var(--rule); border-radius: 3px;
}
.searchrow input::placeholder { color: var(--muted); }
.filters {
  display: flex; gap: 0.4rem; overflow-x: auto;
  padding-bottom: 0.4rem;
  scrollbar-width: none; -ms-overflow-style: none;
  overscroll-behavior-x: contain;
}
.filters button {
  /* 44px, matching the touch-target floor the rest of the board already meets. */
  flex: 0 0 auto; min-height: 44px;
  padding: 0.35rem 0.75rem;
  font: 500 var(--step--1)/1 var(--sans);
  color: var(--ink-soft); background: var(--sheet);
  border: 1px solid var(--rule); border-radius: 999px;
  cursor: pointer; white-space: nowrap;
}
.filters button[aria-pressed="true"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.resultnote {
  font: 500 var(--step--1)/1.4 var(--mono);
  color: var(--muted); padding: 0.4rem 0 0.8rem;
}

/* --------------------------------------------------------------- timeline -- */
.daymark {
  position: sticky; top: 3.05rem; z-index: 10;
  margin: 1.75rem 0 0;
  padding: 0.4rem 0;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-firm);
  font: 600 0.72rem/1 var(--mono); letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--ink);
}

.ev {
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--rule);
  max-width: var(--measure);
  scroll-margin-top: 7rem;
}
.ev[hidden] { display: none; }
.ev:target { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.ev-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem;
  margin-bottom: 0.45rem;
  font: 500 0.7rem/1 var(--mono); color: var(--muted);
}
.ev-meta time { color: var(--ink-soft); font-weight: 600; }

.ev h3 { margin: 0 0 0.45rem; font-size: var(--step-1); line-height: 1.22; letter-spacing: -0.012em; }
.ev h3 a { color: var(--ink); text-decoration: none; }
.ev h3 a:hover { text-decoration: underline; text-underline-offset: 2px; }
.ev p { margin: 0 0 0.6rem; }

.why {
  margin: 0 0 0.7rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--rule);
  font-size: 0.95rem; color: var(--ink-soft);
}
.why b { color: var(--ink); font-weight: 600; }

.tag {
  border: 1px solid currentColor; border-radius: 2px;
  padding: 0.12rem 0.38rem;
  text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.64rem; font-weight: 600;
}
.tag.plain { border-color: var(--rule); color: var(--muted); }
.c-confirmed  { color: var(--confirmed); }
.c-official   { color: var(--official); }
.c-reported   { color: var(--reported); }
.c-unverified { color: var(--unverified); }

.src summary {
  cursor: pointer; list-style: none;
  font: 500 var(--step--1)/1 var(--mono); color: var(--muted);
  padding: 0.3rem 0; min-height: 32px; display: flex; align-items: center; gap: 0.35rem;
}
.src summary::-webkit-details-marker { display: none; }
.src summary::before { content: "▸"; font-size: 0.7em; }
.src[open] summary::before { content: "▾"; }
.src ol { margin: 0.35rem 0 0; padding-left: 1.2rem; font-size: 0.87rem; }
.src li { margin-bottom: 0.3rem; }
.src a { color: var(--accent); word-break: break-word; }

/* ------------------------------------------------------------------ misc -- */
.empty { padding: 2.5rem 0; color: var(--muted); font-style: italic; }
.single { padding: 2.5rem 0 1rem; }
.single .ev { border-bottom: 0; }
.single h1 { font-size: var(--step-2); line-height: 1.15; margin: 0 0 0.6rem; letter-spacing: -0.02em; }
.back { margin: 1.5rem 0 0; font-size: 0.92rem; }

.foot {
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem;
  background: var(--sheet);
}
.foot-in {
  max-width: var(--wide); margin: 0 auto;
  padding: 1.75rem var(--gutter) 3rem;
  font: var(--step--1)/1.6 var(--sans); color: var(--muted);
}
.foot p { margin: 0 0 0.4rem; max-width: var(--measure); }

.banner {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--ink); color: var(--paper);
  border-radius: 999px; padding: 0.6rem 0.7rem 0.6rem 1.1rem;
  font: 600 0.85rem/1 var(--sans);
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.28);
  max-width: calc(100vw - 2rem);
}
.banner button {
  font: inherit; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: 0; border-radius: 999px; padding: 0.4rem 0.85rem; min-height: 32px;
}

/* ------------------------------------------------------------ responsive -- */
@media (max-width: 46rem) {
  .lead h1 { max-width: none; }
  .latest { grid-template-columns: 1fr; gap: 0; }
  .latest a { border-bottom: 1px solid var(--rule); }
  .daymark { top: 2.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

@media print {
  .masthead, .weekbar, .controls, .banner, .skip, .latest { display: none !important; }
  .ev, .src ol { break-inside: avoid; }
  .src[open] summary, .src summary { display: none; }
  .src ol { display: block !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .ev[hidden] { display: block !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.75em; color: #555; }
}

/* ----------------------------------------------------------------- pager -- */
/* Only rendered for weeks past the pagination threshold, so most weeks never show it. */
.pager {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule-firm);
}
.pager a, .pager .pg-nums span {
  font: 500 var(--step--1)/1 var(--sans);
  text-decoration: none;
  color: var(--ink-soft);
  min-height: 44px;
  padding: 0 0.7rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule); border-radius: 3px;
}
.pager a:hover { border-color: var(--ink-soft); color: var(--ink); }
.pg-nums {
  display: flex; justify-content: center; gap: 0.3rem; flex-wrap: wrap;
}
.pg-nums [aria-current="page"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700;
}
.pg-nums .gap { border: 0; min-width: 0; padding: 0 0.15rem; color: var(--muted); }
.pg-note {
  grid-column: 1 / -1;
  margin: 0.35rem 0 0; text-align: center;
  font: 500 var(--step--1)/1.4 var(--mono); color: var(--muted);
}
.pager > span.pg-prev, .pager > span.pg-next { border: 0; }

@media (max-width: 34rem) {
  .pager a { padding: 0 0.55rem; }
  .pg-nums { gap: 0.2rem; }
  /* Below this the masthead row is wordmark + Live + nav. The tagline would wrap to
     two lines and shove the nav down, so it steps aside on phones. */
  .brand-tagline { display: none; }
}

/* The situation desk carries the timestamp of the analysis, not of the page build. An
   undated or overtaken digest is withheld entirely rather than shown unlabelled. */
.desk h2 .desk-stamp {
  margin-left: 0.5rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: none;
}
