/* ============================================================
   Sugar Doesn't Sell Candy — stylesheet
   Palette: one accent (chocolate) + two supporting greys.
   Type: Newsreader (narrative serif) + Archivo (labels/UI sans).
   ============================================================ */

:root {
  --paper: #fbf8f3;
  --ink: #2b2118;          /* dark-chocolate ink instead of black */
  --accent: #8a4b16;       /* milk chocolate — "the thing to look at" */
  --support-grey: #c2bbb1; /* non-focus data */
  --support-slate: #6e675e;/* muted text, axes */
  --serif: "Newsreader", Georgia, serif;
  --sans: "Archivo", -apple-system, sans-serif;
  --measure: 65ch;
}

* { box-sizing: border-box; margin: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
}

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Title section ---------- */

.title-section {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 1.25rem;
  gap: 2rem;
}

.kicker {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--support-slate);
}

.headline {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(2.75rem, 9vw, 6.5rem);
  line-height: 1.04;
  letter-spacing: -0.015em;
  max-width: 14ch;
}

/* Signature: the thesis happens inside the typography itself */
.struck {
  position: relative;
  color: var(--support-slate);
}
.struck::after {
  content: "";
  position: absolute;
  left: -2%; right: -2%;
  top: 54%;
  height: 0.07em;
  background: var(--accent);
  transform: rotate(-2.5deg);
}
.accent { color: var(--accent); }
.accent-text { color: var(--accent); font-weight: 600; }

.hook {
  max-width: 46ch;
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
  line-height: 1.55;
  color: var(--ink);
}

.scroll-hint {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--support-slate);
  margin-top: 1.5rem;
}
.scroll-arrow { display: inline-block; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ---------- Scrolly layout: sticky chart left 60%, steps right ---------- */

#scrolly {
  display: flex;
  gap: 3rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 2rem;
}

.graphic {
  flex: 0 0 60%;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: center;
}

.graphic figure {
  width: 100%;
}

.chart-title {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  min-height: 2.4em; /* prevent layout shift as titles change */
  transition: opacity 0.25s ease;
}

.chart-box {
  position: relative;
  height: min(62vh, 560px);
  width: 100%;
}

.source-line {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--support-slate);
  margin-top: 0.75rem;
}

.steps {
  flex: 1;
  padding: 35vh 0 45vh;
}

/* Inactive steps are de-emphasized WITHOUT fading their text: opacity
   dimming drops ink to ~2:1 contrast and fails WCAG AA. Instead, inactive
   steps lose their border color and shadow, and the label falls back to a
   passing muted grey; the active step gains the accent border, full-ink
   label, and a soft lift. Same visual rhythm, fully readable at every
   scroll position. */
.step {
  margin: 0 0 70vh;
  padding: 1.5rem 1.75rem;
  background: var(--paper);
  border-left: 3px solid var(--support-grey);
  max-width: var(--measure);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.step.is-active {
  border-left-color: var(--accent);
  box-shadow: 0 2px 14px rgba(43, 33, 24, 0.09);
}

.step-label {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--support-slate); /* 5.3:1 on paper */
  margin-bottom: 0.6rem;
  transition: color 0.4s ease;
}

.step.is-active .step-label {
  color: var(--accent); /* 6.4:1 on paper */
}

.payoff-text {
  font-size: 1.35rem;
  line-height: 1.5;
}

/* ---------- Caveats + method ---------- */

.prose-section {
  max-width: var(--measure);
  margin: 6rem auto;
  padding: 0 1.5rem;
}

.prose-section h2,
.method-footer h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.9rem;
  margin-bottom: 1.25rem;
}

.caveat-list {
  list-style: none;
  display: grid;
  gap: 1.1rem;
}
.caveat-list li {
  padding-left: 1.25rem;
  border-left: 3px solid var(--support-grey);
}

.method-footer {
  border-top: 1px solid var(--support-grey);
  margin-top: 5rem;
  padding: 3rem 1.5rem 4rem;
}
.method-footer h2 { font-size: 1.25rem; }
.method-footer p {
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--support-slate);
  max-width: var(--measure);
  margin: 0 auto;
}
.method-footer h2 { max-width: var(--measure); margin: 0 auto 1rem; }
.method-footer .credits { margin-top: 0.75rem; }

/* ---------- Data load failure fallback ---------- */
.data-error {
  font-family: var(--sans);
  padding: 1rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  max-width: 50ch;
}

/* ---------- Mobile: sticky chart on top half, text scrolls below ---------- */

@media (max-width: 820px) {
  #scrolly {
    flex-direction: column;
    gap: 0;
    padding: 0 1rem;
  }
  .graphic {
    flex: none;
    position: sticky;
    top: 0;
    height: auto;
    z-index: 2;
    background: var(--paper);
    padding: 0.75rem 0 0.5rem;
    border-bottom: 1px solid var(--support-grey);
    align-items: flex-start;
  }
  .chart-box { height: 38vh; }
  .chart-title { font-size: 0.85rem; min-height: 2.2em; }
  .steps { padding: 8vh 0 30vh; }
  .step { margin-bottom: 55vh; padding: 1.1rem 1.2rem; }
  body { font-size: 1.0625rem; }
}

/* ---------- Reduced motion: instant swaps everywhere ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-arrow { animation: none; }
  .step, .chart-title { transition: none; }
}
