:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #555;
  --rule: #e4e4df;
  --max-width: 1100px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

header, main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

header { padding-bottom: 0.25rem; }

h1 {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 60ch;
}

#chart-figure {
  margin: 1rem 0 1.5rem;
}

#chart {
  width: 100%;
  min-height: 520px;
}

#chart svg {
  width: 100%;
  height: auto;
  display: block;
  font-family: inherit;
  overflow: visible;
}

figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
  max-width: 75ch;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
  color: var(--muted);
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.controls input[type="range"] { width: 160px; }

.about {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 75ch;
}

.about h2 { font-size: 1rem; margin-bottom: 0.5rem; color: var(--fg); }

.about a { color: inherit; }

/* Sankey */
.column-label {
  font-weight: 700;
  font-size: 1rem;
  fill: var(--fg);
  letter-spacing: 0.02em;
}

.column-supertitle {
  font-weight: 600;
  font-size: 0.7rem;
  fill: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.node rect { stroke: none; }

.node-label {
  font-size: 0.75rem;
  font-weight: 600;
  fill: #fff;
  pointer-events: none;
  user-select: none;
}

.node-label.outside { fill: var(--fg); }

.node-share {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.85;
}

.link {
  fill: none;
  mix-blend-mode: multiply;
  transition: opacity 120ms ease;
}

.link.faded { opacity: 0.08; }

#chart:hover .link:not(.hover):not(.faded) { opacity: 0.55; }

.link.hover { opacity: 0.95; }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(20,20,20,0.92);
  color: #fff;
  font-size: 0.8rem;
  padding: 6px 9px;
  border-radius: 4px;
  max-width: 240px;
  line-height: 1.35;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 10px));
  transition: opacity 100ms ease;
  z-index: 10;
}

.tooltip.visible { opacity: 1; }

.tooltip b { font-weight: 600; }

@media (max-width: 600px) {
  .node-label { font-size: 0.7rem; }
  .column-label { font-size: 0.75rem; }
}
