/* America's Opioid Crisis: stylesheet
 */

:root {
  /* Surfaces */
  --bg: #fafafa;
  --surface: #ffffff;
  --rule: #e8e8e6;
  --rule-strong: #cfcfcc;

  /* Ink */
  --ink: #1a1612;
  --ink-2: #4a4a4a;
  --ink-3: #888;
  /* Chart colors */
  --c-navy: #0a2c4e;

  /* accent — kicker, stat numbers, hover */
  --c-rust: #c44536;

  /* Layout */
  --w: 720px;
  --w-wide: 1120px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

.container {
  max-width: var(--w);
  margin: 0 auto;
  padding: 0 24px;
}

.container.chart-header {
  max-width: var(--w-wide);
}

/* PAGE PROGRESS */

.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 10000;
  background: transparent;
  pointer-events: none;
}

.page-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--c-rust);
  transition: width 80ms linear;
}

/* HERO */

.hero-dark {
  position: relative;
  background: #000000;
  color: #f4f4f4;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(48px, 8vh, 96px) 0;
}

.hero-frame {
  width: min(100%, 1280px);
  padding: 0 clamp(24px, 5vw, 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Kicker */
.hero-kicker {
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--c-rust);
  margin: 0 0 32px;
  opacity: 0;
  animation: hero-fade 600ms ease-out 100ms forwards;
}

/* Image — reveals left-to-right */
.hero-image-wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 0 36px;
}

.hero-image-mask {
  clip-path: inset(0 100% 0 0);
  animation: hero-reveal 1800ms cubic-bezier(0.4, 0, 0.2, 1) 300ms forwards;
}

@keyframes hero-reveal {
  0% {
    clip-path: inset(0 100% 0 0);
  }

  100% {
    clip-path: inset(0 0 0 0);
  }
}

.hero-img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0.95;
  transform: translateY(calc(var(--hero-scroll, 0) * -20px));
  transition: transform 60ms linear;
}

/* Headline */
.hero-headline {
  font-size: clamp(26px, 3.6vw, 48px);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.025em;
  margin: 0 0 24px;
  max-width: 1100px;
  color: #ffffff;
  opacity: 0;
  animation: hero-rise 800ms ease-out 1500ms forwards;
}

/* "opioid deaths" */
.hero-emph-red {
  color: #d6403a;
  white-space: nowrap;
}

.hero-emph {
  color: rgb(calc(142 + var(--hero-scroll, 0) * 72),
      calc(201 + var(--hero-scroll, 0) * -137),
      calc(134 + var(--hero-scroll, 0) * -76));
  transition: color 80ms linear;
}

/* Deck */
.hero-deck {
  font-size: clamp(14px, 1.2vw, 16px);
  line-height: 1.55;
  color: #b8b8b6;
  margin: 0 0 28px;
  max-width: 580px;
  font-weight: 400;
  opacity: 0;
  animation: hero-rise 800ms ease-out 1900ms forwards;
}

/* Byline */
.hero-byline {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #888;
  margin: 0;
  opacity: 0;
  animation: hero-rise 800ms ease-out 2200ms forwards;
}

.hero-byline a {
  color: #c8c8c8;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.25);
  text-underline-offset: 3px;
}

.hero-byline a:hover {
  text-decoration-color: var(--c-rust);
}

@keyframes hero-fade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scroll cue */
.hero-scroll-cue {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #666;
  pointer-events: none;
  opacity: 0;
  animation: hero-fade 800ms ease-out 2600ms forwards, scroll-bob 2.2s ease-in-out 2600ms infinite;
  transition: opacity 200ms ease;
}

@keyframes scroll-bob {

  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }

  50% {
    transform: translateX(-50%) translateY(6px);
  }
}

.hero-scroll-cue.faded {
  opacity: 0 !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  .hero-kicker,
  .hero-headline,
  .hero-deck,
  .hero-byline,
  .hero-scroll-cue,
  .hero-emph-red {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  .hero-image-mask {
    animation: none !important;
    clip-path: none;
  }

  .hero-img {
    transform: none;
  }
}

/* PROSE */

.prose {
  padding: 24px 0;
}

.prose .container {
  max-width: var(--w);
}

/* Keep adjacent prose sections tight */
.prose+.prose {
  padding-top: 0;
}

.prose p {
  font-size: 18px;
  line-height: 1.7;
  margin: 0 0 22px;
  color: var(--ink);
}

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

.prose strong {
  font-weight: 600;
}

.prose em {
  font-style: italic;
}

/* Links */
.prose a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dashed var(--ink-3);
  padding-bottom: 1px;
  transition: color 160ms ease, border-bottom-color 160ms ease;
}

.prose a:hover {
  color: var(--c-rust);
  border-bottom: 1.5px solid var(--c-rust);
}

.prose a:visited {
  color: var(--ink);
}

.lede {
  padding-top: 64px;
  padding-bottom: 32px;
}

.dropcap::first-letter {
  float: left;
  font-size: 64px;
  line-height: 0.95;
  font-weight: 700;
  margin: 4px 12px 0 0;
  color: var(--ink);
  letter-spacing: -0.02em;
}

/* Pull quote */
.pullquote {
  border: none;
  margin: 40px 0;
  padding: 24px 0 18px;
  text-align: center;
  position: relative;
}

.pullquote::before {
  content: "\201C";
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 72px;
  line-height: 1;
  color: var(--c-rust);
  margin: 0 0 8px;
  font-weight: 400;
  letter-spacing: -0.04em;
}

.pullquote p {
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 500;
  line-height: 1.34;
  letter-spacing: -0.012em;
  color: var(--ink);
  border: none;
  padding: 0;
  margin: 0 auto 16px;
  max-width: 640px;
}

.pullquote cite {
  font-style: normal;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  padding-left: 0;
  display: block;
}

/* STAT CALLOUT */

.stat-callout {
  padding: 48px 0;
}

.stat-callout .container {
  max-width: var(--w);
}

.stat-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 36px;
  align-items: baseline;
  padding: 0;
}

.stat-big {
  font-size: clamp(72px, 9vw, 120px);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: var(--c-rust);
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.stat-big span {
  font-size: 0.45em;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-left: 2px;
  color: var(--c-rust);
}

.stat-text p {
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 8px;
}

.stat-text p:last-child {
  margin: 0;
}

.stat-text strong {
  font-weight: 600;
}

/* CHART SECTIONS */

.chart-section {
  padding: 56px 0;
}

.chart-title {
  font-size: clamp(22px, 2.5vw, 30px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.018em;
  margin: 0 0 10px;
  color: var(--ink);
  text-wrap: balance;
}

.chart-deck {
  font-size: 16px;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 0 0 28px;
  max-width: 920px;
  text-wrap: balance;
}

.chart-wrap {
  width: 100%;
  margin: 0 0 24px;
}

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

#chart1 {
  aspect-ratio: 960 / 460;
}

#chart2 {
  aspect-ratio: 960 / 480;
}

#chart4 {
  aspect-ratio: 960 / 460;
}

#chart5 {
  aspect-ratio: 960 / 720;
}

.chart-section-wide .container.chart-header {
  max-width: 1240px;
}

/* Chart note */
.chart-source-mini {
  font-size: 11px;
  color: var(--ink-3);
  margin: 8px 0 0;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

/* Chart toggle */
.chart-toggle {
  display: inline-flex;
  gap: 0;
  margin: 0 0 24px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}

.toggle-btn {
  appearance: none;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--rule-strong);
  padding: 9px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
  letter-spacing: 0.01em;
}

.toggle-btn:last-child {
  border-right: 0;
}

.toggle-btn:hover {
  color: var(--ink);
  background: #f3efe8;
}

.toggle-btn.is-active {
  background: var(--c-navy);
  color: #fff;
  font-weight: 600;
}

.toggle-btn.is-active:hover {
  background: var(--c-navy);
}

.chart-section .axis line,
.chart-section .axis path {
  stroke: var(--rule);
}

.chart-section .axis text {
  font-size: 12px;
  fill: var(--ink-3);
}

.chart-section .grid line {
  stroke: var(--rule);
  stroke-dasharray: 2 3;
}

.chart-section .grid path {
  display: none;
}

/* TOOLTIP */
.tooltip {
  position: fixed;
  display: none;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.45;
  z-index: 9999;
  min-width: 140px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  font-family: inherit;
}

.tooltip .tip-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.tooltip .tip-year {
  margin-bottom: 6px;
  color: #bbb;
  font-size: 11px;
}

.tooltip .tip-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.tooltip .tip-row span:first-child {
  color: #bbb;
}

.tooltip .tip-val {
  color: #fff;
  font-weight: 500;
}

.tooltip .tip-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 6px 0;
}

/* MAP / SCROLLYTELLING */

.map-section {
  padding: 56px 0 0;
}

.scrolly {
  position: relative;
  max-width: 1280px;
  margin: 32px auto 0;
  padding: 0 32px;
}

.map-stage {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

#map {
  width: 100%;
  max-width: 860px;
  max-height: 70vh;
  height: auto;
  margin: 0 0 0 32px;
  display: block;
}

.map-meta {
  position: absolute;
  top: 56px;
  left: 64px;
  z-index: 3;
  pointer-events: none;
}

.map-year {
  font-size: 72px;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.map-caption {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.state {
  stroke: var(--bg);
  stroke-width: 0.6px;
  transition: fill 700ms ease, stroke 150ms ease, stroke-width 150ms ease;
  cursor: pointer;
}

.state:hover {
  stroke: var(--ink);
  stroke-width: 1.2px;
}

.state-bubble {
  fill: rgba(26, 22, 18, 0.55);
  stroke: var(--ink);
  stroke-width: 0.8px;
  transition: r 700ms ease, opacity 700ms ease;
  pointer-events: none;
}

.callout-leader {
  stroke: var(--ink);
  stroke-width: 0.7px;
  fill: none;
}

.callout-text {
  font-size: 13px;
  font-weight: 500;
  fill: var(--ink);
}

.callout-rate {
  font-size: 11px;
  font-weight: 600;
  fill: var(--c-navy);
}

.map-legend {
  position: absolute;
  bottom: 48px;
  left: 64px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(250, 250, 250, 0.92);
  border: 1px solid var(--rule);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend-row+.legend-row {
  padding-top: 16px;
}

.legend-label {
  min-width: 130px;
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

.legend-bins {
  display: flex;
  align-items: flex-end;
}

.legend-bins .bin {
  position: relative;
  width: 28px;
  height: 12px;
}

.legend-bins .bin span {
  position: absolute;
  bottom: -16px;
  left: 0;
  font-size: 10px;
  color: var(--ink-3);
}

.legend-bubbles {
  display: flex;
  align-items: center;
  gap: 16px;
}

.legend-bubbles .lb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-2);
}

.legend-bubbles svg circle {
  fill: rgba(26, 22, 18, 0.55);
  stroke: var(--ink);
  stroke-width: 0.8px;
}


.steps {
  position: relative;
  z-index: 2;
  margin-top: -100vh;
  padding: 30vh 0 35vh;
  pointer-events: none;
}

.step {
  min-height: 28vh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 32px 0 0;
  margin: 0;
  pointer-events: none;
}

.step.has-card {
  min-height: 70vh;
}

.step.is-blank {
  min-height: 28vh;
}

.step-card {
  width: 340px;
  max-width: 92%;
  padding: 22px 24px;
  background: #ffffff;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--c-navy);
  box-shadow: 0 8px 24px rgba(26, 22, 18, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 300ms ease, transform 300ms ease, visibility 300ms ease;
  pointer-events: none;
}

.step.is-active .step-card {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.step-year {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-rust);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-headline {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.018em;
  color: var(--ink);
}

.step-body p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* COLOPHON */

.colophon {
  border-top: 1px solid var(--ink);
  padding: 56px 0 80px;
  margin-top: 56px;
  background: var(--bg);
}

.colophon h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 28px 0 8px;
}

.colophon h3:first-child {
  margin-top: 0;
}

.colophon p {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0 0 14px;
}

.colophon .byline {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 28px;
}

.colophon .byline a {
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* MOBILE */

@media (max-width: 800px) {
  .hero-dark {
    height: auto;
    min-height: 100vh;
    padding: 48px 0 64px;
  }

  .hero-frame {
    padding: 0 20px;
    gap: 0;
  }

  .hero-kicker {
    margin-bottom: 20px;
  }

  .hero-headline {
    font-size: clamp(22px, 6.5vw, 34px);
    line-height: 1.2;
    margin-bottom: 18px;
  }

  .hero-image-wrap {
    margin: 0 0 22px;
  }

  .hero-deck {
    max-width: 100%;
    margin-bottom: 18px;
    font-size: 14px;
  }

  .hero-img {
    max-width: 100%;
  }

  .hero-scroll-cue {
    bottom: 14px;
  }

  .container {
    padding: 0 20px;
  }

  .lede {
    padding-top: 40px;
  }

  .dropcap::first-letter {
    font-size: 48px;
  }

  .prose p {
    font-size: 17px;
  }

  .stat-line {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-big {
    font-size: 64px;
  }

  .chart-section {
    padding: 44px 0;
  }

  .chart-title {
    font-size: 22px;
  }

  .chart-deck {
    font-size: 15px;
  }

  .pullquote {
    margin: 32px 0;
  }

  .pullquote p {
    font-size: 20px;
  }

  .map-section {
    padding-top: 40px;
  }

  .scrolly {
    padding: 0 16px;
  }

  .map-stage {
    height: 100vh;
  }

  #map {
    max-width: 100%;
    max-height: 58vh;
    margin: 32px auto 0;
  }

  .map-meta {
    top: 24px;
    left: 24px;
  }

  .map-year {
    font-size: 48px;
  }

  .map-caption {
    max-width: 220px;
    font-size: 11px;
    line-height: 1.35;
  }

  .map-legend {
    left: 16px;
    right: 16px;
    bottom: 16px;
    padding: 10px 12px;
    gap: 10px;
  }

  .legend-row {
    gap: 10px;
  }

  .legend-label {
    min-width: 90px;
    font-size: 10px;
  }

  .legend-bins .bin {
    width: 22px;
    height: 10px;
  }

  .legend-bubbles {
    gap: 10px;
  }

  .legend-bubbles .lb {
    font-size: 10px;
  }

  .step {
    min-height: 24vh;
    justify-content: center;
    padding: 0 16px;
  }

  .step.has-card {
    min-height: 72vh;
  }

  .step.is-blank {
    min-height: 24vh;
  }

  .step-card {
    width: 100%;
    max-width: 100%;
    padding: 20px 22px;
  }

  .step-headline {
    font-size: 20px;
  }

  .step-body p {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {

  .state,
  .state-bubble,
  .step-card {
    transition: none;
  }
}