/* Hands & Hearts — scroll-driven product story.
   Normal document scroll. One phone (the existing frame + embedded-video
   mockup) stays pinned while the chapter copy scrolls past it; the screen
   crossfades from one recording to the next as each chapter becomes active. */

.crystal-story {
  --story-bg: #f6f3ec;
  --story-bg-mid: #eef2f5;
  --story-bg-end: #ffffff;
  --story-ink: #101826;
  --story-muted: #4b5866;
  --story-line: rgba(16, 24, 38, 0.12);
  --story-chip: rgba(16, 24, 38, 0.05);
  --story-screen: #ffffff;
  --accent: #10b981;
  position: relative;
  color: var(--story-ink);
  background:
    radial-gradient(70% 45% at 92% 6%, rgba(167, 139, 250, 0.16), transparent 60%),
    radial-gradient(60% 40% at 4% 42%, rgba(16, 185, 129, 0.14), transparent 60%),
    radial-gradient(60% 40% at 96% 72%, rgba(244, 114, 182, 0.12), transparent 60%),
    linear-gradient(180deg, var(--story-bg) 0%, var(--story-bg-mid) 62%, var(--story-bg-end) 100%);
  overflow-x: clip;
}

.crystal-story--night {
  --story-bg: #070b14;
  --story-bg-mid: #0a1020;
  --story-bg-end: #030712;
  --story-ink: #f3f6fb;
  --story-muted: #b6c2cf;
  --story-line: rgba(255, 255, 255, 0.14);
  --story-chip: rgba(255, 255, 255, 0.07);
  --story-screen: #0b0f17;
}

/* ---------- Hero ---------- */

.story-hero {
  display: grid;
  align-items: center;
  min-height: 88svh;
  padding: clamp(5.5rem, 12vh, 8rem) clamp(1rem, 6vw, 6rem) clamp(2.5rem, 6vh, 4rem);
}

.story-hero__inner {
  width: min(64rem, 100%);
  margin: 0 auto;
  display: grid;
  gap: 1rem;
}

.story-hero .cinematic-brand {
  margin: 0;
}

.story-hero .cinematic-brand img {
  width: 56px;
  height: 56px;
}

.crystal-story .cinematic-eyebrow {
  color: var(--accent);
}

.crystal-story .story-hero h1 {
  margin: 0;
  max-width: 16ch;
  color: var(--story-ink) !important;
  background: none !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  -webkit-text-fill-color: currentColor !important;
  font-size: clamp(2.5rem, 7vw, 6rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.98;
  text-wrap: balance;
}

.story-hero__lead,
.story-hero__desc {
  margin: 0;
  color: var(--story-muted);
  line-height: 1.5;
}

.story-hero__lead {
  max-width: 34ch;
  color: var(--story-ink);
  font-size: clamp(1.15rem, 2.2vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.story-hero__desc {
  max-width: 54ch;
  font-size: clamp(0.98rem, 1.3vw, 1.12rem);
}

.story-hero__cue {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.25rem 0 0;
  color: var(--story-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.story-hero__cue span {
  display: grid;
  width: 1.9rem;
  height: 1.9rem;
  place-items: center;
  border: 1px solid var(--story-line);
  border-radius: 50%;
  animation: story-bob 1.8s ease-in-out infinite;
}

.story-hero [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  animation: story-rise 720ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: calc(120ms + var(--i, 0) * 110ms);
}

/* ---------- Pinned phone + scrolling chapters ---------- */

.story-scroll {
  position: relative;
  padding: 0 clamp(1rem, 6vw, 6rem) clamp(2rem, 6vh, 4rem);
}

.story-scroll__inner {
  width: min(74rem, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(16rem, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(1.5rem, 5vw, 5rem);
  align-items: start;
}

.story-stage {
  position: sticky;
  top: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1rem;
  height: 100svh;
  padding: 3rem 0;
}

/* Fit the existing compact mockup inside the pinned viewport height */
.story-stage .phone-mockup--compact .phone-mockup__shell {
  width: min(30rem, 44vw, calc((100svh - 6rem) / 1.72));
}

/* Soft accent glow behind the pinned phone, tinted by the active chapter */
.story-stage__phone {
  position: relative;
  isolation: isolate;
}

.story-stage__phone::before {
  content: '';
  position: absolute;
  inset: -12% -34%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 34%, transparent), transparent 74%);
  filter: blur(8px);
  transition: background 700ms ease;
  pointer-events: none;
}

/* Stacked recordings inside the 390×844 screen; only the active one shows */
.story-screen {
  position: relative;
  width: 390px;
  height: 844px;
  overflow: hidden;
  background: var(--story-screen);
}

.story-screen__layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 650ms ease, transform 900ms cubic-bezier(0.2, 0.7, 0.2, 1);
  pointer-events: none;
}

.story-screen__layer.is-active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.story-screen__poster {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.1rem;
  padding: 2rem;
  color: var(--story-ink);
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 62%),
    linear-gradient(180deg, var(--story-screen), color-mix(in srgb, var(--story-screen) 72%, var(--accent) 28%));
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
}

.story-screen__poster img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--story-line);
}

.story-screen .story-screen__video {
  position: absolute;
  inset: 0;
  width: 390px;
  height: 844px;
  object-fit: cover;
  background: transparent;
  opacity: 0;
  transition: opacity 500ms ease;
}

.story-screen .story-screen__video.is-ready {
  opacity: 1;
}

.story-screen__play {
  position: absolute;
  left: 50%;
  bottom: 8%;
  z-index: 3;
  min-height: 56px;
  padding: 0.9rem 1.6rem;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  color: #fff;
  background: rgba(6, 19, 32, 0.8);
  font-size: 1.1rem;
  font-weight: 800;
  transform: translateX(-50%);
  cursor: pointer;
}

.story-screen__play:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.story-stage__dots {
  display: flex;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.story-stage__dots li {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--story-line);
  transition: background 300ms ease, transform 300ms ease;
}

.story-stage__dots li[data-active='true'] {
  background: var(--accent);
  transform: scale(1.35);
}

/* Chapter copy — one block per screen height, revealing when active */
.story-chapters {
  display: grid;
  min-width: 0;
}

.story-chapter {
  display: grid;
  align-items: center;
  min-height: 100svh;
  padding: 2rem 0;
}

.story-copy {
  min-width: 0;
}

.story-copy > * {
  opacity: 0.18;
  transform: translateY(22px);
  transition: opacity 520ms ease, transform 620ms cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--i, 0) * 70ms);
}

.story-chapter[data-active='true'] .story-copy > * {
  opacity: 1;
  transform: translateY(0);
}

.story-copy__step {
  margin: 0 0 0.9rem;
  color: var(--story-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.story-copy__step span {
  display: inline-grid;
  min-width: 2.4rem;
  height: 2.4rem;
  margin-right: 0.35rem;
  place-items: center;
  border-radius: 999px;
  color: #06211c;
  background: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0;
}

.crystal-story--khmer .story-copy__step {
  letter-spacing: 0;
  text-transform: none;
}

.crystal-story .story-copy h2 {
  margin: 0;
  max-width: 18em;
  color: var(--story-ink) !important;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
  font-size: clamp(1.85rem, 3.6vw, 3.1rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.12;
  text-wrap: pretty;
}

.story-copy__body {
  margin: 1.1rem 0 0;
  max-width: 38rem;
  color: var(--story-muted);
  font-size: clamp(1rem, 1.25vw, 1.12rem);
  line-height: 1.55;
  text-align: justify;
  text-justify: inter-word;
  text-wrap: pretty;
  hyphens: none;
}

.story-copy__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
}

.story-copy__tags li {
  padding: 0.38rem 0.7rem;
  border: 1px solid var(--story-line);
  border-radius: 999px;
  color: var(--story-ink);
  background: var(--story-chip);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
}

.story-copy__alt {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.story-copy .cinematic-actions {
  margin-top: 1.4rem;
}

.crystal-story .cinematic-actions a {
  color: #06211c;
  background: linear-gradient(135deg, #9ff3df, #f1d48a);
  border-color: rgba(16, 185, 129, 0.45);
}

.crystal-story .cinematic-actions .cinematic-action--ghost {
  color: var(--story-ink);
  background: rgba(255, 255, 255, 0.35);
  border-color: var(--story-line);
}

.crystal-story--night .cinematic-actions .cinematic-action--ghost {
  background: rgba(255, 255, 255, 0.08);
}

/* ---------- Motion ---------- */

@keyframes story-rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes story-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(0.3rem);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1023px) {
  .story-scroll__inner {
    grid-template-columns: minmax(14rem, 0.8fr) minmax(0, 1.2fr);
  }
}

@media (max-width: 767px) {
  .story-hero {
    min-height: 78svh;
    padding: 5.25rem 1rem 2rem;
  }

  .story-hero__inner {
    gap: 0.8rem;
  }

  .crystal-story .story-hero h1 {
    max-width: none;
    font-size: clamp(2.1rem, 10.5vw, 3.2rem);
  }

  .story-hero__cue {
    display: none;
  }

  .story-scroll {
    padding: 0 1rem calc(5.5rem + env(safe-area-inset-bottom));
  }

  .story-scroll__inner {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Phone pins to the top as a compact band; chapter copy scrolls beneath it */
  .story-stage {
    z-index: 2;
    height: auto;
    padding: 3.75rem 0 0.75rem;
    gap: 0.6rem;
    background: linear-gradient(180deg, var(--story-bg) 78%, transparent);
  }

  .story-stage .phone-mockup--compact .phone-mockup__shell {
    width: min(58vw, 13.5rem, calc((44svh - 4.5rem) / 2));
  }

  .story-chapter {
    min-height: 64svh;
    padding: 1.25rem 0 2rem;
  }

  .story-copy > * {
    opacity: 0.3;
  }

  .crystal-story .story-copy h2 {
    max-width: none;
    font-size: clamp(1.8rem, 8vw, 2.5rem);
  }

  .story-copy__body {
    font-size: 0.98rem;
  }

  .story-copy .cinematic-actions,
  .story-hero .cinematic-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .story-copy .cinematic-actions a,
  .story-hero .cinematic-actions a {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-hero [data-reveal] {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .story-hero__cue span {
    animation: none;
  }

  .story-screen__layer,
  .story-screen .story-screen__video,
  .story-copy > *,
  .story-stage__dots li,
  .story-stage__phone::before {
    transition: none;
  }

  .story-copy > * {
    opacity: 1;
    transform: none;
  }
}

@media (forced-colors: active) {
  .story-copy__tags li {
    border: 1px solid CanvasText;
  }
}
