/* 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(--lilac);
  --rock: var(--dim-grey);
  --country: var(--khaki);
  --hiphop: var(--thistle);
  --rnb: var(--pale-oak);
  --dance: var(--thistle);
  --folk: var(--khaki);

  --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;
}
.tabs {
  display: flex;
  gap: 4px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  background: none;
  font: 700 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 10px 12px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab .num { opacity: 0.55; margin-right: 6px; }
.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(--ink);
  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;
}

/* ---------- Placeholder panels (fill these in later) ---------- */
.chapter {
  max-width: 1100px;
  margin: 0 auto;
  padding: 64px 16px;
}
.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;
}
.genre-bubble.pop { stroke: var(--ink); stroke-width: 1.2; }
.genre-bubble.hovered { stroke: var(--ink); stroke-width: 2.5; }
.legend .count { opacity: 0.6; }
.legend li.is-pop i { border: 2px solid var(--ink); }

/* 03 · Sound: bubble rows by decade */
.axis-caption { font: 400 12px var(--mono); fill: var(--muted); }
.sound-grid line { stroke: var(--rule); stroke-opacity: 0.6; }

/* ---------- 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; }
}
