/* The Iberian blackout replay. Builds on /styles.css (tokens, masthead, colophon). */

.story { background: var(--night); }
.back { pointer-events: auto; text-decoration: none; }
.back::before { content: '← '; }
.back:hover { color: var(--paper); }

/* ------------------------------------------------------------------ the stage: map + HUD, fixed behind the story */
.stage { position: fixed; inset: 0; z-index: 0; }
.stage-map { position: absolute; inset: 0; }
.stage-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 7, 12, 0.0) 40%, rgba(5, 7, 12, 0.55) 64%, rgba(5, 7, 12, 0.85) 100%),
    linear-gradient(0deg, rgba(5, 7, 12, 0.9) 0%, rgba(5, 7, 12, 0) 34%);
  transition: opacity 0.6s;
}
.stage { transition: opacity 0.6s; }
.stage.chapter-mode { opacity: 0; }

.hud {
  position: absolute; left: var(--gutter); bottom: 28px; width: min(560px, calc(100% - 2 * var(--gutter)));
  transition: opacity 0.5s; opacity: 0;
}
.stage.playing .hud { opacity: 1; }
.clock > span { display: block; font: 500 11px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.clock strong {
  display: block; margin-top: 6px;
  font: 300 60px/1 var(--sans); letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; color: var(--paper); white-space: nowrap;
}
.clock strong .ms { font-size: 0.45em; color: var(--dim); letter-spacing: 0; margin-left: 2px; }
.readouts { display: flex; gap: 36px; margin: 14px 0 0; }
.readouts dt { font: 500 10.5px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.readouts dd { margin: 6px 0 0; font: 600 24px/1 var(--sans); font-variant-numeric: tabular-nums; }
#r-lost { color: var(--paper); }
.legend-line { margin: 12px 0 0; font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 8px; }
.legend-line i { width: 18px; height: 2px; background: var(--lights); box-shadow: 0 0 6px rgba(243, 194, 107, 0.6); }
.legend-line i.open { background: repeating-linear-gradient(90deg, var(--cut) 0 3px, transparent 3px 6px); box-shadow: none; }
.trace { margin: 18px 0 0; }
.trace svg { width: 100%; height: 120px; display: block; overflow: visible; }
.trace .grid line { stroke: var(--rule); }
.trace .grid text { font: 10.5px var(--sans); fill: var(--faint); }
.trace .line { fill: none; stroke: var(--paper-2); stroke-width: 1.1; vector-effect: non-scaling-stroke; }
.trace .future { stroke: rgba(239, 232, 219, 0.18); }
.trace .iberia-line { fill: none; stroke: var(--cut); stroke-width: 1.5; }
.trace .iberia-dot { fill: var(--cut); }
.trace .head { stroke: var(--cut); stroke-width: 1; }
.trace .label { font: 11.5px var(--sans); fill: var(--dim); }
.trace .label.cut { fill: var(--cut); }

/* ------------------------------------------------------------------ story column */
.story-body { position: relative; z-index: 2; overflow-x: clip; }
.opening {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 var(--gutter) 9vh;
  /* keep the title off the brightest lights */
  background: linear-gradient(90deg, rgba(5, 7, 12, 0.85), rgba(5, 7, 12, 0.55) 45%, rgba(5, 7, 12, 0) 72%);
}
.opening > * { max-width: 860px; }
.opening .kicker, .chapter .kicker, .step .when {
  margin: 0; font: 600 12px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim);
}
.opening h1 { margin: 16px 0 0; font-size: clamp(52px, 8.5vw, 124px); line-height: 0.95; letter-spacing: -0.045em; font-weight: 700; }
.opening .dek { font-size: clamp(16px, 1.4vw, 20px); max-width: 52ch; }
.scroll-hint { margin: 34px 0 0; font: 500 12px/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); display: flex; align-items: center; gap: 12px; }
.scroll-hint::before { content: ''; width: 34px; height: 1px; background: var(--dim); }

.steps { padding: 0 var(--gutter); }
.step {
  margin: 0 0 0 auto; width: min(420px, 100%);
  min-height: 92vh; display: flex; flex-direction: column; justify-content: center;
}
.step > * { position: relative; }
.step::before { content: none; }
.step h2 { margin: 12px 0 0; font: 650 30px/1.1 var(--sans); letter-spacing: -0.025em; }
.step p { margin: 14px 0 0; color: var(--paper-2); font-size: 16px; line-height: 1.55; text-wrap: pretty; }
.step .note { color: var(--dim); font-size: 13.5px; }
.step .when { font-variant-numeric: tabular-nums; }
.step:last-child { min-height: 110vh; }
/* the text sits on a soft panel so it stays readable over the lights */
.step > :first-child { margin-top: 0; }
.step { --pad: 26px; }
.step-inner {
  padding: var(--pad); background: rgba(5, 7, 12, 0.78); backdrop-filter: blur(3px);
  border-top: 1px solid var(--rule-strong);
}

/* ------------------------------------------------------------------ chapters after the collapse */
.chapter {
  position: relative; background: var(--night);
  padding: 110px var(--gutter) 40px;
  display: grid; grid-template-columns: minmax(240px, 1fr) 2.4fr; gap: 28px 64px;
  max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto;
}
.chapter::before { content: ''; position: absolute; inset: 0 -100vw; background: var(--night); z-index: -1; }
.chapter header { align-self: start; position: sticky; top: 90px; }
.chapter h2 { margin: 12px 0 0; font: 650 38px/1.06 var(--sans); letter-spacing: -0.03em; text-wrap: balance; }
.chapter header p:not(.kicker) { margin: 16px 0 0; color: var(--dim); font-size: 14.5px; max-width: 36ch; text-wrap: pretty; }
.chapter > figure, .chapter > .source, .chapter > .prose, .chapter > .milestones { grid-column: 2; margin: 0; }
.chapter > .source { color: var(--faint); font-size: 12.5px; max-width: 70ch; }

.demand svg, .barcode svg { width: 100%; height: auto; display: block; overflow: visible; }
.demand .axis text { font: 11px var(--sans); fill: var(--faint); }
.demand .axis line { stroke: var(--rule); }
.demand .actual { fill: none; stroke: var(--lights); stroke-width: 1.6; }
.demand .area { fill: url(#demandGold); }
.demand .normal { fill: none; stroke: rgba(239, 232, 219, 0.45); stroke-width: 1; stroke-dasharray: 2 3; }
.demand .ms line { stroke: rgba(239, 232, 219, 0.22); }
.demand .ms circle { fill: var(--night); stroke: var(--lights); stroke-width: 1.3; }
.demand .ms text { font: 600 11px var(--sans); fill: var(--night); }
.demand .ms circle.num { fill: var(--lights); stroke: none; }
.milestones { grid-column: 2; list-style: none; margin: 4px 0 0; padding: 0; columns: 2; column-gap: 32px; counter-reset: m; font-size: 13.5px; color: var(--paper-2); }
.milestones li { counter-increment: m; break-inside: avoid; display: grid; grid-template-columns: 26px 46px 1fr; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.milestones li::before { content: counter(m); width: 18px; height: 18px; border-radius: 50%; background: var(--lights); color: var(--night); font: 600 11px/18px var(--sans); text-align: center; }
.milestones time { font-variant-numeric: tabular-nums; color: var(--paper); font-weight: 600; }
.demand .hover line { stroke: var(--paper-2); stroke-width: 0.8; }
.demand .hover text { font: 12px var(--sans); fill: var(--paper); }
.demand .hover .bg { fill: rgba(5, 7, 12, 0.88); }

.barcode .lbl { font: 10px var(--sans); fill: var(--dim); }
.barcode .lbl.pt { fill: var(--paper-2); }
.barcode .tick text { font: 11px var(--sans); fill: var(--faint); }
.barcode .tick line { stroke: var(--rule-strong); }
.barcode .cut { stroke: var(--cut); stroke-width: 1; stroke-dasharray: 3 3; }
.barcode .group { font: 500 10.5px var(--sans); letter-spacing: 0.1em; fill: var(--faint); text-transform: uppercase; }
.barcode .note { font: italic 13px var(--serif); fill: var(--paper-2); }

.why .prose p { margin: 0 0 18px; font: 400 18px/1.6 var(--sans); color: var(--paper-2); max-width: 64ch; text-wrap: pretty; }

.why .prose .fine { font: 14px/1.5 var(--sans); color: var(--dim); }

.story-colophon { position: relative; background: var(--night); padding-left: var(--gutter); padding-right: var(--gutter); max-width: calc(var(--measure) + 2 * var(--gutter)); border-top: 1px solid var(--rule); margin-top: 60px; }
.reflist { list-style: none; margin: 0; padding: 0; }
.reflist li { padding: 4px 0; border-bottom: 1px dotted var(--rule); }

/* ------------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .step-inner { --pad: 18px; }
  .step h2 { font-size: 25px; }
  .step p { font-size: 15px; }
  .step .note { display: none; }
  .stage-shade { background: linear-gradient(0deg, rgba(5, 7, 12, 0.95) 0%, rgba(5, 7, 12, 0.2) 55%, rgba(5, 7, 12, 0) 100%); }
  .hud {
    left: 0; right: 0; bottom: 0; width: auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(5, 7, 12, 0.94); border-top: 1px solid var(--rule-strong);
    display: grid; grid-template-columns: auto 1fr; gap: 4px 18px; align-items: end;
  }
  .clock > span { font-size: 9.5px; white-space: nowrap; }
  .clock strong { font-size: 30px; }
  .readouts { margin: 0; gap: 14px; justify-content: flex-end; }
  .readouts dt { font-size: 9px; white-space: nowrap; }
  .readouts dd { font-size: 17px; white-space: nowrap; }
  .story .maplibregl-ctrl-bottom-right { bottom: 84px; }
  .trace, .legend-line { display: none; }
  .step { width: 100%; min-height: 100svh; justify-content: flex-end; padding-bottom: calc(118px + 6vh); }
  .milestones { grid-column: 1; columns: 1; }
  .chapter { grid-template-columns: 1fr; padding-top: 80px; }
  .chapter header { position: static; }
  .chapter > figure, .chapter > .source, .chapter > .prose, .chapter > .milestones { grid-column: 1; }
  .chapter h2 { font-size: 30px; }
  .why .prose p { font-size: 18px; }
}
