/* Styles for "Is Everything Pop Now?" */

:root {
  /* Palette */
  --dim-grey: #69626D;
  --khaki: #BCAF9C;
  --pale-oak: #CBBEB3;
  --thistle: #D9BDC5;
  --lilac: #E8C7DE;

  --bg: #F6F1EC;          /* light tint of Pale Oak */
  --ink: #3A3540;         /* darkened Dim Grey, for readable text */
  --muted: var(--dim-grey);
  --rule: var(--pale-oak);

  /* Genre colors: keep these the same in every chart */
  --pop: var(--dim-grey);   /* darkest color: pop is the main story */
  --rock: var(--lilac);
  --country: var(--khaki);
  --hiphop: var(--thistle);
  --rnb: var(--pale-oak);
  --dance: var(--thistle);
  --folk: var(--khaki);
  /* songs where pop is a secondary genre: a soft-pink ramp down from --pop */
  --pop-2: #B5879F;   /* pop is the 2nd genre */
  --pop-3: #D9A9C6;   /* pop is the 3rd genre */
  --pop-45: var(--lilac);   /* pop is the 4th or 5th genre */
  --non-pop: #DCD6D1;       /* songs with no pop at all (neutral grey) */

  --display: "Archivo Black", "Arial Black", sans-serif;
  --body: "Inter", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  overflow-x: hidden;
}

/* ---------- Top nav + progress bar ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}
.progress {
  height: 4px;
  background: var(--rule);
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--dim-grey);
  transition: width 0.5s ease;
}
/* every tab stays in view: the row spans the window and the tabs share it,
   with text that shrinks on smaller screens (no sideways scrolling) */
.tabs {
  display: flex;
  justify-content: space-between;
  gap: 2px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 12px;
}
/* back link to the portfolio, sitting left of the tabs */
.navrow {
  display: flex;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding-left: 12px;
}
.navrow .tabs { flex: 1 1 auto; min-width: 0; margin: 0; }
.back-link {
  flex: 0 0 auto;
  font: 700 clamp(9px, 0.82vw, 12px)/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  padding: 14px 10px 12px 0;
  border-right: 1px solid var(--rule);
}
.back-link:hover { text-decoration: underline; }
.tab {
  flex: 0 1 auto;
  min-width: 0;
  appearance: none;
  border: 0;
  background: none;
  font: 700 clamp(9px, 0.82vw, 12px)/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  padding: 14px clamp(3px, 0.6vw, 10px) 12px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab .num { opacity: 0.55; margin-right: 0.45em; }
/* narrow screens, or whenever the full names don't fit (main.js adds .compact):
   tabs you're not on show just their number */
@media (max-width: 900px) {
  .tab:not([aria-selected="true"]) .lbl { display: none; }
  .tab:not([aria-selected="true"]) .num { margin-right: 0; opacity: 0.8; }
  .tab { font-size: 11px; padding-left: 6px; padding-right: 6px; }
}
.tabs.compact .tab:not([aria-selected="true"]) .lbl { display: none; }
.tabs.compact .tab:not([aria-selected="true"]) .num { margin-right: 0; opacity: 0.8; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------- Panels ---------- */
main { padding-top: 48px; }
.panel { display: none; min-height: calc(100vh - 48px); }
.panel.active { display: block; }

/* ---------- Landing ---------- */
#intro { position: relative; overflow: hidden; }

/* faint figure on the right, sitting behind the text */
.hero-figure {
  position: absolute;
  right: max(0px, calc((100vw - 1280px) / 2));
  bottom: 0;
  height: min(92%, 900px);
  width: auto;
  max-width: 60vw;
  object-fit: contain;
  object-position: right bottom;
  opacity: 0.3;
  filter: saturate(0.55);
  pointer-events: none;
  user-select: none;
  z-index: 0;
  -webkit-mask-image: linear-gradient(to top, transparent 0%, #000 22%),
                      linear-gradient(to right, transparent 0%, #000 18%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to top, transparent 0%, #000 22%),
                      linear-gradient(to right, transparent 0%, #000 18%);
          mask-composite: intersect;
}
.hero { position: relative; z-index: 1; }

/* on narrow screens it would sit right behind the text, so hide it */
@media (max-width: 760px) {
  .hero-figure { display: none; }
}

.hero {
  min-height: calc(100vh - 48px);
  max-width: 1280px;
  margin: 0 auto;
  padding: 8vh 16px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.kicker {
  font: 700 13px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 24px;
}
.headline {
  font-family: var(--display);
  font-weight: 400;
  /* fallback size; the script below fits it to the screen */
  font-size: clamp(40px, 10vw, 200px);
  line-height: 0.9;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  margin: 0 0 0 -0.04em;
}
.headline .line { display: block; }
/* first line keeps a fixed height so a shrunken word doesn't leave a gap */
.headline .genre-line {
  display: flex;
  align-items: flex-end;
  height: 0.95em;
}
.headline .line + .line { margin-top: 0.06em; }
.genre-slot {
  position: relative;
  display: inline-block;
  color: var(--genre-text, var(--bg));
  background: var(--genre-color, var(--rock));
  padding: 0.02em 0.1em 0;
  min-width: 0.3em;
  min-height: 0.92em;
  vertical-align: bottom;
  transition: background 0.3s ease, color 0.3s ease;
  white-space: nowrap;
}
/* the strike-through that crosses out each genre */
.genre-slot::after {
  content: "";
  position: absolute;
  left: -2%;
  top: 52%;
  height: 0.09em;
  width: 0;
  background: var(--ink);
  transform: rotate(-2deg);
  transition: width 0.35s ease;
}
.genre-slot.struck::after { width: 104%; }
.cursor {
  display: inline-block;
  width: 0.07em;
  height: 0.8em;
  margin-left: 0.04em;
  background: var(--ink);
  vertical-align: -0.04em;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.is-pop { color: var(--ink); }
.is-pop .pop-word {
  color: var(--bg);
  background: var(--pop);
  padding: 0 0.12em;
  box-decoration-break: clone;
}

.dek {
  max-width: 620px;
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.5;
  margin: 36px 0 0;
}
.dek strong { font-weight: 600; }
.byline {
  font: 400 13px/1.6 var(--mono);
  color: var(--muted);
  margin: 20px 0 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
  font: 400 12px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: 7px; }
.legend i {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--c);
  border: 1px solid var(--dim-grey);
  display: inline-block;
}

.start {
  align-self: flex-start;
  margin-top: 44px;
  appearance: none;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  font: 700 14px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 16px 22px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.start:hover { background: var(--bg); color: var(--ink); }
.hint {
  font: 400 12px/1 var(--mono);
  color: var(--muted);
  margin-top: 14px;
}

/* 04 · Pop share: checkboxes that split the "no pop" band by genre.
   Lighter versions of the Distance to Pop genre colors, so they sit with the pastels */
#songs {
  --split-rock:   color-mix(in srgb, #7E6BA3 55%, var(--bg));
  --split-rnb:    color-mix(in srgb, #A9844F 50%, var(--bg));
  --split-hiphop: color-mix(in srgb, #4F8583 50%, var(--bg));
  --split-dance:  color-mix(in srgb, #D07A3A 50%, var(--bg));
  --split-other:  var(--khaki);
}
.split-genres {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 12px 0 4px;
}
.split-genres .seg-label { margin-right: 4px; font-size: 12px; color: var(--ink); font-weight: 700; }
/* each genre is a big clickable chip; checked chips fill with the genre's color */
.split-box {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: 700 13px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink);
  padding: 8px 12px; border: 1.5px solid var(--ink); background: var(--bg);
  transition: background 0.15s;
}
.split-box:hover { background: color-mix(in srgb, var(--c) 35%, var(--bg)); }
.split-box:has(input:checked) { background: color-mix(in srgb, var(--c) 70%, var(--bg)); }
.split-box input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.split-box i { width: 14px; height: 14px; border-radius: 3px; background: var(--c); border: 1px solid var(--dim-grey); }

/* ---------- 05 · Interlude: Part 1 summary + Part 2 question ---------- */
/* step 1 fills the window; the answer and findings pop in on → */
.interlude,
.turn {
  position: relative;
  min-height: calc(100vh - 48px);
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 3vh, 40px) 16px 72px;
  box-sizing: border-box;
  flex-direction: column;
  /* start near the top instead of centering, so the page sits higher */
  justify-content: flex-start;
}
.interlude { display: flex; padding-bottom: clamp(64px, 11vh, 120px); }
/* sizes follow the window height too, so the whole summary fits in one screen */
.interlude .kicker { margin-bottom: clamp(12px, 2.5vh, 24px); }
.interlude-head,
.turn-head {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 0;
}
.interlude-head { font-size: clamp(40px, min(9vw, 14vh), 132px); line-height: 0.92; }
.interlude-head .line { display: block; }
.interlude-head .line + .line { margin-top: 0.08em; }
.turn-head { font-size: clamp(34px, 6vw, 84px); line-height: 0.98; max-width: 1050px; }
#turn .pop-word,
#conclusion .pop-word {
  color: var(--bg);
  background: var(--pop);
  padding: 0 0.12em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.findings {
  list-style: none;
  padding: 0;
  margin: clamp(18px, 4vh, 56px) 0 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 44px);
}
.findings li { border-top: 3px solid var(--ink); padding-top: clamp(10px, 1.8vh, 16px); }
.findings .big {
  display: block;
  font: 400 clamp(26px, min(4.2vw, 6vh), 60px)/1 var(--display);
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: clamp(8px, 1.4vh, 12px);
}
.findings .arrow { color: var(--muted); }
.findings .what { display: block; font-size: clamp(15px, 1.35vw, 18px); line-height: 1.5; color: var(--ink); }

/* hidden until revealed: the answer pops, then the findings rise one by one */
.reveal-answer {
  display: inline-block;
  opacity: 0;
  transform: scale(0.6) translateY(0.15em);
  transform-origin: left center;
  transition: opacity 0.45s ease, transform 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.findings li {
  opacity: 0;
  transform: translateY(28px) scale(0.96);
  transition: opacity 0.6s ease, transform 0.75s cubic-bezier(0.34, 1.4, 0.64, 1);
  transition-delay: calc(0.45s + var(--i) * 0.2s);
}
.interlude.revealed .reveal-answer,
.interlude.revealed .findings li { opacity: 1; transform: none; }

/* "see what we found" prompt at the bottom, gone once revealed */
.turn-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(56px, 10vh, 110px);
  transform: translateX(-50%);
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid var(--ink);
  padding: 4px 2px;
  font: 700 13px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.3s;
}
.turn-hint span { display: inline-block; animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(5px); } }
.interlude.revealed .turn-hint { opacity: 0; pointer-events: none; }

/* scroll sign on the right edge, shows after the findings are in */
.scroll-cue {
  position: absolute;
  /* pinned near the window's right edge, outside the centered text column */
  right: calc((100% - 100vw) / 2 + 22px);
  /* vertically centered, well clear of the ← → page buttons in the corner */
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  font: 700 14px/1 var(--mono);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.scroll-cue span { writing-mode: vertical-rl; }
.scroll-cue i {
  position: relative;
  width: 3px;
  height: 110px;
  background: var(--rule);
  overflow: hidden;
}
.scroll-cue i::after {
  content: "";
  position: absolute;
  left: 0; top: -36px;
  width: 3px; height: 36px;
  background: var(--ink);
  animation: scrollDrop 1.6s ease-in-out infinite;
}
@keyframes scrollDrop { to { top: 110px; } }
.interlude.revealed .scroll-cue { opacity: 1; transition-delay: 1.4s; }
.interlude.revealed.scrolled .scroll-cue { opacity: 0; transition-delay: 0s; }

/* step 2: only there once the answer is out; fades in as it scrolls into view */
.turn { display: none; border-top: 2px dashed var(--rule); }
.turn.shown { display: flex; }
.turn > * {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1.2s ease, transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.turn > :nth-child(2) { transition-delay: 0.2s; }
.turn > :nth-child(3) { transition-delay: 0.45s; }
.turn > :nth-child(4) { transition-delay: 0.7s; }
.turn.in > * { opacity: 1; transform: none; }
.turn .kicker { margin-bottom: 18px; }
.turn .dek { margin-top: 24px; max-width: 760px; }
.turn .start { margin-top: 32px; }

/* when the window is too narrow for a free margin, keep the text clear of the sign */
@media (max-width: 1300px) {
  .interlude { padding-right: 64px; }
}
@media (max-width: 760px) {
  .findings { grid-template-columns: 1fr; gap: 20px; }
  .interlude { padding-right: 44px; }
  .scroll-cue { right: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal-answer, .findings li, .turn > *, .scroll-cue { transition: none !important; }
  .turn-hint span, .scroll-cue i::after { animation: none; }
}

/* ---------- 06 · Pop definition: blurb left, sound pentagon right ---------- */
/* a stronger pink than the soft pop ramp, so pop's shape stands out on this chart */
#define { --define-pop: #C2457A; }
.define {
  min-height: calc(100vh - 48px);
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 3vh, 40px) 16px 72px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(20px, 3vw, 48px);
  align-items: center;
}
.define-text .kicker { margin-bottom: 14px; }
.define-text h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(30px, min(4vw, 6vh), 54px);
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0 0 14px;
}
.define-blurb { font-size: 15px; line-height: 1.5; margin: 0 0 14px; max-width: 560px; }
.define-list { margin: 0; }
.define-list .item {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  padding: clamp(6px, 1.1vh, 10px) 8px;
  border-top: 1px solid var(--rule);
  cursor: default;
  transition: background 0.15s;
}
.define-list .item:last-child { border-bottom: 1px solid var(--rule); }
.define-list .item.active { background: color-mix(in srgb, var(--pale-oak) 35%, transparent); }
.define-list dt { font: 700 12px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; }
.define-list dd { margin: 0; }
.define-list .def { grid-column: 1 / -1; font-size: 13px; line-height: 1.45; color: var(--ink); margin-top: 3px; }
.define-list .vals { font: 400 12px/1.3 var(--mono); color: var(--muted); white-space: nowrap; }
.define-list .vals b { color: var(--define-pop); }
.define-takeaway { font-size: 15px; line-height: 1.5; margin: 14px 0 0; max-width: 560px; }
.define-chart { display: flex; flex-direction: column; align-items: center; }
.define-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.define-radar { position: relative; flex: 1 1 auto; min-width: 0; }
/* decade filter for the other No. 1s: a vertical button stack beside the chart */
.define-filter {
  display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto;
  margin-left: auto;
  margin-right: max(-110px, min(0px, calc((1180px - 100vw) / 2 + 12px)));   /* lean into the right margin on wide screens */
}
.define-filter .seg-label { margin: 0 0 2px; font-size: 9px; }
.define-filter .seg-btn { text-align: left; white-space: nowrap; font-size: 9.5px; padding: 4px 7px; border-width: 1px; }
.define-filter .seg-btn.play { margin-top: 6px; }
.define-filter .seg-btn.play.on { background: var(--define-pop); border-color: var(--define-pop); }
.define-radar svg { display: block; width: 100%; height: auto; overflow: visible; }
.define-legend { margin: 6px 0 0; justify-content: center; }
.define-legend .swatch {
  width: 22px; height: 12px; display: inline-block; box-sizing: border-box;
}
.define-legend .swatch.pop { background: color-mix(in srgb, var(--define-pop) 30%, transparent); border: 2px solid var(--define-pop); }
.define-legend .swatch.other { background: color-mix(in srgb, var(--pale-oak) 40%, transparent); border: 2px dashed var(--dim-grey); }
.radar-ring { fill: none; stroke: var(--rule); stroke-width: 1; }
.radar-ring-label { font: 400 10px var(--mono); fill: var(--muted); }
.radar-axis line { stroke: var(--rule); stroke-width: 1; transition: stroke 0.15s; }
.radar-axis .name { font: 700 12px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; fill: var(--ink); }
.radar-axis .val { font: 700 12px var(--mono); fill: var(--define-pop); }
.radar-axis .hit { fill: transparent; cursor: default; }
.radar-axis.active line { stroke: var(--ink); stroke-width: 2; }
.radar-other { fill: var(--pale-oak); fill-opacity: 0.35; stroke: var(--dim-grey); stroke-width: 1.5; stroke-dasharray: 5 4; }
.radar-pop { fill: var(--define-pop); fill-opacity: 0.28; stroke: var(--define-pop); stroke-width: 3; stroke-linejoin: round; }
.radar-dot { fill: var(--define-pop); stroke: var(--bg); stroke-width: 2; transition: r 0.15s; }
.radar-dot.active { r: 7; }
@media (max-width: 860px) {
  .define { grid-template-columns: 1fr; align-items: start; }
  .define-chart { order: -1; }
  .define-row { flex-direction: column; }
  .define-filter { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; margin: 0; }
  .define-filter .seg-btn.play { margin-top: 0; }
}

/* ---------- 07 · Distance to pop: one line per genre, pop as the baseline ---------- */
#distance {
  --dist-pop: #C2457A;      /* same pink as the Pop definition tab */
  --dist-rock: #7E6BA3;
  --dist-rnb: #A9844F;
  --dist-hiphop: #4F8583;
  --dist-dance: #D07A3A;
}
.dist-chart { position: relative; width: 100%; margin-top: 4px; }
.dist-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
/* genre filter: the picked genre stays at full strength, the others fade back */
.dist-controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; margin: 10px 0 2px; }
/* spread the header parts out over the page height (the chart fills what's left) */
@media (min-width: 761px) {
  #distance .chapter.fit { padding-top: clamp(18px, 4vh, 48px); }
  #distance .chapter.fit h2 { margin-bottom: clamp(10px, 2.2vh, 24px); }
  #distance .chapter.fit .chart-intro { margin-bottom: clamp(6px, 1.6vh, 18px); }
  #distance .dist-controls { margin: clamp(10px, 2.2vh, 24px) 0 clamp(4px, 1vh, 10px); }
  #distance .chart-hint { margin-bottom: clamp(6px, 1.6vh, 18px); }
  #distance .dist-chart { margin-top: clamp(4px, 1.6vh, 18px); }
  #distance .chapter.fit .chart-note { margin-top: clamp(8px, 2vh, 22px); }
}
.dist-band { fill: var(--ink); fill-opacity: 0.05; pointer-events: none; }
.dist-grid .row line { stroke: var(--rule); stroke-width: 1; }
.dist-filter .line-key {
  display: inline-block; width: 16px; height: 3px; border-radius: 2px;
  background: var(--c); margin-right: 6px; vertical-align: 3px;
}
.dist-filter .seg-btn.on .line-key { box-shadow: 0 0 0 1px var(--bg); }
.dist-grid text, .dist-axis text { font: 400 12px var(--mono); fill: var(--muted); }
.dist-axis text.decade { font-weight: 700; fill: var(--ink); }
.dist-ytitle { font: 700 11px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; fill: var(--muted); }
.dist-pop-line { stroke: var(--dist-pop); stroke-width: 4; stroke-linecap: round; }
.dist-pop-label { font: 700 12px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; fill: var(--dist-pop); }
.dist-closer { font: 400 11px var(--mono); fill: var(--muted); }
.dist-line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; transition: opacity 0.2s, stroke-width 0.2s; }
.dist-dot { stroke: var(--bg); stroke-width: 2; transition: opacity 0.2s; }
.dist-hit { fill: transparent; cursor: pointer; }
.dist-end { font: 700 12px var(--mono); letter-spacing: 0.04em; transition: opacity 0.2s; }
.dist-end .chg { font-weight: 400; fill: var(--muted); }
.dist-genre.dim .dist-line, .dist-genre.dim .dist-dot, .dist-genre.dim .dist-end:not(.off) { opacity: 0.15 !important; }
/* labels that don't belong to the current view (end labels when zoomed in, value labels when not) */
.dist-end.off { visibility: hidden; }
/* zoomed-in value labels: a halo in the background color keeps them clear of the lines */
.dist-value { paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.dist-genre.focus .dist-line { stroke-width: 4.5; }

/* ---------- 08 · Sounds like pop: pop grey, pop-sounding songs pink ---------- */
#alike { --alike: #E4A3C1; --alike-bg: #F6E3EC; }   /* pastel pink, in the family of the theme's lilac and thistle */
.alike-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 28px; }
.alike-controls .chart-legend { margin: 10px 0 2px; }
#alikeLegend li.faded i { opacity: 0.6; }
.alike-slider {
  display: flex; align-items: center; gap: 8px;
  font: 400 11px/1 var(--mono); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.alike-slider .lbl { color: var(--ink); font-weight: 700; margin-right: 4px; }
.alike-slider input { width: 160px; accent-color: var(--alike); }
.alike-slider output { min-width: 3.5em; color: var(--ink); font-weight: 700; }
.genre-bubble.alike { fill-opacity: 1; stroke: var(--bg); transition: fill 0.35s, fill-opacity 0.35s; }
@media (max-width: 760px) {
  .alike-slider { flex-wrap: wrap; }
  .alike-slider .lbl { flex-basis: 100%; }
}

/* ---------- 09 · Pop reach: Pop Share plus a striped "sounds like pop" layer ---------- */
#reach { --alike: #E4A3C1; --alike-bg: #F6E3EC; }   /* same pastel pink as Sounds Like Pop */
/* a bigger, easier-to-spot cutoff slider */
:is(#reach, #alike) .alike-slider {
  margin: 14px 0 4px;
  gap: 12px;
  font-size: 13px;
  padding: 10px 14px;
  border: 1.5px solid var(--ink);
  background: color-mix(in srgb, var(--alike-bg) 70%, var(--bg));
  width: fit-content;
  max-width: 100%;
}
:is(#reach, #alike) .alike-slider .lbl { font-size: 13px; }
:is(#reach, #alike) .alike-slider output { font-size: 14px; min-width: 9em; }
:is(#reach, #alike) .alike-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: clamp(180px, 26vw, 340px);
  height: 22px;
  background: transparent;
  cursor: pointer;
}
:is(#reach, #alike) .alike-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 4px; background: var(--alike);
}
:is(#reach, #alike) .alike-slider input[type="range"]::-moz-range-track {
  height: 8px; border-radius: 4px; background: var(--alike);
}
:is(#reach, #alike) .alike-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px; margin-top: -7px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--bg); box-shadow: 0 0 0 1.5px var(--ink);
}
:is(#reach, #alike) .alike-slider input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--bg); box-shadow: 0 0 0 1.5px var(--ink);
}
:is(#reach, #alike) .alike-slider input[type="range"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
#reachLegend li.striped i {
  background: repeating-linear-gradient(45deg, var(--alike) 0 3px, var(--alike-bg) 3px 6px);
}

/* ---------- 10 · Conclusion: the Part 2 look, everything rising in on open ---------- */
.interlude.conclusion { padding-bottom: clamp(32px, 6vh, 72px); padding-right: 16px; }
.conclusion .kicker { margin-bottom: clamp(12px, 2.5vh, 24px); }
.conclusion .turn-head { font-size: clamp(32px, min(5.6vw, 9vh), 80px); max-width: 1100px; }
/* the findings are always shown here (on Part 2 they wait for →) */
#conclusion .findings li { opacity: 1; transform: none; transition: none; }
.conclusion-dek { margin-top: clamp(20px, 4vh, 44px); max-width: 820px; font-size: clamp(16px, 1.5vw, 20px); }
.conclusion-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: clamp(18px, 3.5vh, 36px); }
.conclusion-actions .start { margin-top: 0; }
.start.ghost { background: var(--bg); color: var(--ink); }
.start.ghost:hover { background: var(--ink); color: var(--bg); }
/* each part rises in, one after another, whenever the tab opens */
@keyframes riseIn { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
#conclusion.active .rise { animation: riseIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(0.15s + var(--d) * 0.18s); }
#methods.active .rise { animation: riseIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(0.1s + var(--d) * 0.07s); }
@media (prefers-reduced-motion: reduce) {
  #conclusion.active .rise, #methods.active .rise { animation: none; }
}

/* ---------- 11 · Methods: a stats strip, then the method notes in a two-column grid ---------- */
.methods { max-width: 1100px; margin: 0 auto; padding: clamp(18px, 4vh, 48px) 16px 96px; }
.methods > h2 {
  font-family: var(--display); font-weight: 400; text-transform: uppercase; letter-spacing: -0.02em;
  font-size: clamp(36px, 6vw, 72px); line-height: 1; margin: 0 0 16px;
}
.methods .kicker { margin-bottom: 14px; }
.methods-lede { max-width: 720px; font-size: clamp(16px, 1.4vw, 19px); line-height: 1.55; margin: 0; }
.methods a { color: var(--ink); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.methods-stats {
  list-style: none; padding: 0; margin: clamp(24px, 4vh, 40px) 0 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
}
.methods-stats li { border-top: 3px solid var(--ink); padding-top: 12px; }
.methods-stats b { display: block; font: 400 clamp(24px, 3vw, 40px)/1 var(--display); letter-spacing: -0.02em; }
.methods-stats span { display: block; margin-top: 8px; font: 400 12px/1.3 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.methods-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(24px, 3vw, 40px) clamp(28px, 4vw, 56px); margin-top: clamp(32px, 5vh, 56px);
}
.methods-grid section { border-top: 1px solid var(--rule); padding-top: 16px; }
.methods-grid section.wide { grid-column: 1 / -1; }
.methods-grid h3 {
  font: 700 14px/1.2 var(--mono); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 10px;
}
.methods-grid h3 .n { color: var(--muted); font-weight: 400; margin-right: 10px; }
.methods-grid p, .methods-grid li { font-size: 15px; line-height: 1.6; }
.methods-grid p { margin: 0; }
.methods-grid ul { margin: 0; padding-left: 18px; }
.methods-grid li + li { margin-top: 6px; }
.methods-grid .start { margin-top: 20px; }
@media (max-width: 760px) {
  .methods-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .methods-grid { grid-template-columns: 1fr; }
}

/* ---------- Placeholder panels (fill these in later) ---------- */
.chapter {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
/* chart chapters on desktop: the chart keeps its full size; the text around it
   is set smaller and tighter (but not cramped) so the whole page fits the window */
@media (min-width: 761px) {
  .chapter.fit { padding: 18px 16px 16px; }
  .chapter.fit h2 { font-size: clamp(28px, 3.4vw, 40px); margin-bottom: 8px; }
  .chapter.fit .bubbles-intro,
  .chapter.fit .chart-intro { font-size: 15px; line-height: 1.45; max-width: 820px; margin-bottom: 4px; }
  .chapter.fit .legend { font-size: 11px; gap: 6px 16px; }
  .chapter.fit .chart-legend { margin: 10px 0 2px; }
  .chapter.fit .size-key { margin: 8px 0 2px; font-size: 11px; }
  .chapter.fit .chart-note { font-size: 11px; line-height: 1.5; max-width: 900px; margin-top: 6px; }
}
.chapter h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(32px, 6vw, 64px);
  line-height: 1;
  margin: 0 0 16px;
}
.chapter .question {
  font-size: 20px;
  color: var(--muted);
  max-width: 640px;
  margin: 0 0 32px;
}
.chart-slot {
  min-height: 420px;
  border: 2px dashed var(--rule);
  display: grid;
  place-items: center;
  font: 400 13px/1 var(--mono);
  color: var(--muted);
}

/* ---------- 01 · Every No. 1 (bubble timeline) ---------- */
.bubbles-intro {
  max-width: 720px;
  font-size: 17px;
  line-height: 1.55;
  margin: 0 0 8px;
}
.size-key {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin: 14px 0 6px;
  font: 400 12px/1 var(--mono);
  color: var(--muted);
}
.size-key span { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.size-key svg { display: block; overflow: visible; }

#bubbleChart { position: relative; width: 100%; }
#bubbleChart svg { display: block; width: 100%; height: auto; overflow: visible; }
.bubble {
  fill: var(--pale-oak);
  stroke: var(--bg);
  stroke-width: 0.6;
  cursor: pointer;
  transition: fill 0.15s;
}
.bubble:hover, .bubble.hovered { fill: var(--dim-grey); }
.bubble.featured {
  fill: var(--lilac);
  stroke: var(--ink);
  stroke-width: 2.5;
}
.axis text { font: 400 12px var(--mono); fill: var(--muted); }
.axis path, .axis line { stroke: var(--dim-grey); }
.decade-line { stroke: var(--rule); stroke-dasharray: 2 4; }

.note-title { font: 700 14px var(--body); fill: var(--ink); text-transform: uppercase; letter-spacing: 0.02em; }
.note-sub   { font: 400 13px var(--body); fill: var(--muted); }
.note-weeks { font: 400 13px var(--body); fill: var(--ink); }
.note-weeks tspan.b { font-weight: 700; }
.note text { paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.note-line { stroke: var(--ink); stroke-width: 1; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 12px;
  font: 400 13px/1.45 var(--body);
  max-width: 260px;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.12s;
  z-index: 5;
}
.tooltip.show { opacity: 1; }
.tooltip .t { font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.tooltip .m { font-family: var(--mono); font-size: 11px; opacity: 0.8; margin-top: 4px; }
.chart-status { font: 400 13px var(--mono); color: var(--muted); padding: 40px 0; }

/* ---------- 02 · Diversity and 03 · Sound (line charts) ---------- */
.chart-intro {
  max-width: 720px;
  font-size: 17px;
  line-height: 1.55;
  margin: 0 0 8px;
}
.chart-legend { margin: 18px 0 4px; }
.chart-note {
  max-width: 720px;
  font: 400 12px/1.6 var(--mono);
  color: var(--muted);
  margin: 12px 0 0;
}
/* 02 · Diversity: bubble timeline colored by genre */
.genre-swarm { position: relative; width: 100%; margin-top: 8px; }
.genre-swarm svg { display: block; width: 100%; height: auto; overflow: visible; }
.genre-bubble {
  stroke: var(--bg);
  stroke-width: 0.6;
  cursor: pointer;
}
/* pop is solid, every other genre is faded back */
.genre-bubble { fill-opacity: 0.6; stroke: none; transition: fill-opacity 0.15s, filter 0.15s; }
.genre-bubble.pop { fill-opacity: 1; stroke: var(--bg); }
/* hover: full color, darker, outlined */
.genre-bubble.hovered { fill-opacity: 1; filter: brightness(0.75); stroke: var(--ink); stroke-opacity: 1; stroke-width: 2.5; }
.legend .count { opacity: 0.6; }
#diversityLegend li.faded i { opacity: 0.6; }

/* 03 · Pop hits: pop-only bubble timeline, range filter, song picker, player */
.pop-bubble {
  fill: var(--pop);
  stroke: var(--bg);
  stroke-width: 0.8;
  cursor: pointer;
  transition: opacity 0.2s, filter 0.15s;
}
.pop-bubble.pop2 { fill: var(--pop-2); }
.pop-bubble.pop3 { fill: var(--pop-3); }
.pop-bubble.hovered { filter: brightness(0.75); stroke: var(--ink); stroke-width: 2.5; }
.pop-bubble.dimmed { opacity: 0.25; }
/* the picked song keeps its own color; a heavy outline + everything else fading marks it */
.pop-bubble.selected {
  stroke: var(--ink);
  stroke-width: 3.5;
  opacity: 1;
}

.pop-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin: 12px 0 8px;
}
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  appearance: none;
  border: 1.5px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn .n { font-weight: 400; opacity: 0.6; margin-left: 2px; }
.seg-btn .tag {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  background: var(--lilac);
  color: var(--ink);
  padding: 1px 5px;
  margin-left: 2px;
}
.seg-btn:hover { background: var(--pale-oak); }
.seg-btn.on { background: var(--ink); color: var(--bg); }
.seg-btn.on .n { opacity: 0.75; }

/* second filter row: how central pop is (its colored dots double as the legend) */
.seg-level { flex-basis: 100%; align-items: center; }
.seg-label { font: 400 11px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 2px; }
.seg-btn .dot, .search-results .dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
  box-shadow: 0 0 0 1px var(--bg);
}

/* song search: a text box with a results list under it */
.song-search { position: relative; flex: 1 1 240px; max-width: 360px; margin-left: auto; }
.song-search input {
  width: 100%;
  font: 400 13px var(--body);
  color: var(--ink);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%233A3540' stroke-width='2'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='M9.5 9.5L13 13'/%3E%3C/svg%3E") no-repeat 10px center;
  border: 1.5px solid var(--ink);
  padding: 7px 10px 7px 32px;
  border-radius: 0;
}
.song-search input:focus { outline: 2px solid var(--pop-2); outline-offset: 1px; }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 20;
  max-height: 340px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg);
  border: 1.5px solid var(--ink);
  box-shadow: 0 8px 24px rgba(58, 53, 64, 0.18);
}
.search-results li { padding: 6px 12px; cursor: pointer; line-height: 1.3; }
.search-results li.head {
  font: 400 11px var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: default;
  padding: 4px 12px 6px;
}
.search-results li[role=option]:hover,
.search-results li[aria-selected="true"] { background: var(--pale-oak); }
.search-results .rt { font-weight: 600; font-size: 13px; }
.search-results .ra { display: block; margin-left: 15px; font: 400 11px var(--mono); color: var(--muted); }

.pop-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 12px;
  border: 1.5px solid var(--ink);
  background: var(--bg);
}
.pop-card.empty { border-style: dashed; border-color: var(--rule); }
.pop-card .play {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  font: 700 14px/40px var(--body);
  text-align: center;
  cursor: pointer;
  padding: 0;
}
.pop-card .play:hover, .pop-card .play.playing { background: var(--dim-grey); }
.pop-card .play.ghost { background: var(--rule); cursor: default; }
.pop-card .info { flex: 1; min-width: 0; line-height: 1.3; }
.pop-card .t { font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; font-size: 14px; }
.pop-card .a { font-size: 13px; }
.pop-card .m, .pop-card .s { font: 400 11px var(--mono); color: var(--muted); }
.pop-card .s a { color: var(--ink); }
.pop-card .hint { font: 400 12px var(--mono); color: var(--muted); }
.pop-card .close {
  flex: none;
  appearance: none;
  border: 0;
  background: none;
  font: 400 22px/1 var(--body);
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
}
.pop-card .close:hover { color: var(--ink); }

/* 04 · Pop share: stacked area by decade */
.chart-hint { font: 400 12px var(--mono); color: var(--ink); margin: 8px 0 0; }
.chart-hint::before { content: "↳ "; color: var(--muted); }
.share-area { position: relative; width: 100%; margin-top: 6px; }
.share-area svg { display: block; width: 100%; height: auto; overflow: visible; }
.share-seam { fill: none; stroke: var(--bg); stroke-width: 2; }
.share-outline {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-dasharray: 3 3;
  pointer-events: none;
}
.share-big { font: 400 40px var(--display); fill: var(--ink); letter-spacing: -0.02em; }
.share-caption {
  font: 700 11px var(--mono);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  fill: var(--muted);
}
.share-label { font: 600 12px var(--body); pointer-events: none; }
.share-axis text { font: 700 12px var(--mono); fill: var(--ink); }
.share-hit { fill: transparent; cursor: crosshair; }
.share-band { fill: var(--ink); fill-opacity: 0.08; pointer-events: none; }
.tooltip .row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.tooltip .row i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.tooltip .row b { margin-left: auto; padding-left: 12px; font-family: var(--mono); font-weight: 400; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Prev / next footer ---------- */
.pager {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}
.pager button {
  appearance: none;
  width: 44px; height: 44px;
  border: 2px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  font: 700 18px/1 var(--mono);
  cursor: pointer;
}
.pager button:disabled { opacity: 0.25; cursor: default; }
.pager button:not(:disabled):hover { background: var(--ink); color: var(--bg); }

@media (max-width: 600px) {
  .hero { padding-top: 6vh; }
  .start { margin-top: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .genre-slot::after, .progress-fill { transition: none; }
}
