/* One stylesheet for every page. Colors are tokens, redefined for dark mode.
   The chart colors (--s1 … --s8) are a categorical palette validated for
   color-vision deficiency on both surfaces, in this order: a site keeps its
   slot (app.js), so the order is part of the check. Three light slots are
   under 3:1 on white, so the chart also labels its series (legend, tooltip)
   and has a table view. */
:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --faint: #898781;
  --border: #e1e0d9;
  --grid: #ecebe6;
  --axis: #c3c2b7;
  --link: #1d4ed8;
  --accent: #b45309;
  --bar: #2a78d6;
  --up: #006300;
  --down: #b42318;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #4a3aa7;
  --s8: #e34948;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --card: #17181b;
    --text: #e8e8e8;
    --muted: #a3a3a3;
    --faint: #898781;
    --border: #2c2d31;
    --grid: #24252a;
    --axis: #3a3b40;
    --link: #8ab4ff;
    --accent: #f59e0b;
    --bar: #3987e5;
    --up: #0ca30c;
    --down: #e66767;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --s8: #e66767;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 3rem 1rem;
}

h1 {
  margin: 0.25rem 0 0;
  font-size: 1.9rem;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

p {
  max-width: 44rem;
}

a {
  color: var(--link);
}

.muted {
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.back {
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
}

.back:hover {
  text-decoration: underline;
}

footer {
  margin-top: 2.5rem;
  font-size: 0.9rem;
}

code {
  font-size: 0.9em;
}

/* --- filters: one row above everything they scope --- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1.25rem;
  margin: 1.5rem 0 1.25rem;
}

.filters > label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

select {
  min-width: 12rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.range {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  overflow: hidden;
}

.range label {
  position: relative;
}

.range input {
  position: absolute;
  opacity: 0;
}

.range span {
  display: block;
  padding: 0.45rem 0.8rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.range label + label span {
  border-left: 1px solid var(--border);
}

.range input:checked + span {
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}

.range input:focus-visible + span {
  outline: 2px solid var(--link);
  outline-offset: -2px;
}

/* --- tiles --- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
}

.tile,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 1rem 1.1rem;
}

.tile-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.tile-value {
  margin-top: 0.15rem;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
}

.tile-delta {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.tile-delta.up {
  color: var(--up);
}

.tile-delta.down {
  color: var(--down);
}

/* --- the trend chart --- */

figure.card {
  margin: 1rem 0 0;
}

figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.key-line {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

.chart svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.chart .grid {
  stroke: var(--grid);
  stroke-width: 1;
}

.chart .baseline {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .area {
  opacity: 0.1;
}

.chart .crosshair {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart .dot {
  stroke: var(--card);
  stroke-width: 2;
}

.chart rect:focus-visible {
  outline: 2px solid var(--link);
}

details {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

summary {
  cursor: pointer;
  color: var(--muted);
}

.table-wrap {
  max-height: 20rem;
  overflow: auto;
  margin-top: 0.5rem;
}

table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 0.3rem 0.9rem 0.3rem 0;
  border-bottom: 1px solid var(--grid);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  font-weight: 600;
  color: var(--muted);
}

.tooltip {
  position: absolute;
  z-index: 10;
  min-width: 9rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--card);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
  font-size: 0.85rem;
  pointer-events: none;
}

.tip-head {
  margin-bottom: 0.25rem;
  color: var(--muted);
}

.tip-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- ranked lists --- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.unit {
  margin-left: 0.35rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--faint);
}

.bars {
  display: grid;
  gap: 0.55rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.bars li {
  display: grid;
  gap: 0.15rem;
}

.bar-label {
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bar {
  height: 10px;
  min-width: 2px;
  border-radius: 0 4px 4px 0;
  background: var(--bar);
}

.bar-value {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bars .empty {
  font-size: 0.9rem;
}

/* --- the architecture page's diagram --- */

.diagram {
  margin: 2rem 0;
  overflow-x: auto;
}

.diagram svg {
  display: block;
  width: 100%;
  min-width: 36rem;
  height: auto;
  color: var(--text);
}
