@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap");

/* ===== Base layout & typography ===== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top left, #3b1578 0%, #1a1041 35%, #120b2f 100%);
  color: #f5f3ff;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.hero {
  padding: 1.5rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(29, 7, 66, 0.9) 0%, rgba(104, 40, 186, 0.82) 45%, rgba(236, 72, 153, 0.78) 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 14px 34px rgba(8, 5, 23, 0.45);
  backdrop-filter: blur(4px);
}

.kicker {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f5d0fe;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15;
}

p {
  margin-top: 0;
  line-height: 1.5;
}

.authors {
  margin-bottom: 0.35rem;
  color: #f9f5ff;
}

.subtitle {
  margin-bottom: 0;
  color: #ede9fe;
  max-width: 70ch;
}

.intro {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  border-left: 4px solid #f472b6;
  background: rgba(76, 29, 149, 0.42);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 20px rgba(8, 5, 23, 0.25);
}

.intro p {
  margin-bottom: 0.85rem;
  color: #f3e8ff;
}

.intro p:last-child {
  margin-bottom: 0;
}

/* ===== Mini-viz sections (shared card chrome) ===== */

.mini-viz {
  margin-top: 1.75rem;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.78) 0%, rgba(88, 28, 135, 0.78) 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 14px 30px rgba(8, 5, 23, 0.34);
}

.mini-viz h2 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
}

.mini-viz-description {
  margin-bottom: 1rem;
  color: #e9d5ff;
}

/* ===== Tempo viz (#mini-viz-1) — slider, scatter toggle, player panel ===== */

.tempo-view-switch {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(253, 224, 71, 0.35);
  background: rgba(15, 23, 42, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tempo-view-label {
  margin: 0 0 0.3rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fde68a;
}

.tempo-view-hint {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: #c4b5fd;
  line-height: 1.4;
}

.tempo-view-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0.28rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tempo-view-btn {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #c4b5fd;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: background 150ms, color 150ms, box-shadow 150ms;
}

.tempo-view-btn:hover:not(.is-active) {
  color: #f5f3ff;
  background: rgba(255, 255, 255, 0.08);
}

.tempo-view-btn.is-active {
  background: linear-gradient(90deg, #ec4899 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
}

.tempo-view-btn:focus-visible {
  outline: 2px solid #fde047;
  outline-offset: 2px;
}

.tempo-view-panel[hidden] {
  display: none !important;
}

/* ===== Shared D3 chart containers ===== */

.viz-chart {
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.viz-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.viz-chart .axis path,
.viz-chart .axis line {
  stroke: rgba(196, 181, 253, 0.35);
}

.viz-chart .axis text {
  fill: #c4b5fd;
  font-size: 10px;
}

.tempo-scatter-chart {
  width: 100%;
  min-height: 520px;
}

.tempo-scatter-status {
  margin: 0.55rem 0 0;
  font-size: 0.76rem;
  color: #a78bfa;
}

/* ===== Mood heatmap (#mini-viz-mood) ===== */

.mood-heatmap-chart {
  width: 100%;
  min-height: 580px;
}

.mood-heatmap-chart .heatmap-cell {
  stroke: rgba(15, 23, 42, 0.65);
  stroke-width: 1px;
  cursor: crosshair;
}

.mood-heatmap-chart .heatmap-cell.is-active {
  stroke: #fde047;
  stroke-width: 2px;
}

.mood-heatmap-readout {
  margin: 0.4rem 0 0;
  min-height: 0;
  font-size: 0.76rem;
  color: #c4b5fd;
}

.mood-heatmap-readout:not(:empty) {
  min-height: 1.1rem;
}

.tempo-player {
  display: flex;
  gap: 2rem;
  align-items: center;
  flex-wrap: wrap;
}

.slider-column {
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.tempo-label {
  font-size: 0.82rem;
  color: #f5d0fe;
  font-weight: 600;
}

.tempo-input-wrap {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.tempo-input-label {
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #f5d0fe;
}

.tempo-input {
  width: 74px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(15, 23, 42, 0.55);
  color: #ffffff;
  text-align: center;
  font-weight: 600;
  padding: 0.35rem 0.45rem;
}

.tempo-input:focus {
  outline: none;
  border-color: #f472b6;
  box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.25);
}

.tempo-slider-shell {
  width: 52px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.tempo-cone-track {
  position: absolute;
  width: 22px;
  height: 344px;
  background: linear-gradient(180deg, #fb7185 0%, #fbbf24 100%);
  clip-path: polygon(20% 100%, 80% 100%, 100% 0, 0 0);
  border-radius: 9px;
  opacity: 0.9;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.tempo-fill-track {
  position: absolute;
  bottom: 8px;
  width: 14px;
  height: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #fde68a 100%);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
  pointer-events: none;
  z-index: 1;
  transition: height 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.tempo-slider {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  --track-thickness: 10px;
  width: 22px;
  height: 344px;
  margin: 0;
  writing-mode: vertical-lr;
  direction: rtl;
  background: transparent;
  position: relative;
  z-index: 2;
  opacity: 0;
  cursor: ns-resize;
}

.tempo-slider::-webkit-slider-runnable-track {
  width: var(--track-thickness);
  border-radius: 999px;
  background: transparent;
}

.tempo-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0;
  height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  margin-left: 0;
  transform: none;
  box-shadow: none;
}

.tempo-slider::-moz-range-track {
  width: var(--track-thickness);
  border-radius: 999px;
  background: transparent;
}

.tempo-slider::-moz-range-thumb {
  width: 0;
  height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  margin: 0;
  transform: none;
  box-shadow: none;
}

.song-panel {
  flex: 1;
  min-width: 280px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  padding: 1rem;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.65) 0%, rgba(49, 46, 129, 0.66) 100%);
}

.popularity-panel {
  width: 260px;
  min-height: 380px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(55, 48, 163, 0.5) 0%, rgba(190, 24, 93, 0.4) 100%);
  box-shadow: 0 8px 20px rgba(8, 5, 23, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 0.7rem;
}

.popularity-title {
  margin: 0 0 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  color: #fdf2f8;
}

.song-kicker {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #fbcfe8;
  margin-bottom: 0.4rem;
}

.song-panel h3 {
  margin: 0 0 0.35rem;
  color: #ffffff;
}

#song-artist,
#song-metrics {
  margin-bottom: 0.4rem;
  color: #ede9fe;
}

.player-controls {
  display: flex;
  gap: 0.6rem;
  margin: 0.8rem 0 0.55rem;
}

.youtube-link {
  display: inline-block;
  text-decoration: none;
  border: none;
  border-radius: 999px;
  padding: 0.52rem 0.95rem;
  font-weight: 700;
  background: linear-gradient(90deg, #ec4899 0%, #8b5cf6 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(168, 85, 247, 0.35);
}

.youtube-link.disabled {
  pointer-events: none;
  background: rgba(148, 163, 184, 0.5);
  color: #e2e8f0;
  box-shadow: none;
}

.popularity-visual {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  width: 100%;
}

.popularity-bubble {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fef3c7 0%, #fb7185 65%, #be185d 100%);
  box-shadow: 0 0 16px rgba(244, 114, 182, 0.45);
  flex: 0 0 auto;
  transition: width 260ms cubic-bezier(0.22, 1, 0.36, 1), height 260ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 260ms ease;
}

.popularity-label {
  margin: 0.45rem 0 0;
  color: #f5d0fe;
  font-size: 0.92rem;
  text-align: center;
}

.audio-note {
  margin-bottom: 0;
  color: #f5d0fe;
  font-size: 0.92rem;
}

.viz-disclaimer {
  margin: 0.65rem 0 0;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.35);
  color: #a5b4fc;
  font-size: 0.65rem;
  line-height: 1.35;
}

.viz-disclaimer strong {
  font-weight: 600;
  color: #c4b5fd;
}

.viz-transition {
  margin: 0.8rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: #fdf4ff;
}

/* ===== Insight blurbs between chapters ===== */

.insight-section {
  margin-top: 1.2rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(30, 41, 59, 0.45);
}

.insight-lead {
  margin: 0 0 1rem;
  color: #e9d5ff;
  line-height: 1.55;
}

.insight-section p {
  margin: 0;
  color: #e9d5ff;
}

/* ===== “What it all means” bridge section ===== */

.big-picture-section {
  margin-top: 2rem;
  padding: 1.35rem 1.25rem;
  border-radius: 14px;
  border: 1px solid rgba(253, 224, 71, 0.28);
  background: linear-gradient(145deg, rgba(30, 27, 75, 0.82) 0%, rgba(76, 29, 149, 0.55) 100%);
  box-shadow: 0 12px 28px rgba(8, 5, 23, 0.35);
}

.big-picture-section h2 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  color: #fef9c3;
}

.big-picture-body,
.big-picture-bridge {
  margin: 0;
  color: #ede9fe;
  line-height: 1.6;
  max-width: 68ch;
}

.big-picture-punchline {
  margin: 0.9rem 0 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fdf4ff;
  line-height: 1.5;
  max-width: 68ch;
}

.big-picture-break {
  margin: 1.35rem 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(253, 224, 71, 0.55) 20%,
    rgba(244, 114, 182, 0.55) 80%,
    transparent 100%
  );
}

.big-picture-bridge {
  font-weight: 500;
  color: #f5d0fe;
}

/* ===== 3D neighbor explorer (#mini-viz-neighbor) ===== */

.nbr-search-wrap {
  margin-bottom: 1rem;
}

.nbr-search-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  color: #e9d5ff;
}

.nbr-search-group {
  position: relative;
  max-width: 480px;
}

.nbr-search-input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  padding: 0.6rem 0.75rem;
  font-size: 0.97rem;
  font-family: "Outfit", "Segoe UI", Arial, sans-serif;
}

.nbr-search-input:focus {
  outline: none;
  border-color: #f472b6;
  box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.22);
}

.nbr-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  overflow: hidden;
  z-index: 30;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

.nbr-sugg {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nbr-sugg:last-child {
  border-bottom: none;
}

.nbr-sugg:hover,
.nbr-sugg:focus {
  background: rgba(244, 114, 182, 0.15);
  outline: none;
}

.nbr-sugg-title {
  color: #f5f3ff;
  font-weight: 600;
  font-size: 0.93rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nbr-sugg-meta {
  color: #a78bfa;
  font-size: 0.8rem;
  flex: 0 0 auto;
  white-space: nowrap;
}

.nbr-selected-info {
  margin: 0.5rem 0 0;
  color: #d9f99d;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 1.4em;
}

.nbr-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1.25rem;
  align-items: start;
  margin-top: 0.25rem;
}

@media (max-width: 860px) {
  .nbr-layout {
    grid-template-columns: 1fr;
  }
}

.nbr-plot {
  width: 100%;
  height: 760px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nbr-list {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 23, 42, 0.48);
  padding: 0.9rem 0.85rem;
  max-height: 760px;
  overflow-y: auto;
}

.nbr-list-title {
  margin: 0 0 0.75rem;
  color: #fde68a;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.nbr-hint {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
  font-style: italic;
}

.nbr-row {
  display: grid;
  grid-template-columns: 20px 1fr auto 26px;
  gap: 0.45rem;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.nbr-row:last-child {
  border-bottom: none;
}

.nbr-rank {
  color: #a78bfa;
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
}

.nbr-info {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.nbr-info strong {
  color: #f5f3ff;
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nbr-info span {
  color: #94a3b8;
  font-size: 0.73rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nbr-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.08rem;
}

.nbr-badges span {
  font-size: 0.71rem;
  color: #c4b5fd;
  white-space: nowrap;
}

.nbr-yt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(157, 23, 77, 0.85);
  color: #fff;
  text-decoration: none;
  font-size: 0.68rem;
  flex: 0 0 auto;
  transition: background 150ms;
}

/* ===== Energy brush (#mini-viz-energy) ===== */

.energy-brush-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 760px) {
  .energy-brush-layout {
    grid-template-columns: 1fr;
  }
}

.energy-panel-label {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #e9d5ff;
}

.energy-brush-chart,
.energy-pop-chart {
  width: 100%;
  min-height: 260px;
}

.energy-pop-chart {
  min-height: 360px;
}

.energy-brush-chart .selection {
  fill: rgba(56, 189, 248, 0.22);
  stroke: #38bdf8;
  stroke-width: 1.5;
}

.nbr-yt:hover {
  background: rgba(190, 24, 93, 0.95);
}

/* ===== Closing & footer ===== */

.closing-section {
  margin-top: 2rem;
  padding: 1.15rem 1.2rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-left: 4px solid #f472b6;
  background: rgba(30, 41, 59, 0.5);
}

.closing-body {
  margin: 0 0 0.85rem;
  color: #e9d5ff;
  line-height: 1.6;
  max-width: 68ch;
}

.closing-signoff {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 1rem;
  font-weight: 600;
  color: #f5d0fe;
}

.ai-disclaimer {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
}

.site-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.acknowledgements {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0.75rem;
}

.acknowledgements p {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #94a3b8;
  max-width: 72ch;
}

.acknowledgements p:last-child {
  margin-bottom: 0;
}

.acknowledgements a {
  color: #c4b5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.acknowledgements a:hover {
  color: #e9d5ff;
}

.acknowledgements strong {
  color: #c4b5fd;
  font-weight: 600;
}

.ai-disclaimer p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #94a3b8;
  max-width: 72ch;
}

.ai-disclaimer strong {
  color: #c4b5fd;
  font-weight: 600;
}

/* ===== Genre bubble chart (#mini-viz-genre) ===== */

.genre-bubble-chart {
  width: 100%;
  min-height: 400px;
}

.genre-bubble-readout {
  margin: 0.4rem 0 0;
  min-height: 0;
  font-size: 0.76rem;
  color: #c4b5fd;
}

.genre-bubble-readout:not(:empty) {
  min-height: 1.1rem;
}

.genre-node {
  cursor: default;
}
