:root {
  /* Macaron palette. Each hue has a pastel fill and a deepened text-safe
     counterpart, because the pastels alone never clear AA on a light page.
     *-rgb components keep every rgba() tint tied to the same hue. */
  --ink-rgb: 74, 65, 88;        /* deep cocoa-violet, softer than black */
  --blue-rgb: 63, 116, 171;     /* blueberry, text-safe */
  --teal-rgb: 51, 125, 105;     /* pistachio-mint, text-safe */
  --red-rgb: 179, 85, 107;      /* rose, text-safe */
  --gold-rgb: 190, 140, 42;     /* vanilla, text-safe */
  --sky-rgb: 138, 180, 220;     /* pastel blue, decoration only */
  --deep-rgb: 58, 50, 70;       /* darkest cocoa */

  --ink: rgb(var(--ink-rgb));
  --muted: #746a80;
  --paper: #fdf9f5;             /* cream */
  --white: #ffffff;
  --line: #efe2e8;              /* pale rose rule */

  --blue: rgb(var(--blue-rgb));
  --blue-soft: #6f9fd0;         /* bar gradient light end */
  --teal: rgb(var(--teal-rgb));
  --teal-deep: #2f7361;
  --teal-light: #c2e8da;
  --red: rgb(var(--red-rgb));
  --red-light: #f9d2dc;
  --gold: rgb(var(--gold-rgb));
  --orange: #e8a178;            /* peach */
  --sky: rgb(var(--sky-rgb));

  --shadow: 0 18px 55px rgba(var(--ink-rgb), 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f0e7ed;
  color: var(--ink);
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
}

button {
  font: inherit;
}

.deck {
  width: 100%;
  height: 100%;
  position: relative;
}

.slide {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.6rem;
  padding: clamp(2rem, 4.2vw, 5rem) clamp(2.2rem, 6vw, 7rem) 2.2rem;
  background:
    radial-gradient(circle at 94% 4%, rgba(var(--sky-rgb), 0.10), transparent 25%),
    var(--paper);
  opacity: 0;
  visibility: hidden;
  transform: translateX(3%);
  transition: opacity 260ms ease, transform 260ms ease;
}

.slide.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  z-index: 2;
}

.slide::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 7px;
  background: linear-gradient(90deg, var(--blue), var(--teal), var(--red));
}

.title-slide {
  /* macaron shelf: soft pastel blooms over cream, dark cocoa type */
  background:
    radial-gradient(ellipse 70% 60% at 8% 12%, rgba(var(--red-rgb), 0.16), transparent 60%),
    radial-gradient(ellipse 65% 55% at 92% 18%, rgba(var(--blue-rgb), 0.15), transparent 62%),
    radial-gradient(ellipse 75% 65% at 78% 95%, rgba(var(--teal-rgb), 0.15), transparent 60%),
    radial-gradient(ellipse 60% 50% at 25% 92%, rgba(var(--gold-rgb), 0.14), transparent 62%),
    var(--paper);
  color: var(--ink);
}

.title-slide::after {
  content: "";
  position: absolute;
  width: min(56vw, 850px);
  height: min(56vw, 850px);
  right: -18vw;
  bottom: -35vw;
  border: 2px solid rgba(var(--ink-rgb), 0.09);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(var(--ink-rgb), 0.022),
              0 0 0 140px rgba(var(--ink-rgb), 0.016);
}

.kicker {
  margin: 0 0 0.6rem;
  color: var(--teal);
  font-size: clamp(0.8rem, 1.1vw, 1.1rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.title-slide .kicker {
  color: var(--teal-deep);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 1100px;
  margin-bottom: 1.2rem;
  font-size: clamp(2.9rem, 6vw, 6.8rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3.4vw, 4rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
}

h3 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.05rem, 1.45vw, 1.55rem);
}

.subtitle {
  max-width: 850px;
  color: rgba(var(--ink-rgb), 0.75);
  font-size: clamp(1.15rem, 1.8vw, 1.85rem);
  line-height: 1.45;
}

.title-meta {
  align-self: end;
  display: flex;
  gap: 2rem;
  color: var(--muted);
  font-size: 1rem;
}

.content {
  min-height: 0;
  display: flex;
  align-items: center;
}

.grid-2 {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.5rem, 3vw, 3.5rem);
  align-items: center;
}

.grid-3 {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 2vw, 2rem);
}

.card {
  height: 100%;
  padding: clamp(1.1rem, 2vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 28px rgba(var(--ink-rgb), 0.06);
}

.card.accent-blue {
  border-top: 6px solid var(--blue);
}

.card.accent-teal {
  border-top: 6px solid var(--teal);
}

.card.accent-red {
  border-top: 6px solid var(--red);
}

.big-number {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--blue);
  font-size: clamp(2.2rem, 4vw, 4.7rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
}

.metric-label {
  color: var(--muted);
  font-size: clamp(0.86rem, 1.15vw, 1.12rem);
  line-height: 1.35;
}

.question {
  max-width: 850px;
  padding-left: 1.3rem;
  border-left: 6px solid var(--red);
  font-size: clamp(1.4rem, 2.5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.25;
}

.plain-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li {
  position: relative;
  margin: 0.8rem 0;
  padding-left: 1.4rem;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.3vw, 1.3rem);
  line-height: 1.4;
}

.plain-list li::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}

.cycle-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  width: 100%;
}

.cycle {
  position: relative;
  padding: 1.5rem 1rem;
  border-radius: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  text-align: center;
  box-shadow: 0 8px 26px rgba(var(--ink-rgb), 0.06);
}

.cycle:not(:last-child)::after {
  content: "→";
  position: absolute;
  top: 50%;
  right: -1rem;
  z-index: 1;
  transform: translateY(-50%);
  color: var(--red);
  font-size: 1.5rem;
  font-weight: 800;
}

.cycle strong {
  display: block;
  color: var(--blue);
  font-size: clamp(1.5rem, 2.4vw, 2.7rem);
}

.cycle span {
  color: var(--muted);
}

.formula {
  padding: 1.4rem 1.8rem;
  border-radius: 14px;
  background: var(--ink);
  color: var(--white);
  font-family: Georgia, serif;
  font-size: clamp(1.1rem, 1.65vw, 1.7rem);
  line-height: 1.5;
  text-align: center;
}

.image-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-image {
  display: block;
  max-width: 100%;
  max-height: min(64vh, 700px);
  object-fit: contain;
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.result-image.tall {
  max-height: min(67vh, 760px);
}

.caption {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
}

.metric {
  padding: 1rem;
  border-radius: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  text-align: center;
}

.metric b {
  display: block;
  color: var(--blue);
  font-size: clamp(1.6rem, 2.7vw, 3rem);
}

.metric span {
  color: var(--muted);
}

.comparison {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
  background: var(--white);
  box-shadow: 0 8px 28px rgba(var(--ink-rgb), 0.06);
}

.comparison th,
.comparison td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: clamp(0.9rem, 1.2vw, 1.2rem);
}

.comparison th {
  background: var(--ink);
  color: var(--white);
}

.comparison tr:last-child td {
  border-bottom: 0;
}

.comparison .best {
  color: var(--teal);
  font-weight: 800;
}

.callout {
  padding: 1rem 1.2rem;
  border-left: 5px solid var(--gold);
  background: rgba(var(--gold-rgb), 0.10);
  color: var(--ink);
  font-size: clamp(0.95rem, 1.25vw, 1.25rem);
  line-height: 1.4;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(var(--teal-rgb), 0.12);
  color: var(--teal-deep);
  font-weight: 800;
}

.status::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--teal);
}

.takeaway {
  font-size: clamp(1.1rem, 1.7vw, 1.7rem);
  line-height: 1.45;
}

.takeaway strong {
  color: var(--red);
}

.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.title-slide .footer {
  color: var(--muted);
}

.controls {
  position: fixed;
  right: 1.2rem;
  bottom: 1.05rem;
  z-index: 20;
  display: flex;
  gap: 0.4rem;
}

.control {
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid rgba(var(--ink-rgb), 0.14);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(var(--ink-rgb), 0.12);
}

.control:hover {
  background: var(--ink);
  color: var(--white);
}

.progress {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 25;
  height: 5px;
  width: 0;
  background: var(--red);
  transition: width 220ms ease;
}

.counter {
  position: fixed;
  left: 1.2rem;
  bottom: 1.25rem;
  z-index: 20;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.overview .slide {
  position: relative;
  inset: auto;
  width: min(44vw, 700px);
  height: min(40vh, 430px);
  display: grid;
  flex: none;
  padding: 1.5rem;
  opacity: 1;
  visibility: visible;
  transform: none;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.overview .deck {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-content: flex-start;
  justify-content: center;
  height: auto;
  min-height: 100%;
  padding: 2rem;
}

body.overview {
  overflow: auto;
}

.overview .slide > * {
  transform: scale(0.62);
  transform-origin: top left;
  width: 160%;
}

.overview .controls,
.overview .counter {
  position: fixed;
}

.notes-panel {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 30;
  width: min(800px, calc(100vw - 8rem));
  max-height: 30vh;
  padding: 1rem 1.2rem;
  overflow: auto;
  transform: translateX(-50%);
  border-radius: 14px;
  background: rgba(var(--ink-rgb), 0.96);
  color: var(--white);
  box-shadow: var(--shadow);
  display: none;
  line-height: 1.45;
}

.notes-panel.visible {
  display: block;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(var(--deep-rgb), 0.93);
}

.lightbox.visible {
  display: flex;
}

.lightbox img {
  max-width: 96vw;
  max-height: 94vh;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 2.4rem;
  cursor: pointer;
}

@media (max-width: 900px) {
  .slide {
    padding: 2rem 1.4rem 3rem;
    gap: 1rem;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .content {
    overflow: auto;
    align-items: flex-start;
  }

  .cycle-flow {
    grid-template-columns: repeat(2, 1fr);
  }

  .cycle::after {
    display: none;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .slide,
  .progress {
    transition: none;
  }
}


/* ---------- Animated forecast-convergence timeline (slide 02) ---------- */

.lead-timeline {
  width: 100%;
  --lt-label-w: clamp(4.6rem, 7vw, 7rem);
  --lt-col-gap: 0.9rem;
  --lt-row-h: clamp(2rem, 3.1vh, 2.9rem);
  /* four cycles cover [0,48] [6,48] [12,48] [18,48] h -> intersection starts at 18/48 */
  --lt-overlap-start: 37.5%;
}

.lt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  margin-bottom: 0.85rem;
  font-size: clamp(0.72rem, 0.95vw, 0.92rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.lt-key {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.lt-swatch {
  width: 1.05rem;
  height: 0.62rem;
  border-radius: 3px;
  flex: none;
}

.lt-swatch--bar {
  background: linear-gradient(90deg, var(--blue-soft), var(--blue));
}

.lt-swatch--overlap {
  background: rgba(var(--teal-rgb), 0.16);
  border: 1px dashed rgba(var(--teal-rgb), 0.85);
}

.lt-swatch--conv {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--red);
}

/* --- plot area: label column + track column, rows stack on top of each other --- */

.lt-grid {
  position: relative;
  display: grid;
  grid-template-columns: var(--lt-label-w) 1fr;
  column-gap: var(--lt-col-gap);
  row-gap: clamp(0.4rem, 0.85vh, 0.7rem);
  padding: clamp(0.8rem, 1.6vh, 1.3rem) clamp(1rem, 1.8vw, 1.6rem);
  border-radius: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 8px 26px rgba(var(--ink-rgb), 0.06);
}

/* --- hour axis --- */

.lt-axis {
  position: relative;
  grid-column: 2;
  height: 1.35rem;
  border-bottom: 1px solid var(--line);
}

.lt-axis span {
  position: absolute;
  bottom: 0.3rem;
  left: var(--at);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: clamp(0.66rem, 0.88vw, 0.84rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.lt-axis span::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 1px;
  height: 0.32rem;
  background: var(--line);
}

.lt-axis span:first-child { transform: translateX(-10%); }
.lt-axis span:last-child  { transform: translateX(-90%); }

/* --- cycle label --- */

.lt-label {
  grid-column: 1;
  align-self: center;
  text-align: right;
  line-height: 1.1;
}

.lt-label strong {
  display: block;
  color: var(--blue);
  font-size: clamp(1rem, 1.55vw, 1.5rem);
  font-weight: 800;
}

.lt-label span {
  font-size: clamp(0.62rem, 0.82vw, 0.78rem);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* --- one forecast's coverage --- */

.lt-track {
  position: relative;
  z-index: 1;
  grid-column: 2;
  align-self: center;
  height: var(--lt-row-h);
  border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.035);
}

/* every hour shown is a real forecast: one solid bar, init time to Day +2 12Z */
.lt-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--start);
  width: var(--span);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-soft), var(--blue));
  box-shadow: 0 3px 12px rgba(var(--blue-rgb), 0.30);
  transform: scaleX(0);
  transform-origin: left center;
}

.lt-tip {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: clamp(0.62rem, 0.82vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.92);
  opacity: 0;
}

.lt-dot {
  position: absolute;
  top: 50%;
  left: 100%;
  width: 0.72rem;
  height: 0.72rem;
  margin: -0.36rem 0 0 -0.36rem;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(var(--red-rgb), 0.18);
  transform: scale(0);
}

/* --- the interval where all four cycles overlap = the 06Z run in full --- */

.lt-overlap {
  position: relative;
  z-index: 0;
  grid-column: 2;
  pointer-events: none;
  opacity: 0;
}

.lt-overlap::before {
  content: "";
  position: absolute;
  top: calc(var(--lt-row-h) * -0.16);
  bottom: calc(var(--lt-row-h) * -0.16);
  left: var(--lt-overlap-start);
  right: 0;
  border-radius: 12px;
  background: rgba(var(--teal-rgb), 0.13);
  border-left: 2px dashed rgba(var(--teal-rgb), 0.9);
}

/* --- shared endpoint --- */

.lt-converge {
  position: absolute;
  top: clamp(0.8rem, 1.6vh, 1.3rem);
  bottom: clamp(0.8rem, 1.6vh, 1.3rem);
  right: clamp(1rem, 1.8vw, 1.6rem);
  width: 2px;
  z-index: 2;
  background: linear-gradient(
    180deg,
    rgba(var(--red-rgb), 0) 0%,
    rgba(var(--red-rgb), 0.55) 18%,
    rgba(var(--red-rgb), 0.55) 100%
  );
  opacity: 0;
}

.lt-converge-flag {
  position: absolute;
  top: -0.2rem;
  right: 0;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  font-size: clamp(0.6rem, 0.8vw, 0.74rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---- playback ---- */

@keyframes lt-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes lt-pop {
  0%   { transform: scale(0); }
  65%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes lt-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes lt-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(var(--red-rgb), 0.18); }
  50%      { box-shadow: 0 0 0 7px rgba(var(--red-rgb), 0.05); }
}

.slide.replay .lt-bar {
  animation: lt-grow 620ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
  animation-delay: calc(160ms + var(--i) * 190ms);
}

.slide.replay .lt-tip {
  animation: lt-fade 340ms ease both;
  animation-delay: calc(520ms + var(--i) * 190ms);
}

.slide.replay .lt-dot {
  animation:
    lt-pop 460ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
    lt-pulse 2.4s ease-in-out 1.9s infinite;
  animation-delay: calc(600ms + var(--i) * 190ms), 2.1s;
}

/* overlap band arrives last, after all four bars have landed */
.slide.replay .lt-overlap {
  animation: lt-fade 620ms ease both;
  animation-delay: 1.5s;
}

.slide.replay .lt-converge {
  animation: lt-fade 620ms ease both;
  animation-delay: 1.25s;
}

@media (max-width: 900px) {
  .lead-timeline {
    --lt-label-w: 3.6rem;
  }

  .lt-converge-flag {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lt-bar {
    transform: scaleX(1);
  }

  .lt-dot {
    transform: scale(1);
  }

  .lt-tip,
  .lt-overlap,
  .lt-converge {
    opacity: 1;
  }

  .slide.replay .lt-bar,
  .slide.replay .lt-tip,
  .slide.replay .lt-dot,
  .slide.replay .lt-overlap,
  .slide.replay .lt-converge {
    animation: none;
  }
}

/* ---------- Entrance animations for figures and metric cards ---------- */

@keyframes fig-pop {
  0%   { opacity: 0; transform: translateY(22px) scale(0.93); }
  55%  { opacity: 1; transform: translateY(-8px) scale(1.025); }
  80%  { transform: translateY(2px) scale(0.995); }
  100% { opacity: 1; transform: none; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

@keyframes count-in {
  0%   { opacity: 0; transform: translateY(10px) scale(0.86); }
  70%  { opacity: 1; transform: translateY(0) scale(1.06); }
  100% { opacity: 1; transform: none; }
}

/* figures bounce in */
.slide.replay .result-image {
  animation: fig-pop 760ms cubic-bezier(0.34, 1.4, 0.5, 1) both;
  animation-delay: 140ms;
}

/* metric cards and numbers stagger up */
.slide.replay .card,
.slide.replay .metric {
  animation: rise-in 500ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

.slide.replay .card:nth-child(1),
.slide.replay .metric:nth-child(1) { animation-delay: 160ms; }
.slide.replay .card:nth-child(2),
.slide.replay .metric:nth-child(2) { animation-delay: 245ms; }
.slide.replay .card:nth-child(3),
.slide.replay .metric:nth-child(3) { animation-delay: 330ms; }
.slide.replay .card:nth-child(4),
.slide.replay .metric:nth-child(4) { animation-delay: 415ms; }

.slide.replay .big-number,
.slide.replay .metric b {
  animation: count-in 520ms cubic-bezier(0.34, 1.45, 0.6, 1) both;
  animation-delay: 300ms;
}

/* table rows draw in */
.slide.replay .comparison tbody tr {
  animation: rise-in 420ms ease both;
}
.slide.replay .comparison tbody tr:nth-child(1) { animation-delay: 180ms; }
.slide.replay .comparison tbody tr:nth-child(2) { animation-delay: 260ms; }
.slide.replay .comparison tbody tr:nth-child(3) { animation-delay: 340ms; }
.slide.replay .comparison tbody tr:nth-child(4) { animation-delay: 420ms; }

@media (prefers-reduced-motion: reduce) {
  .slide.replay .result-image,
  .slide.replay .card,
  .slide.replay .metric,
  .slide.replay .big-number,
  .slide.replay .metric b,
  .slide.replay .comparison tbody tr {
    animation: none;
  }
}

/* ---------- Two parallel tracking streams feeding one matching step ---------- */

.pipeline {
  display: grid;
  grid-template-columns: 1fr 0.92fr 1.05fr 1.05fr 0.95fr;
  gap: clamp(0.35rem, 0.7vh, 0.5rem) clamp(1.1rem, 1.9vw, 1.9rem);
  width: 100%;
  margin-top: 1.2rem;
}

.pl-node {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
  padding: clamp(0.5rem, 1.1vh, 0.85rem) clamp(0.55rem, 1vw, 0.95rem);
  border-radius: 13px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  box-shadow: 0 6px 20px rgba(var(--ink-rgb), 0.055);
  text-align: left;
}

.pl-node b {
  font-size: clamp(0.72rem, 1.02vw, 0.98rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
}

.pl-node small {
  font-size: clamp(0.58rem, 0.76vw, 0.72rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--muted);
}

/* arrows sit in the column gap */
.pl-node::after {
  content: "›";
  position: absolute;
  top: 50%;
  right: clamp(-1.35rem, -1.35vw, -0.78rem);
  transform: translate(50%, -54%);
  color: var(--red);
  font-size: clamp(1.2rem, 1.9vw, 1.8rem);
  font-weight: 700;
  line-height: 1;
  opacity: 0;
}

/* last column produces nothing further */
.pl-node--out::after {
  content: none;
}

/* the two stream colours */
.pl-node--fcst {
  border-left-color: var(--blue);
  background: linear-gradient(180deg, var(--white) 0%, #ecf3fc 100%);
}
.pl-node--obs {
  border-left-color: var(--teal);
  background: linear-gradient(180deg, var(--white) 0%, #e8f6f0 100%);
}
.pl-node--proc {
  border-left-color: var(--sky);
  background: linear-gradient(180deg, var(--white) 0%, #f4f0fa 100%);
}

.pl-node--match {
  border-left-color: var(--red);
  background: linear-gradient(180deg, var(--white) 0%, #fdeef2 100%);
}

.pl-node--out {
  border-left-color: var(--gold);
  background: linear-gradient(180deg, var(--white) 0%, #fdf4e0 100%);
}

/* the two streams converge on the matching box */
.pl-node--match::before {
  content: "";
  position: absolute;
  left: clamp(-1.35rem, -1.35vw, -0.78rem);
  top: 22%;
  bottom: 22%;
  width: 2px;
  background: rgba(var(--red-rgb), 0.4);
  transform: translateX(-50%);
  opacity: 0;
}

/* ---- playback ---- */

@keyframes pl-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.slide.replay .pl-node {
  animation: pl-in 460ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
  animation-delay: calc(1.75s + var(--i) * 150ms);
}

.slide.replay .pl-node::after,
.slide.replay .pl-node--match::before {
  animation: lt-fade 320ms ease both;
  animation-delay: calc(1.95s + var(--i) * 150ms);
}

@media (max-width: 1100px) {
  .pipeline {
    grid-template-columns: 1fr 1fr 1fr;
  }

  /* stack the two streams, then matching, then outputs */
  .pl-node { grid-area: auto !important; }

  .pl-node::after,
  .pl-node--match::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slide.replay .pl-node,
  .slide.replay .pl-node::after,
  .slide.replay .pl-node--match::before {
    animation: none;
  }

  .pl-node::after,
  .pl-node--match::before {
    opacity: 1;
  }
}

/* ---------- Large-figure and chart layouts ---------- */

/* figure + narrow commentary column; the figure gets most of the width */
.content.figure-layout {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 2.45fr) minmax(210px, 0.8fr);
  gap: clamp(1.2rem, 2.4vw, 2.6rem);
  align-items: center;
}

/* figure alone, as large as the slide allows */
.content.figure-only {
  width: 100%;
  display: block;
}

.content.figure-only .image-wrap {
  width: 100%;
  height: 100%;
}

.content.figure-only .result-image {
  max-width: 100%;
  max-height: 76vh;
}

/* figures inside a two-column slide still get more room than before */
.content.figure-layout .result-image {
  max-height: 72vh;
}

.content.figure-layout .result-image.tall {
  max-height: 74vh;
}

.fig-side {
  min-width: 0;
}

.fig-side .plain-list li {
  margin: 0.55rem 0;
  font-size: clamp(0.85rem, 1.05vw, 1.05rem);
}

.fig-side .takeaway {
  font-size: clamp(1rem, 1.3vw, 1.3rem);
  margin-bottom: 0.9rem;
}

.fig-side .caption {
  margin-top: 0.8rem;
}

/* live Chart.js canvases */
.chart-box {
  position: relative;
  width: 100%;
  height: min(70vh, 640px);
  padding: clamp(0.8rem, 1.6vh, 1.3rem) clamp(0.9rem, 1.6vw, 1.5rem);
  border-radius: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 8px 26px rgba(var(--ink-rgb), 0.06);
}

.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* compact stat row on the case slide */
.ratio-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ratio {
  padding: 0.6rem 0.7rem;
  border-radius: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  text-align: left;
}

.ratio b {
  display: block;
  color: var(--blue);
  font-size: clamp(1.15rem, 1.7vw, 1.7rem);
  font-weight: 800;
  line-height: 1.1;
}

.ratio span {
  color: var(--muted);
  font-size: clamp(0.62rem, 0.8vw, 0.76rem);
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* ---------- Matching schematic (slide 02) ---------- */

.match-figure {
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-figure svg {
  width: 100%;
  max-height: 58vh;
}

.mf-obs {
  fill: rgba(var(--ink-rgb), 0.10);
  stroke: var(--ink);
  stroke-width: 2.5;
}

.mf-fcst {
  fill: rgba(var(--red-rgb), 0.16);
  stroke: var(--red);
  stroke-width: 2.5;
  stroke-dasharray: 9 6;
}

.mf-dcent {
  stroke: var(--blue);
  stroke-width: 2.5;
  stroke-dasharray: 5 4;
}

.mf-dot--obs { fill: var(--ink); }
.mf-dot--fcst { fill: var(--red); }

.mf-t {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.mf-t--obs { fill: var(--ink); }
.mf-t--fcst { fill: var(--red); text-anchor: start; }

.mf-d {
  fill: var(--blue);
  font-size: 15px;
  font-weight: 800;
  text-anchor: middle;
}

.mf-n {
  fill: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-anchor: middle;
}

.mf-sub { font-size: 10px; }

/* schematic draws itself in */
@keyframes mf-appear {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}

.slide.replay .match-figure svg {
  animation: mf-appear 620ms cubic-bezier(0.22, 0.9, 0.3, 1) both;
  animation-delay: 140ms;
  transform-origin: center;
}

@media (max-width: 1100px) {
  .content.figure-layout {
    grid-template-columns: 1fr;
  }

  .chart-box {
    height: min(48vh, 420px);
  }

  .content.figure-only .result-image,
  .content.figure-layout .result-image,
  .content.figure-layout .result-image.tall {
    max-height: 52vh;
  }

  .ratio-strip {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .slide.replay .match-figure svg {
    animation: none;
  }
}

/* Figure-only slides: give the image the whole content box rather than a
   viewport fraction, which overflowed once the header and footer were counted.
   Trimming the slide padding buys the figure real height on a 16:9 screen. */
.slide:has(> .content.figure-only) {
  padding-top: clamp(1.5rem, 2.8vw, 2.8rem);
  padding-bottom: 1.4rem;
  gap: 0.85rem;
}

.slide:has(> .content.figure-only) h2 {
  font-size: clamp(1.7rem, 2.7vw, 3.1rem);
}

.content.figure-only .result-image {
  max-height: 100%;
  max-width: 100%;
}

/* percentage max-height fails when the ancestor's height is auto, so size the
   figure box explicitly and let object-fit do the letterboxing */
.content.figure-only {
  display: flex;
  height: 100%;
  min-height: 0;
}

.content.figure-only .image-wrap {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  width: auto;   /* overrides the earlier width:100%, which fought flex-grow */
}

.content.figure-only .result-image {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

/* ---------- Two charts side by side, with one shared note underneath ---------- */

.content.chart-pair {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(0.6rem, 1.4vw, 1.4rem);
  align-items: stretch;
}

.chart-cell {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chart-label {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.68rem, 0.92vw, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* inside a pair the box fills its cell instead of using a viewport fraction */
.chart-pair .chart-box {
  flex: 1 1 0%;
  min-height: 0;
  height: auto;
}

.pair-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.7rem 1rem;
  border-left: 4px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: rgba(var(--gold-rgb), 0.10);
  color: var(--ink);
  font-size: clamp(0.78rem, 1.02vw, 1.02rem);
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .content.chart-pair {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .chart-pair .chart-box {
    height: min(38vh, 320px);
    flex: 0 0 auto;
  }
}

/* ---------- "Original figure" button on live-chart slides ---------- */

.fig-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  padding: 0.38rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  font-size: clamp(0.66rem, 0.85vw, 0.8rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: zoom-in;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.fig-link::before {
  content: "⛶";
  font-size: 0.9em;
  line-height: 1;
}

.fig-link:hover {
  color: var(--ink);
  border-color: var(--blue);
  background: #ecf3fc;
}

/* inside a chart pair the button sits under the shared note */
.chart-pair .fig-link {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 0;
}

/* ---------- Frame-by-frame GIF player ---------- */

.fig-link--play::before {
  content: "▶";
}

.gif-player {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 2rem 2rem 1.4rem;
  background: rgba(var(--deep-rgb), 0.94);
}

.gif-player.visible {
  display: flex;
}

.gif-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
}

.gif-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gif-canvas,
.gif-fallback {
  max-width: min(92vw, 1100px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 10px;
  background: var(--white);
}

.gif-status {
  margin: 0;
  min-height: 1.2em;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
  font-weight: 600;
}

.gif-controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.gif-controls button {
  min-width: 2.4rem;
  height: 2.1rem;
  padding: 0 0.6rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.gif-controls button:hover {
  background: var(--white);
}

.gif-scrub {
  width: clamp(140px, 32vw, 420px);
  accent-color: var(--red);
  cursor: pointer;
}

.gif-count {
  min-width: 4.5rem;
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* compact scene-complexity table on the method slide */
.scene-table {
  margin-top: 1rem;
  font-size: clamp(0.7rem, 0.92vw, 0.9rem);
}

.scene-table th,
.scene-table td {
  padding: 0.35rem 0.5rem;
  font-size: inherit;
}

.comparison .warn {
  color: var(--red);
  font-weight: 800;
}
