@font-face { font-family: "Instrument Serif"; src: url(fonts/serif-400.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url(fonts/serif-400i.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(fonts/sans-var.woff2) format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --bg-2: #11161d;
  --bg-3: #171d26;
  --ink: #ede8de;
  --ink-2: #c9c3b6;
  --muted: #8f8a80;
  --line: #232a34;
  --line-2: #2f3743;
  --nodata: #1a2029;
  --nodata-line: #252d38;
  --dark-end: #f0673a;
  --bright-end: #4fcfe6;
  --mood: #8d877d;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
a:hover { text-decoration-color: currentColor; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px var(--gutter) 0;
  max-width: 1440px; margin: 0 auto;
}
.mark { white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-size: 1.3rem; letter-spacing: .005em; }
.mark svg { width: 26px; height: 26px; color: var(--ink-2); }
.mark svg circle:last-child { transition: fill .8s var(--ease); }
.top-actions { display: flex; align-items: center; gap: 18px; font-size: .9rem; }
.link-how { color: var(--ink-2); text-decoration: none; }
.link-how:hover { color: var(--ink); }

@media (max-width: 520px) {
  .top-actions { gap: 16px; }
  .link-how:first-child { display: none; }
  .mark { font-size: 1.18rem; }
  .zoom { left: 6px; bottom: 6px; gap: 4px; }
  .zoom button { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; font-size: 1rem; }
}

/* ---------- hero ---------- */
main { max-width: 1440px; margin: 0 auto; }
.hero { padding: clamp(28px, 6vw, 72px) var(--gutter) clamp(12px, 2vw, 24px); }
.kicker { margin: 0 0 14px; color: var(--muted); font-size: .92rem; }
.kicker #dateLong { color: var(--ink-2); }
.kicker .dot { margin: 0 4px; }
.headline {
  margin: 0;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.6rem, 9.2vw, 6.6rem);
  line-height: .98; letter-spacing: -.018em;
  max-width: 14ch;
  text-wrap: balance;
}
.mood-word {
  font-style: italic;
  color: var(--mood);
  transition: color .8s var(--ease);
  white-space: nowrap;
}
.mood-word.swap { animation: wordIn .5s var(--ease); }
@keyframes wordIn { from { opacity: 0; transform: translateY(.06em); } to { opacity: 1; transform: none; } }

.hero-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px 28px;
  margin-top: clamp(22px, 4vw, 40px);
  max-width: 760px;
}
.stat { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.stat-wide { grid-column: 1 / -1; }
.stat-num { font-size: clamp(1.5rem, 4.4vw, 2.1rem); font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.stat-label { color: var(--muted); font-size: .85rem; }
.spark { width: 100%; height: 44px; display: block; overflow: visible; }
.spark .area { fill: color-mix(in srgb, var(--mood) 16%, transparent); }
.spark .ln { fill: none; stroke: var(--mood); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark .base { stroke: var(--line-2); stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.spark .now { fill: var(--ink); }
.spark .cursor { stroke: var(--ink); stroke-opacity: .18; vector-effect: non-scaling-stroke; }
.stale { margin: -4px 0 16px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 10px; color: var(--ink-2); font-size: .88rem; max-width: 640px; }

@media (min-width: 760px) {
  .hero-meta { grid-template-columns: auto auto 1fr; }
  .stat-wide { grid-column: auto; }
}
@media (min-width: 1100px) {
  .hero { display: grid; grid-template-columns: 1fr minmax(340px, 440px); column-gap: 56px; align-items: end; }
  .kicker { grid-column: 1 / -1; }
  .headline { max-width: none; font-size: clamp(4rem, 6.6vw, 6.4rem); }
  .hero-meta { margin: 0 0 .6rem; grid-template-columns: 1fr 1fr; }
  .stat-wide { grid-column: 1 / -1; }
}

/* ---------- map ---------- */
.mapwrap { padding: 0 clamp(0px, 2vw, 24px); }
.map { position: relative; aspect-ratio: 1000 / 487; width: 100%; user-select: none; -webkit-user-select: none; }
.map svg { width: 100%; height: 100%; display: block; overflow: hidden; touch-action: manipulation; }
.map.zoomed svg { touch-action: none; cursor: grab; }
.map.dragging svg { cursor: grabbing; }
#sphere { stroke: var(--line); stroke-width: .6; }
.grat { fill: none; stroke: #ffffff; stroke-opacity: .045; stroke-width: .5; vector-effect: non-scaling-stroke; }
#countries path { fill-rule: evenodd; }
#countries path, #dots circle {
  stroke: var(--bg); stroke-width: .35; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill .55s var(--ease), opacity .3s;
  cursor: pointer;
}
#dots circle { stroke-width: .8; }
#dots { transition: opacity .3s; }
#countries path.nodata { fill: url(#hatch); }
.map.has-sel #countries path:not(.sel), .map.has-sel #dots circle:not(.sel) { opacity: .55; }
#countries path:hover { filter: brightness(1.18); }
.sel-outline { fill: none; stroke: var(--ink); stroke-width: 1.6; vector-effect: non-scaling-stroke; pointer-events: none; }

.zoom { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.zoom button { display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2);
  font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--ink-2);
}
.zoom button:hover { color: var(--ink); border-color: var(--muted); }
.zoom svg { width: 16px; height: 16px; }
.zoom button[hidden] { display: none; }

.tip {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 5;
  background: color-mix(in srgb, var(--bg-3) 94%, transparent); border: 1px solid var(--line-2);
  padding: 8px 12px; border-radius: 10px; font-size: .86rem; line-height: 1.3; white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  transform: translate(-50%, calc(-100% - 14px));
}
.tip b { font-weight: 600; display: block; }
.tip span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); font-size: .9rem; transition: opacity .5s; }
.loading span:first-child { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--ink-2); animation: spin 1s linear infinite; }
.loading.done { opacity: 0; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.under-map {
  display: grid; gap: 20px; padding: 16px var(--gutter) 0;
}
@media (min-width: 900px) { .under-map { grid-template-columns: minmax(260px, 360px) 1fr; align-items: start; gap: 48px; } }

.legend { font-size: .8rem; color: var(--muted); }
.legend-bar { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--grad, #f0673a, #7d786f, #4fcfe6)); }
.legend-labels { display: flex; justify-content: space-between; margin-top: 6px; }
.legend-mid { color: var(--ink-2); }
.legend-nodata { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.legend-nodata i { width: 22px; height: 10px; border-radius: 3px; background: repeating-linear-gradient(45deg, var(--nodata) 0 3px, #2a333f 3px 4.5px); }

.timeline { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; }
.play {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-2);
  display: grid; place-items: center; cursor: pointer; transition: border-color .2s, background .2s;
}
.play:hover { border-color: var(--muted); }
.play svg { width: 18px; height: 18px; fill: var(--ink); }
.play .i-pause { display: none; }
.play[aria-pressed="true"] .i-play { display: none; }
.play[aria-pressed="true"] .i-pause { display: inline; }
.slider { position: relative; }
.slider-ends { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); margin-top: 2px; }
#dateShort { font-variant-numeric: tabular-nums; font-size: .95rem; min-width: 6.5ch; text-align: right; color: var(--ink); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--ink-2) var(--p, 100%), var(--line-2) var(--p, 100%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-2); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--ink-2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); margin-top: -7px; border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--ink-2); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 3px solid var(--bg); }

/* ---------- panel ---------- */
.panel {
  position: relative;
  margin: 22px var(--gutter) 0;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px;
  animation: panelIn .45s var(--ease);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.panel-close { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 10px; display: grid; place-items: center; }
.panel-close:hover { color: var(--ink); background: var(--bg-3); }
.panel-kicker { margin: 0; color: var(--muted); font-size: .82rem; }
.panel h2 { margin: 2px 40px 12px 0; font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 6vw, 2.6rem); line-height: 1.02; letter-spacing: -.01em; }
.panel-score { display: flex; align-items: center; gap: 14px; }
.swatch { width: 44px; height: 44px; border-radius: 12px; flex: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); transition: background .5s var(--ease); }
.p-tone { display: block; font-size: 1.7rem; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.1; }
.p-sub { color: var(--ink-2); font-size: .9rem; }
.p-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin: 20px 0 16px; }
.p-facts div { border-top: 1px solid var(--line-2); padding-top: 6px; }
.p-facts dt { color: var(--muted); font-size: .76rem; }
.p-facts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.up { color: var(--bright-end); }
.down { color: var(--dark-end); }
.spark-lg { height: 60px; }
.p-spark-label { margin: 4px 0 14px; color: var(--muted); font-size: .76rem; }
.stories h3 { margin: 16px 0 6px; font-size: .76rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.stories ul { list-style: none; margin: 0; padding: 0; }
.stories li { padding: 8px 0; border-top: 1px solid var(--line); }
.stories a { text-decoration: none; display: block; font-size: .95rem; line-height: 1.35; }
.stories a:hover .st-t { text-decoration: underline; text-decoration-color: var(--muted); }
.st-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .76rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.st-meta i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.st-note { color: var(--muted); font-size: .72rem; margin: 10px 0 0; }
.share-country, .share {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px;
  border: 1px solid var(--line-2); background: var(--bg-3); border-radius: 999px; padding: 8px 16px; min-height: 40px;
  cursor: pointer; font-size: .9rem; transition: border-color .2s, transform .2s var(--ease);
}
.share-country:hover, .share:hover { border-color: var(--muted); }
.share-country:active, .share:active { transform: scale(.97); }
.share-country svg, .share svg { width: 16px; height: 16px; }
.share { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.share:hover { border-color: var(--ink); filter: brightness(.94); }

@media (min-width: 1100px) {
  main { display: grid; grid-template-columns: 1fr; position: relative; }
  .panel {
    position: absolute; right: calc(var(--gutter) + 4px); top: var(--panel-top, 300px);
    width: 360px; margin: 0; max-height: min(var(--panel-max, 80vh), calc(100vh - 40px)); overflow: auto; z-index: 6;
    overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
    box-shadow: 0 24px 60px rgba(0,0,0,.45);
    background: var(--bg-2);
  }
}

/* ---------- explore ---------- */
.explore { padding: clamp(40px, 6vw, 72px) var(--gutter) 0; }
.find { margin-top: 40px; }
.find label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.find input {
  width: 100%; max-width: 420px; font: inherit; color: var(--ink);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px;
}
.find input::placeholder { color: #6d6960; }
.find input:focus { outline: none; border-color: var(--ink-2); }
.ranks { display: grid; gap: 32px; }
@media (min-width: 760px) { .ranks { grid-template-columns: 1fr 1fr; gap: 48px; } }
@media (min-width: 1180px) { .ranks { grid-template-columns: repeat(3, 1fr); gap: 40px; } }
.rank-col[hidden] { display: none; }
.rank-col h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: clamp(1.7rem, 4vw, 2.2rem); letter-spacing: -.01em; }
.rk-dot { width: 12px; height: 12px; border-radius: 50%; }
.rk-bright { background: var(--bright-end); }
.rk-dark { background: var(--dark-end); }
.rk-shift { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-2); }

/* ---------- stories of the day ---------- */
.day-stories { padding: clamp(40px, 6vw, 72px) var(--gutter) 0; }
.day-stories > h2 { margin: 0 0 16px; font-family: var(--serif); font-weight: 400; font-size: clamp(1.7rem, 4vw, 2.2rem); letter-spacing: -.01em; }
.ds-cards { display: grid; gap: 16px; }
@media (min-width: 760px) { .ds-cards { grid-template-columns: 1fr 1fr; gap: 20px; } }
.ds-card { position: relative; padding: 20px 20px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); display: flex; flex-direction: column; gap: 12px; }
.ds-card::before { content: ""; position: absolute; left: 20px; right: 20px; top: -1px; height: 2px; border-radius: 2px; }
.ds-bright::before { background: var(--bright-end); }
.ds-dark::before { background: var(--dark-end); }
.ds-kicker { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; }
.ds-kicker .rk-dot { width: 8px; height: 8px; }
.rk-bright.rk-dot, .ds-bright .rk-dot { background: var(--bright-end); }
.ds-dark .rk-dot { background: var(--dark-end); }
.ds-title { font-family: var(--serif); font-size: clamp(1.45rem, 3.4vw, 1.9rem); line-height: 1.12; text-decoration: none; letter-spacing: -.005em; text-wrap: balance; }
.ds-title:hover { text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--muted); }
.ds-meta { margin: auto 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.ds-meta i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ds-country { border: 0; background: none; padding: 0; color: var(--ink-2); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.ds-country:hover { color: var(--ink); text-decoration-color: var(--ink-2); }
.rank-list { list-style: none; margin: 0; padding: 0; counter-reset: rk; }
.rank-list li { counter-increment: rk; }
.rank-list button {
  width: 100%; display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 12px;
  background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 2px; text-align: left; cursor: pointer;
  font-size: 1.02rem;
}
.rank-list li:last-child button { border-bottom: 1px solid var(--line); }
.rank-list button::before { content: counter(rk); color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; }
.rank-list button:hover .rk-name { text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 3px; }
.rk-val { display: inline-flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .92rem; }
.rk-bar { width: 54px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.rk-bar i { display: block; height: 100%; border-radius: 6px; }
.rank-note { color: var(--muted); font-size: .8rem; margin: 12px 0 0; }
.share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; margin-top: 20px; }
.download { color: var(--ink-2); font-size: .9rem; margin-top: 16px; }

/* ---------- how ---------- */
.how { padding: clamp(56px, 9vw, 110px) var(--gutter) 0; }
.how-inner { max-width: 760px; }
.how h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 1; margin: 0 0 22px; letter-spacing: -.015em; }
.how h3 { font-size: 1rem; font-weight: 600; margin: 28px 0 6px; }
.how p, .how li { color: var(--ink-2); font-size: 1rem; line-height: 1.62; }
.how p { margin: 0 0 12px; }
.how ul { padding-left: 1.1em; margin: 0 0 12px; }
.how strong { color: var(--ink); font-weight: 600; }
.how .lede { font-size: 1.15rem; color: var(--ink); }

.foot { max-width: 1440px; margin: 72px auto 0; padding: 22px var(--gutter) calc(32px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.foot p { margin: 0 0 6px; max-width: 900px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .9rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s var(--ease); z-index: 60;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

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