:root {
  --sea: #0f1a2c;
  --land: #1d2b42;
  --coast: #3a5274;
  --paper: #e6e1d3;
  --muted: #8d97a8;
  --sodium: #f2b544;
  --tor: #7fd1c7;
  --glass: #cfe3ff;
  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --text: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }

html {
  background: var(--sea);
  color: var(--paper);
  scrollbar-width: none;
}
html::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  font: 400 1.125rem/1.6 var(--text);
}

#stage {
  position: fixed;
  inset: 0 0 0 38%;
}
#globe { width: 100%; height: 100%; display: block; }

#legend {
  position: absolute;
  right: 5rem;
  bottom: 1.5rem;
  margin: 0;
  max-width: 22rem;
  font-size: .875rem;
  color: var(--muted);
  text-align: right;
}

#story {
  position: relative;
  width: min(38%, 36rem);
  padding: 0 0 30vh 4vw;
}

.step {
  min-height: 100vh;
  padding: 22vh 0 8vh;
}
.step.wide { width: min(140%, 46rem); }

h1, h2 {
  font-family: var(--display);
  font-weight: 800;
  line-height: .95;
  margin: 0 0 1.5rem;
}
h1 { font-size: clamp(3.5rem, 7vw, 6.5rem); letter-spacing: -.01em; }
h2 { font-size: clamp(2.25rem, 4vw, 3.5rem); }
h2 [data-fill] { color: var(--sodium); }
[data-scene^="tor"] h2 [data-fill] { color: var(--tor); }
[data-scene="cables"] h2 [data-fill] { color: var(--glass); }

.hero { padding-top: 30vh; }
.lede { font-size: 1.5rem; line-height: 1.4; font-style: italic; max-width: 28rem; }
.scroll-hint { margin-top: 18vh; color: var(--muted); font-size: 1rem; }

p { max-width: 34rem; margin: 0 0 1.1rem; }
.note { color: var(--muted); font-size: 1rem; }
.figure-line strong { font-family: var(--display); font-size: 2rem; color: var(--sodium); }

.ticker { margin: 0 0 1.5rem; color: var(--muted); }
.ticker strong {
  display: block;
  font: 800 clamp(3rem, 6vw, 5rem)/1 var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--sodium);
}

#live-spark { display: flex; align-items: flex-end; gap: 1px; height: 4.5rem; margin: 1.25rem 0 1.75rem; max-width: 30rem; }
#live-spark div { flex: 1; min-height: 1px; background: var(--sodium); opacity: .8; }
#live-spark div:last-child { opacity: .35; }

.type-switch { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1.5rem 0 .5rem; max-width: 30rem; }
.type-switch button {
  font: 500 1rem/1 var(--display);
  letter-spacing: .02em;
  color: var(--paper);
  background: none;
  border: 1px solid var(--coast);
  border-radius: 1rem;
  padding: .4rem .8rem;
  cursor: pointer;
}
.type-switch button:hover { border-color: var(--sodium); }
.type-switch button[aria-pressed="true"] { background: var(--sodium); border-color: var(--sodium); color: var(--sea); }
.type-switch button:focus-visible { outline: 2px solid var(--sodium); outline-offset: 2px; }

.ranking {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  max-width: 26rem;
  font-size: 1rem;
}
.ranking li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  padding: .3rem 0;
  border-bottom: 1px solid var(--land);
}
.ranking li span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); }

.bars { display: grid; gap: .5rem; margin: 1.5rem 0; font-size: .95rem; }
.bar-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 1fr;
  gap: .75rem;
  align-items: center;
}
.bar-row.head { color: var(--muted); font-size: .875rem; }
.bar-track { position: relative; height: 1.25rem; }
.bar-fill { height: 100%; background: var(--sodium); min-width: 2px; }
.bar-fill.bytes { background: var(--coast); }
.bar-row.inferred > span:first-child { font-style: italic; }
.bar-row.inferred .bar-fill { background: none; box-shadow: inset 0 0 0 1px var(--sodium); }
.bar-row.inferred .bar-fill.bytes { box-shadow: inset 0 0 0 1px #6f88ad; }
.bar-row.inferred .bar-track span:not(.outside) { color: var(--paper); font-weight: 400; }
.bar-track span {
  position: absolute;
  left: .4rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--sea);
  font-weight: 600;
  white-space: nowrap;
}
.bar-track span.outside { color: var(--paper); font-weight: 400; }

.facets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5rem 3rem;
}
.facets figure { margin: 0; }
.facets figcaption { font-family: var(--display); font-weight: 500; font-size: 1.5rem; margin-bottom: .75rem; }
.facet-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr 3.5rem;
  gap: .5rem;
  align-items: center;
  font-size: .9rem;
  padding: .15rem 0;
}
.facet-row .bar-fill { height: .6rem; }
.facet-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

#coverage { display: flex; align-items: flex-end; gap: 3px; height: 8rem; margin: 1.5rem 0 2rem; max-width: 40rem; }
#coverage div { flex: 1; background: var(--sodium); min-height: 2px; }
#coverage div.gap { background: var(--land); }

#rail {
  position: fixed;
  top: 12vh;
  bottom: 12vh;
  right: 1.75rem;
  width: 1.5rem;
  z-index: 2;
}
#rail-track {
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: none;
}
#rail-track::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 1px dashed var(--coast);
}
#rail.dragging #rail-track { cursor: grabbing; }
#rail-thumb {
  position: absolute;
  left: calc(50% - 2px);
  width: 4px;
  border-radius: 2px;
  background: var(--paper);
  opacity: .75;
  transition: opacity .2s, width .2s, left .2s;
}
#rail:hover #rail-thumb, #rail.dragging #rail-thumb { opacity: 1; width: 6px; left: calc(50% - 3px); }
#rail-marks { list-style: none; margin: 0; padding: 0; }
#rail-marks li {
  position: absolute;
  left: 0;
  width: 100%;
  height: 0;
}
#rail-marks button {
  position: absolute;
  left: 50%;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
#rail-marks button::after {
  content: "";
  position: absolute;
  inset: calc(50% - 4px);
  border-radius: 50%;
  border: 1px solid var(--coast);
  background: var(--sea);
  transition: background .3s, border-color .3s, transform .2s;
}
#rail-marks li.passed button::after { background: var(--sodium); border-color: var(--sodium); }
#rail-marks li.passed[data-scene^="tor"] button::after { background: var(--tor); border-color: var(--tor); }
#rail-marks li.passed:is([data-scene="cables"], [data-scene="hubs"]) button::after { background: var(--glass); border-color: var(--glass); }
#rail-marks button:hover::after { transform: scale(1.5); }
#rail-marks button:focus-visible { outline: 2px solid var(--sodium); outline-offset: 2px; border-radius: 50%; }
#rail-label {
  position: absolute;
  top: 0;
  right: 2.25rem;
  margin: 0;
  translate: 0 -50%;
  white-space: nowrap;
  font: 500 1.05rem/1 var(--display);
  letter-spacing: .02em;
  color: var(--muted);
  pointer-events: none;
}
#rail:hover #rail-label, #rail.dragging #rail-label { color: var(--paper); }

@media (max-width: 860px) {
  #rail { right: .25rem; top: 8vh; bottom: 8vh; }
  #rail-label { display: none; }
  #stage { inset: 0 0 auto 0; height: 50svh; }
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent 40svh, var(--sea) 52svh);
  }
  #story { width: auto; padding: 0 2.25rem 30vh 1.25rem; z-index: 1; }
  .step { padding-top: 50svh; min-height: 100svh; }
  .hero { padding-top: 46svh; }
  h1 { font-size: 3.25rem; }
  .lede { font-size: 1.25rem; }
  .scroll-hint { margin-top: 8vh; }
  .step.wide { width: auto; }
  .facets { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 5.5rem 1fr 1fr; }
  #legend { top: .5rem; bottom: auto; left: 1.25rem; right: 2.25rem; text-align: left; font-size: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  #rail-thumb, #rail-marks button::after { transition: none; }
}
