/* The recitation story is isolated here so the waitlist page can keep its
   existing visual system while this interaction remains easy to test. */
.story-sec {
  position: relative;
  overflow: clip;
  padding: clamp(6rem, 10vw, 10rem) 0;
  border-block: 1px solid rgba(255, 255, 255, 0.06);
  background:
    radial-gradient(circle at 18% 30%, rgba(124, 77, 240, 0.14), transparent 34rem),
    radial-gradient(circle at 82% 72%, rgba(52, 211, 153, 0.07), transparent 30rem),
    #09080f;
}

.story-intro {
  width: min(1180px, calc(100% - 2.5rem));
  margin: 0 auto clamp(4rem, 8vw, 7rem);
  text-align: center;
}

.story-intro .lede { max-width: 42rem; }

.story-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(18rem, 0.88fr);
  gap: clamp(3rem, 8vw, 8rem);
  width: min(1180px, calc(100% - 2.5rem));
  margin: 0 auto;
}

.story-visual {
  position: sticky;
  top: clamp(5.5rem, 10vh, 8rem);
  align-self: start;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 10rem);
}

.story-device {
  position: relative;
  width: min(100%, 31rem);
  aspect-ratio: 0.72;
  padding: 0.55rem;
  border: 1px solid rgba(166, 137, 255, 0.28);
  border-radius: 2.4rem;
  background: linear-gradient(145deg, rgba(255,255,255,.11), rgba(255,255,255,.025));
  box-shadow: 0 3rem 8rem rgba(0,0,0,.48), 0 0 6rem rgba(124,77,240,.13);
}

.story-device::before {
  content: "";
  position: absolute;
  z-index: 6;
  top: 0.9rem;
  left: 50%;
  width: 5.1rem;
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  transform: translateX(-50%);
}

.story-screen {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 1.95rem;
  background: #07060d;
}

.story-topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.65rem 1.35rem 0.75rem;
  color: #8e899c;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.story-quran {
  position: absolute;
  inset: 4.2rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1rem, 3vw, 1.7rem);
  border: 1px solid rgba(124,77,240,.38);
  border-radius: 1rem;
  background: radial-gradient(circle at 50% 42%, rgba(124,77,240,.08), transparent 58%);
  will-change: transform, opacity, filter;
  transition: opacity .58s ease, transform .72s cubic-bezier(.16,.84,.2,1), filter .58s ease;
}

.story-basmala {
  margin: 0 0 1.4rem;
  color: #b8a3ff;
  font: 400 clamp(1.2rem, 3vw, 1.7rem)/1.8 "Amiri", serif;
  text-align: center;
}

.story-ayahs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: .55rem .38rem;
  direction: rtl;
  font: 400 clamp(1.75rem, 4.3vw, 2.45rem)/1.72 "Amiri", serif;
  text-align: center;
}

.story-word {
  position: relative;
  display: inline-block;
  color: #f5f0e6;
  text-shadow: 0 0 0 transparent;
  transition: color .38s cubic-bezier(.2,.8,.2,1), text-shadow .38s ease, transform .38s ease;
}

.story-word::after {
  content: "";
  position: absolute;
  right: 8%;
  bottom: .18em;
  left: 8%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0;
  transform: scaleX(.35);
  transition: opacity .35s ease, transform .45s ease;
}

.story-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .22rem;
  height: 2.2rem;
  margin-top: 1.6rem;
  opacity: .2;
  transition: opacity .35s ease;
}

.story-wave i {
  display: block;
  width: .22rem;
  height: var(--bar-height, 50%);
  border-radius: 99px;
  background: #9d7cff;
  transform: scaleY(.45);
}

.story-score {
  position: absolute;
  z-index: 4;
  right: .65rem;
  bottom: .65rem;
  left: .65rem;
  padding: 1.35rem 1.25rem 1.2rem;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 1.8rem;
  background: rgba(29, 28, 38, .97);
  box-shadow: 0 -2rem 5rem rgba(0,0,0,.48);
  opacity: 0;
  transform: translateY(112%);
  will-change: transform, opacity;
  transition: transform .72s cubic-bezier(.16,.84,.2,1), opacity .54s ease;
}

.story-score-handle {
  width: 3.5rem;
  height: .28rem;
  margin: 0 auto 1.1rem;
  border-radius: 99px;
  background: rgba(255,255,255,.25);
}

.story-score-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.story-score h3,
.story-plan h3 { margin: 0; color: #fff; font-size: 1.35rem; }
.story-score p,
.story-plan p { margin: .25rem 0 0; color: #8e899c; font-size: .82rem; }

.story-ring {
  position: relative;
  width: 7.5rem;
  height: 7.5rem;
  margin: 1.1rem auto;
}

.story-ring svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.story-ring circle {
  fill: none;
  stroke-width: 8;
}

.story-ring-track { stroke: rgba(255,255,255,.1); }
.story-ring-value {
  stroke: #34d399;
  stroke-linecap: round;
  stroke-dasharray: 88 100;
}

.story-ring-copy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .28rem;
  text-align: center;
}

.story-ring-copy strong {
  color: #fff;
  font-size: 2rem;
  line-height: 1;
}

.story-ring-copy span {
  color: #8e899c;
  font-size: .67rem;
}

.story-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: .6rem 0 1rem;
  padding: .85rem .35rem;
  border-radius: 1rem;
  background: #17161e;
  text-align: center;
}

.story-stats div + div { border-left: 1px solid rgba(255,255,255,.07); }
.story-stats strong { display: block; color: #fff; font-size: 1.15rem; }
.story-stats span { color: #8e899c; font-size: .66rem; }

.story-continue {
  display: block;
  width: 100%;
  padding: .85rem;
  border: 0;
  border-radius: .9rem;
  color: #fff;
  background: linear-gradient(135deg, #6d45e8, #8b63ff);
  font: 700 .82rem/1 "Instrument Sans", sans-serif;
}

.story-plan {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 4.15rem 1.2rem 1rem;
  background:
    radial-gradient(circle at 50% 18%, rgba(124,77,240,.2), transparent 42%),
    #0b0a12;
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
  will-change: transform, opacity;
  transition: opacity .58s ease, transform .76s cubic-bezier(.16,.84,.2,1);
}

.story-plan-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .75rem;
  padding: .45rem .7rem;
  border-radius: 99px;
  color: #bda9ff;
  background: rgba(124,77,240,.14);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.story-plan-badge::before {
  content: "✓";
  display: grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  color: #08110d;
  background: #34d399;
}

.story-session {
  margin-top: 1rem;
  padding: .85rem;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 1.1rem;
  background: rgba(255,255,255,.035);
}

.story-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.story-session strong { color: #fff; font-size: .92rem; }
.story-session time { color: #bda9ff; font-size: .72rem; font-weight: 700; }

.story-grid-label {
  margin: 1rem 0 .6rem;
  color: #787382;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.story-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: .42rem;
  min-height: 0;
}

.story-grid span {
  display: grid;
  place-items: center;
  min-height: 1.8rem;
  border-radius: .58rem;
  color: #6f6b79;
  background: #1a1921;
  font-size: .62rem;
  font-weight: 700;
}

.story-grid .perfect { color: #072117; background: #34d399; }
.story-grid .strong { color: #fff; background: #7c4df0; }
.story-grid .review { color: #250508; background: #ef4444; }
.story-grid .next { color: #291700; background: #f59e0b; }

.story-copy { position: relative; }

.story-is-scrubbed .story-quran,
.story-is-scrubbed .story-score,
.story-is-scrubbed .story-plan,
.story-is-scrubbed .story-beat {
  animation: none !important;
  transition:
    opacity 1000ms cubic-bezier(.65,0,.35,1),
    transform 1000ms cubic-bezier(.65,0,.35,1) !important;
}

.story-is-initializing .story-quran,
.story-is-initializing .story-score,
.story-is-initializing .story-plan,
.story-is-initializing .story-beat {
  transition: none !important;
}

.story-copy-sticky {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  align-items: center;
  height: 100vh;
}

.story-beat {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transform: translateY(1.2rem);
  pointer-events: none;
  will-change: transform, opacity, filter;
  transition: opacity .46s ease, transform .58s ease, visibility 0s linear .58s;
}

.story-beat.is-active {
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition-delay: 0s;
}

.story-beat.is-leaving {
  visibility: visible;
  pointer-events: none;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="forward"] .story-beat.is-active {
  animation: story-copy-in-forward .9s cubic-bezier(.16,.84,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="forward"] .story-beat.is-leaving {
  animation: story-copy-out-forward .7s cubic-bezier(.4,0,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"] .story-beat.is-active {
  animation: story-copy-in-backward .9s cubic-bezier(.16,.84,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"] .story-beat.is-leaving {
  animation: story-copy-out-backward .7s cubic-bezier(.4,0,.2,1) both;
}
.story-beat-step { color: #9d7cff; font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.story-beat h3 { max-width: 14ch; margin: .8rem 0 1rem; color: #fff; font: 500 clamp(2rem, 4vw, 3.4rem)/1.02 "Newsreader", serif; }
.story-beat p { max-width: 28rem; margin: 0; color: #aaa5b3; font-size: clamp(1rem, 1.6vw, 1.18rem); line-height: 1.7; }

.story-driver {
  position: relative;
  z-index: 1;
  margin-top: -100vh;
  padding-block: 50vh;
}

.story-trigger { display: block; height: 42vh; min-height: 18rem; }
.story-trigger[data-story-stage="page"] { height: 7vh; min-height: 3.25rem; }
.story-trigger[data-story-stage="listen"] { height: 7vh; min-height: 3.25rem; }
.story-trigger[data-story-stage="score"] { height: 126vh; min-height: 48rem; }

.story-word.is-resolved[data-result="good"] { color: #34d399; text-shadow: 0 0 1.2rem rgba(52,211,153,.25); }
.story-word.is-resolved[data-result="miss"] { color: #ef4444; text-shadow: 0 0 1.2rem rgba(239,68,68,.25); }
.story-word.is-resolved::after { opacity: .7; transform: scaleX(1); }
.story-word.is-current {
  transform: translateY(-.08em) scale(1.06);
  animation: story-word-in .34s cubic-bezier(.2,.85,.25,1) both;
}
[data-story-state="listen"] .story-wave { opacity: 1; }
[data-story-state="listen"] .story-wave i { animation: story-pulse .75s ease-in-out infinite alternate; animation-delay: calc(var(--bar-order) * -70ms); }
[data-story-state="score"] .story-quran { opacity: 0; transform: translateY(-30%) scale(.97); filter: blur(2px); }
[data-story-state="score"] .story-score { opacity: 1; transform: none; }
[data-story-state="plan"] .story-quran,
[data-story-state="plan"] .story-score { opacity: 0; transform: translateY(-112%); }
[data-story-state="plan"] .story-plan { opacity: 1; transform: none; }

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="forward"][data-story-state="listen"] .story-quran {
  animation: story-visual-in-forward .62s cubic-bezier(.16,.84,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="page"] .story-quran,
.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="listen"] .story-quran {
  animation: story-visual-in-backward .62s cubic-bezier(.16,.84,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="forward"][data-story-state="score"] .story-quran,
.story-is-transitioning:not(.story-use-waapi)[data-story-direction="forward"][data-story-state="plan"] .story-score {
  animation: story-panel-out-forward .82s cubic-bezier(.4,0,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="forward"][data-story-state="score"] .story-score,
.story-is-transitioning:not(.story-use-waapi)[data-story-direction="forward"][data-story-state="plan"] .story-plan {
  animation: story-panel-in-forward .96s cubic-bezier(.16,.84,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="score"] .story-plan,
.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="page"] .story-score,
.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="listen"] .story-score {
  animation: story-panel-out-backward .82s cubic-bezier(.4,0,.2,1) both;
}

.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="score"] .story-score,
.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="page"] .story-quran,
.story-is-transitioning:not(.story-use-waapi)[data-story-direction="backward"][data-story-state="listen"] .story-quran {
  animation: story-panel-in-backward .96s cubic-bezier(.16,.84,.2,1) both;
}

@keyframes story-pulse { to { transform: scaleY(1); } }

@keyframes story-copy-in-forward {
  from { opacity: 0; transform: translateY(4.5rem); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes story-copy-out-forward {
  from { opacity: 1; transform: none; filter: blur(0); }
  to { opacity: 0; transform: translateY(-3.5rem); filter: blur(3px); }
}

@keyframes story-copy-in-backward {
  from { opacity: 0; transform: translateY(-4.5rem); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes story-copy-out-backward {
  from { opacity: 1; transform: none; filter: blur(0); }
  to { opacity: 0; transform: translateY(3.5rem); filter: blur(3px); }
}

@keyframes story-visual-in-forward {
  from { opacity: .58; transform: translateY(1.7rem) scale(.975); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes story-visual-in-backward {
  from { opacity: .58; transform: translateY(-1.7rem) scale(.975); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes story-panel-in-forward {
  from { opacity: 0; transform: translateY(46%); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes story-panel-out-forward {
  from { opacity: 1; transform: none; filter: blur(0); }
  to { opacity: 0; transform: translateY(-34%); filter: blur(3px); }
}

@keyframes story-panel-in-backward {
  from { opacity: 0; transform: translateY(-34%); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@keyframes story-panel-out-backward {
  from { opacity: 1; transform: none; filter: blur(0); }
  to { opacity: 0; transform: translateY(46%); filter: blur(3px); }
}

@keyframes story-word-in {
  from { opacity: .4; transform: translateY(.45em) scale(.96); }
  to { opacity: 1; transform: translateY(-.08em) scale(1.06); }
}

.story-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 820px) {
  .story-sec { padding-bottom: 4rem; }
  .story-intro { margin-bottom: 2.5rem; }
  .story-shell { display: block; width: min(100% - 1.25rem, 40rem); }
  .story-visual { top: 4.6rem; z-index: 1; min-height: 0; height: min(62vh, 36rem); align-items: start; }
  .story-device { width: min(100%, 25rem); height: min(58vh, 34rem); aspect-ratio: auto; border-radius: 1.8rem; }
  .story-screen { border-radius: 1.4rem; }
  .story-copy { z-index: 2; margin-top: -10vh; }
  .story-copy-sticky { align-items: end; padding-bottom: 1rem; }
  .story-beat { width: 100%; padding: 2rem 1.3rem; border: 1px solid rgba(255,255,255,.08); border-radius: 1.4rem; background: linear-gradient(180deg, rgba(14,13,21,.78), rgba(14,13,21,.98)); box-shadow: 0 1.4rem 4rem rgba(0,0,0,.32); }
  .story-beat h3 { font-size: clamp(1.8rem, 8vw, 2.8rem); }
  .story-trigger { height: 46vh; min-height: 19rem; }
  .story-trigger[data-story-stage="page"] { height: 8vh; min-height: 3.75rem; }
  .story-trigger[data-story-stage="listen"] { height: 8vh; min-height: 3.75rem; }
  .story-trigger[data-story-stage="score"] { height: 132vh; min-height: 50rem; }
}

@media (max-width: 480px) {
  .story-sec { padding-top: 5rem; }
  .story-intro, .story-shell { width: calc(100% - 1rem); }
  .story-visual { top: 4rem; height: 60vh; }
  .story-device { height: 56vh; padding: .38rem; }
  .story-topbar { padding: 1.35rem 1rem .5rem; font-size: .58rem; }
  .story-quran { inset: 3.5rem .65rem .65rem; padding: .85rem; }
  .story-ayahs { font-size: clamp(1.48rem, 7vw, 1.9rem); gap: .35rem .28rem; }
  .story-basmala { margin-bottom: .7rem; font-size: 1.05rem; }
  .story-wave { margin-top: .7rem; }
  .story-score { padding: .95rem; border-radius: 1.25rem; }
  .story-ring { width: 5.8rem; height: 5.8rem; margin: .7rem auto; }
  .story-ring-copy strong { font-size: 1.5rem; }
  .story-stats { margin-bottom: .7rem; padding: .6rem .2rem; }
  .story-plan { padding: 3.55rem .85rem .7rem; }
  .story-grid { gap: .3rem; }
  .story-grid span { height: 1.65rem; }
  .story-session { margin-top: .75rem; padding: .7rem; }
  .story-grid-label { margin: .75rem 0 .45rem; }
}

@media (prefers-reduced-motion: reduce) {
  .story-sec *, .story-sec *::before, .story-sec *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition-duration: .01ms !important;
  }

}
