/* ============================================================
   Suggested Isn't Safe - editorial data-journalism styling
   Mobile-first. One sharp accent (red) reserved for danger.
   ============================================================ */

:root {
  --bg:        #f6f4ef;   /* warm paper */
  --bg-2:      #efece4;
  --ink:       #17150f;   /* near-black text */
  --muted:     #6b6559;
  --line:      #ded9cf;
  --card:      rgba(252, 251, 248, 0.92);

  --red:       #e0231b;   /* THE accent - collisions / danger only */
  --suggested: #d6890f;   /* amber - unprotected suggested routes */
  --painted:   #4a7ab0;   /* steel blue - painted lanes */
  --protected: #1f8a70;   /* green - protected / segregated */

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --maxw: 40rem;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; border-bottom: 1px solid rgba(224,35,27,0.45); }
a:hover { border-bottom-color: var(--red); color: var(--red); }

.kicker {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--red);
  margin: 0 0 1.1rem;
}
.malovey-link { color: inherit; border-bottom: 1px solid currentColor; opacity: 1; }
.malovey-link:hover { color: inherit; border-bottom-color: currentColor; opacity: 0.7; }

/* coloured inline emphasis */
.ink-suggested { color: var(--suggested); font-weight: 600; }
.ink-painted   { color: var(--painted);   font-weight: 600; }
.ink-protected { color: var(--protected); font-weight: 600; }
.ink-red       { color: var(--red);       font-weight: 600; }
.num-red       { color: var(--red); font-variant-numeric: tabular-nums; }

/* ───────────────────────── HERO ───────────────────────── */
.hero {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: clamp(1.5rem, 5vw, 5rem);
  background:
    radial-gradient(120% 90% at 82% 8%, rgba(224,35,27,0.06), transparent 55%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.hero__inner { max-width: 54rem; }
.hero__title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(3.4rem, 15vw, 9rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}
.hero__title-em { color: var(--red); font-style: italic; }
.hero__standfirst {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 3.4vw, 1.7rem);
  line-height: 1.45;
  max-width: 34rem;
  color: #2c281f;
  margin: 0 0 3rem;
}
.hero__scrollcue {
  font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 0.6rem; margin: 0;
}
.hero__arrow { animation: bob 1.8s ease-in-out infinite; font-size: 1.1rem; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ───────────────── SCROLLYTELLING SCENES ───────────────── */
/* Sticky graphic + steps that scroll over it (Pudding position:sticky pattern) */
.scene { position: relative; }
.scene__graphic {
  position: sticky;
  top: 0;
  height: 100svh;
  width: 100%;
  overflow: hidden;
  z-index: 1;
}
.scene__steps {
  position: relative;
  z-index: 2;
  margin-top: -100svh;   /* pull steps up to overlay the sticky graphic */
  padding: 0 0 12vh;
}
.step {
  min-height: 92svh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 clamp(1rem, 5vw, 4rem);
  pointer-events: none;   /* let map pan through gaps */
}
.scene--map .scene__steps { padding-top: 8vh; }
.step:first-child { min-height: 96svh; }

.step__card {
  pointer-events: auto;
  background: var(--card);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(20,18,12,0.14);
  padding: clamp(1.4rem, 3.5vw, 2.1rem);
  max-width: 30rem;
  transform: translateY(14px);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.step.is-active .step__card { opacity: 1; transform: none; }
.step__card--solid { background: rgba(252,251,248,0.97); }

.step__card h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.5rem, 4.6vw, 2rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 0.7rem;
}
.step__card p { margin: 0 0 0.85rem; }
.step__card p:last-child { margin-bottom: 0; }
.step__eyebrow {
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem;
  font-weight: 700; color: var(--muted); margin: 0 0 0.5rem !important;
}
.step__big {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 9vw, 4rem) !important;
  line-height: 0.98;
  margin: 0 0 0.8rem !important;
}
.step__note {
  font-size: 0.95rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
  margin-top: 1rem !important;
}

/* ───────────────────────── MAP ───────────────────────── */
#map { position: absolute; inset: 0; }
.map-scrim {
  position: absolute; inset: 0; pointer-events: none;
  /* soften the left side where cards sit, for legibility */
  background: linear-gradient(90deg, rgba(246,244,239,0.35) 0%, rgba(246,244,239,0) 42%);
}
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-bottom-right { z-index: 3; }

/* Legend */
.legend {
  position: absolute; right: clamp(0.8rem, 2vw, 1.5rem); top: clamp(0.8rem, 2vw, 1.5rem);
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 0.8rem 0.95rem; font-size: 0.8rem; z-index: 4;
  box-shadow: 0 6px 22px rgba(20,18,12,0.12);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  max-width: min(70vw, 17rem);
  transition: opacity 0.5s ease;
}
.legend[hidden] { display: block; opacity: 0; pointer-events: none; }
.legend__row { display: flex; align-items: center; gap: 0.5rem; padding: 0.16rem 0; color: #34302a; }
.legend__row em { color: var(--muted); font-style: normal; font-size: 0.72rem; }
.legend__swatch { width: 15px; height: 5px; border-radius: 2px; flex: 0 0 auto; }
.sw-suggested { background: var(--suggested); }
.sw-painted   { background: var(--painted); }
.sw-protected { background: var(--protected); }
.sw-collision { width: 11px; height: 11px; border-radius: 50%; background: var(--red); border: 1.5px solid #fff; }

/* Hook annotation */
.map-annotation {
  position: absolute; z-index: 4; pointer-events: none;
  right: clamp(1rem, 6vw, 5rem); top: 22%;
  text-align: right; transition: opacity 0.6s ease;
}
.map-annotation[hidden] { display: block; opacity: 0; }
.map-annotation__num {
  font-family: var(--serif); font-weight: 700; color: var(--red);
  font-size: clamp(3rem, 12vw, 6rem); line-height: 0.9;
  text-shadow: 0 2px 20px rgba(246,244,239,0.9);
}
.map-annotation__label {
  font-size: 0.85rem; font-weight: 600; color: var(--ink); letter-spacing: 0.02em;
  text-shadow: 0 1px 8px rgba(246,244,239,0.9);
}

/* Pulsing hook marker (HTML marker on the map) */
.hook-marker {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); border: 3px solid #fff;
  box-shadow: 0 0 0 rgba(224,35,27,0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(224,35,27,0.55); }
  70%  { box-shadow: 0 0 0 22px rgba(224,35,27,0); }
  100% { box-shadow: 0 0 0 0 rgba(224,35,27,0); }
}

/* ───────────────────────── CHART ───────────────────────── */
.scene--chart .scene__graphic {
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: clamp(3vh, 8vh, 12vh);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
@media (min-width: 900px) { .scene--chart .scene__graphic { align-items: center; padding-top: 0; } }
.chart-wrap { width: min(92vw, 46rem); padding: 1rem; }
.chart-title {
  font-family: var(--serif); font-weight: 700; font-size: clamp(1.05rem, 3.2vw, 1.35rem);
  margin: 0 0 1.1rem; letter-spacing: -0.01em;
}
#chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-source { font-size: 0.78rem; color: var(--muted); margin: 1rem 0 0; }
.bar { fill: var(--suggested); }
.bar--hook { fill: var(--red); }
.bar-label { font-family: var(--sans); font-size: 12px; fill: #34302a; }
.bar-value { font-family: var(--sans); font-size: 12px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.bar-value--hook { fill: var(--red); }

.scene--chart .scene__steps { padding-top: 4vh; }
/* dock chart-scene cards to the bottom so the chart stays visible above them */
.scene--chart .step { align-items: flex-end; padding-bottom: 6vh; }
.scene--chart .step__card { max-width: 34rem; margin: 0 auto; }
@media (min-width: 900px) {
  .scene--chart .step { justify-content: flex-start; }
  .scene--chart .step__card { margin: 0; }
}

/* ───────────────── STATIC SECTIONS ───────────────── */
.section { padding: clamp(3.5rem, 9vw, 8rem) clamp(1.2rem, 6vw, 5rem); border-top: 1px solid var(--line); }
.section__head { max-width: var(--maxw); margin: 0 auto 3rem; text-align: center; }
.section__title {
  font-family: var(--serif); font-weight: 700; font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.05; letter-spacing: -0.02em; margin: 0 0 1rem;
}
.section__lede { font-family: var(--serif); font-size: 1.2rem; color: var(--muted); margin: 0; }

/* Profiles */
.profiles {
  display: grid; gap: 1.5rem; max-width: 68rem; margin: 0 auto;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .profiles { grid-template-columns: repeat(3, 1fr); } }
.profile {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 1.6rem 1.5rem 1.4rem; box-shadow: 0 6px 26px rgba(20,18,12,0.06);
  display: flex; flex-direction: column;
}
.profile__tag {
  display: inline-block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--suggested); background: rgba(214,137,15,0.1);
  padding: 0.25rem 0.55rem; border-radius: 4px; margin-bottom: 0.9rem; align-self: flex-start;
}
.profile__street { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; margin: 0 0 0.15rem; line-height: 1.1; }
.profile__total { font-family: var(--serif); font-size: 3.2rem; font-weight: 700; color: var(--red); line-height: 1; margin: 0.6rem 0 0.1rem; font-variant-numeric: tabular-nums; }
.profile__total-label { font-size: 0.85rem; color: var(--muted); margin: 0 0 1.1rem; }
.profile__blurb { font-size: 0.95rem; color: #34302a; margin: 0 0 1.2rem; }
.profile__worst { font-size: 0.82rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 0.9rem; margin-top: auto; }
.profile__worst strong { color: var(--ink); }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 40px; margin: 0.6rem 0 0.2rem; }
.spark__bar { flex: 1; background: var(--suggested); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.spark__bar.is-peak { background: var(--red); }
.spark__yr { font-size: 0.6rem; color: var(--muted); text-align: center; }
.spark-labels { display: flex; gap: 4px; }
.spark-labels span { flex: 1; text-align: center; }

/* The ask */
.section--ask { background: var(--ink); color: #f3efe6; text-align: center; border-top: none; }
.section--ask .kicker { color: var(--suggested); }
.ask__inner { max-width: 44rem; margin: 0 auto; }
.ask__title { font-family: var(--serif); font-size: clamp(2.2rem, 7vw, 3.6rem); line-height: 1.05; margin: 0 0 1.6rem; letter-spacing: -0.02em; }
.ask__body { font-size: 1.1rem; line-height: 1.7; color: #cfc8ba; margin: 0 auto 1.4rem; max-width: 38rem; }
.section--ask a { border-bottom-color: var(--suggested); }
.section--ask a:hover { color: var(--suggested); }
.ask__kicker { font-family: var(--serif); font-style: italic; font-size: clamp(1.3rem, 4vw, 1.9rem); color: #fff; margin: 2.5rem 0 0; }

/* Methodology */
.methodology { background: var(--bg-2); padding: clamp(3rem, 7vw, 6rem) clamp(1.2rem, 6vw, 5rem); border-top: 1px solid var(--line); }
.methodology__inner { max-width: 60rem; margin: 0 auto; }
.methodology__title { font-family: var(--serif); font-size: 1.6rem; margin: 0 0 2rem; }
.methodology__grid { display: grid; gap: 1.8rem 2.5rem; grid-template-columns: 1fr; }
@media (min-width: 680px) { .methodology__grid { grid-template-columns: 1fr 1fr; } }
.methodology__grid h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--red); margin: 0 0 0.5rem; }
.methodology__grid p { font-size: 0.92rem; color: #3c372e; margin: 0; line-height: 1.6; }
.methodology__grid code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82em; background: rgba(23,21,15,0.06); padding: 0.05em 0.35em; border-radius: 3px; }
.methodology__credit { margin-top: 2.6rem; padding-top: 1.6rem; border-top: 1px solid var(--line); font-size: 0.88rem; color: var(--muted); }
.methodology__credit strong { color: var(--ink); }
.methodology__back { margin-top: 0.8rem; }

/* ───────────────── responsive: cards over map on small screens ───────────────── */
@media (max-width: 640px) {
  .step { justify-content: center; align-items: flex-end; padding-bottom: 8vh; }
  .step__card { max-width: 100%; }
  .map-annotation { top: auto; bottom: 40%; right: 1rem; }
  .legend { font-size: 0.72rem; top: auto; bottom: 1rem; right: 1rem; }
}

/* Loading state */
.map-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.9rem; background: var(--bg); z-index: 5;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .hero__arrow, .hook-marker { animation: none !important; }
  .step__card { transition: opacity 0.2s ease; transform: none; }
}
