/*
  World electricity story: "current" redesign.
  Mechanics follow run-framework/assets/data-story-template.css (one insight per snapped viewport,
  scrolling copy column, sticky visual stage that dissolves between insights, progress line, mobile
  visual-above-copy, reduced-motion final states). Look follows the reviewer's reference
  ("The current beneath the crossover") via ../shared/current.css: near-black, off-white type,
  numbered uppercase labels, hairlines, monochrome source palette. This replaces the template's
  lavender/lime at the reviewer's request.
*/
:root {
  --bar-h: 72px;
  --gutter: max(24px, calc((100vw - 1280px) / 2));
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}
* {
  box-sizing: border-box;
}
html {
  scroll-padding-top: var(--bar-h);
}
html:not(.js) {
  scroll-snap-type: y mandatory;
}
body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.scroll-progress {
  display: none !important;
}
.motion .story {
  background-color: transparent;
  box-shadow: none;
  clip-path: none;
}

/* Progress line under the top bar */
.progress {
  position: fixed;
  top: var(--bar-h);
  left: 0;
  right: 0;
  height: 1px;
  z-index: 30;
  pointer-events: none;
  background: var(--cur-hair);
}
.progress span {
  display: block;
  height: 100%;
  background: var(--cur-ink);
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 0.6s var(--ease-out);
}

/* Layout: scrolling copy + sticky stage */
.story {
  display: grid;
  grid-template-columns: minmax(280px, 36%) minmax(0, 1fr);
  column-gap: clamp(24px, 4vw, 64px);
  padding: 0 var(--gutter);
}
.steps {
  grid-column: 1;
  grid-row: 1;
}
.step {
  height: calc(100svh - var(--bar-h));
  display: flex;
  align-items: center;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.viz {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: var(--bar-h);
  height: calc(100svh - var(--bar-h));
  align-self: start;
}
html:not(.js) .viz {
  display: none;
}

/* Copy */
.copy {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  padding: clamp(20px, 4vh, 44px) 0;
}
.copy > * {
  margin: 0;
}
.motion .copy > * {
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.8s var(--ease-out);
}
.motion .step:not(.is-active) .copy > * {
  opacity: 0.16;
  transform: translateY(12px);
}
.motion .step.is-active .copy > *:nth-child(2) {
  transition-delay: 0.05s;
}
.motion .step.is-active .copy > *:nth-child(3) {
  transition-delay: 0.1s;
}
.motion .step.is-active .copy > *:nth-child(4) {
  transition-delay: 0.15s;
}
.motion .step.is-active .copy > *:nth-child(5) {
  transition-delay: 0.2s;
}
.copy .meta-row {
  margin: 0 0 8px;
  padding-bottom: 12px;
  font-size: 11px;
}
.display {
  font-size: clamp(40px, 4.6vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  font-weight: 700;
  color: var(--cur-ink);
}
.lede {
  font-size: clamp(17px, 1.5vw, 21px);
  line-height: 1.4;
  color: var(--cur-body);
}
.big {
  font-size: clamp(44px, 5.4vw, 80px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-weight: 700;
  color: var(--cur-ink);
  font-variant-numeric: tabular-nums;
}
.big-sm {
  font-size: clamp(34px, 3.6vw, 52px);
}
.statement {
  font-size: clamp(19px, 1.7vw, 24px);
  line-height: 1.32;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--cur-ink);
  max-width: 30ch;
}
.statement .sw {
  transition: opacity 0.3s ease;
}
.statement .sw.dim {
  opacity: 0.22;
}
.note {
  color: var(--cur-body);
  font-size: 15px;
  line-height: 1.55;
  max-width: 44ch;
}
.scroll-cue {
  color: var(--cur-muted);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.scroll-cue span {
  display: inline-block;
  margin-left: 6px;
  animation: nudge 1.6s ease-in-out infinite;
}
@keyframes nudge {
  50% {
    transform: translateY(4px);
  }
}
.links {
  /* two equal-width buttons */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-width: 520px;
  margin-top: 8px !important;
}
.links a {
  display: block;
  text-align: center;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cur-bg);
  background: var(--cur-ink);
  border: 1px solid var(--cur-ink);
}
.links a + a {
  background: transparent;
  color: var(--cur-ink);
  border-color: var(--cur-hair-strong);
}

/* Mix legend in the copy column */
.mix-legend {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  font-size: 13px;
  color: var(--cur-body);
  font-variant-numeric: tabular-nums;
}
.mix-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mix-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

/* Stage: stacked items, dissolve between them (template) */
.viz-item {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vh, 36px) 0;
  opacity: 0;
  visibility: hidden;
  filter: blur(14px);
  transform: scale(0.96);
  transition:
    opacity 0.75s ease,
    filter 0.75s ease,
    transform 0.9s var(--ease-out),
    visibility 0s linear 0.9s;
}
.viz-item.is-active {
  opacity: 1;
  visibility: visible;
  filter: blur(0);
  transform: none;
  transition:
    opacity 0.75s ease 0.12s,
    filter 0.75s ease 0.12s,
    transform 0.9s var(--ease-out) 0.12s,
    visibility 0s;
}
.viz-item.leave-up {
  transform: scale(1.04) translateY(-3%);
}
.viz-item.leave-down {
  transform: scale(1.04) translateY(3%);
}
.viz-item > svg {
  width: 100%;
  height: 100%;
  max-height: min(78svh, 680px);
  overflow: visible;
}

/* SVG type and marks */
.t-axis {
  fill: var(--cur-muted);
  font: 500 12px var(--cur-font);
}
.t-year {
  fill: var(--cur-ink);
  font: 500 13px var(--cur-font);
}
.t-label {
  fill: var(--cur-body);
  font: 700 12px var(--cur-font);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.t-value {
  fill: var(--cur-ink);
  font: 700 26px var(--cur-font);
  letter-spacing: -0.02em;
}
.t-small {
  fill: var(--cur-body);
  font: 500 14px var(--cur-font);
}
.t-num {
  fill: var(--cur-ink);
  font: 600 14px var(--cur-font);
  font-variant-numeric: tabular-nums;
}
.g-rule {
  stroke: var(--cur-hair);
  stroke-dasharray: 1 5;
}
.g-center {
  stroke: var(--cur-hair-strong);
}
.thread {
  fill: none;
  stroke: var(--cur-ink);
  stroke-width: 1.2;
  stroke-dasharray: 1.2 3.2;
  stroke-linecap: round;
  opacity: 0.85;
}
.texture {
  fill: none;
  stroke: var(--cur-ink);
  stroke-width: 0.8;
  stroke-dasharray: 0.9 3;
  stroke-linecap: round;
  opacity: 0.26;
}
.endpoint {
  fill: var(--cur-ink);
}
.endpoint-halo {
  fill: var(--cur-ink);
  opacity: 0.22;
}
.mid-dot {
  fill: var(--cur-ink);
}
.leader {
  stroke: var(--cur-hair-strong);
}
.s-solid {
  fill: none;
  stroke: var(--ser-1);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.s-dash {
  fill: none;
  stroke: var(--ser-2);
  stroke-width: 2.5;
  stroke-dasharray: 8 6;
  stroke-linejoin: round;
}

.foot {
  scroll-snap-align: end;
  padding: 32px var(--gutter) 48px;
  border-top: 1px solid var(--cur-hair);
  color: var(--cur-body);
  font-size: 14px;
  line-height: 1.6;
}
.foot p {
  max-width: 980px;
  margin: 0;
}
.foot .foot-sign {
  margin-top: 10px;
  color: var(--cur-ink);
}
.foot a {
  color: var(--cur-ink);
}

/* Narrow screens: stage on top, copy snaps beneath (template) */
@media (max-width: 760px) {
  :root {
    --viz-h: 44svh;
  }
  html {
    scroll-padding-top: calc(var(--bar-h) + var(--viz-h));
  }
  .story {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 16px;
  }
  .viz {
    grid-column: 1;
    grid-row: 1;
    height: var(--viz-h);
    z-index: 2;
    background: var(--cur-bg);
    border-bottom: 1px solid var(--cur-hair);
  }
  .steps {
    grid-row: 2;
  }
  .step {
    height: calc(100svh - var(--bar-h) - var(--viz-h));
    align-items: flex-start;
  }
  .copy {
    gap: 8px;
    padding: 12px 0;
  }
  .copy .meta-row,
  .scroll-cue {
    display: none;
  }
  .display {
    font-size: clamp(30px, 9vw, 44px);
  }
  .big {
    font-size: clamp(36px, 11vw, 52px);
  }
  .big-sm {
    font-size: 28px;
  }
  .statement {
    font-size: 17px;
  }
  .note {
    font-size: 13px;
  }
  .lede {
    font-size: 15px;
  }
  .kicker-num {
    font-size: 10px;
    margin-bottom: 4px;
  }
  .mix-legend {
    font-size: 11px;
    gap: 4px 10px;
  }
  .step:last-child .note {
    display: none;
  }
  .viz-item > svg {
    max-height: calc(var(--viz-h) - 16px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .viz-item,
  .viz-item.is-active,
  .copy > *,
  .progress span {
    transition: none !important;
  }
  .viz-item {
    filter: none;
    transform: none;
  }
  .scroll-cue span {
    animation: none;
  }
}
@media print {
  html {
    scroll-snap-type: none;
  }
  .progress,
  .scroll-cue,
  .viz {
    display: none;
  }
  .step {
    height: auto;
    break-inside: avoid;
  }
}
/* Story buttons: beat the design guide's global link colour */
html.theme-current .links a {
  color: var(--cur-bg);
}
html.theme-current .links a + a {
  color: var(--cur-ink);
}
