/* ============================================================
   CourseFM — Episode Story page
   Cinematic chaptered scroll experience.
   The Three.js paint canvas sits behind everything (z -1);
   scenes are translucent so the paint breathes through.
   ============================================================ */

body:has(#episode-story) {
  background: #07090f;
}

body:has(#episode-story) .site-footer {
  position: relative;
  z-index: 2;
}

.story-canvas-wrap {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(160deg, #0d1b3d 0%, #101a33 55%, #0a0f1e 100%);
}

#story-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.story {
  position: relative;
  z-index: 1;
  overflow-x: clip;
}

.story-toast {
  position: relative;
  z-index: 5;
  margin: 1rem auto 0;
  max-width: 680px;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  background: rgba(38, 99, 235, 0.16);
  border: 1px solid rgba(120, 160, 255, 0.35);
  color: #dbe6ff;
  font-size: 0.9rem;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ---------- Scenes ---------- */

.scene {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: clamp(4rem, 10vh, 7rem) 1.5rem;
}

.scene-inner {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.scene-inner-wide { max-width: 1240px; }

.scene-dark { color: #eef2fb; }
.scene-light { color: #141a26; }

/* Soft readability wash per scene — translucent so paint shows through */
.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.scene-dark::before {
  background: radial-gradient(ellipse 90% 70% at 50% 50%, rgba(4, 7, 16, 0) 0%, rgba(4, 7, 16, 0.38) 100%);
}

.scene-light::before {
  background: linear-gradient(180deg, rgba(244, 246, 250, 0) 0%, rgba(244, 246, 250, 0.28) 18%, rgba(244, 246, 250, 0.28) 82%, rgba(244, 246, 250, 0) 100%);
}

/* ---------- Typography ---------- */

.chapter-tag {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  opacity: 0.82;
  margin: 0 0 1.75rem;
}

.chapter-num {
  font-family: "Playfair Display", serif;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0;
  opacity: 0.55;
}

.chapter-tag::after {
  content: "";
  flex: 0 0 64px;
  height: 1px;
  background: currentColor;
  opacity: 0.35;
}

.scene-kicker {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #9db8f5;
  margin: 0 0 1.25rem;
}

.kicker-sep { margin: 0 0.5rem; opacity: 0.5; }

.story-title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.6rem, 7vw, 5.2rem);
  font-weight: 900;
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0 0 1.5rem;
  max-width: 15ch;
}

.story-title .w {
  display: inline-block;
  will-change: transform, opacity;
}

.story-subtitle {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.55;
  color: rgba(230, 238, 255, 0.82);
  max-width: 52ch;
  margin: 0 0 2.25rem;
}

.scene-heading {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  line-height: 1.12;
  margin: 0 0 2rem;
}

/* ---------- Buttons ---------- */

.story-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.9rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: "Inter", sans-serif;
  letter-spacing: 0.01em;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s, background 0.25s, color 0.25s;
}

.story-btn-primary {
  background: linear-gradient(120deg, #3B7BF7, #2663EB);
  color: #fff;
  box-shadow: 0 8px 32px rgba(38, 99, 235, 0.45);
}

.story-btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 44px rgba(38, 99, 235, 0.6);
}

.story-btn-ghost {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  opacity: 0.9;
}

.story-btn-ghost:hover { opacity: 1; transform: translateY(-1px); }

.story-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #e8eeff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.2s, border-color 0.2s;
}

.story-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

/* ---------- Glass panels ---------- */

.glass-panel {
  background: rgba(12, 18, 36, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.scene-light .glass-panel {
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(20, 26, 38, 0.1);
  box-shadow: 0 24px 80px rgba(20, 26, 38, 0.12);
}

/* ---------- Hero (Overture) ---------- */

.scene-hero {
  min-height: 108vh;
  align-items: center;
}

/* Pexels hero film — graded into the painted world */
.hero-film {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.hero-film video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* cinematic grade: cooled, dimmed, slightly crushed so text always reads */
  filter: brightness(0.5) saturate(0.72) contrast(1.08) hue-rotate(-8deg);
  transform: scale(1.04);
}

.hero-film-grade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* blue wash + vignette + long fade into the paint below */
  background:
    linear-gradient(180deg, rgba(9, 14, 32, 0.55) 0%, rgba(9, 14, 32, 0.18) 34%, rgba(9, 14, 32, 0.28) 62%, rgba(10, 15, 30, 0.96) 100%),
    radial-gradient(ellipse 120% 90% at 50% 38%, rgba(13, 27, 61, 0) 30%, rgba(13, 27, 61, 0.6) 100%),
    linear-gradient(120deg, rgba(36, 85, 200, 0.16), rgba(90, 46, 166, 0.14));
}

/* keep the hero readability wash out of the film's way */
.scene-hero.has-film::before { display: none; }

.hero-inner { max-width: 1100px; }

.story-crumb {
  display: flex;
  gap: 0.6rem;
  font-size: 0.8rem;
  margin-bottom: 2.5rem;
  opacity: 0.7;
}

.story-crumb a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.story-crumb a:hover { border-color: currentColor; }

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin: 0 0 1.75rem;
}

.hero-cast {
  font-size: 0.9rem;
  color: rgba(220, 230, 250, 0.72);
  margin: 0;
}

.hero-cast strong { color: #fff; font-weight: 600; }

.hero-art {
  position: absolute;
  right: clamp(-4rem, -2vw, 0rem);
  top: 50%;
  translate: 0 -50%;
  width: clamp(260px, 30vw, 430px);
  aspect-ratio: 3 / 4;
  border-radius: 20px;
  overflow: hidden;
  margin: 0;
  z-index: 1;
  opacity: 0.9;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.55);
  transform: rotate(3deg);
  mask-image: radial-gradient(120% 120% at 30% 40%, #000 55%, transparent 100%);
  -webkit-mask-image: radial-gradient(120% 120% at 30% 40%, #000 55%, transparent 100%);
}

.hero-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.92) contrast(1.05);
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 3rem;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(230, 238, 255, 0.6);
  z-index: 2;
}

.scroll-cue-line {
  width: 1px;
  height: 54px;
  background: linear-gradient(180deg, rgba(230, 238, 255, 0.7), transparent);
  animation: cue-drop 2.2s ease-in-out infinite;
  transform-origin: top;
}

@keyframes cue-drop {
  0% { transform: scaleY(0); }
  45% { transform: scaleY(1); }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ---------- Premise ---------- */

.premise-lede {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.5rem, 3.4vw, 2.4rem);
  font-weight: 700;
  font-style: italic;
  line-height: 1.35;
  margin: 0 0 2rem;
  color: #f2f6ff;
}

.premise-body {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  line-height: 1.8;
  color: rgba(228, 236, 252, 0.85);
  max-width: 62ch;
  margin: 0 0 2.5rem;
}

.premise-meta { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.meta-chip {
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.meta-chip-glow {
  border-color: rgba(84, 220, 190, 0.55);
  color: #7dedd6;
  box-shadow: 0 0 18px rgba(60, 200, 170, 0.25);
}

/* ---------- Takeaways ---------- */

.takeaway-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.takeaway-card {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
  padding: 1.6rem 1.9rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(20, 26, 38, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 40px rgba(20, 26, 38, 0.08);
}

.takeaway-index {
  font-family: "Playfair Display", serif;
  font-size: 1.9rem;
  font-weight: 800;
  color: #b8860b;
  opacity: 0.85;
  flex-shrink: 0;
  line-height: 1;
}

.takeaway-card p {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.65;
}

/* ---------- Listening Room ---------- */

.listen-room {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2.25rem;
  padding: 2.5rem;
  align-items: center;
}

.listen-room.no-cover { grid-template-columns: 1fr; }

.listen-room-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.1rem;
  padding: 3.5rem 2.5rem;
}

.listen-lock-icon { opacity: 0.75; }

.listen-lock-note {
  max-width: 46ch;
  color: rgba(228, 236, 252, 0.8);
  margin: 0 0 0.75rem;
  line-height: 1.6;
}

.listen-cover {
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 1;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.listen-cover img { width: 100%; height: 100%; object-fit: cover; }

.listen-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #93b1f2;
  margin: 0 0 0.5rem;
}

.listen-title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 0.4rem;
}

.listen-cast {
  font-size: 0.85rem;
  color: rgba(228, 236, 252, 0.66);
  margin: 0 0 1.6rem;
}

/* Waveform seek */
.listen-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 56px;
  cursor: pointer;
  touch-action: none;
}

.listen-wave .bar {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  height: 30%;
  transition: background 0.18s;
}

.listen-wave .bar.is-played { background: #5b8dff; }

.listen-wave:hover .bar { background: rgba(255, 255, 255, 0.32); }
.listen-wave:hover .bar.is-played { background: #74a0ff; }

.listen-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: rgba(228, 236, 252, 0.6);
  margin: 0.4rem 0 1.5rem;
}

.listen-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.listen-play {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s;
}

.listen-play:hover { transform: scale(1.05); background: rgba(255, 255, 255, 0.14); }

.listen-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.listen-ring circle {
  fill: none;
  stroke-width: 3;
}

.listen-ring-track { stroke: rgba(255, 255, 255, 0.15); }

.listen-ring-fill {
  stroke: #4880F0;
  stroke-linecap: round;
  stroke-dasharray: 226.2;
  stroke-dashoffset: 226.2;
}

.listen-icon { position: relative; z-index: 1; }
.listen-icon-pause { display: none; }
.listen-play.is-playing .listen-icon-play { display: none; }
.listen-play.is-playing .listen-icon-pause { display: block; }

.listen-skip {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: rgba(235, 241, 255, 0.85);
  cursor: pointer;
  font-size: 0.62rem;
  font-weight: 700;
  transition: color 0.2s, transform 0.2s;
}

.listen-skip:hover { color: #fff; transform: scale(1.08); }

.listen-speeds {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
}

.listen-speeds button {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  color: rgba(235, 241, 255, 0.75);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.listen-speeds button:hover { border-color: rgba(255, 255, 255, 0.5); color: #fff; }

.listen-speeds button.is-active {
  background: #2663EB;
  border-color: #2663EB;
  color: #fff;
}

.listen-caption {
  margin: 1.5rem 0 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: rgba(228, 236, 252, 0.85);
  border-left: 2px solid rgba(91, 141, 255, 0.6);
  padding-left: 1rem;
  min-height: 1.6em;
}

.listen-soon {
  color: rgba(228, 236, 252, 0.78);
  line-height: 1.65;
  margin: 0 0 1.25rem;
}

/* ---------- Transcript ---------- */

.transcript-panel {
  position: relative;
  padding: 2.75rem clamp(1.5rem, 4vw, 3.25rem);
}

.transcript-body {
  font-size: 1.02rem;
  line-height: 1.85;
  max-width: 68ch;
  margin: 0 auto;
}

.transcript-body p { margin: 0 0 1.2em; }

.transcript-body p:first-child::first-letter {
  font-family: "Playfair Display", serif;
  font-size: 3.4em;
  font-weight: 800;
  float: left;
  line-height: 0.85;
  padding: 0.06em 0.12em 0 0;
  color: #2663EB;
}

.transcript-panel.is-collapsed .transcript-body {
  max-height: 26rem;
  overflow: hidden;
}

.transcript-fade {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5.25rem;
  height: 9rem;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(250, 250, 252, 0.95));
  border-radius: 0 0 24px 24px;
}

.transcript-panel.is-collapsed .transcript-fade { display: block; }

.transcript-toggle {
  display: flex;
  margin: 1.5rem auto 0;
}

.transcript-gated {
  text-align: center;
  padding: 3.5rem 2.5rem;
}

.transcript-gated p {
  max-width: 50ch;
  margin: 0 auto 1.75rem;
  line-height: 1.7;
  opacity: 0.85;
}

/* ---------- Finale ---------- */

.finale-row { margin-bottom: 3rem; }

.finale-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  padding: 2.25rem 2.5rem;
}

.finale-cta h3 {
  font-family: "Playfair Display", serif;
  font-size: 1.45rem;
  margin: 0 0 0.4rem;
}

.finale-cta p { margin: 0; opacity: 0.78; line-height: 1.6; }

/* ---------- Chapter rail ---------- */

.story-rail {
  position: fixed;
  right: 1.4rem;
  top: 50%;
  translate: 0 -50%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.story-rail button {
  position: relative;
  width: 10px;
  height: 10px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: transparent;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s, border-color 0.25s;
}

.story-rail button:hover { transform: scale(1.35); }

.story-rail button.is-active {
  background: #4880F0;
  border-color: #4880F0;
  box-shadow: 0 0 12px rgba(72, 128, 240, 0.8);
}

.story-rail button .rail-label {
  position: absolute;
  right: 22px;
  top: 50%;
  translate: 0 -50%;
  white-space: nowrap;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(10, 14, 26, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, translate 0.2s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.story-rail button:hover .rail-label { opacity: 1; }

/* ---------- Homepage / catalog scenes ---------- */

.scene-catalog,
.scene-continue,
.scene-search {
  min-height: auto;
  align-items: flex-start;
  padding: clamp(4rem, 9vh, 6.5rem) 1.5rem;
}

.catalog-story-row {
  position: relative;
}

.scene-continue .continue-listening-row {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}

.scene-continue .continue-listening-row::-webkit-scrollbar {
  display: none;
}

.scene-continue .continue-card {
  flex: 0 0 min(320px, 85vw);
  padding: 1rem;
  color: #eef2fb;
}

.scene-continue .continue-card h3 a {
  color: inherit;
  text-decoration: none;
}

.scene-continue .continue-card h3 a:hover {
  color: #9db8f5;
}

.scene-search .episodes-grid {
  margin-top: 0.5rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .hero-art { display: none; }
}

@media (max-width: 860px) {
  .story-rail { display: none; }

  .listen-room {
    grid-template-columns: 1fr;
    padding: 1.75rem;
  }

  .listen-cover { max-width: 200px; }

  .listen-speeds { margin-left: 0; width: 100%; }
}

@media (max-width: 560px) {
  .scene { padding: 3.5rem 1.1rem; }
  .listen-play { width: 68px; height: 68px; }
  .finale-cta { padding: 1.75rem 1.5rem; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .scroll-cue-line { animation: none; }
}
