/* ---------- Palette ---------- */
:root{
  --cream: #f3eee3;
  --purple: #4a1c65;
  --gray: #b3b3b3;
  --purple-soft: rgba(74, 28, 101, 0.82);   /* body copy: purple, slightly softened */
  --panel-bg: rgba(243, 238, 227, 0.94);    /* cream panel, mostly opaque */
  --hairline: rgba(74, 28, 101, 0.18);
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--purple);
  font-family: "Georgia", "Iowan Old Style", serif;
  scroll-behavior: smooth;
}

h1, h2, h3{
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--purple);
}

/* ---------- Progress bar (with a puck that rides the fill edge) ---------- */
.progress-track{
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 5px;
  background: rgba(74, 28, 101, 0.12);
  z-index: 50;
}
.progress-fill{
  position: relative;
  height: 100%;
  width: 0%;
  background: var(--purple);
  transition: width 80ms linear;
}
.progress-fill::after{
  content: "";
  position: absolute;
  right: -5px;
  top: -3.5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 0 4px rgba(74, 28, 101, 0.16);
}

/* ---------- Sound toggle ---------- */
.sound-toggle{
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(243, 238, 227, 0.35);
  background: var(--purple);
  color: var(--cream);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(74, 28, 101, 0.25);
}
.sound-toggle:hover{ filter: brightness(1.1); }
.sound-toggle.muted{ opacity: 0.55; }

/* ---------- Live chapter counter ---------- */
.scene-counter{
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 50;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--purple);
  background: rgba(243, 238, 227, 0.85);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 14px;
  backdrop-filter: blur(4px);
}
.scene-counter b{ color: var(--purple); }
.scene-counter span{ color: var(--gray); }

/* ---------- Newsletter signup (top-right) ---------------------------------
   beehiiv's v3 loader script injects the real form into #subscribeWidget —
   we don't control its internal markup, so this just constrains the box
   it renders into (position + max width) rather than styling its insides.
   If beehiiv's default widget renders larger/smaller than expected, the
   fix is usually in beehiiv's own form-builder style settings, not here;
   `transform: scale()` below is a fallback if it still needs shrinking. */
.subscribe-widget{
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 110; /* above the start overlay (100) so it's visible immediately */
  max-width: min(420px, calc(100vw - 32px));
  font-family: "Helvetica Neue", Arial, sans-serif;
  /* Safety-net shrink: scales whatever beehiiv renders down uniformly.
     This can only make it smaller, not reshape a tall card into a wide
     short one — that reshaping has to come from beehiiv's own form
     style setting (see the note below). Raise this toward 1 (or drop it)
     once the form itself is set to a compact/inline style. */
  transform: scale(0.8);
  transform-origin: top right;
}

@media (max-width: 640px){
  .subscribe-widget{ max-width: min(240px, calc(100vw - 24px)); }
}

/* ---------- Start overlay ---------- */
.start-overlay{
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #ffffff 0%, var(--cream) 65%);
  text-align: center;
  padding: 24px;
}
.start-card h1{
  font-size: clamp(2rem, 6vw, 3.5rem);
  margin: 0 0 12px;
  color: var(--purple);
}
.start-card p{
  max-width: 32em;
  margin: 0 auto 28px;
  color: var(--purple-soft);
  line-height: 1.5;
}
#startButton{
  font-size: 1.1rem;
  padding: 14px 28px;
  border-radius: 999px;
  border: none;
  background: var(--purple);
  color: var(--cream);
  font-weight: 700;
  cursor: pointer;
  animation: nudge 2.4s ease-in-out infinite;
}
#startButton:hover{ filter: brightness(1.15); animation: none; }
.start-overlay.hidden{
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
@keyframes nudge{
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ---------- Scenes ---------- */
main#story{
  position: relative;
  background: var(--cream);
}

.scene{
  position: relative;
  min-height: 180vh; /* scroll distance the media stays pinned for */
}

.scene.short{ min-height: 100vh; }

.scene-media{
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--purple);
}

.scene-media img,
.scene-media video{
  width: 100%;
  height: 100%;
  object-fit: cover;
  will-change: transform;
  transform: scale(1);
}

/* soft cream fade at the seams + a light purple wash so mixed source photos
   still feel like one palette */
.scene-media::after{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(243, 238, 227, 0.55) 0%,
    rgba(243, 238, 227, 0) 16%,
    rgba(74, 28, 101, 0.12) 50%,
    rgba(243, 238, 227, 0) 84%,
    rgba(243, 238, 227, 0.6) 100%
  );
}

.scene-text{
  position: relative;
  z-index: 5;
  max-width: 32em;
  margin: -68vh auto 20vh; /* pull the text panel up over the pinned media */
  padding: 40px 36px;
  background: var(--panel-bg);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(74, 28, 101, 0.18);
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* alternate which side the panel sits on for scroll rhythm */
.scene-text.align-left{ margin-left: 8%; margin-right: auto; }
.scene-text.align-right{ margin-right: 8%; margin-left: auto; }

.scene.active .scene-text{
  opacity: 1;
  transform: translateY(0);
}

/* staggered reveal of each line inside the panel */
.scene-text > *{
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.scene.active .scene-text > *{ opacity: 1; transform: translateY(0); }
.scene-text > *:nth-child(1){ transition-delay: 0.05s; }
.scene-text > *:nth-child(2){ transition-delay: 0.15s; }
.scene-text > *:nth-child(3){ transition-delay: 0.25s; }
.scene-text > *:nth-child(4){ transition-delay: 0.35s; }
.scene-text > *:nth-child(5){ transition-delay: 0.45s; }

.scene-text .kicker{
  display: inline-block;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 10px;
}

.scene-text h2{
  font-size: 1.8rem;
  margin: 0 0 16px;
}

.scene-text p{
  font-size: 1.08rem;
  line-height: 1.7;
  margin: 0 0 14px;
  color: var(--purple-soft);
}

.scene.layout-full.short .scene-text{
  margin-top: -40vh;
}

/* ---------- Inset layout: a smaller framed image beside the text, ---------
   in normal scroll flow — no pinning, no full-bleed background. This is
   the more common case; reserve "full" for a handful of cinematic beats. */
.scene.layout-inset{
  min-height: 0; /* override the pinned-layout scroll-length trick */
}

.scene-inset-inner{
  display: flex;
  align-items: center;
  gap: 48px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12vh 24px;
  flex-wrap: wrap;
}

.scene-inset-inner.media-right{
  flex-direction: row-reverse;
}

.scene-media-inset{
  flex: 1 1 380px;
  max-width: 460px;
  aspect-ratio: 4 / 3;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(74, 28, 101, 0.16);
  border: 1px solid var(--hairline);
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.scene.active .scene-media-inset{
  opacity: 1;
  transform: translateY(0) scale(1);
}

.scene-media-inset img,
.scene-media-inset video{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scene-inset-inner .scene-text{
  flex: 1 1 320px;
  max-width: 30em;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  opacity: 1;         /* the inner children still stagger-fade; the wrapper itself doesn't need to */
  transform: none;
  transition: none;
}

/* ---------- Footer ---------- */
.end-note{
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 18vh 24px 14vh;
  background: var(--cream);
}
.end-note p{ font-size: 1.6rem; margin-bottom: 14px; color: var(--purple); }
.end-note a{ color: var(--purple); text-decoration: none; border-bottom: 1px solid var(--hairline); }

/* ---------- Small screens ---------- */
@media (max-width: 640px){
  .scene.layout-full{ min-height: 150vh; }
  .scene.layout-full .scene-text,
  .scene.layout-full .scene-text.align-left,
  .scene.layout-full .scene-text.align-right{ margin: -60vh 16px 14vh; padding: 28px 22px; }

  .scene-inset-inner,
  .scene-inset-inner.media-right{
    flex-direction: column;
    padding: 8vh 20px;
    gap: 24px;
  }
  .scene-media-inset{ max-width: 100%; }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce){
  .scene-media img, .scene-media video{ transition: none !important; }
  #startButton{ animation: none; }
  .scene-text, .scene-text > *{ transition-duration: 0.15s; }
}
