/* ==========================================================================
   Wire Willow — site stylesheet
   One shared file, linked by every page. Mobile-first: base rules target
   phones, then @media (min-width: 560px) and (min-width: 900px) layer on.

   Contents
     1. Fonts
     2. Tokens
     3. Base + utilities
     4. Header
     5. Ticker
     6. Shared type (eyebrows, section heads, bylines)
     7. Lead story (hero)
     8. Factbox
     9. Story grid (cards)
    10. Numbers band
    11. Briefs + "how this paper works" panel
    12. Subscribe
    13. Story, briefs, about, archive pages
    14. Footer
    15. Breakpoints
    16. Motion + print
   ========================================================================== */

/* 1. Fonts — Archivo variable, self-hosted (SIL OFL, see assets/fonts/OFL.txt) */
@font-face {
  font-family: Archivo;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/archivo-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}

@font-face {
  font-family: Archivo;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/archivo-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* 2. Tokens */
:root {
  color-scheme: light;

  --bg: #fff;
  --ink: #0c0c14;
  --ink-2: #3d3d47;
  --ink-3: #696972;          /* ≥ 4.5:1 on --bg and --muted-bg */
  --line: #e5e5ea;
  --line-soft: #efeff2;
  --accent: #3730cf;
  --accent-dark: #2a24a8;
  --accent-soft: #a5a0f5;    /* accent text on --navy */
  --navy: #0a1526;
  --cream: #f5f2ec;
  --muted-bg: #f7f7f9;
  --on-dark: #c3cbdb;
  --on-dark-2: #8e9ab2;
  --sans: "Archivo", -apple-system, "Segoe UI", helvetica, arial, sans-serif;
  --wrap: 1240px;
  --gutter: 20px;
  --notch: 12px;             /* size of the cut corner on buttons and panels */
  --focus: 3px solid var(--accent);
}

/* 3. Base + utilities */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
picture { display: block; }

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

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

button, input { font: inherit; }

/* stylelint-disable-next-line declaration-no-important -- must beat component display rules */
[hidden] { display: none !important; }

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 8px; color: #fff; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

/* 4. Header */
.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--ink);
}

.topbar-in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-height: 58px;
  padding-block: 8px;
}

.wordmark {
  font-weight: 900;
  font-size: 23px;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark:hover { color: var(--ink); }
.wordmark-accent { color: var(--accent); }

.wordmark-tick {
  display: inline-block;
  width: 9px; height: 9px;
  margin-left: 5px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

/* Section filter: one scrollable row on phones, wraps on wider screens */
.sectionnav {
  order: 3;
  display: flex;
  gap: 2px;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: -10px;
}
.sectionnav::-webkit-scrollbar { display: none; }

/* Fade the right edge while more filters are off-screen (class set by main.js) */
.sectionnav.has-more {
  mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent);
}

.fbtn {
  flex: none;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
}
.fbtn:hover, .fbtn[aria-pressed="true"] { color: var(--accent); }
.fbtn[aria-pressed="true"] { text-decoration: underline 2px; text-underline-offset: 6px; }
.fbtn:focus-visible { outline-offset: -3px; }

.searchbox {
  order: 2;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
}
.searchbox svg { flex: none; }

.searchbox input {
  width: 120px;
  min-height: 40px;
  padding: 7px 2px;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
}
.searchbox input::placeholder { color: var(--ink-3); font-weight: 600; }
.searchbox input:focus { border-bottom-color: var(--accent); }
.searchbox input:focus-visible { outline: none; border-bottom-color: var(--accent); box-shadow: 0 2px 0 var(--accent); }

.topnav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-left: auto; }

.topnav a {
  padding: 8px 2px;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 700;
  text-decoration: none;
}
.topnav a:hover { color: var(--accent); }

/* 5. Ticker */
.ticker { background: var(--navy); color: #fff; overflow: hidden; }

.ticker-inner {
  display: flex;
  align-items: stretch;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.ticker-label {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 8px 12px;
  background: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ticker-track { flex: 1; display: flex; align-items: center; overflow: hidden; }

.ticker-items {
  display: flex;
  width: max-content;

  /* 120s loop so the ticker is slow enough to read (was 46s — too fast to read). */
  animation: ticker 120s linear infinite;
}

.ticker.is-paused .ticker-items,
.ticker-track:hover .ticker-items { animation-play-state: paused; }

.ticker-set {
  display: flex;
  gap: 34px;
  margin: 0;
  padding: 8px 34px 8px 16px;
  list-style: none;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.ticker-set b { font-weight: 800; }
.ticker-set .up { color: #7fe0ae; }
.ticker-set .down { color: #ff9d8f; }

.ticker-toggle {
  flex: none;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid rgb(255 255 255 / 15%);
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  cursor: pointer;
}
.ticker-toggle:focus-visible { outline-color: #fff; outline-offset: -4px; }

@keyframes ticker { to { transform: translateX(-50%); } }

/* 6. Shared type */
.eyebrow {
  margin: 0;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.eyebrow.accent { color: var(--accent); }

.sechead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px 14px;
  margin: 0 0 20px;
}

.sechead h2 {
  margin: 0;
  font-size: clamp(26px, 3.6vw, 36px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.sechead-more {
  margin: 0;
  padding-bottom: 5px;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.datestrip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 16px 0 0;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.byline {
  margin: 0;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.byline b { color: var(--ink); }

.caption { margin: 9px 0 0; color: var(--ink-3); font-size: 12.5px; line-height: 1.45; }

/* Shared cut-corner shape for the primary button and accent panels */
.notched { clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--notch)), calc(100% - var(--notch)) 100%, 0 100%); }

/* 7. Lead story */
.hero { padding: 18px 0 6px; }
.hero-media { margin: 0; }
.hero-media img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }

.hero-card {
  position: relative;
  margin: -40px 10px 0;
  padding: 22px 20px 24px;
  background: #fff;
  box-shadow: 0 14px 40px rgb(10 15 40 / 14%);
}

.hero-card::before {
  content: "";
  position: absolute;
  left: -13px; top: 38px;
  width: 26px; height: 64px;
  background: var(--accent);
  clip-path: polygon(55% 0, 100% 0, 45% 100%, 0 100%);
}

.hero-card h1 {
  max-width: 22ch;
  margin: 9px 0 12px;
  font-size: clamp(28px, 4.4vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.08;
}

.hero-card .dek {
  max-width: 68ch;
  margin: 0 0 14px;
  color: var(--ink-2);
  font-size: clamp(15.5px, 2vw, 18.5px);
  line-height: 1.5;
}

.readbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  margin-top: 18px;
  padding: 13px 22px;
  background: var(--accent);
  color: #fff;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.readbtn:hover { background: var(--accent-dark); color: #fff; }

/* The notch clips outside outlines, so draw focus inside the button */
.readbtn:focus-visible { outline: 3px solid #fff; outline-offset: -7px; }

/* 8. Factbox */
.factbox {
  position: relative;
  margin-top: 28px;
  padding: 22px 20px 14px;
  background: var(--cream);
  overflow: hidden;
}

.factbox::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 34px; height: 52px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 38% 100%, 0 100%);
}

.factbox h2 {
  margin: 0 0 14px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.factbox ul {
  display: grid;
  gap: 4px 34px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.factbox li { padding: 9px 0; border-top: 2px solid #fff; font-size: 15px; line-height: 1.5; }
.factbox strong { font-weight: 800; }

/* 9. Story grid */
.front { padding: 38px 0 6px; }
.grid { display: grid; gap: 30px 26px; }
.card { position: relative; display: flex; flex-direction: column; }

/* A lone card on the last row spans the row as a wide card (see breakpoints).
   build.py adds .is-last-odd / .is-last-third to the last card when needed. */
.card-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card-body { display: flex; flex: 1; flex-direction: column; gap: 7px; padding-top: 13px; }

.card-title {
  margin: 0;
  font-size: 20.5px;
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1.18;
}
.card-link { color: var(--ink); text-decoration: none; }
.card-link::after { content: ""; position: absolute; inset: 0; } /* whole card is clickable */
.card:hover .card-link { color: var(--accent); }
.card-link:focus-visible { outline: none; }
.card-link:focus-visible::after { outline: var(--focus); outline-offset: 4px; }
.card-dek { flex: 1; margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; }

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding-top: 9px;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-cta { color: var(--accent); font-weight: 800; }

.noresults {
  grid-column: 1 / -1;
  margin: 0;
  padding: 36px 10px;
  color: var(--ink-2);
  font-size: 19px;
  font-weight: 700;
  text-align: center;
}

/* 10. Numbers band */
.band { margin-top: 44px; padding: 34px 0 38px; background: var(--navy); color: #fff; }
.band .sechead-more { color: var(--accent-soft); }
.numbers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 26px; }
.stat { padding-top: 13px; border-top: 3px solid var(--accent); }

.stat-big {
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-label { margin: 8px 0 0; color: var(--on-dark); font-size: 13.5px; line-height: 1.45; }

/* 11. Briefs + panel */
.cols { display: grid; gap: 44px; margin: 44px 0 8px; }
.brief { padding: 13px 0 15px; }

.brief::before {
  content: "";
  display: block;
  width: 44px; height: 3px;
  margin-bottom: 11px;
  background: var(--accent);
}

.brief h2, .brief h3 {
  margin: 0 0 4px;
  font-size: 18.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.brief p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.brief .eyebrow { margin-bottom: 4px; }
.src { margin: 6px 0 0; font-size: 12px; font-weight: 600; }
.briefs-links { margin: 4px 0 0; font-size: 13px; font-weight: 600; }

.panel { padding: 24px 22px; background: var(--muted-bg); }

.panel h2 {
  margin: 6px 0 8px;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
}
.steps { margin: 8px 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }

.steps li::before {
  counter-increment: step;
  content: counter(step);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
}
.steps h3 { margin: 0; font-size: 15.5px; font-weight: 800; }
.steps p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.watchbox { margin-top: 18px; padding-top: 14px; border-top: 3px solid var(--ink); }

.watchbox h3 {
  margin: 0 0 9px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.watchbox ul { margin: 0; padding-left: 18px; font-size: 14.5px; line-height: 1.55; }
.watchbox li { margin-bottom: 5px; }

/* 12. Subscribe */
.subscribe {
  --notch: 26px;

  display: grid;
  gap: 24px;
  align-items: center;
  margin: 40px 0 0;
  padding: 30px 22px calc(30px + var(--notch) / 2);
  background: var(--accent);
  color: #fff;
}

.subscribe h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3.4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
}
.subscribe-copy { margin: 0; color: #d9d5ff; font-size: 15px; line-height: 1.5; }
.subscribe-form { display: flex; flex-wrap: wrap; gap: 9px; }

.subscribe-form input {
  flex: 1;
  min-width: 200px;
  min-height: 48px;
  padding: 12px 15px;
  border: 2px solid #fff;
  background: #fff;
  color: var(--ink);
  font-size: 15px;
}
.subscribe-form input::placeholder { color: var(--ink-3); }

.subscribe-form button {
  min-height: 48px;
  padding: 12px 22px;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}
.subscribe-form button:hover { background: #000; }
.subscribe :focus-visible { outline-color: #fff; }
.subscribe-note { margin: 10px 0 0; color: #d9d5ff; font-size: 12.5px; line-height: 1.5; }

/* 13. Story, briefs, about, archive pages */
.story { max-width: 780px; margin: 0 auto; padding: 8px 0 30px; }

.crumbs {
  margin: 18px 0 0;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.crumbs a { text-decoration: underline; text-underline-offset: 3px; }
.crumbs a:hover { color: var(--accent-dark); }
.story-kicker { margin-top: 14px; }

.story h1 {
  margin: 10px 0 14px;
  font-size: clamp(30px, 4.6vw, 46px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.08;
}
.story .dek { margin: 0 0 14px; color: var(--ink-2); font-size: clamp(16px, 2vw, 19px); line-height: 1.55; }
.story-figure { margin: 22px 0; }
.story .factbox { margin: 0 0 28px; }
.story-figure img { width: 100%; }
.story-body p { margin: 0 0 18px; font-size: 17.5px; line-height: 1.7; }
.story-body h2 { margin: 26px 0 10px; font-size: 22px; }
.sources { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.sources h2 { margin: 0 0 10px; font-size: 18px; }
.sources li { margin: 0 0 6px; }
.related { margin: 28px 0; padding: 20px 22px; border: 1px solid var(--line); background: var(--muted-bg); }
.related h2 { margin: 0 0 10px; font-size: 16px; letter-spacing: 0.08em; text-transform: uppercase; }
.related ul { margin: 0; padding-left: 20px; }
.related li { margin: 0 0 8px; }
.storynav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; margin: 26px 0 0; }
.storynav a { font-weight: 700; text-decoration: none; }
.storynav a:hover { text-decoration: underline; }

.archivelist { margin: 0; padding: 0; list-style: none; }
.archivelist > li { padding: 20px 0; border-bottom: 1px solid var(--line); }
.archivelist h2 { margin: 4px 0 8px; font-size: 22px; }
.archive-headline { color: var(--ink); text-decoration: none; }
.archive-headline:hover { color: var(--accent); }
.archive-desk { color: var(--ink-3); }

/* 14. Footer */
.site-footer { margin-top: 48px; padding: 34px 0 40px; background: var(--navy); color: var(--on-dark); font-size: 14px; }
.site-footer a { color: var(--accent-soft); }
.site-footer a:hover { color: #fff; }
.site-footer :focus-visible { outline-color: #fff; }
.footer-cols { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 30px; }
.footer-logo { color: #fff; font-size: 26px; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.footer-logo .wordmark-accent { color: var(--accent-soft); }
.site-footer p { max-width: 58ch; margin: 8px 0 6px; line-height: 1.55; }
.site-footer strong { color: #fff; }

.footer-fine {
  color: var(--on-dark-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* 15. Breakpoints */
@media (width >= 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); }

  .card.is-last-odd {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    column-gap: 26px;
    align-items: start;
  }
  .card.is-last-odd .card-body { padding-top: 0; }
  .hero-card { margin: -52px 18px 0; padding: 24px 22px 26px; }
  .factbox { padding: 22px 26px 14px; }
  .searchbox input { width: 150px; }
  .subscribe { padding: 32px 30px calc(32px + var(--notch) / 2); }
  .panel { padding: 24px 26px; }
}

@media (width >= 900px) {
  .topbar { position: sticky; top: 0; z-index: 50; }
  .topbar-in { flex-wrap: nowrap; gap: 26px; }
  .sectionnav { order: 0; width: auto; margin: 0; overflow: visible; flex-wrap: wrap; }
  .searchbox { order: 0; }
  .hero-media img { aspect-ratio: auto; max-height: 560px; }
  .hero-card { margin: -72px 56px 0; padding: 28px 34px 30px; }
  .factbox ul { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .card.is-last-odd { display: flex; grid-column: auto; }
  .card.is-last-odd .card-body { padding-top: 13px; }

  .card.is-last-third {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 2fr;
    column-gap: 26px;
    align-items: start;
  }
  .card.is-last-third .card-body { padding-top: 0; }
  .card.is-last-third .card-title { font-size: 24px; }
  .numbers { grid-template-columns: repeat(4, 1fr); }
  .cols { grid-template-columns: 1.15fr 0.85fr; }
  .subscribe { grid-template-columns: 1.15fr 0.85fr; }
}

/* 16. Motion + print */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ticker-items { animation: none; width: auto; }
  .ticker-set { flex-wrap: wrap; gap: 6px 34px; white-space: normal; }
  .ticker-set[aria-hidden="true"], .ticker-toggle { display: none; }
}

@media print {
  .topbar, .ticker, .subscribe, .readbtn, .storynav { display: none; }
  .site-footer { background: none; color: var(--ink); }
}
