:root {
  --bg: #faf8f4;
  --ink: #1d1d1f;
  --muted: #6b6b6b;
  --accent: #c0392b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Source Serif 4", serif;
}

/* One scroll container: the stage sticks while the beat spacers scroll past it. */
.scrolly { position: relative; }

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

#stage-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Beat spacers sit on top of the stage so scroll position drives the scene. */
.steps {
  position: relative;
  margin-top: -100vh;
  pointer-events: none;
}

.step { height: 100vh; }

/* Captions: slide in from below, or slide up when they leave. Never fade. */
.caption {
  position: absolute;
  margin: 0;
  padding: 16px 20px;
  background: rgba(250, 248, 244, 0.94);
  /* border-left: 3px solid var(--accent); */
  font-size: clamp(17px, 1.7vw, 23px);
  line-height: 1.45;
  pointer-events: none;

  /* Hidden: parked below the stage. The stage clips it. */
  translate: 0 110vh;
  transition: translate 1s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.caption.is-visible { translate: 0 0; }

/* Leaving: slides up out of the stage. */
.caption.is-exited { translate: 0 -110vh; }

/* Centred over the 435-dot box. */
.pos-center {
  width: min(420px, 80vw);
  transform: translate(-50%, -50%);
  text-align: left;
}

/* Centred over a group, or over a point on the chart. */
.pos-group {
  width: min(260px, 40vw);
  transform: translate(-50%, -50%);
  text-align: left;
  font-size: clamp(15px, 1.4vw, 19px);
}

.source {
  position: absolute;
  left: 4%;
  bottom: 2.5vh;
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  font-family: "Helvetica Neue", Arial, sans-serif;
}

/* SVG text and lines */
#stage-svg .chart-title {
  font-family: Georgia, "Source Serif 4", serif;
  font-size: 18px;
  fill: var(--ink);
}

#stage-svg .axis-text {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  fill: var(--muted);
}

/* Size comes from the font-size attribute so the labels can rise in from 0. */
#stage-svg .count-label {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  fill: var(--ink);
}

#stage-svg line.grid { stroke: rgba(0, 0, 0, 0.08); }

#stage-svg .axis-line {
  stroke: var(--ink);
  stroke-width: 1.5;
}

@media (max-width: 600px) {
  .pos-center {
    width: 84vw;
    padding: 12px 14px;
    font-size: 17px;
  }
  .pos-group {
    width: 44vw;
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* Static title, above the stage graphics. Does not change between beats. */
.title {
  position: absolute;
  top: 3vh;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 16px;
  z-index: 1;
  pointer-events: none;
  text-align: center;
  font-family: Georgia, "Source Serif 4", serif;
  font-weight: normal;
  font-size: clamp(22px, 2.6vw, 34px);
  color: var(--ink);
}
