/* Data Mechanics. Kalshi's dark market front page, with a cyberpunk edge.
   Greys from Kalshi; logo gold is the one accent. */

@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-latin.de2f1fe81758.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  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";
  src: url("../fonts/archivo-latin-ext.589f7bc0fac4.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-latin.b636a65da4f0.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Ground and surfaces (Kalshi) */
  --bg: #121416;
  --card: #17191b;
  --well: #1d1f21;
  --raised: #222427;
  --pill: #2f3132;
  --line: #2c2e30;
  --line-strong: #3a3d41;

  /* Ink */
  --ink: #f2f3f4;
  --ink-2: #b6b9bd;
  --ink-3: #8b8f94;

  /* Accent */
  --gold: #ffd700;
  --gold-hover: #ffe24d;
  --gold-wash: rgb(255 215 0 / 0.1);
  --gold-glow: 0 0 0 1px var(--gold), 0 0 18px rgb(255 215 0 / 0.28);

  /* Good and bad: only in Politics mode, for the change during a presidency, and always beside an arrow */
  --good: #2bc892;
  --bad: #f2545b;

  /* Type */
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --condensed: 75%;

  --radius: 12px;
  --gutter: clamp(16px, 4vw, 40px);
  --wide: 1272px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

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

html {
  background: var(--bg);
  scrollbar-color: var(--line-strong) var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  /* A faint 32px grid: the cyberpunk ground under Kalshi's greys. */
  background-color: var(--bg);
  background-image:
    linear-gradient(rgb(255 255 255 / 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.022) 1px, transparent 1px);
  background-size: 32px 32px;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.55;
  caret-color: var(--gold);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold); color: var(--bg); }

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

:focus-visible { outline: none; box-shadow: var(--gold-glow); border-radius: 6px; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  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: 8px 16px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--bg);
  font-weight: 700;
}
.skip-link:focus { top: 12px; }

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

.mono { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.02em; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(18 20 22 / 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.bar {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
}
.wordmark img { width: 34px; height: 34px; }

/* The gear turns slowly, as it did on the old site. */
.spin { animation: gearspin 7s linear infinite; transform-origin: 50% 50%; }
@keyframes gearspin { to { transform: rotate(360deg); } }

.nav { display: flex; align-items: center; gap: 22px; }
.nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: color 150ms ease;
}
.nav__link:hover, .nav__link[aria-current="page"], .nav__link.is-current, .menu.is-open .menu__button { color: var(--gold); }
/* The languages in the menu and the menu button belong to phones; .langs and .round-btn come later, so these name the bar. */
.bar .nav__langs, .bar .nav-toggle { display: none; }

/* "Metrics" opens the categories as a vertical list under it, scaling in from the button. */
.menu { position: relative; }
.menu__button svg { width: 14px; height: 14px; transition: transform 200ms var(--ease-out); }
.menu.is-open .menu__button svg { transform: rotate(180deg); }
.menu__panel {
  display: none;
  position: absolute;
  top: calc(100% + 24px);
  left: -12px;
  z-index: 60;
  width: 280px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.55);
  transform-origin: top left;
}
.menu.is-open .menu__panel { display: block; animation: pop 180ms var(--ease-out); }
.menu__heading { display: none; }
.menu__list { margin: 0; padding: 0; list-style: none; }
.menu__item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}
.menu__item:hover { background: var(--raised); color: var(--ink); }
.menu__item[aria-current="page"] { color: var(--gold); }
.menu__icon { display: grid; place-items: center; color: var(--ink-3); transition: color 150ms ease; }
.menu__item:hover .menu__icon, .menu__item[aria-current="page"] .menu__icon { color: var(--gold); }
.menu__count { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.search { position: relative; flex: 0 1 400px; margin-left: auto; }

/* Language switcher: the page in English, German or Portuguese. Codes in mono, the current one gold. */
.langs { display: flex; flex-shrink: 0; gap: 2px; margin-left: -14px; }
.langs a {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 32px;
  padding: 0 6px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease;
}
.langs a:hover { color: var(--ink); background: var(--raised); }
.langs a[aria-current="true"] { color: var(--gold); }
.search__field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--pill);
  border: 1px solid transparent;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.search__field:focus-within { border-color: var(--gold); box-shadow: 0 0 16px rgb(255 215 0 / 0.18); }
.search__field svg { flex-shrink: 0; color: var(--ink-3); }
.search__field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  font-size: 1rem;
  color: var(--ink);
}
.search__field input::placeholder { color: var(--ink-3); }
.search__field input:focus { outline: none; }
.search__field input::-webkit-search-cancel-button { display: none; }

.search__results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.5);
}
.search__option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}
.search__option[aria-selected="true"] { background: var(--raised); }
.search__option strong { font-weight: 700; }
.search__option span { grid-column: 1; font-size: 0.8125rem; color: var(--ink-3); }
.search__option em {
  grid-column: 2;
  grid-row: 1;
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.search__empty { padding: 12px; color: var(--ink-3); font-size: 0.875rem; }


.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: var(--gold);
  color: var(--bg);
  font-weight: 700;
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}
.button:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.button:active { transform: scale(0.97); }
.button--outline { background: transparent; color: var(--gold); }
.button--outline:hover { background: var(--gold-wash); color: var(--gold); border-color: var(--gold); }
.button svg { width: 16px; height: 16px; }

/* The home page's way into the metrics: one link per category, with its icon and how many metrics it holds. */
#categories { scroll-margin-top: 84px; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.category-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease;
}
.category-link:hover { border-color: var(--gold); background: var(--raised); }
.category-link .icon-tile { grid-row: 1 / 3; }
.category-link__name { font-weight: 700; color: var(--ink); }
.category-link__count { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); }

/* ---------- Page grid ---------- */

.page { padding-block: 24px 64px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  gap: 48px;
  align-items: start;
}
.layout__rail { display: flex; flex-direction: column; gap: 24px; }
/* The rail follows the scroll only where it fits on screen. */
@media (min-width: 1101px) and (min-height: 1040px) {
  .layout__rail { position: sticky; top: 92px; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.section { margin-top: 56px; }
.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.section__title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-stretch: var(--condensed);
  font-size: 1.75rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-decoration: none;
}
a.section__title:hover svg { transform: translateX(3px); }
.section__title svg { color: var(--gold); transition: transform 150ms var(--ease-out); }


/* Category icon tile */
.icon-tile {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gold-wash);
  color: var(--gold);
  flex-shrink: 0;
}
.icon-tile svg { width: 18px; height: 18px; }
.icon-tile--lg { width: 40px; height: 40px; border-radius: 10px; }
.icon-tile--lg svg { width: 22px; height: 22px; }

/* Value pill: Kalshi's odds pill, in gold */
.value-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 36px;
  padding: 0 14px;
  border: 1.5px solid var(--gold);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 150ms ease;
}
a.value-pill:hover { background: var(--gold-wash); box-shadow: 0 0 16px rgb(255 215 0 / 0.3); }

.flag {
  width: 28px;
  height: 21px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08);
  flex-shrink: 0;
}
.flag--round { width: 30px; height: 30px; border-radius: 50%; }

.country-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}
.country-row__name { font-size: 1rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-row__rank { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); }

/* Chart wells: the ground every chart is drawn on */
.well {
  position: relative;
  background: var(--well);
  border-radius: 8px;
}

.source-line {
  font-size: 0.8125rem;
  color: var(--ink-3);
}
.source-line a { color: var(--ink-2); text-decoration-color: var(--line-strong); }
.source-line a:hover { color: var(--gold); text-decoration-color: var(--gold); }


/* ---------- Home: introduction ---------- */

.intro { padding-block: 24px 40px; }
.intro__title {
  font-weight: 700;
  font-stretch: var(--condensed);
  font-size: clamp(2.75rem, 6.4vw, 5.75rem);
  line-height: 0.94;
  letter-spacing: -0.02em;
}
/* One phrase per line on wide screens; they wrap naturally on phones. */
.intro__title span { display: inline-block; }
.intro__text { margin-top: 20px; max-width: 62ch; font-size: 1.125rem; line-height: 1.6; color: var(--ink-2); }
.intro__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.intro__actions .button { height: 44px; padding: 0 20px; font-size: 0.9375rem; }

/* ---------- Home: spotlight ---------- */

.spotlight { padding: 24px; }
.spotlight__top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.pager { display: flex; align-items: center; gap: 12px; font-size: 0.875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.round-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}
.round-btn:hover { border-color: var(--gold); color: var(--gold); }
.round-btn:active { transform: scale(0.94); }
.round-btn:disabled { opacity: 0.35; cursor: default; border-color: var(--line); color: var(--ink-3); }
.round-btn svg { width: 16px; height: 16px; }

.slide[hidden] { display: none; }
.slide.is-entering { animation: slide-in 180ms var(--ease-out); }
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } }
.slide__title {
  margin-top: 18px;
  font-weight: 700;
  font-stretch: var(--condensed);
  font-size: clamp(1.75rem, 2.6vw, 2.125rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.slide__title a { text-decoration: none; }
.slide__title a:hover { color: var(--gold); }
.slide__subtitle { margin-top: 6px; font-size: 1.0625rem; color: var(--ink-2); }
.slide__body {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 28px;
  margin-top: 18px;
  align-items: start;
}
.slide__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  padding-bottom: 6px;
  font-size: 0.8125rem;
  color: var(--ink-3);
}
.slide__rows { display: flex; flex-direction: column; gap: 14px; margin: 6px 0 0; padding: 0; list-style: none; }
.slide__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--line-strong);
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.slide__meta a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; font-weight: 700; white-space: nowrap; }
.slide__meta a svg { color: var(--gold); transition: transform 150ms var(--ease-out); }
.slide__meta a:hover svg { transform: translateX(3px); }
.slide__meta a:hover { color: var(--gold); }
.slide__about { margin-top: 16px; font-size: 0.9375rem; line-height: 1.6; color: var(--ink-2); }
.slide__about strong { color: var(--ink); font-weight: 700; }

.map-canvas { position: absolute; inset: 0; }
.spotlight__map .source-line { margin-top: 10px; }
.spotlight__map .spotlight__source { margin: 0 0 8px; }

/* Trust row */
.trust { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 24px; }
.trust__item { display: flex; gap: 14px; align-items: flex-start; padding: 18px; text-decoration: none; transition: border-color 150ms ease; }
a.trust__item:hover { border-color: var(--line-strong); }
.trust__text strong { display: block; font-weight: 700; font-size: 1rem; }
.trust__text span { display: block; margin-top: 2px; font-size: 0.8125rem; color: var(--ink-3); }

/* Metric strip (horizontal scroller) */
.strip-controls { display: flex; gap: 8px; }
.strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 152px;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.strip::-webkit-scrollbar { display: none; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 186px;
  padding: 16px;
  scroll-snap-align: start;
  text-decoration: none;
  transition: border-color 150ms ease;
}
.tile:hover { border-color: var(--gold); }
.tile__years { margin-top: 6px; font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.tile__title { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.tile__tag {
  margin-top: auto;
  align-self: flex-start;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
}

/* Market cards (category sections) */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.market__metric { margin-top: 4px; font-size: 0.8125rem; color: var(--ink-3); }
.market { display: flex; flex-direction: column; padding: 20px; }
.market__title { margin-top: 14px; font-weight: 700; font-size: 1.0625rem; line-height: 1.3; }
.market__title a { text-decoration: none; }
.market__title a:hover { color: var(--gold); }
.market__rows { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 0; padding: 0; list-style: none; }
.market__foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  font-size: 0.8125rem;
  color: var(--ink-3);
}
.market__foot strong { color: var(--ink-2); font-weight: 600; }

/* Rail cards */
.rail-card { padding: 20px; }
.rail-card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
}
a.rail-card__title:hover { color: var(--gold); }
.rail-card__title svg { width: 14px; height: 14px; color: var(--ink-3); }
.rail-list { margin: 0; padding: 0; list-style: none; }
.rail-list li + li { border-top: 1px solid var(--line); }
.rail-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 14px 0;
  text-decoration: none;
}
.rail-item:last-child { padding-bottom: 0; }
.rail-item__title { grid-column: 1; font-size: 0.875rem; line-height: 1.35; }
.rail-item__sub { grid-column: 1; font-size: 0.8125rem; color: var(--ink-3); }
a.rail-item:hover .rail-item__title { color: var(--gold); }

.rank-list { margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.rank-list li {
  display: grid;
  grid-template-columns: 22px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  font-size: 0.875rem;
}
.rank-list li + li { border-top: 1px solid var(--line); }
.rank-list__n { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); }
.rank-list__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list button {
  all: unset;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-list button:hover { color: var(--gold); }
.rank-list button:focus-visible { box-shadow: var(--gold-glow); border-radius: 4px; }
.rank-list__value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Posts on the home page */
.post-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.post-card { display: flex; flex-direction: column; overflow: hidden; text-decoration: none; transition: border-color 150ms ease; }
.post-card:hover { border-color: var(--gold); }
.post-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: left top; border-bottom: 1px solid var(--line); background: var(--well); }
.post-card__body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; flex: 1; }
.post-card__title { font-weight: 700; font-size: 1rem; line-height: 1.3; }
.post-card__meta { margin-top: auto; font-size: 0.8125rem; color: var(--ink-3); }

.chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  text-decoration: none;
}
a.chip:hover { border-color: var(--gold); color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Metric page ---------- */

.crumbs { display: flex; gap: 8px; font-size: 0.8125rem; color: var(--ink-3); }
.crumbs a { text-decoration: none; color: var(--ink-2); }
.crumbs a:hover { color: var(--gold); }

.metric-head { margin-top: 14px; }
.metric-head h1 {
  font-weight: 700;
  font-stretch: var(--condensed);
  font-size: clamp(2.25rem, 4.4vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
}
.metric-head__summary { margin-top: 10px; font-size: 1.125rem; color: var(--ink); max-width: 60ch; }
.metric-head__about { margin-top: 12px; max-width: 72ch; color: var(--ink-2); line-height: 1.65; }
.metric-head .chips { margin-top: 16px; }

.series-tabs {
  display: flex;
  gap: 24px;
  margin-top: 28px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
/* Tabs that do not fit scroll; the fade shows there is more (metric-page.js sets the class). */
.series-tabs.is-overflowing { mask-image: linear-gradient(90deg, #000 88%, transparent); }
/* What the open measure means, when it needs saying (e.g. PPP). */
.series-note { margin-top: 12px; max-width: 72ch; font-size: 0.875rem; line-height: 1.55; color: var(--ink-2); }
.series-tabs button {
  position: relative;
  flex-shrink: 0;
  padding: 0 0 12px;
  border: 0;
  background: none;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 150ms ease;
}
.series-tabs button:hover { color: var(--ink); }
.series-tabs button[aria-pressed="true"] { color: var(--ink); font-weight: 800; }
.series-tabs button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--gold);
  box-shadow: 0 0 10px rgb(255 215 0 / 0.5);
}

.chart-card { margin-top: 24px; padding: 20px 20px 18px; }
.chart-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.chart-card__title { font-weight: 700; font-size: 1.125rem; }
.chart-card__title span { color: var(--ink-3); font-weight: 600; }
.chart-card .source-line { margin-top: 6px; }
.chart-card .well { margin-top: 16px; }
.chart-card.is-loading .well { opacity: 0.55; transition: opacity 150ms ease; }

/* Save as image: a quiet button in the well's free corner. It shows on hover or focus, and stays faint on touch. */
.chart-save {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  opacity: 0.3;
  cursor: pointer;
  transition: opacity 150ms ease, color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}
.chart-card:hover .chart-save, .spotlight:hover .chart-save, .chart-save:focus-visible { opacity: 1; }
.chart-save:hover { color: var(--gold); border-color: var(--line-strong); background: rgb(23 25 27 / 0.9); }
.chart-save--inline { position: static; flex-shrink: 0; }
.chart-save:disabled { cursor: progress; }
.chart-save.is-busy svg { animation: chart-save-busy 900ms ease-in-out infinite alternate; }
@keyframes chart-save-busy { to { opacity: 0.3; } }
@media (hover: none) { .chart-save { opacity: 0.45; } }

/* Where the saved image's chart is drawn, out of sight. */
.chart-image-stage { position: fixed; left: -10000px; top: 0; pointer-events: none; }
/* The reel's preview (?reel=1 on a Politics page): the video frame over the page. */
.reel-stage { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: #000; cursor: pointer; }
/* As large as the window allows, in its own shape: tall for a reel, wide for &format=wide. */
.reel-stage canvas { max-width: 100vw; max-height: 100dvh; }
.chart-image-stage__well { position: relative; width: 100%; height: 100%; }

/* The map box keeps the projection's proportions, so the map fills it without stretching. */
.map-well { aspect-ratio: 1.54 / 1; max-height: 580px; }
.map-well--spotlight { aspect-ratio: 1.5 / 1; }
.line-well { height: clamp(320px, 36vw, 420px); }

.select {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--ink-3);
}
.select select {
  appearance: none;
  height: 36px;
  padding: 0 34px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--well) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23b6b9bd' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.select select:hover { border-color: var(--gold); }
.select select:focus-visible { box-shadow: var(--gold-glow); border-radius: 999px; }

.legend { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; margin-top: 14px; font-size: 0.8125rem; color: var(--ink-2); }
.legend__scale { display: grid; grid-template-columns: auto minmax(160px, 260px) auto; align-items: center; gap: 10px; }
.legend__bar { height: 10px; border-radius: 999px; }
.legend__ends { display: flex; justify-content: space-between; grid-column: 2; font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.legend__nodata { display: inline-flex; align-items: center; gap: 8px; }
.legend__nodata i { width: 14px; height: 10px; border-radius: 3px; background: #2a2c2f; box-shadow: inset 0 0 0 1px var(--line-strong); }

/* Country picker */
.picker { position: relative; }
.picker__button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  max-width: 320px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--well);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
}
.picker__button:hover { border-color: var(--gold); }
.picker__button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker__button svg { flex-shrink: 0; width: 10px; color: var(--ink-2); }
.picker__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: min(340px, calc(100vw - 2 * var(--gutter)));
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.55);
  transform-origin: top right;
  animation: pop 160ms var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(-4px); } }
@keyframes sheet { from { opacity: 0; transform: translateY(-8px); } }
/* On a phone the button wraps to the left, so the panel hangs from its left edge (js/lib/country-picker.js). */
.picker__panel.is-left { left: 0; right: auto; transform-origin: top left; }
.picker__search {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--well);
}
.picker__search:focus { outline: none; border-color: var(--gold); }
.picker__hint { padding: 8px 4px 4px; font-size: 0.75rem; color: var(--ink-3); }
.picker__list { max-height: 300px; margin: 4px 0 0; padding: 0; overflow-y: auto; list-style: none; }
.picker__option {
  display: grid;
  grid-template-columns: 18px auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 6px;
  font-size: 0.875rem;
  cursor: pointer;
}
.picker__option .flag { width: 24px; height: 18px; }
.picker__option.is-active { background: var(--raised); }
.picker__option[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.picker__check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
}
.picker__option[aria-selected="true"] .picker__check {
  border-color: var(--gold);
  background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='8' viewBox='0 0 10 8'%3E%3Cpath d='M1 4l3 3 5-6' fill='none' stroke='%23121416' stroke-width='1.8'/%3E%3C/svg%3E") no-repeat center;
}
.picker__option--world { border-bottom: 1px solid var(--line); border-radius: 6px 6px 0 0; margin-bottom: 4px; }

.series-keys { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.series-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--well);
  font-size: 0.8125rem;
}
.series-key__line { width: 14px; height: 2px; border-radius: 2px; }
.series-key__line--dashed { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; color: #c9ccd0; }
.series-key .flag { width: 20px; height: 15px; }
.series-key button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.series-key button:hover { background: var(--raised); color: var(--ink); }
.series-key button svg { width: 10px; height: 10px; }

.numbers { margin-top: 14px; }
.numbers summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.numbers summary::-webkit-details-marker { display: none; }
.numbers summary::before {
  content: "";
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 150ms var(--ease-out);
}
.numbers[open] summary::before { transform: rotate(45deg); }
.numbers summary:hover { color: var(--ink); }
.table-scroll { margin-top: 12px; max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.numbers table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.numbers th, .numbers td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.numbers th:first-child, .numbers td:first-child { text-align: left; font-family: var(--mono); color: var(--ink-3); }
.numbers thead th { position: sticky; top: 0; background: var(--card); color: var(--ink-2); font-weight: 600; }

.downloads { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; margin-top: 24px; }
.downloads p { font-size: 0.8125rem; color: var(--ink-3); }
.text-link { color: var(--ink-2); font-weight: 600; font-size: 0.875rem; text-decoration-color: var(--line-strong); }
.text-link:hover { color: var(--gold); text-decoration-color: var(--gold); }

/* Chart tooltip (ECharts renders it; these are its contents) */
.tip { font-family: var(--font); font-size: 0.8125rem; color: var(--ink); min-width: 160px; }
.tip__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 700; }
.tip__head img { width: 22px; height: 16px; border-radius: 2px; }
.tip__value { font-size: 1.125rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tip__muted { color: var(--ink-3); }
.tip__row { display: grid; grid-template-columns: 14px 18px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 2px 0; }
.tip__row i { width: 12px; height: 2px; border-radius: 2px; }
.tip__row img { width: 18px; height: 13px; border-radius: 2px; }
.tip__row strong { font-variant-numeric: tabular-nums; }
/* The Politics chart's comparison group: its dashed line, its name and its value, with no flag column. */
.tip__row--group { grid-template-columns: 14px minmax(0, 1fr) auto; }
.tip__row .tip__dash { height: 0; background: none; border-top: 2px dashed currentColor; border-radius: 0; }

/* Metric list (search results) */
.results-head h1 { font-weight: 700; font-stretch: var(--condensed); font-size: clamp(2.25rem, 4vw, 3rem); line-height: 1; letter-spacing: -0.02em; }
.results-head p { margin-top: 10px; color: var(--ink-2); }
.results-head .results-head__quip { margin-top: 12px; font-size: 1.25rem; color: var(--ink); }
.results-search { display: flex; gap: 10px; margin-top: 20px; max-width: 560px; }
.results-search .search__field { flex: 1; background: var(--card); border-color: var(--line-strong); }
.empty { padding: 32px; text-align: center; color: var(--ink-2); }

/* ---------- Posts ---------- */

.page-title { font-weight: 700; font-stretch: var(--condensed); font-size: clamp(2.5rem, 5vw, 3.5rem); line-height: 1; letter-spacing: -0.02em; }
.page-sub { margin-top: 10px; color: var(--ink-2); }

.post-list { display: flex; flex-direction: column; gap: 16px; margin: 28px 0 0; padding: 0; list-style: none; }
.post-row {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  padding: 16px;
  text-decoration: none;
  transition: border-color 150ms ease;
}
.post-row:hover { border-color: var(--gold); }
.post-row img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: left top; border-radius: 8px; background: var(--well); }
.post-row__body { display: flex; flex-direction: column; gap: 10px; padding-block: 4px; }
.post-row__title { font-weight: 700; font-size: 1.25rem; line-height: 1.25; }
.post-row__excerpt { color: var(--ink-2); font-size: 0.9375rem; }
.post-row__meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; font-size: 0.8125rem; color: var(--ink-3); }

.article { max-width: 760px; }
.article__meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-size: 0.875rem; color: var(--ink-3); }
.article h1 {
  margin-top: 14px;
  font-weight: 700;
  font-stretch: var(--condensed);
  font-size: clamp(2.25rem, 4.6vw, 3.25rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.article__cover { margin-top: 28px; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line); }

.prose { margin-top: 32px; font-size: 1.0625rem; line-height: 1.75; color: #d9dbde; }
.prose > * + * { margin-top: 1.15em; }
.prose h2 { margin-top: 2em; font-weight: 700; font-stretch: 85%; font-size: 1.625rem; line-height: 1.2; color: var(--ink); }
.prose h3 { margin-top: 1.7em; font-weight: 700; font-size: 1.25rem; color: var(--ink); }
.prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
.prose a { color: var(--gold); text-decoration-color: rgb(255 215 0 / 0.4); }
.prose a:hover { text-decoration-color: var(--gold); }
.prose strong { color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose code { font-family: var(--mono); font-size: 0.85em; padding: 2px 6px; border-radius: 4px; background: var(--well); border: 1px solid var(--line); }
.prose pre {
  margin-inline: 0;
  padding: 18px 20px;
  overflow-x: auto;
  border-radius: 10px;
  background: #0d0f10;
  border: 1px solid var(--line);
  font-size: 0.875rem;
  line-height: 1.65;
  tab-size: 4;
}
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; color: #e6e7e8; }
.prose figure { margin-inline: 0; }
.prose figure figure { margin: 0; }
.prose figure img { border-radius: 8px; border: 1px solid var(--line); }
.prose figcaption { margin-top: 8px; font-size: 0.8125rem; color: var(--ink-3); }
.prose figcaption br:first-child { display: none; }

.post-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 760px; margin-top: 56px; }
.post-nav a { display: flex; flex-direction: column; gap: 6px; padding: 18px; text-decoration: none; transition: border-color 150ms ease; }
.post-nav a:hover { border-color: var(--gold); }
.post-nav a span { font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.post-nav a strong { font-size: 1rem; line-height: 1.3; }
.post-nav__newer { grid-column: 2; text-align: right; }

/* ---------- Error pages ---------- */

.error-page { padding-block: 48px 24px; }
.error-page__code { font-family: var(--mono); font-size: 0.875rem; letter-spacing: 0.1em; color: var(--gold); }
.error-page .page-title { margin-top: 12px; }
.error-page .page-sub { max-width: 56ch; }

/* ---------- About the author + footer ---------- */

.about { margin-top: 72px; }
.about__card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px 28px;
  padding: 28px;
  position: relative;
  overflow: hidden;
}
.about__card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgb(255 215 0 / 0.6), transparent);
}
.about__photo { width: 96px; height: 96px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px rgb(255 215 0 / 0.55); }
.about h2 { font-weight: 700; font-stretch: var(--condensed); font-size: 1.625rem; line-height: 1.1; }
.about p { margin-top: 8px; max-width: 68ch; color: var(--ink-2); }
.about__links { display: flex; flex-direction: column; gap: 10px; }

.site-footer { margin-top: 40px; border-top: 1px solid var(--line); }
.site-footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; padding-block: 28px 40px; }
.site-footer__brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.site-footer__brand img { width: 28px; height: 28px; }
.site-footer nav { display: flex; gap: 20px; flex-wrap: wrap; font-size: 0.875rem; }
.site-footer nav a { color: var(--ink-2); text-decoration: none; }
.site-footer nav a:hover { color: var(--gold); }
.site-footer__soon { color: var(--ink-3); }
.site-footer__credit { width: 100%; font-size: 0.8125rem; color: var(--ink-3); }
.site-footer__credit a { color: var(--ink-2); }


/* Small notes in rail cards; market card head and the "all metrics" card. */
.rail-note { margin-top: 12px; font-size: 0.8125rem; color: var(--ink-3); }
.rail-note--top { margin-top: 10px; }
.rail-note strong { color: var(--ink); }
.chips { margin: 0; padding: 0; list-style: none; }
.market__head { display: flex; align-items: flex-start; gap: 12px; }
.market__head .market__title { margin-top: 4px; }
.market--more { justify-content: space-between; gap: 12px; text-decoration: none; border-style: dashed; transition: border-color 150ms ease; }
.market--more:hover { border-color: var(--gold); }
.market--more .market__title { margin-top: 0; }
.market__note { color: var(--ink-2); font-size: 0.9375rem; }
.market--more .market__foot { align-items: center; color: var(--gold); font-weight: 700; }
.results-grid { margin-top: 32px; }
.post-card .chips { flex-wrap: wrap; }

/* ---------- Politics mode ---------- */

/* A party's logo sits on a light tile: many logos have black lettering that would vanish on the dark ground. */
.party-chip {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 3px;
  border-radius: 8px;
  background: #f2f3f4;
  flex-shrink: 0;
}
.party-logo { width: 100%; height: 100%; object-fit: contain; }
.party-badge {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  background: var(--party, #999999);
  color: #121416;
  font-family: var(--mono);
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.party-badge--none { background: transparent; border: 1px dashed #8b8f94; color: #5a5e63; font-size: 0.75rem; }

.country-card { display: flex; flex-direction: column; gap: 18px; padding: 22px; text-decoration: none; transition: border-color 150ms ease; }
.country-card:hover { border-color: var(--gold); }
.country-card__head { display: flex; align-items: center; gap: 14px; }
.country-card__flag { width: 52px; height: 52px; }
.country-card__name { display: block; font-weight: 700; font-stretch: var(--condensed); font-size: 1.625rem; line-height: 1.05; letter-spacing: -0.01em; }
.country-card__meta { display: block; margin-top: 4px; font-size: 0.8125rem; color: var(--ink-3); }
.country-card__current { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--well); font-size: 0.9375rem; line-height: 1.3; }
.country-card__current strong { display: block; }
.country-card__label { display: block; font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.country-card--soon { justify-content: center; gap: 8px; border-style: dashed; background: transparent; }
.country-card--soon .country-card__name { font-size: 1.25rem; color: var(--ink-2); }
.country-card--soon .country-card__meta { max-width: 34ch; line-height: 1.5; }
.country-card__cta { display: flex; align-items: center; gap: 6px; margin-top: auto; color: var(--gold); font-weight: 700; font-size: 0.875rem; }
.country-card__cta svg { transition: transform 150ms var(--ease-out); }
.country-card:hover .country-card__cta svg { transform: translateX(3px); }

.pol-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px 22px; margin-top: 18px; }
.pol-head__flag { width: 68px; height: 68px; box-shadow: 0 0 0 1px var(--line-strong), 0 0 28px rgb(255 215 0 / 0.12); }
.pol-head h1 { font-weight: 700; font-stretch: var(--condensed); font-size: clamp(2.5rem, 5vw, 3.75rem); line-height: 0.95; letter-spacing: -0.02em; }
.pol-head p { margin-top: 8px; color: var(--ink-2); }
.pol-head__current {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 12px;
  margin: 0;
  padding: 10px 18px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 0.875rem;
  color: var(--ink-2);
}
.pol-head__current .party-chip { grid-row: span 2; width: 40px; height: 40px; }
.pol-head__current strong { color: var(--ink); }

/* Metrics: categories as big tabs, the metrics of the open category as pills under them. */
.pol-picker { margin-top: 36px; }
/* Sideways only: the underline pokes 1px out, and without overflow-y the row also scrolls up and down on phones. */
.pol-cats { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.pol-cats.is-overflowing { mask-image: linear-gradient(90deg, #000 calc(100% - 80px), transparent); }
.pol-cats.is-scrolled { mask-image: linear-gradient(90deg, transparent, #000 80px); }
.pol-cats.is-scrolled.is-overflowing { mask-image: linear-gradient(90deg, transparent, #000 80px, #000 calc(100% - 80px), transparent); }
/* Arrows over the ends of the category tabs, while tabs hide past that end. Touch screens swipe instead. */
.pol-cats-wrap { position: relative; }
.pol-cats__arrow { position: absolute; top: 7px; z-index: 2; width: 32px; height: 32px; background: var(--bg); }
.pol-cats__arrow--prev { left: 0; }
.pol-cats__arrow--next { right: 0; }
.pol-cats__arrow[hidden] { display: none; }
@media (pointer: coarse) { .pol-cats__arrow { display: none; } }
.pol-cat {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 8px 14px 14px;
  color: var(--ink-3);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: color 150ms ease;
}
.pol-cat:first-child { padding-left: 2px; }
.pol-cat:hover { color: var(--ink); }
.pol-cat[aria-current="true"] { color: var(--ink); }
.pol-cat[aria-current="true"] svg { color: var(--gold); }
.pol-cat[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--gold);
  box-shadow: 0 0 10px rgb(255 215 0 / 0.5);
}
.pol-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pol-metric {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}
.pol-metric:hover { border-color: var(--ink-3); color: var(--ink); }
.pol-metric[aria-current="page"] { border-color: var(--gold); background: var(--gold-wash); color: var(--ink); box-shadow: 0 0 14px rgb(255 215 0 / 0.16); }

.pol-chart { margin-top: 20px; }
/* A measure without data for the country shows its message alone (politics-page.js, showEmpty). */
.pol-chart.is-empty :is(.year-slicer, .pol-chart__note, .timeline-bar, .timeline, .ranking, .timeline__note, .numbers, .term-well .chart-save) { display: none; }
.chart-card__title .chart-card__name { color: var(--ink); font-weight: 700; }
.pol-chart__summary { margin-top: 6px; max-width: 72ch; color: var(--ink-2); }
.pol-chart .series-tabs { margin-top: 18px; }
.pol-chart__note { margin-top: 12px; max-width: 90ch; font-size: 0.8125rem; color: var(--ink-3); }
.pol-chart__tools { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
/* The dropdown's swatch: the group's dashed line, as a legend for it. */
.compare-select__line { width: 22px; height: 0; border-top: 2px dashed #c9ccd0; }
.compare-select { white-space: nowrap; }
.compare-select[data-none] .compare-select__line { opacity: 0.3; }
/* The year slider: one window of years for the chart and every list under it. Quiet: a thin track, small handles. */
/* A chart spanning under two years has no window to pick (metric-page.js). */
.year-slicer[hidden] { display: none; }
.year-slicer {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 0 4px;
}
.year-slicer__label { font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.year-slicer__year { min-width: 2.6em; font-family: var(--mono); font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }
/* A handle's centre travels from half a handle in to half a handle short of the end, so the drawn track spans that.
   --from and --to are the window's ends, from 0 to 1 of the years (js/lib/year-slicer.js). */
.year-slicer__track { --from: 0; --to: 1; --thumb: 16px; position: relative; height: 28px; }
.year-slicer__track::before, .year-slicer__track::after {
  content: "";
  position: absolute;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  pointer-events: none;
}
.year-slicer__track::before { left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); background: var(--line-strong); }
.year-slicer__track::after {
  left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--from));
  right: calc(var(--thumb) / 2 + (100% - var(--thumb)) * (1 - var(--to)));
  background: rgb(255 215 0 / 0.7);
}
/* Two range inputs share the track; only their handles take the pointer, so both stay draggable. */
.year-slicer__track input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 28px;
  margin: 0;
  background: none;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
}
.year-slicer__track input::-webkit-slider-runnable-track { height: 28px; background: none; }
.year-slicer__track input::-moz-range-track { background: none; }
/* A 12 px gold dot in a 2 px ring; on touch screens a transparent border grows the part a finger can catch to 28 px. */
.year-slicer__track input::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  margin-top: 6px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--gold) padding-box;
  cursor: grab;
  pointer-events: auto;
}
.year-slicer__track input::-moz-range-thumb {
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--gold) padding-box;
  cursor: grab;
  pointer-events: auto;
}
@media (pointer: coarse) {
  .year-slicer__track { --thumb: 28px; }
  .year-slicer__track input::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: 0; border: 7px solid transparent; }
  .year-slicer__track input::-moz-range-thumb { width: 28px; height: 28px; border: 7px solid transparent; }
}
.year-slicer__track input:active::-webkit-slider-thumb { cursor: grabbing; }
.year-slicer__track input:active::-moz-range-thumb { cursor: grabbing; }
.year-slicer__track input:focus-visible { box-shadow: none; }
.year-slicer__track input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgb(255 215 0 / 0.35); }
.year-slicer__track input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px rgb(255 215 0 / 0.35); }

.timeline-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.timeline-bar .series-tabs { flex: 1; margin-top: 0; }
.pol-credits { margin-top: 18px; }
.term-well { height: clamp(380px, 42vw, 520px); }
.term-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; color: var(--ink-3); text-align: center; z-index: 1; }

/* ---------- The party compass (templates/politics/compass.html, static/js/lib/compass.js) ---------- */
.compass-well { height: min(720px, max(340px, 90vw)); overflow: hidden; }
.compass-canvas { position: absolute; inset: 0; display: block; touch-action: manipulation; }
/* The tooltip beside a logo: the party, its two numbers on their scales, and how Wikipedia describes it. */
.compass-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  width: min(300px, calc(100% - 16px));
  padding: 14px 16px;
  background: rgb(23 25 27 / 0.97);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.55);
  font-size: 0.8125rem;
  animation: pop 160ms var(--ease-out);
  /* While it only follows the pointer it takes no pointer itself, so it can never flicker over the logo; pinned, its link works. */
  pointer-events: none;
}
.compass-tip.is-pinned { pointer-events: auto; }
.compass-stage { position: relative; }
/* With no room beside the logo, the tooltip takes its place under the chart, the width of the card. */
.compass-tip.is-docked { position: static; width: auto; margin-top: 12px; box-shadow: none; }
.compass-tip__inferred { margin-top: 10px; padding: 8px 10px; border: 1px dashed rgb(255 215 0 / 0.5); border-radius: 8px; color: var(--ink-2); }
.compass-inferred { padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 8px; }
.compass-inferred strong { color: var(--ink); }
.compass-tip__head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.compass-tip__head .party-chip { width: 44px; height: 44px; }
.compass-tip__head strong { display: block; font-size: 1rem; }
.compass-tip__head span { color: var(--ink-2); }
.compass-tip__note { margin-top: 8px; color: var(--ink-3); }
.compass-tip__axes { display: grid; gap: 10px; margin: 12px 0 0; }
.compass-tip__axes div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 10px; }
.compass-tip__axes dt { font-family: var(--mono); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.compass-tip__axes dd { display: contents; }
.compass-tip__axes strong { font-family: var(--mono); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.compass-tip__scale { grid-column: 1 / -1; position: relative; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--line-strong); }
.compass-tip__scale i { position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 2px var(--card); }
.compass-tip__ends { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: 0.6875rem; color: var(--ink-3); }
.compass-tip__views { margin-top: 12px; color: var(--ink-2); }
.compass-tip__views strong { color: var(--ink); }
.compass-tip__meta { margin-top: 8px; color: var(--ink-3); }
.compass-tip__meta a { color: var(--ink-2); }
.compass-tip__meta a:hover { color: var(--gold); }
/* A party's logo in the picker, on the light tile every logo sits on. */
.picker__logo { width: 34px; height: 24px; padding: 2px 3px; border-radius: 5px; background: #f2f3f4; object-fit: contain; }
.compass-notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 24px; }
.compass-note { padding: 22px 24px; }
.compass-note h2 { font-weight: 700; font-size: 1.125rem; }
.compass-note p { margin-top: 10px; max-width: 68ch; color: var(--ink-2); }
.compass-limits { display: grid; gap: 10px; margin: 12px 0 0; padding-left: 1.1em; color: var(--ink-2); }
.compass-limits strong { color: var(--ink); }
/* ---------- The seats in Congress (templates/politics/_congress.html, static/js/lib/hemicycle.js) ---------- */
.congress-body { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 20px; align-items: start; margin-top: 16px; }
.congress-well { height: clamp(260px, 34vw, 440px); }
.congress-canvas { position: absolute; inset: 0; display: block; }
.seat-list { display: grid; margin: 0; padding: 0; list-style: none; max-height: 440px; overflow-y: auto; }
.seat-row {
  display: grid;
  grid-template-columns: 4px auto minmax(0, 1fr) auto 3.4rem;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background-color 150ms ease;
}
.seat-row.is-lit, .seat-row:hover { background: var(--raised); }
.seat-row .party-badge--small { font-size: 0.5rem; letter-spacing: -0.04em; }
.seat-row__swatch { width: 4px; height: 26px; border-radius: 2px; background: var(--party); }
.seat-row__name { display: grid; min-width: 0; }
.seat-row__name strong { font-size: 0.9375rem; }
.seat-row__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; color: var(--ink-3); }
.seat-row__seats { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.seat-row__share { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
/* By bloc: each bloc heads its parties, with a rule above every bloc but the first. */
.seat-bloc { grid-template-columns: 4px minmax(0, 1fr) auto 3.4rem; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); border-radius: 0; }
.seat-bloc:first-child { margin-top: 0; padding-top: 6px; border-top: 0; }
.seat-bloc .seat-row__swatch { height: 34px; }
.seat-bloc .seat-row__name strong { font-size: 1.0625rem; font-weight: 800; }
.seat-bloc .seat-row__seats { font-size: 1.0625rem; }
.congress-card .series-tabs { margin-top: 14px; }

/* The labels over the chart (static/js/lib/term-chart.js places them). */
.term-labels { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 200ms ease; }
.term-labels.is-shown { opacity: 1; }
.term-label, .term-dot, .term-stem { position: absolute; left: 0; top: 0; }
.term-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgb(23 25 27 / 0.94);
  box-shadow: inset -3px 0 0 var(--party), 0 6px 18px rgb(0 0 0 / 0.35);
  font-size: 0.75rem;
  line-height: 1.25;
  white-space: nowrap;
}
.term-label .party-chip { width: 32px; height: 32px; padding: 2px; border-radius: 7px; }
.term-label__text { display: flex; flex-direction: column; gap: 3px; }
.term-label.is-compact .term-label__full, .term-label.is-mini .term-label__full, .term-label.is-mini .term-label__kicker { display: none; }
.term-label.is-mini { padding-block: 3px; }
.term-label.is-mini .party-chip { width: 26px; height: 26px; }
.term-label__kicker { color: var(--ink-3); font-size: 0.6875rem; }
.term-label__kicker strong { color: var(--ink); font-size: 0.75rem; font-weight: 700; }
.term-label__row { display: flex; align-items: center; gap: 8px; }
.term-label__value { font-family: var(--mono); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.term-dot { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 2px var(--well); }
.term-stem { width: 1px; background: var(--party); opacity: 0.75; }

/* The change during a presidency: green when good for the metric, red when bad, grey when neither. */
.trend { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 0.75rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.trend svg { width: 16px; height: 16px; flex-shrink: 0; }
.trend--good { color: var(--good); }
.trend--bad { color: var(--bad); }

/* The presidents with data, newest first. The rail between the years and the logos takes each party's colour,
   like the line above, and the dot marks the presidency. */
.timeline { margin: 18px 0 0; padding: 0; list-style: none; }
.term-row {
  display: grid;
  grid-template-columns: 6.25rem 20px auto minmax(0, 1fr) auto 8rem 6.5rem;
  align-items: center;
  gap: 0 14px;
  width: 100%;
  min-height: 56px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}
.term-row:hover { background: var(--raised); }
.term-row[aria-pressed="true"] { border-color: var(--gold); background: var(--raised); box-shadow: 0 0 14px rgb(255 215 0 / 0.16); }
.term-row__years { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); text-align: right; white-space: nowrap; }
.term-row__rail { position: relative; align-self: stretch; }
.term-row__rail::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  bottom: -7px;
  width: 2px;
  margin-left: -1px;
  background: var(--party);
  opacity: 0.6;
}
.timeline li:first-child .term-row__rail::before { top: 50%; }
.timeline li:last-child .term-row__rail::before { bottom: 50%; }
.term-row__rail::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--party);
  box-shadow: 0 0 0 3px var(--card);
}
.term-row.is-current .term-row__rail::after { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--party); }
.term-row__logos { display: flex; }
.term-row__logos .party-chip { width: 32px; height: 32px; padding: 2px; border-radius: 7px; }
.term-row__logos .party-chip + .party-chip { margin-left: -8px; box-shadow: 0 0 0 2px var(--card); }
.term-row__who { min-width: 0; }
.term-row__who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9375rem; font-weight: 700; }
.term-row__who > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-3); }
.term-row__when { display: none; }
.term-row__values { font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.term-row .trend { font-size: 0.8125rem; }
.term-row__change { justify-self: end; display: grid; justify-items: end; gap: 3px; }
/* The comparison group's change: small and grey, so the term's own change leads. */
.term-row__compare { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-3); }
.term-row .term-row__compare .trend { font-size: 0.6875rem; font-weight: 600; }
.term-row__compare .trend svg { width: 13px; height: 13px; }
/* The change as a data bar on one axis shared by every row: the axis runs down the list like the rail. */
.term-row__bar { position: relative; align-self: stretch; }
.term-row__bar::before {
  content: "";
  position: absolute;
  left: var(--axis);
  top: -7px;
  bottom: -7px;
  width: 1px;
  background: var(--line-strong);
}
.timeline li:first-child .term-row__bar::before { top: 6px; }
.timeline li:last-child .term-row__bar::before { bottom: 6px; }
.ranking__list li:first-child .term-row__bar::before { top: 6px; }
.ranking__list li:last-child .term-row__bar::before { bottom: 6px; }
.term-row__fill { position: absolute; top: 50%; min-width: 2px; height: 10px; margin-top: -5px; border-radius: 3px; opacity: 0.8; }
.term-row__fill--good { background: var(--good); }
.term-row__fill--bad { background: var(--bad); }
.term-row__fill--neutral { background: var(--ink-3); }
/* The rankings: the changes added up by party or by president, best first. */
.ranking { margin-top: 18px; }
.ranking__list { margin: 0; padding: 0; list-style: none; }
.group-row {
  display: grid;
  grid-template-columns: 1.5rem auto minmax(0, 1fr) 8rem 6.5rem 6.5rem;
  align-items: center;
  gap: 0 14px;
  min-height: 56px;
  padding: 6px 12px;
}
.group-head {
  min-height: 0;
  padding-block: 0 6px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.group-head span:nth-child(n + 5) { text-align: right; }
.group-row__rank { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); text-align: right; }
.group-row__who { min-width: 0; }
.group-row__name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row__name strong { font-size: 0.9375rem; font-weight: 700; }
.group-row__name em { margin-left: 6px; font-family: var(--mono); font-size: 0.6875rem; font-style: normal; color: var(--ink-3); }
.group-row__who > span:not(.group-row__name) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-3); }
.group-row__change { justify-self: end; }
.group-row .trend { font-size: 0.8125rem; }
.timeline__note { margin-top: 10px; padding-left: calc(6.25rem + 46px); font-size: 0.8125rem; color: var(--ink-3); }
.ranking .timeline__note, .ranking:not([hidden]) ~ .timeline__note { padding-left: 12px; }

.tip__who { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.tip__who .party-chip { width: 26px; height: 26px; padding: 2px; border-radius: 6px; }
.tip__who em { margin-left: 6px; font-style: normal; color: var(--ink-3); }

/* ---------- Narrow screens ---------- */

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .layout__rail { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .compass-notes { grid-template-columns: minmax(0, 1fr); }
  .congress-body { grid-template-columns: minmax(0, 1fr); }
  .congress-well { height: clamp(200px, 52vw, 380px); }
  .seat-list { max-height: none; }
  .bar { gap: 16px; height: 60px; }
  /* Phones and small tablets: the menu button opens the navigation as a panel under the bar, the categories first. */
  .nav { display: none; }
  .bar .nav-toggle { display: grid; flex-shrink: 0; width: 44px; height: 44px; margin-left: -6px; }
  .nav-toggle__close, .site-header.is-nav-open .nav-toggle__open { display: none; }
  .site-header.is-nav-open .nav-toggle__close { display: contents; }
  .site-header.is-nav-open .nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: calc(100dvh - 60px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px var(--gutter) 22px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 24px 40px rgb(0 0 0 / 0.5);
    animation: sheet 220ms var(--ease-out);
  }
  .site-header.is-nav-open .menu__button { display: none; }
  .site-header.is-nav-open .menu__panel {
    display: block;
    position: static;
    width: auto;
    padding: 0 0 8px;
    background: none;
    border: 0;
    box-shadow: none;
    animation: none;
  }
  .site-header.is-nav-open .menu__heading {
    display: block;
    margin: 0 0 6px;
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
  }
  .site-header.is-nav-open .menu__item { min-height: 44px; padding: 0 6px; }
  .site-header.is-nav-open .nav > .nav__link { min-height: 48px; border-top: 1px solid var(--line); font-size: 0.875rem; }
    .search { flex: 1; }
  .slide__body { grid-template-columns: minmax(0, 1fr); }
  .trust { grid-template-columns: minmax(0, 1fr); }
  .post-cards { grid-template-columns: minmax(0, 1fr); }
  .about__card { grid-template-columns: auto minmax(0, 1fr); }
  .about__links { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .pol-head { grid-template-columns: auto minmax(0, 1fr); }
  .pol-head__current { grid-column: 1 / -1; justify-self: start; }
}

@media (max-width: 640px) {
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  /* The wordmark stays; search folds into a round button that opens across the bar. The languages move into the menu. */
  .bar { position: relative; gap: 10px; }
  .wordmark span { font-size: 1rem; }
  .search { flex: 0 0 44px; margin-left: auto; }
  .bar__langs { display: none; }
  .site-header.is-nav-open .bar .nav__langs { display: flex; gap: 6px; margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
  .nav__langs a { min-width: 44px; height: 40px; border: 1px solid var(--line-strong); }
  .search__field { position: relative; width: 44px; height: 44px; padding: 0; justify-content: center; }
  .search__field input { position: absolute; inset: 0; opacity: 0; }
  .search:focus-within { position: absolute; left: var(--gutter); right: var(--gutter); top: 8px; z-index: 5; }
  .search:focus-within .search__field { width: 100%; padding: 0 16px; justify-content: flex-start; background: var(--raised); }
  .search:focus-within .search__field input { position: static; opacity: 1; }
  .layout__rail { grid-template-columns: minmax(0, 1fr); }
  .spotlight { padding: 18px; }
  .post-row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .post-nav { grid-template-columns: minmax(0, 1fr); }
  .post-nav__newer { grid-column: 1; text-align: left; }
  .about__card { grid-template-columns: minmax(0, 1fr); padding: 22px; }
  .about__photo { width: 80px; height: 80px; }
  .chart-card { padding: 16px 14px; }
  .pol-head__flag { width: 52px; height: 52px; }
  .term-well { height: 400px; }
  /* Phones: the years move under the name, so the name keeps its room. */
  .term-row { grid-template-columns: 16px auto minmax(0, 1fr) 3rem auto; gap: 0 10px; padding-inline: 4px 8px; }
  .term-row__years, .term-row__values { display: none; }
  .group-row { grid-template-columns: 1.25rem auto minmax(0, 1fr) auto auto; gap: 0 10px; padding-inline: 4px 8px; }
  .group-row .term-row__bar, .group-head span:nth-child(4) { display: none; }
  /* "No change" is words, not a number: on a phone it may wrap, so the names keep their room. */
  .group-row .trend--none { max-width: 5rem; white-space: normal; text-align: right; }
  .year-slicer { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
  .year-slicer__label { display: none; }
  .term-row__when { display: inline; }
  .timeline__note { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .chart-save.is-busy svg { animation: none; }
  .spin { animation: none; }
  .slide.is-entering, .picker__panel, .menu.is-open .menu__panel, .site-header.is-nav-open .nav { animation: none; }
  .button:active, .round-btn:active { transform: none; }
}


/* ---------- Conflicts: World War II ---------- */

.section-title { font-weight: 700; font-stretch: var(--condensed); font-size: 1.75rem; line-height: 1.1; letter-spacing: -0.01em; }
.chart-note { max-width: 82ch; margin-top: 14px; font-size: 0.8125rem; line-height: 1.6; color: var(--ink-3); }

.war-head { margin-top: 14px; }
.war-head h1 { font-weight: 700; font-stretch: var(--condensed); font-size: clamp(2.5rem, 5vw, 3.5rem); line-height: 1; letter-spacing: -0.02em; }
.war-head__years { margin-top: 8px; font-family: var(--mono); font-size: 0.8125rem; letter-spacing: 0.06em; color: var(--ink-3); }
.war-head__lead { margin-top: 14px; max-width: 62ch; font-size: 1.125rem; line-height: 1.6; color: var(--ink-2); }
.war-head__credit { margin-top: 10px; font-size: 0.875rem; color: var(--ink-3); }
.war-head__credit a, .war-sources a { color: var(--ink-2); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.war-head__credit a:hover, .war-sources a:hover { color: var(--gold); text-decoration-color: var(--gold); }
.war-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.war-jump a {
  display: inline-flex; align-items: center; height: 32px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  color: var(--ink-2); font-size: 0.8125rem; font-weight: 600; text-decoration: none;
  transition: color 150ms ease, border-color 150ms ease;
}
.war-jump a:hover { color: var(--gold); border-color: var(--gold); }

/* Casualties by country: a chart card like the metrics pages', with the parts to show as checkable pills. */
.war-card { position: relative; margin-top: 40px; scroll-margin-top: 80px; }
.war-card__summary { margin-top: 8px; max-width: 72ch; font-size: 0.9375rem; color: var(--ink-2); }
.toggle-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 10px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: transparent;
  color: var(--ink-2); font: 600 0.8125rem var(--font); cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}
.toggle i { width: 12px; height: 12px; border-radius: 3px; opacity: 0.35; transition: opacity 150ms ease; }
.toggle:hover { color: var(--ink); border-color: var(--gold); }
.toggle:active { transform: scale(0.97); }
.toggle:focus-visible { outline: none; box-shadow: var(--gold-glow); }
.toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--gold); background: var(--gold-wash); }
.toggle[aria-pressed="true"] i { opacity: 1; }
.toggle-group__key { display: inline-flex; align-items: center; gap: 8px; margin-left: 4px; font-size: 0.8125rem; color: var(--ink-3); }
.toggle-group__key i { width: 12px; height: 12px; border-radius: 3px; background: rgb(182 185 189 / 0.3); }
.casualties-well { height: clamp(320px, 38vw, 440px); }
.war-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--ink-3); }

/* Tooltips drawn by the World War II charts, over their canvas. */
.tooltip-layer {
  position: absolute; top: 0; left: 0; z-index: 4; max-width: 300px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.5); pointer-events: none;
}
.tip__title { margin-bottom: 2px; font-size: 0.9375rem; font-weight: 700; }
.tip__line { display: flex; justify-content: space-between; gap: 18px; padding-top: 3px; color: var(--ink-2); }
.tip__line strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.tip__side { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; margin-top: 8px; }
.tip__side i { width: 10px; height: 10px; border-radius: 50%; }
.tip__side strong { font-variant-numeric: tabular-nums; }
.tip__flags { display: flex; flex-wrap: wrap; gap: 4px; }
.tip__flags img, .tip__ruler img { width: 20px; height: 15px; border-radius: 3px; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.08); }
.tip__ruler { display: inline-flex; align-items: center; gap: 6px; margin-left: 4px; color: var(--ink-3); font-weight: 500; }
.tip--battle { min-width: 220px; }
.tip--battle > .tip__muted:last-child { margin-top: 8px; font-size: 0.75rem; }

.table-scroll--tall { max-height: 520px; }
.war-table th[scope="row"] { font-family: var(--font); color: var(--ink); text-align: left; font-weight: 600; }
.war-table__state { display: inline-flex; align-items: center; gap: 8px; }
.war-table__state .flag { width: 20px; height: 15px; }
.war-table__note { display: block; max-width: 34ch; font-size: 0.75rem; font-weight: 400; line-height: 1.4; white-space: normal; color: var(--ink-3); }
.war-table td strong { color: var(--ink); }

/* Battles: the map, its legend and the war's timeline in one card. */
.war-views { margin: 0; border: 0; }
.war-well { overflow: hidden; }
.war-map { display: block; width: 100%; aspect-ratio: 1.9 / 1; max-height: 640px; touch-action: pan-y; }
.war-well.is-zoomed .war-map { cursor: grab; touch-action: none; }
.war-well.is-zoomed .war-map:active { cursor: grabbing; }
.war-caption {
  position: absolute; top: 14px; left: 14px; max-width: min(420px, 72%); padding: 8px 12px;
  background: rgb(23 25 27 / 0.92); border: 1px solid var(--line-strong); border-radius: 10px;
  font-size: 0.875rem; font-weight: 600; color: var(--ink);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.war-caption time { display: block; margin-bottom: 2px; font-family: var(--mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.war-caption.is-shown { opacity: 1; transform: none; }
.war-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 0.8125rem; color: var(--ink-2); }
.war-legend li { display: inline-flex; align-items: center; gap: 8px; }
.war-legend__swatch { width: 16px; height: 11px; border-radius: 3px; }
.war-legend__swatch--allies { background: #264060; box-shadow: inset 0 0 0 1px #3987e5; }
.war-legend__swatch--axis { background: #6c3723; box-shadow: inset 0 0 0 1px #d95926; }
.war-legend__swatch--none { background: #2a2c2f; box-shadow: inset 0 0 0 1px var(--line-strong); }
.war-legend__dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 1.5px var(--well), 0 0 0 2.5px rgb(242 243 244 / 0.45); }
.war-legend__dot + .war-legend__dot { margin-left: 4px; }
.war-legend__dot:last-of-type { margin-right: 4px; }
.war-map.is-over-battle { cursor: pointer; }
.war-reset { position: absolute; right: 14px; bottom: 14px; display: none; }
.war-well.is-zoomed .war-reset { display: inline-flex; align-items: center; }
/* A pinned card stays while the pointer leaves; its link can then be pressed. */
.tooltip-layer.is-pinned { pointer-events: auto; }
.tip__picture { display: block; width: 100%; max-height: 150px; margin: -2px 0 8px; object-fit: cover; border-radius: 6px; }
.tip--large { width: 340px; }
.tip--large .tip__picture { max-height: 255px; }
.tooltip-layer:has(.tip--large) { max-width: 364px; }
.tip__credit { margin: -4px 0 8px; font-size: 0.6875rem; color: var(--ink-3); }
.tip__link { display: inline-block; margin-top: 8px; color: var(--gold); font-weight: 600; text-decoration: none; }
.tip__link:hover { text-decoration: underline; }

.war-timeline { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.war-timeline__bar { display: flex; align-items: center; gap: 14px; }
.play-button {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: var(--gold); color: var(--bg); cursor: pointer;
  transition: background-color 150ms ease, transform 120ms var(--ease-out);
}
.play-button:hover { background: var(--gold-hover); }
.play-button:active { transform: scale(0.94); }
.play-button:focus-visible { outline: none; box-shadow: var(--gold-glow); }
.play-button svg { fill: currentColor; }
.play-button__play svg { margin-left: 2px; }
.play-button__pause, .play-button.is-playing .play-button__play { display: none; }
.play-button.is-playing .play-button__pause { display: grid; }
.war-timeline__date { min-width: 11ch; font-family: var(--mono); font-size: 1.25rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.war-timeline__date.is-whole { font-size: 1rem; font-weight: 500; color: var(--ink-2); }
.war-timeline__hint { margin-left: auto; font-size: 0.75rem; color: var(--ink-3); }
.war-timeline__key { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 0.75rem; color: var(--ink-3); }
.war-timeline__key li { display: inline-flex; align-items: center; gap: 7px; }
.war-timeline__key i { width: 16px; height: 6px; border-radius: 3px; }
.war-timeline__scroll { position: relative; margin-top: 12px; }
.war-timeline__track { position: relative; cursor: pointer; touch-action: pan-y; border-radius: 8px; user-select: none; }
.war-timeline__track:focus-visible { outline: none; box-shadow: var(--gold-glow); }
.war-timeline__svg { display: block; overflow: visible; }
.war-timeline__year { font-family: var(--mono); font-size: 11px; fill: var(--ink-3); }
.war-timeline__year-line { stroke: rgb(255 255 255 / 0.05); }
.war-timeline__lane { font-family: var(--font); font-size: 11px; font-weight: 600; fill: var(--ink-3); paint-order: stroke; stroke: var(--card); stroke-width: 3px; }
.war-timeline__rule { stroke: var(--line); }
.war-timeline__bar { opacity: 0.8; transition: opacity 150ms ease; }
.war-timeline__bar.is-future { opacity: 0.16; }
.war-timeline__bar.is-now, .war-timeline__bar.is-lit { opacity: 1; stroke: var(--ink); stroke-width: 1; }
.war-timeline__head { position: absolute; top: -6px; bottom: 18px; left: 0; width: 2px; margin-left: -1px; background: var(--gold); box-shadow: 0 0 10px rgb(255 215 0 / 0.45); pointer-events: none; }
.war-timeline__head::before { content: ""; position: absolute; top: -4px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }

.war-sources { margin-top: 56px; scroll-margin-top: 80px; }
.war-sources__list { margin: 14px 0 0; padding: 0; list-style: none; max-width: 90ch; }
.war-sources__list li { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 0.875rem; line-height: 1.6; color: var(--ink-2); }

/* Battle by battle: the Politics timeline's rows, with flags for logos and two casualty bars on one scale. */
.battle-list .term-row--battle, .battle-head { grid-template-columns: 8.5rem 20px 56px minmax(0, 1fr) auto 32px 6.5rem 24px; cursor: default; }
.battle-row__pie { width: 28px; height: 28px; border-radius: 50%; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--line-strong); }
.battle-head { margin-top: 18px; }
.battle-list .term-row--battle.is-lit { background: var(--raised); }
.battle-list .term-row--event { grid-template-columns: 8.5rem 20px minmax(0, 1fr) 24px; cursor: default; }
.battle-row__picture { display: block; width: 56px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--well); }
.battle-row__picture--none { box-shadow: inset 0 0 0 1px var(--line); }
.battle-row__name {
  display: block; max-width: 100%; padding: 0; border: 0; background: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink); font: 700 0.9375rem var(--font); text-align: left; cursor: pointer; text-decoration-color: transparent;
  transition: color 150ms ease;
}
.battle-row__name:hover { color: var(--gold); }
.battle-row__name:focus-visible { outline: none; box-shadow: var(--gold-glow); border-radius: 4px; }
.battle-row__name[aria-pressed="true"] { color: var(--gold); }
.battle-row__sides { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.battle-row__sides > span { display: flex; align-items: center; }
.battle-row__sides .flag { width: 18px; height: 13.5px; }
.battle-row__theatre { font-family: var(--mono); font-size: 0.6875rem; color: var(--ink-3); white-space: nowrap; }
.battle-row__link {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line-strong); border-radius: 50%;
  color: var(--ink-2); font: 700 0.75rem serif; text-decoration: none; transition: color 150ms ease, border-color 150ms ease;
}
.battle-row__link:hover { color: var(--gold); border-color: var(--gold); }
.battle-row__sides .flag + .flag, .battle-row__sides .flag + .battle-row__more { margin-left: -5px; box-shadow: 0 0 0 2px var(--card); }
.battle-row__more { display: inline-grid; place-items: center; width: 18px; height: 13.5px; border-radius: 3px; background: var(--pill); font: 600 0.625rem var(--mono); font-style: normal; color: var(--ink-2); }
.battle-row__values { display: grid; gap: 3px; font-family: var(--mono); font-size: 0.75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.battle-row__values span { display: inline-flex; align-items: center; gap: 6px; }
.battle-row__values i { width: 8px; height: 8px; border-radius: 50%; }
.battle-row__result { justify-self: end; font-family: var(--mono); font-size: 0.6875rem; text-align: right; color: var(--ink-3); }
.term-row--battle[aria-pressed="true"] .battle-row__result { color: var(--ink); }

/* Conflicts index */
.conflict-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; margin-top: 28px; }
.conflict-card { display: flex; flex-direction: column; gap: 10px; min-height: 280px; padding: 24px; text-decoration: none; transition: border-color 150ms ease; }
.conflict-card:hover { border-color: var(--gold); }
.conflict-card:hover .country-card__cta svg { transform: translateX(3px); }
.conflict-card__years { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.06em; color: var(--ink-3); }
.conflict-card__name { font-weight: 700; font-stretch: var(--condensed); font-size: 2rem; line-height: 1.05; color: var(--ink); }
.conflict-card__meta { max-width: 44ch; color: var(--ink-2); line-height: 1.5; }
.conflict-card--soon { justify-content: center; min-height: 0; border-style: dashed; background: transparent; }
.conflict-card--soon .conflict-card__name { font-size: 1.25rem; font-stretch: 100%; color: var(--ink-2); }

@media (max-width: 640px) {
  .war-map { aspect-ratio: 1.5 / 1; }
  /* A battle's card would not fit over the map: it opens under it, inside the well, with a smaller picture. */
  .war-well .tooltip-layer { position: static; max-width: none; margin: 0 8px 8px; transform: none !important; }
  .war-well .tip--battle { min-width: 0; }
  .war-well .tip__picture { max-height: 110px; }
  .casualties-well { height: 320px; }
  /* Phones: the battle rows keep the dates, flags, name and bar; the values and result move to the tooltip-free table. */
  /* Phones: a battle's row stacks its parts beside the rail: dates, name and flags, casualties, result. No picture, no pie. */
  .battle-list .term-row--battle { grid-template-columns: 16px minmax(0, 1fr) 24px; grid-template-rows: auto auto auto auto; gap: 2px 10px; padding-inline: 4px 6px; }
  .battle-list .term-row--battle .term-row__rail { grid-column: 1; grid-row: 1 / span 4; }
  /* Politics hides a term's years on phones; a battle keeps its dates, over its name. */
  .battle-list .term-row--battle .term-row__years { display: block; grid-column: 2; grid-row: 1; text-align: left; font-size: 0.6875rem; white-space: normal; }
  .battle-list .term-row--battle .term-row__who { grid-column: 2; grid-row: 2; }
  .battle-list .term-row--battle .battle-row__values { grid-column: 2; grid-row: 3; grid-auto-flow: column; justify-content: start; gap: 14px; margin-top: 2px; }
  .battle-list .term-row--battle .battle-row__result { grid-column: 2; grid-row: 4; justify-self: start; text-align: left; }
  .battle-list .term-row--battle .battle-row__link { grid-column: 3; grid-row: 1 / span 4; align-self: center; }
  .battle-row__name { white-space: normal; }
  .battle-row__picture, .battle-row__pie, .battle-head { display: none; }
  .battle-list .term-row--event { grid-template-columns: 4.5rem 16px minmax(0, 1fr) 24px; gap: 0 8px; padding-inline: 4px 8px; }
  .battle-row__sides { gap: 6px; }
  .battle-row__sides .flag { width: 16px; height: 12px; }
  .war-timeline__hint { display: none; }
  .war-views { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .war-caption { transition: none; }
}
