/* The home page's cinematic layer (docs/website-wow.md): the hero intro, the
   headline letters, the aurora, the scroll story, tilt and spotlight cards and
   the sign-up constellation. Motion uses transform and opacity; the three
   short exceptions are named where they are. Everything has a calm version
   for Reduce Motion (no `wow` class on <html>) and a light one (`lite`). */

/* ───────────── The hero as a stage ───────────── */

.hero-wl {
  position: relative;
  isolation: isolate;
}

/* The aurora: two soft bands of light behind the hero, sweeping slowly. */
.hero-aurora {
  position: absolute;
  z-index: -1;
  inset: -90px 0 -40px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 62%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 62%, transparent 100%);
}

.wow .hero-aurora {
  animation: aurora-on 2.4s ease 0.15s forwards;
}

.hero-aurora i {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 44%;
  border-radius: 50%;
  filter: blur(64px);
  will-change: transform;
}

.hero-aurora i:first-child {
  top: 6%;
  background: linear-gradient(90deg, transparent 5%, rgba(47, 217, 154, 0.26) 34%, rgba(108, 132, 255, 0.16) 62%, transparent 92%);
  transform: rotate(-9deg) translate3d(-12%, 0, 0);
  animation: aurora-a 17s ease-in-out infinite alternate;
}

.hero-aurora i:last-child {
  top: 40%;
  background: linear-gradient(90deg, transparent 8%, rgba(108, 132, 255, 0.13) 30%, rgba(47, 217, 154, 0.2) 66%, transparent 94%);
  transform: rotate(7deg) translate3d(10%, 0, 0);
  animation: aurora-b 23s ease-in-out infinite alternate;
}

@keyframes aurora-on {
  to {
    opacity: 1;
  }
}

@keyframes aurora-a {
  to {
    transform: rotate(-3deg) translate3d(14%, 9%, 0) scale(1.12, 1.3);
  }
}

@keyframes aurora-b {
  to {
    transform: rotate(2deg) translate3d(-13%, -12%, 0) scale(1.1, 0.8);
  }
}

/* Off screen, or the light version: the bands rest. */
.hero-off .hero-aurora i,
.lite .hero-aurora i {
  animation-play-state: paused;
}

.lite .hero-aurora i {
  filter: blur(40px);
}

/* ───────────── The intro (first visit of a session) ───────────── */

/* A black veil lifts off the sky. */
.wow-first body::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background: #000;
  pointer-events: none;
  animation: veil-off 1.3s ease forwards;
}

@keyframes veil-off {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* The logo catches the star's light. */
.brand {
  position: relative;
}

.wow-first .site-header .brand::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -18px;
  width: 64px;
  height: 64px;
  margin-top: -32px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(214, 251, 234, 0.95), rgba(47, 217, 154, 0.4) 45%, transparent 72%);
  opacity: 0;
  pointer-events: none;
  animation: ignite 1.2s ease-out 0.95s;
}

@keyframes ignite {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(2.4);
  }
}

/* The order of the hero's pieces: pill, (headline by letters), lead, then
   the form or status card and the note last. */
.wow-first .hero-copy > .hero-in:not(.is-entering):nth-child(1) { animation-delay: 0.55s; }
.wow-first .hero-copy > .hero-in:not(.is-entering):nth-child(3) { animation-delay: 1.4s; }
.wow-first .hero-copy > .hero-in:not(.is-entering):nth-child(4) { animation-delay: 1.65s; }
.wow-first .hero-copy > .hero-in:not(.is-entering):nth-child(5) { animation-delay: 1.8s; }

.wow-first .place-card:not(.is-leaving) {
  animation: hero-enter 0.8s var(--ease) 1.65s both;
}

/* The phone rises from below, tilted, and settles. */
.wow-first .device-stage {
  animation: phone-rise 1.35s cubic-bezier(0.16, 1, 0.3, 1) 1.05s forwards;
}

@keyframes phone-rise {
  from {
    opacity: 0;
    transform: translate3d(0, 150px, 0) rotateX(26deg) scale(0.88);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* The chips pop in with a spring (`scale`, so their own drift stays). */
.wow-first .float-chip {
  opacity: 0;
  scale: 0.4;
  animation: chip-pop 0.75s var(--spring) forwards;
}

.wow-first .float-chip-a { animation-delay: 1.9s; }
.wow-first .float-chip-b { animation-delay: 2.1s; }

@keyframes chip-pop {
  to {
    opacity: 1;
    scale: 1;
  }
}

/* A glint crosses the phone's screen: once as it lands, then now and then. */
.device-glint {
  position: absolute;
  inset: 9px;
  overflow: hidden;
  border-radius: 46px;
  pointer-events: none;
}

.device-glint::before {
  content: "";
  position: absolute;
  top: -20%;
  left: 0;
  width: 46%;
  height: 140%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.5) 45%, rgba(255, 255, 255, 0.12) 60%, transparent);
  opacity: 0;
  transform: translate3d(-140%, 0, 0) skewX(-14deg);
}

.wow .device-glint::before {
  animation: glint 9s ease-in-out 2s infinite;
}

@keyframes glint {
  0% {
    opacity: 0;
    transform: translate3d(-140%, 0, 0) skewX(-14deg);
  }
  3% {
    opacity: 1;
  }
  13% {
    opacity: 1;
    transform: translate3d(330%, 0, 0) skewX(-14deg);
  }
  14%,
  100% {
    opacity: 0;
    transform: translate3d(330%, 0, 0) skewX(-14deg);
  }
}

.hero-off .device-glint::before,
.hero-off .device-float {
  animation-play-state: paused;
}

/* Any key, tap or scroll finishes the intro at once: nobody waits to type. */
.wow-skip .hero-in,
.wow-skip .hero-letter,
.wow-skip .device-stage,
.wow-skip .float-chip,
.wow-skip .place-card:not(.is-leaving),
.wow-skip body::after,
.wow-skip .site-header .brand::after {
  animation-delay: 0s !important;
  animation-duration: 0.01s !important;
}

/* ───────────── The headline, letter by letter ───────────── */

/* Until wow.js has split it, the headline waits (and shows by itself after
   1.4 s if the script never comes). */
.wow .hero-wl h1.hero-in:not(.is-split) {
  animation: rise-in 0.8s var(--ease) 1.4s forwards;
}

.wow .hero-wl h1.is-split {
  opacity: 1;
  transform: none;
  animation: none;
}

.hero-word {
  display: inline-block;
  white-space: nowrap;
}

.hero-letter {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 0.3em, 0) scale(1.1);
  /* Exception 1: blur to sharp, 0.7 s, once. */
  filter: blur(10px);
  animation: letter-in 0.7s var(--ease) forwards;
  animation-delay: calc(var(--ld, 0.2s) + var(--i) * var(--ls, 14ms));
  will-change: transform, opacity;
}

.wow-first .hero-letter {
  --ld: 0.95s;
  --ls: 26ms;
}

@keyframes letter-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* The key words: one slowly moving emerald gradient. The letter itself only
   moves and fades; the gradient sits on a plain inline span inside it (the
   same build as the place number, which iPhones draw correctly: a gradient
   clipped to text fails there across child boxes or under a filter). Each
   letter shows its own slice of the gradient: --x is its place in the phrase. */
.hero-letter.is-key {
  filter: none;
}

.key-ink {
  color: #9ff2cf;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .key-ink {
    background-image: linear-gradient(100deg, #9ff2cf 0%, #2fd99a 28%, #e4fdf2 50%, #2fd99a 72%, #9ff2cf 100%);
    background-size: 9em 100%;
    background-position: calc(var(--x, 0em) * -1) 0;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }

  /* Exception 2: the gradient drifts through a few letters. */
  .wow .key-ink {
    animation: key-shimmer 7s linear 2.6s infinite;
  }
}

@keyframes key-shimmer {
  to {
    background-position: calc(var(--x, 0em) * -1 - 9em) 0;
  }
}

.lite .hero-letter {
  filter: none;
}

.lite .key-ink,
.hero-off .key-ink {
  animation-play-state: paused;
}

/* ───────────── The scroll story ───────────── */

.story-scroll {
  position: relative;
  margin-top: clamp(40px, 7vw, 96px);
}

/* Five steps of scrolling, the stage pinned for all of them. */
.story-track {
  position: relative;
  height: calc(100svh + 4 * 78svh);
  view-timeline: --story block;
}

.story-stage {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 5vw, 96px);
  width: min(1120px, 100%);
  height: 100svh;
  margin-inline: auto;
  padding: calc(var(--header-h) + 8px) 24px 24px;
  overflow: hidden;
}

.story-marks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  pointer-events: none;
}

.story-phone {
  position: relative;
  display: grid;
  place-items: center;
  justify-self: end;
  perspective: 1400px;
}

.story-glow {
  position: absolute;
  width: 150%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(47, 217, 154, 0.26), rgba(47, 217, 154, 0.07) 55%, transparent 72%);
  pointer-events: none;
}

.story-device .device-shine {
  opacity: 0.5;
}

.story-device {
  width: min(310px, calc((100svh - var(--header-h) - 96px) / 2.06));
  min-width: 190px;
  transform: rotateY(-8deg) rotateX(3deg);
}

.story-screens {
  position: relative;
  aspect-ratio: 600 / 1218;
  overflow: hidden;
  border-radius: 46px;
  /* The app's own cream, so a screen shown a little higher ends cleanly. */
  background: #f4ede4;
}

.story-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0;
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 0.7s ease, transform 1.1s var(--ease);
}

/* Two screens sit a little higher, without their top row. */
.story-screen-low {
  transform: translate3d(0, -8%, 0) scale(1.05);
}

.story-screen.is-on {
  opacity: 1;
  transform: none;
}

.story-screen-low.is-on {
  transform: translate3d(0, -8%, 0);
}

.story-copy {
  position: relative;
  display: grid;
  align-content: center;
  gap: 18px;
  max-width: 460px;
}

.story-eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.story-lines {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.story-line {
  grid-area: 1 / 1;
  display: grid;
  align-content: start;
  gap: 12px;
  opacity: 0;
  transform: translate3d(0, 26px, 0);
  transition: opacity 0.45s ease, transform 0.7s var(--ease);
  pointer-events: none;
}

.story-line.is-on {
  opacity: 1;
  transform: none;
  transition-delay: 0.12s;
  pointer-events: auto;
}

/* The line that just left moves up and away. */
.story-line.is-past {
  transform: translate3d(0, -22px, 0);
}

.story-kicker {
  justify-self: start;
  padding: 6px 13px;
  border: 1px solid rgba(63, 224, 166, 0.3);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.story-line h3 {
  color: var(--ink);
  font-size: clamp(34px, 4.6vw, 64px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.story-line p {
  color: var(--text);
  font-size: clamp(17px, 1.5vw, 20px);
  font-weight: 300;
  line-height: 1.5;
}

.story-dots {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.story-dots i {
  width: 26px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  transform-origin: left center;
  transition: background-color 0.4s ease, transform 0.5s var(--ease);
}

.story-dots i.is-on {
  background: var(--accent);
  transform: scaleX(1.5);
}

.story-dots i.is-on ~ i {
  transform: translate3d(13px, 0, 0);
}

/* Where the browser can tie animation to scrolling, the phone also turns a
   little and its light drifts as the story goes by. */
@supports (animation-timeline: view()) {
  .wow .story-device {
    animation: story-turn linear both;
    animation-timeline: --story;
    animation-range: contain 0% contain 100%;
  }

  .wow .story-glow {
    animation: story-drift linear both;
    animation-timeline: --story;
    animation-range: contain 0% contain 100%;
  }
}

@keyframes story-turn {
  from {
    transform: rotateY(-11deg) rotateX(4deg);
  }
  to {
    transform: rotateY(9deg) rotateX(-2deg);
  }
}

@keyframes story-drift {
  from {
    transform: translate3d(-12%, 6%, 0) scale(0.92);
  }
  to {
    transform: translate3d(12%, -6%, 0) scale(1.08);
  }
}

@media (max-width: 820px) {
  .story-track {
    height: calc(100svh + 4 * 70svh);
  }

  .story-stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: center;
    justify-items: center;
    gap: 18px;
    padding: calc(var(--header-h) + 4px) 20px 20px;
    text-align: center;
  }

  .story-phone {
    justify-self: center;
  }

  .story-device {
    width: min(230px, 58vw, calc((100svh - var(--header-h) - 250px) / 2.06));
    min-width: 132px;
    padding: 7px;
    border-radius: 40px;
  }

  .story-device .story-screens,
  .story-device .device-shine {
    border-radius: 34px;
  }

  .story-device .device-shine {
    inset: 7px;
  }

  .story-device .device-island {
    top: 15px;
    height: 16px;
  }

  .story-copy {
    justify-items: center;
    gap: 10px;
    width: 100%;
  }

  .story-eyebrow {
    display: none;
  }

  .story-line {
    justify-items: center;
    gap: 8px;
  }

  .story-kicker {
    justify-self: center;
  }

  .story-line h3 {
    font-size: clamp(28px, 8vw, 40px);
  }

  .story-line p {
    font-size: 16px;
  }

  .story-dots {
    justify-content: center;
  }
}

/* ───────────── Cards: tilt and a border that lights up at the cursor ───────────── */

.spot {
  position: absolute;
  z-index: 3;
  inset: 0;
  padding: 1.5px;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(214, 251, 234, 0.95), rgba(47, 217, 154, 0.5) 35%, transparent 62%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

@media (hover: hover) and (pointer: fine) {
  .wow .fcard.is-in.is-tilt {
    transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translate3d(0, -6px, 0);
    transition: transform 0.18s ease-out, box-shadow 0.6s var(--ease);
    box-shadow: var(--shadow-lift);
  }

  .wow .fcard.is-in.is-tilt .spot {
    opacity: 1;
  }
}

/* Touch screens: a light runs once round the border as the card arrives. */
@media (hover: none) {
  .wow .fcard .spot {
    overflow: hidden;
    background: none;
  }

  .wow .fcard .spot::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 160%;
    aspect-ratio: 1;
    margin: -80% 0 0 -80%;
    background: conic-gradient(from 0deg, transparent 0 78%, rgba(47, 217, 154, 0.7) 90%, rgba(214, 251, 234, 0.95) 96%, transparent 100%);
    transform: rotate(-60deg);
  }

  .wow .fcard.is-in .spot {
    animation: spot-show 2s ease 0.3s;
  }

  .wow .fcard.is-in .spot::before {
    animation: spot-run 2s cubic-bezier(0.4, 0, 0.3, 1) 0.3s;
  }
}

@keyframes spot-show {
  10%,
  80% {
    opacity: 1;
  }
}

@keyframes spot-run {
  to {
    transform: rotate(300deg);
  }
}

/* ───────────── The sign-up moment ───────────── */

.hero-moment {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.moment-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hero-moment {
  transition: opacity 2.4s ease;
}

.hero-moment.is-resting {
  opacity: 0.32;
}

/* Exception 3: the lines draw themselves (stroke offset, once). */
.moment-line {
  stroke: rgba(184, 245, 220, 0.55);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
  animation: moment-draw 0.22s linear forwards;
  animation-delay: calc(0.5s + var(--n) * 0.13s);
}

@keyframes moment-draw {
  to {
    stroke-dashoffset: 0;
  }
}

.moment-star {
  position: absolute;
  width: var(--s, 14px);
  height: var(--s, 14px);
  margin: calc(var(--s, 14px) / -2) 0 0 calc(var(--s, 14px) / -2);
  background: #fff;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  opacity: 0;
  transform: scale(0.2);
  animation: moment-star 0.7s ease-out forwards;
  animation-delay: calc(0.5s + var(--n) * 0.13s);
}

@keyframes moment-star {
  35% {
    opacity: 1;
    transform: scale(1.9) rotate(30deg);
  }
  100% {
    opacity: 0.95;
    transform: scale(1) rotate(0deg);
  }
}

.moment-burst {
  position: absolute;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(228, 253, 242, 0.75), rgba(47, 217, 154, 0.28) 38%, transparent 70%);
  opacity: 0;
  transform: scale(0.2);
  animation: moment-burst 1.5s var(--ease) 0.35s;
}

@keyframes moment-burst {
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

.moment-spark {
  position: absolute;
  width: var(--s, 8px);
  height: var(--s, 8px);
  background: var(--c, #fff);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  opacity: 0;
  animation: moment-spark var(--t, 1.4s) cubic-bezier(0.15, 0.7, 0.3, 1) var(--d, 0.4s) forwards;
}

@keyframes moment-spark {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.3);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx), var(--dy), 0) scale(1) rotate(160deg);
  }
}

/* ───────────── Reduce Motion: the calm version ───────────── */

@media (prefers-reduced-motion: reduce) {
  .hero-aurora {
    opacity: 0.7;
  }

  .hero-aurora i,
  .device-glint::before {
    animation: none;
  }

  .story-screen,
  .story-line,
  .story-dots i {
    transition: opacity 0.3s ease;
    transform: none;
  }

  .story-screen-low,
  .story-screen-low.is-on {
    transform: translate3d(0, -8%, 0);
  }

  .story-line.is-past {
    transform: none;
  }

  .story-device {
    transform: none;
  }

  .spot,
  .hero-moment {
    display: none;
  }
}

/* The hero's pieces are in the page from the first frame at 1 % opacity
   (not to be seen, least of all under the opening black), so the browser
   counts the largest text and picture as painted when they have loaded, not
   when the intro reveals them. */
.wow .device-stage,
.wow .hero-copy > .hero-in:not(.is-split),
.wow .hero-letter {
  opacity: 0.01;
}

@keyframes phone-rise {
  from {
    opacity: 0.01;
    transform: translate3d(0, 150px, 0) rotateX(26deg) scale(0.88);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
