/* ============================================================
   INTERACTIVE KEY IDEAS SYSTEM
   Premium Framework for Key Ideas
   ============================================================ */

/* --- Custom Variables for Idea UI --- */
.interactive-deck-container {
  --slide-bg: rgba(255, 255, 255, 0.64);
  --slide-border: rgba(26, 26, 26, 0.08);
  --slide-shadow: 0 28px 70px rgba(26, 26, 26, 0.07), 0 2px 12px rgba(26, 26, 26, 0.03);
  --glass-blur: 18px;
  --panel-width: min(1120px, calc(100vw - 3rem));
  --transition-speed: 0.52s;
  --transition-ease: cubic-bezier(0.25, 1, 0.3, 1);
  --control-surface: rgba(255, 255, 255, 0.48);
  --control-border: rgba(26, 26, 26, 0.08);
  /* Reserve must cover the fixed nav + title header (~210px) plus the bottom
     margin (~24px) so the whole card — including its nav footer — fits within
     the fold. A too-small reserve let the card grow past the viewport. */
  --deck-h: clamp(560px, calc(100vh - 245px), 700px);
}

/* Dark mode overrides (if body has dark class, or automatic based on site context) */
@media (prefers-color-scheme: dark) {
  /* We can enable dark mode if needed, but we will align with the page theme first.
     To make the aesthetics stand out, we will design rich glass surfaces. */
}

/* Floating Gradient Blobs in Background */
.ambient-glows {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.08;
  mix-blend-mode: multiply;
  animation: floatAround 25s ease-in-out infinite;
}

.glow-blob-1 {
  top: 15%;
  left: 20%;
  width: 420px;
  height: 420px;
  background-color: var(--accent);
}

.glow-blob-2 {
  bottom: 10%;
  right: 15%;
  width: 460px;
  height: 460px;
  background-color: color-mix(in srgb, var(--accent) 50%, #fff);
  animation-delay: -5s;
  animation-duration: 30s;
}

@keyframes floatAround {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(30px, -50px) scale(1.1);
  }
  66% {
    transform: translate(-20px, 40px) scale(0.95);
  }
}

/* Main Container Layout */
.interactive-deck-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  max-width: var(--panel-width);
  margin: 0.6rem auto 1.5rem;
  min-height: auto;
  position: relative;
  z-index: 10;
}

.deck-title {
  max-width: var(--panel-width) !important;
  padding-top: 3.9rem !important;
  padding-bottom: 0 !important;
}

.deck-title .article-category {
  margin-bottom: 1rem;
}

.deck-title .article-title {
  font-size: clamp(1.75rem, 2.6vw, 2.25rem) !important;
  margin-top: 0.15rem !important;
}

.deck-title .thin-rule {
  margin-top: 0.85rem !important;
  margin-bottom: 0 !important;
}

/* Key Idea Window */
.slide-window {
  height: var(--deck-h);
  background: var(--slide-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--slide-border);
  border-radius: 12px;
  box-shadow: var(--slide-shadow);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: background 0.4s, border-color 0.4s;
}

.slide-window::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.42), transparent 38%),
    radial-gradient(circle at 88% 12%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 32%);
  opacity: 0.72;
  z-index: 0;
}

/* Mode Selector */
.deck-mode-toggle {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.deck-hint {
  margin-right: auto;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-sec);
  opacity: 0.48;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(26, 26, 26, 0.07);
  padding: 0.4rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px;
  color: var(--text-sec);
  cursor: pointer;
  transition: all 0.3s var(--ease-out-quart);
}

.mode-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}

/* Idea Wrapper & Transitions */
.slide-deck {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  width: 100%;
  height: 100%;
  flex-grow: 1;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.idea-slide {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: clamp(1.65rem, 3.4vw, 3.25rem);
  padding: clamp(1.6rem, 2.5vw, 2.6rem);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(40px);
  transition:
    opacity var(--transition-speed) var(--transition-ease),
    transform var(--transition-speed) var(--transition-ease),
    visibility 0s var(--transition-speed);
  min-height: 0;
  position: relative;
}

.idea-slide::before {
  content: attr(data-idea-number);
  position: absolute;
  top: clamp(1.15rem, 2vw, 1.75rem);
  right: clamp(1.15rem, 2vw, 1.75rem);
  font-family: var(--mono);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 1;
  color: var(--text);
  opacity: 0.035;
  pointer-events: none;
}

.idea-slide::after {
  content: attr(data-idea-number) ' / ' attr(data-idea-total);
  position: absolute;
  top: clamp(1.35rem, 2.2vw, 1.95rem);
  left: clamp(1.35rem, 2.2vw, 1.95rem);
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-sec);
  opacity: 0.42;
  pointer-events: none;
}

/* Active idea state */
.idea-slide.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  transition:
    opacity var(--transition-speed) var(--transition-ease),
    transform var(--transition-speed) var(--transition-ease),
    visibility 0s 0s;
}

/* Previous idea exit animation */
.idea-slide.exit-left {
  transform: translateX(-40px);
  opacity: 0;
  visibility: visible;
}

/* Next idea exit animation */
.idea-slide.exit-right {
  transform: translateX(40px);
  opacity: 0;
  visibility: visible;
}

/* ============================================================
   IDEA ENTRANCE CHOREOGRAPHY
   When an idea becomes active its pieces assemble in sequence
   instead of arriving as one block: the copy fades up line by
   line and the visualization blooms in just after, so each idea
   reads as composed. The copy uses an opacity-led rise (small
   offset) because the slide itself already lifts on the Y axis
   (see .deck-vertical .idea-slide); the visual gets a distinct
   scale-bloom so it lands as the composed centerpiece rather
   than a second vertical shove. Re-runs on every navigation
   because updateSlides() removes then re-adds .active. Fully
   disabled under prefers-reduced-motion (block far below).
   ============================================================ */
.idea-slide.active .idea-copy > * {
  animation: ideaCopyRise 0.5s var(--ease-out-expo) both;
}
.idea-slide.active .idea-copy > *:nth-child(1) { animation-delay: 0.04s; }
.idea-slide.active .idea-copy > *:nth-child(2) { animation-delay: 0.10s; }
.idea-slide.active .idea-copy > *:nth-child(3) { animation-delay: 0.16s; }
.idea-slide.active .idea-copy > *:nth-child(4) { animation-delay: 0.21s; }
.idea-slide.active .idea-copy > *:nth-child(5) { animation-delay: 0.26s; }
.idea-slide.active .idea-copy > *:nth-child(n + 6) { animation-delay: 0.30s; }

.idea-slide.active .idea-visual {
  animation: ideaVisualBloom 0.64s var(--ease-out-expo) 0.1s both;
}

@keyframes ideaCopyRise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes ideaVisualBloom {
  from { opacity: 0; transform: translateY(14px) scale(0.986); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Idea Copy Section */
.idea-copy {
  display: flex;
  flex-direction: column;
  /* `safe center` centers content that fits but falls back to top-alignment
     when the column is taller than the card, so dense slides never clip their
     opening lines. Paired with overflow-y:auto + min-height:0, the rare
     over-tall slide scrolls within its column instead of hiding content. */
  justify-content: safe center;
  align-items: flex-start;
  max-width: 500px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.idea-kicker {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.85rem;
  margin-top: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.idea-kicker::after {
  content: '';
  width: 24px;
  height: 1px;
  background-color: currentColor;
  opacity: 0.35;
}

.idea-slide h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.95rem, 3.2vw, 2.65rem);
  line-height: 1.04;
  color: var(--text);
  margin-bottom: 1rem;
  text-wrap: balance;
}

.idea-lede {
  font-size: 0.98rem;
  line-height: 1.62;
  color: var(--text-sec);
  margin-bottom: 1.15rem;
}

.idea-points {
  list-style: none;
  padding: 0;
  margin: 0 0 1.15rem 0;
  display: grid;
  gap: 0.52rem;
}

.idea-points li {
  font-size: 0.83rem;
  line-height: 1.48;
  color: var(--text-sec);
  opacity: 0.82;
  position: relative;
  padding-left: 1.25rem;
}

.idea-points li::before {
  content: '·';
  position: absolute;
  left: 0.15rem;
  top: 0.05rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--accent);
}

/* Visualization Panel */
.idea-visual {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  min-width: 0;
}

.visual-container {
  width: 100%;
  max-width: 440px;
  aspect-ratio: 4/3;
  background:
    linear-gradient(rgba(26, 26, 26, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 26, 26, 0.028) 1px, transparent 1px),
    rgba(255, 255, 255, 0.34);
  background-size: 22px 22px;
  border: 1px solid rgba(26, 26, 26, 0.06);
  box-shadow: inset 0 2px 8px rgba(26, 26, 26, 0.02);
  border-radius: 10px;
  padding: clamp(1rem, 2.2vw, 1.45rem);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.4s var(--ease-out-quart);
}

.visual-container::before {
  content: attr(data-visual-label);
  position: absolute;
  left: 1rem;
  top: 0.82rem;
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-sec);
  opacity: 0.38;
  pointer-events: none;
}

.visual-container:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.45);
}

.visual-container svg {
  width: 100%;
  height: 100%;
  max-height: min(280px, 40vh);
  overflow: visible;
}

.visual-caption {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-sec);
  opacity: 0.55;
  margin-top: 0.78rem;
  text-align: center;
  max-width: 320px;
}

/* Interactive SVG animations and controls */
.slide-control-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin-top: 0.95rem;
  padding: 0.68rem 0.82rem;
  background: var(--control-surface);
  border: 1px solid var(--control-border);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.34) inset;
}

.slide-control-panel label {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  white-space: nowrap;
}

.slide-slider {
  flex-grow: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.slide-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.slide-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.slide-btn {
  background: rgba(255, 255, 255, 0.45);
  color: var(--text);
  border: 1px solid rgba(26, 26, 26, 0.22);
  padding: 0.4rem 1rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  transition: all 0.3s var(--ease-out-quart);
}

.slide-btn.active {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 82%, #000);
  color: #fff;
}

.slide-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
  filter: brightness(1.08);
}

.slide-btn:disabled,
.start-btn:disabled {
  cursor: progress;
  filter: saturate(0.65);
  opacity: 0.68;
  transform: none;
}

.interactive-desc-panel {
  background: rgba(255, 255, 255, 0.48) !important;
  border-color: rgba(26, 26, 26, 0.06) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.interactive-desc-panel strong {
  color: var(--text);
  font-weight: 500;
}

.slide-btn:active {
  transform: translateY(0);
}

/* Control Footer Layout */
.deck-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.78rem 1.1rem;
  background: rgba(255, 255, 255, 0.25);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 0 0 12px 12px;
  position: relative;
  z-index: 2;
}

/* Progress Fill Indicator */
.deck-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(0, 0, 0, 0.03);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
}

.deck-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width var(--transition-speed) var(--transition-ease);
}

/* Navigation Controls */
.deck-controls {
  display: flex;
  align-items: center;
  gap: 0.72rem;
}

.control-btn {
  background: rgba(255, 255, 255, 0.32);
  border: 1px solid rgba(0, 0, 0, 0.08);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.3s var(--ease-out-quart);
}

.control-btn:hover:not(:disabled) {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  transform: scale(1.05);
}

.control-btn:disabled {
  opacity: 0.24;
  cursor: not-allowed;
}

/* Idea index indicator */
.slide-indicator {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-sec);
  letter-spacing: 0.05em;
  opacity: 0.7;
  min-width: 4.5rem;
}

.slide-dots {
  display: flex;
  gap: 0.42rem;
  align-items: center;
  justify-content: center;
}

.slide-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s;
  border: 0;
  padding: 0;
}

.slide-dot.active {
  background: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* Opening and Closing Ideas */
.deck-intro-slide,
.deck-outro-slide {
  grid-template-columns: 1fr !important;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
  place-items: center;
}

.deck-intro-slide .idea-copy,
.deck-outro-slide .idea-copy {
  align-items: center;
  max-width: 600px;
}

.deck-intro-slide::before,
.deck-outro-slide::before {
  opacity: 0.05;
}

.deck-intro-slide h2 {
  font-size: clamp(2.1rem, 4vw, 3.05rem);
  margin-bottom: 1.1rem;
}

.deck-intro-slide .deck-intro-desc {
  font-size: 1.03rem;
  line-height: 1.68;
  color: var(--text-sec);
  margin-bottom: 1.7rem;
}

.start-btn {
  font-size: 0.85rem;
  padding: 0.7rem 1.8rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
  transition: all 0.3s var(--ease-out-quart);
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
  filter: brightness(1.06);
}

/* Linear reading mode container overrides */
.linear-read-mode .slide-window {
  height: auto;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.linear-read-mode .slide-deck {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.linear-read-mode .idea-slide {
  display: grid;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: none;
  padding: clamp(2rem, 4vw, 3.25rem);
  border: 1px solid var(--slide-border);
  background: var(--slide-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02);
  scroll-margin-top: 5rem;
}

.linear-read-mode .deck-footer,
.linear-read-mode .deck-progress-bar,
.linear-read-mode .start-btn {
  display: none;
}

/* Responsive adjust */
@media (max-width: 960px) {
  .interactive-deck-container {
    --panel-width: calc(100vw - 2rem);
    --deck-h: auto;
  }

  .deck-title {
    padding-top: 5.1rem !important;
  }

  .slide-window {
    height: auto;
    min-height: 0;
  }

  .idea-slide {
    grid-template-columns: 1fr;
    gap: 1.65rem;
    padding: 2.25rem;
    min-height: auto;
  }

  /* On mobile the slide-window height is auto, and all slides share one grid
     cell (1/1). Inactive slides are only visibility:hidden, so they still
     inflate the grid row to the tallest slide — leaving short slides (e.g. the
     centered intro) marooned in a tall card with a void above. Pull inactive
     slides out of flow so the card sizes to the ACTIVE slide only. */
  .idea-slide:not(.active) {
    position: absolute;
    inset: 0;
  }

  .idea-copy {
    max-width: 100%;
  }

  .idea-visual {
    width: 100%;
  }

  .visual-container {
    max-width: 100%;
    max-height: 330px;
  }

  .interactive-deck-container {
    margin: 1rem;
  }

  .deck-hint {
    display: none;
  }
}

@media (max-width: 600px) {
  .deck-title {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .deck-mode-toggle {
    justify-content: stretch;
  }

  .mode-btn {
    flex: 1;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
    font-size: 0.58rem;
  }

  .idea-slide {
    padding: 1.55rem 1.15rem;
  }
  
  .idea-slide h2 {
    font-size: 1.72rem;
  }

  .idea-lede {
    font-size: 0.93rem;
  }

  .slide-control-panel {
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
  }

  .deck-footer {
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    padding: 1.25rem;
  }

  .deck-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .slide-dots {
    display: none; /* Hide dots on small mobile to save space */
  }
}

@media (prefers-reduced-motion: reduce) {
  .glow-blob,
  .flow-path {
    animation: none !important;
  }

  .idea-slide,
  .deck-progress-fill,
  .visual-container,
  .slide-btn,
  .start-btn,
  .control-btn,
  .mode-btn,
  svg .animating-node {
    transition-duration: 0.01ms !important;
  }

  .idea-slide.active .idea-copy > *,
  .idea-slide.active .idea-visual {
    animation: none !important;
  }
}

/* ============================================================
   VERTICAL NAVIGATION MODE (.deck-vertical)
   A guided vertical rail instead of a horizontal presentation:
   the ideas form a visible spine you step down through, and the
   slides transition vertically rather than sliding sideways.
   ============================================================ */
.interactive-deck-container.deck-vertical {
  --rail-pad: clamp(1rem, 1.6vw, 1.45rem);
  --panel-width: min(1200px, calc(100vw - 3rem));
  /* The rail's up/down arrows sit at the very bottom of the card, so the
     whole card (chrome ~210px + this height) must clear the fold. A lower
     floor than the horizontal deck lets short laptops (~720px) fit without
     pushing the rail controls below the viewport. */
  --deck-h: clamp(460px, calc(100vh - 222px), 720px);
}

/* Window becomes rail + stage side by side. */
.deck-vertical .slide-window {
  flex-direction: row;
  align-items: stretch;
}

/* Retire the horizontal chrome — the rail owns navigation now. */
.deck-vertical .deck-footer,
.deck-vertical .deck-progress-bar {
  display: none;
}

/* Transitions move on the Y axis. We reuse the engine's exit-left
   (forward → previous exits upward) and exit-right (backward →
   previous exits downward) classes, only changing the axis. */
.deck-vertical .idea-slide {
  transform: translateY(34px);
}
.deck-vertical .idea-slide.active {
  transform: translateY(0);
}
.deck-vertical .idea-slide.exit-left {
  transform: translateY(-34px);
}
.deck-vertical .idea-slide.exit-right {
  transform: translateY(34px);
}

/* The slide stage fills the space beside the rail. */
.deck-vertical .slide-deck {
  flex-grow: 1;
  min-width: 0;
}

/* --- The rail --- */
.deck-rail {
  flex: 0 0 clamp(178px, 17vw, 218px);
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 2.4vw, 2.1rem) 0 clamp(1.2rem, 2vw, 1.6rem);
  border-right: 1px solid var(--slide-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.12));
  position: relative;
  z-index: 4;
  min-height: 0;
}

.deck-rail-eyebrow {
  font-family: var(--mono);
  font-size: 0.56rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-sec);
  opacity: 0.5;
  padding: 0 var(--rail-pad);
  margin-bottom: 0.9rem;
}

.deck-rail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  position: relative;
}

/* The spine line behind the step markers. */
.deck-rail-list::before {
  content: '';
  position: absolute;
  left: calc(var(--rail-pad) + 4px);
  top: 0.85rem;
  bottom: 0.85rem;
  width: 1px;
  background: rgba(26, 26, 26, 0.1);
}

/* The accent fill that grows as you descend. */
.deck-rail-fill {
  position: absolute;
  left: calc(var(--rail-pad) + 4px);
  top: 0.85rem;
  width: 1px;
  height: 0;
  background: var(--accent);
  opacity: 0.85;
  transition: height var(--transition-speed) var(--transition-ease);
  pointer-events: none;
}

.deck-rail-step {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  position: relative;
  padding: 0.46rem var(--rail-pad) 0.46rem calc(var(--rail-pad) + 1.45rem);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  color: var(--text-sec);
  transition: color 0.3s var(--ease-out-quart);
}

.deck-rail-step::before {
  content: '';
  position: absolute;
  left: var(--rail-pad);
  top: 0.62rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid rgba(26, 26, 26, 0.2);
  transition: all 0.3s var(--ease-out-quart);
}

.deck-rail-step .rail-num {
  font-family: var(--mono);
  font-size: 0.54rem;
  letter-spacing: 0.12em;
  opacity: 0.55;
}

.deck-rail-step .rail-label {
  font-family: var(--sans);
  font-size: 0.78rem;
  line-height: 1.24;
  font-weight: 400;
  text-wrap: balance;
}

.deck-rail-step:hover {
  color: var(--text);
}
.deck-rail-step:hover::before {
  border-color: var(--accent);
}

.deck-rail-step.done {
  color: var(--text-sec);
}
.deck-rail-step.done::before {
  background: var(--accent);
  border-color: var(--accent);
  opacity: 0.45;
}

.deck-rail-step.active {
  color: var(--text);
}
.deck-rail-step.active .rail-label {
  font-weight: 500;
}
.deck-rail-step.active::before {
  background: var(--accent);
  border-color: var(--accent);
  opacity: 1;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.deck-rail-step:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 4px;
}

/* Up / down stepping arrows pinned below the spine. */
.deck-rail-nav {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem var(--rail-pad) 0;
  margin-top: 0.5rem;
  border-top: 1px solid var(--slide-border);
}

/* --- Linear ("Full List") mode hides the rail and restacks. --- */
.deck-vertical.linear-read-mode .slide-window {
  flex-direction: column;
}
.deck-vertical.linear-read-mode .deck-rail {
  display: none;
}

/* --- Short viewports: compress the rail so the full spine stays above the fold --- */
@media (min-width: 961px) and (max-height: 768px) {
  .deck-vertical .deck-rail-eyebrow { margin-bottom: 0.45rem; }
  .deck-vertical .deck-rail-step {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }
  .deck-vertical .deck-rail-step .rail-num { display: none; }
  .deck-vertical .deck-rail-step .rail-label { font-size: 0.74rem; }
  .deck-vertical .deck-rail-step::before { top: 0.48rem; }
}

/* --- Vertical mode responsive: rail goes to a horizontal strip --- */
@media (max-width: 960px) {
  .deck-vertical .slide-window {
    flex-direction: column;
  }
  .deck-rail {
    flex: none;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0.8rem 0.9rem;
    border-right: none;
    border-bottom: 1px solid var(--slide-border);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .deck-rail::-webkit-scrollbar { display: none; }
  .deck-rail-eyebrow { display: none; }
  .deck-rail-list {
    flex-direction: row;
    overflow-y: visible;
    overflow-x: visible;
    gap: 0.35rem;
  }
  .deck-rail-list::before,
  .deck-rail-fill {
    display: none;
  }
  .deck-rail-step {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0.34rem 0.7rem;
    border: 1px solid var(--slide-border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.4);
  }
  .deck-rail-step::before {
    position: static;
    width: 6px;
    height: 6px;
  }
  .deck-rail-step .rail-label {
    font-size: 0.7rem;
    white-space: nowrap;
  }
  .deck-rail-step:not(.active) .rail-label {
    display: none;
  }
  .deck-rail-step .rail-num { display: none; }
  .deck-rail-nav {
    border-top: none;
    margin: 0 0 0 auto;
    padding: 0;
    flex: 0 0 auto;
  }
}
