:root {
  --bg: #f0eee9;
  --bg-2: #f7f4ef;
  --ink: #1d1f24;
  --muted: #5a616b;
  --accent: #a63d40;
  --accent-2: #2f7e7b;
  --panel: #ffffff;
  --grid: rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(166, 61, 64, 0.12), transparent 60%),
    radial-gradient(900px 600px at 80% 10%, rgba(47, 126, 123, 0.12), transparent 60%),
    var(--bg);
  color: var(--ink);
}

main {
  position: relative;
}

.hero {
  position: relative;
  padding: 96px 6vw 72px;
  overflow: hidden;
}

.hero-inner {
  max-width: 900px;
  position: relative;
  z-index: 2;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(166, 61, 64, 0.12), rgba(47, 126, 123, 0.08));
  mask-image: radial-gradient(circle at 20% 30%, rgba(0, 0, 0, 0.9), transparent 70%);
  z-index: 1;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0 0 12px;
}

.eyebrow a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.eyebrow a:hover {
  border-bottom-color: currentColor;
}

h1 {
  font-family: "Fraunces", serif;
  font-size: clamp(2.6rem, 5vw, 4.2rem);
  margin: 0 0 16px;
}

.dek {
  max-width: 650px;
  font-size: 1.1rem;
  line-height: 1.5;
  color: var(--muted);
}

.scrolly {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 4vw;
  padding: 0 6vw 120px;
}

.graphic {
  position: sticky;
  top: 24px;
  align-self: start;
  height: calc(100vh - 48px);
  display: flex;
  align-items: center;
}

.graphic-inner {
  width: 100%;
  position: relative;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(247, 244, 239, 0.9));
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 26px 24px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.viz-header {
  margin-bottom: 12px;
}

.viz-header h2 {
  font-family: "Fraunces", serif;
  font-size: 1.9rem;
  margin: 0 0 6px;
}

.viz-header p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.viz-stats {
  margin-top: 6px;
  font-size: 1.05rem;
  color: var(--ink);
  font-weight: 500;
}

#chart {
  width: 100%;
  height: auto;
}

.controls {
  margin-top: 12px;
  display: none;
  flex-direction: column;
  gap: 6px;
}

.controls.active {
  display: flex;
}

.controls label {
  font-size: 0.9rem;
  color: var(--muted);
}

.controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.text {
  padding: 120px 0 160px;
}

.step {
  margin: 0 0 80px;
  padding: 28px 28px 28px 32px;
  border-left: 2px solid rgba(0, 0, 0, 0.12);
  min-height: 90vh;
}

.step.is-active {
  border-left-color: var(--accent);
}

.step h3 {
  margin: 0 0 10px;
  font-size: 1.5rem;
}

.step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1.25rem;
}

.set-stage-highlight {
  display: inline-block;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.set-stage-highlight.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.team-color {
  font-weight: 600;
}

.team-inline-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: text-bottom;
  margin-right: 6px;
}

.label-box {
  fill: rgba(240, 238, 233, 0.9);
  stroke: rgba(0, 0, 0, 0.12);
  stroke-width: 0.6;
  rx: 4;
  ry: 4;
}

.label-text {
  font-weight: 700;
}

.handwrite {
  font-family: "Shadows Into Light", cursive;
  fill: #a63d40;
  font-size: 18px;
}

.required-info {
  margin-top: 10px;
  display: none;
  gap: 10px;
  flex-wrap: wrap;
}

.required-info.active {
  display: flex;
}

.required-card {
  background: rgba(240, 238, 233, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 180px;
}

.required-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.required-logos {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.required-logos .logo-card {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.required-logos img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.axis path,
.axis line {
  stroke: var(--grid);
}

.axis text {
  fill: var(--muted);
  font-size: 14px;
}

.grid line {
  stroke: rgba(0, 0, 0, 0.08);
}

.grid path {
  stroke: none;
}

.regression {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.point {
  fill: rgba(255, 255, 255, 0.8);
}

.small-multiple .panel {
  fill: rgba(0, 0, 0, 0.02);
  stroke: rgba(0, 0, 0, 0.08);
}

.small-multiple text.label {
  fill: var(--muted);
  font-size: 11px;
}

@media (max-width: 700px) {
  .small-multiple text.label {
    display: none;
  }
}

.line-series {
  fill: none;
  stroke-width: 2.2;
}

.line-series.r2 {
  stroke: var(--accent);
}

.line-series.slope {
  stroke: var(--accent-2);
}

.line-series.intercept {
  stroke: #f77f00;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  color: var(--ink);
  opacity: 0;
  transform: translate(-50%, -120%);
  transition: opacity 0.2s ease;
  z-index: 10;
}

.tooltip-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.tooltip-row img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.tooltip.active {
  opacity: 1;
}

.tooltip.above {
  transform: translate(-50%, -120%);
}

.tooltip.below {
  transform: translate(-50%, 20px);
}

@media (max-width: 960px) {
  .scrolly {
    grid-template-columns: 1fr;
  }

  .graphic {
    position: sticky;
    top: 12px;
    height: 70vh;
    order: 0;
    align-items: stretch;
  }

  .text {
    order: 1;
  }

  #chart {
    height: 100%;
  }

  .text {
    padding-top: 24px;
  }

  .graphic-inner {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}
