/* First screen: a real discovery, recorded in the app. Phone first; the install button never leaves the screen. */
:root {
  --pw: min(62vw, 290px);
}

.fm { display: flex; flex-direction: column; align-items: center; min-height: 100svh; padding: var(--nav-h) 20px calc(100px + env(safe-area-inset-bottom)); overflow: hidden; }
.fm-copy { align-self: stretch; }
.fm-h1 { margin: 6px 0 0; font-family: var(--display); font-weight: 400; font-size: clamp(38px, 11vw, 96px); line-height: 1.02; letter-spacing: -0.035em; }
.fm-h1 em { font-style: normal; text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 0.09em; text-underline-offset: 0.1em; text-decoration-skip-ink: none; }
.fm-sub { margin: 10px 0 0; max-width: 32ch; font-size: 18px; line-height: 1.4; font-weight: 500; }

/* the phone playing the recording, with other kinds of finds fanned behind it */
.fm-stage { position: relative; display: flex; flex-direction: column; align-items: center; margin: 28px 0 0; }
.phone { position: relative; z-index: 1; width: var(--pw); aspect-ratio: 390 / 844; padding: calc(var(--pw) * 0.03); border-radius: calc(var(--pw) * 0.15); background: #10160f; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12) inset, 0 28px 60px rgba(29, 49, 36, 0.28); }
.phone-video { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: calc(var(--pw) * 0.12); background: #17211a; }
.fan { position: absolute; top: 16%; width: calc(var(--pw) * 0.78); border-radius: 4.5% / 3.2%; box-shadow: 0 14px 30px rgba(29, 49, 36, 0.2); }
.fan--l { left: 50%; transform: translateX(-118%) rotate(-11deg); }
.fan--r { left: 50%; top: 26%; transform: translateX(18%) rotate(9deg); }

/* install */
.fm-cta { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(247, 239, 221, 0), var(--paper) 32%); }
.fm-get { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 58px; padding: 0 20px; border-radius: 14px; background: var(--orange); color: var(--ink); font-size: 18px; font-weight: 600; text-decoration: none; transition: transform 0.15s ease; }
.fm-get:hover { transform: translateY(-2px); }
.fm-get svg { width: 22px; height: 22px; fill: currentColor; }
.fm-qr { display: none; }
.fm-small { margin: 14px 0 0; font-size: 15px; font-weight: 600; }

@media (min-width: 900px) {
  :root { --pw: min(23vw, calc(76svh / 2.164), 340px); }
  .fm { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 1fr auto auto auto 1fr; grid-template-areas: '. stage' 'copy stage' 'cta stage' 'small stage' '. stage'; column-gap: 4vw; align-items: center; max-width: 1560px; margin: 0 auto; padding: var(--nav-h) 56px 40px; }
  .fm-copy { grid-area: copy; }
  .fm-h1 { font-size: clamp(56px, 6vw, 92px); max-width: 12.5ch; }
  .fm-sub { margin-top: 22px; font-size: 22px; }
  .fm-stage { grid-area: stage; margin: 0 calc(var(--pw) * 0.45) 0 calc(var(--pw) * 0.55); }
  .fm-cta { grid-area: cta; position: static; align-self: start; flex-wrap: wrap; align-items: center; gap: 16px 24px; margin-top: 32px; padding: 0; background: none; }
  .fm-get { flex: none; padding: 0 28px; }
  /* the code alone on a small white square, its label beside it as plain text */
  .fm-qr { display: flex; align-items: center; gap: 14px; }
  .fm-qr img { display: block; box-sizing: content-box; padding: 10px; border-radius: 14px; background: #fffdf8; border: 1.5px solid rgba(29, 49, 36, 0.14); }
  .fm-qr p { margin: 0; max-width: 8.5em; text-align: left; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--forest); }
  .fm-small { grid-area: small; align-self: start; }
}

/* ---- the sections below: a headline, one line, and the app doing it ---- */
.sec { display: flex; flex-direction: column; align-items: center; gap: 30px; padding: 72px 20px 24px; }
.sec-copy { align-self: stretch; }
.sec-h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: clamp(38px, 10vw, 84px); line-height: 1.02; letter-spacing: -0.035em; }
.sec-h2 em, .end-h2 em { font-style: normal; text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 0.09em; text-underline-offset: 0.1em; text-decoration-skip-ink: none; }
.sec-p { margin: 14px 0 0; max-width: 34ch; font-size: 18px; line-height: 1.45; font-weight: 500; }
.sec-stage { position: relative; display: flex; justify-content: center; }
.sticker { position: absolute; z-index: 2; width: calc(var(--pw) * 0.3); filter: drop-shadow(0 6px 10px rgba(29, 49, 36, 0.22)); }
.sticker--a { left: 50%; top: 8%; transform: translateX(calc(-50% - var(--pw) * 0.62)) rotate(-14deg); }
.sticker--b { left: 50%; top: 44%; transform: translateX(calc(-50% + var(--pw) * 0.6)) rotate(12deg); }
.sticker--c { left: 50%; bottom: 10%; transform: translateX(calc(-50% - var(--pw) * 0.58)) rotate(8deg); }

.end { display: flex; flex-direction: column; min-height: 100svh; }
.end-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--nav-h) + 48px) 20px 64px; text-align: center; }
.end-h2 { margin: 0; max-width: 12ch; font-family: var(--display); font-weight: 400; font-size: clamp(42px, 11vw, 96px); line-height: 1.02; letter-spacing: -0.035em; }
.end-cta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 16px 24px; margin-top: 32px; }
.end-cta .fm-get { flex: none; padding: 0 28px; }
.end-small { margin: 16px 0 0; font-size: 15px; font-weight: 600; }
/* On a phone the pinned install button steps aside once the closing one is on screen. */
.fm-cta { transition: transform 0.3s ease, opacity 0.3s ease; }
body.at-end .fm-cta { transform: translateY(110%); opacity: 0; pointer-events: none; }

@media (min-width: 900px) {
  .sec { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 4vw; align-items: center; max-width: 1560px; margin: 0 auto; padding: 96px 56px; }
  .sec--flip { grid-template-columns: auto minmax(0, 1fr); }
  .sec--flip .sec-stage { order: -1; }
  .sec-copy { align-self: center; }
  .sec-stage { margin: 0 calc(var(--pw) * 0.45) 0 calc(var(--pw) * 0.55); }
  .sec--flip .sec-stage { margin: 0 calc(var(--pw) * 0.55) 0 calc(var(--pw) * 0.45); }
  .sec-h2 { font-size: clamp(52px, 5vw, 80px); max-width: 11ch; }
  .sec-p { margin-top: 20px; font-size: 21px; }
  .end-main { padding: calc(var(--nav-h) + 56px) 56px 72px; }
  .end-h2 { font-size: clamp(60px, 6vw, 96px); max-width: 14ch; }
  body.at-end .fm-cta { transform: none; opacity: 1; pointer-events: auto; }
}

/* ---- one section per scroll: the page stops on each part while its recording plays ---- */
html { scroll-snap-type: y mandatory; }
.fm, .sec { scroll-snap-align: start; scroll-snap-stop: always; }
.end { scroll-snap-align: end; }
.sec { min-height: 100svh; justify-content: center; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
/* Each part fits one phone screen: the phone shrinks on short screens rather than running under the install bar. */
.sec { --pw: min(62vw, 290px, calc((100svh - 372px) / 2.164)); }
@media (min-width: 900px) {
  .sec { --pw: min(23vw, calc(76svh / 2.164), 340px); min-height: 100vh; padding-bottom: 72px; }
}

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---- captions that follow the recording: one line per moment, with a story-style progress bar ---- */
.beat-bar { display: flex; gap: 6px; max-width: 240px; margin-top: 18px; }
.beat-bar span { position: relative; flex: 1; height: 4px; overflow: hidden; border-radius: 2px; background: rgba(29, 49, 36, 0.14); }
.beat-bar span::after { content: ''; position: absolute; inset: 0; background: var(--forest); transform: scaleX(var(--p, 0)); transform-origin: left; }
.beats { display: grid; max-width: 34ch; margin: 12px 0 0; padding: 0; list-style: none; }
.beats li { grid-area: 1 / 1; font-size: 18px; line-height: 1.45; font-weight: 500; opacity: 0; transform: translateY(6px); transition: opacity 0.35s ease, transform 0.35s ease; }
.beats li.on { opacity: 1; transform: none; }
@media (min-width: 900px) {
  .beat-bar { margin-top: 26px; }
  .beats { margin-top: 16px; }
  .beats li { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { .beats li { transition: none; } }

/* Desktop sections: the words sit right beside the phone, so the eye barely travels between them.
   The cards and stickers gather on the phone's far side to make that room. */
@media (min-width: 900px) {
  .sec { grid-template-columns: auto minmax(0, 440px); justify-content: center; column-gap: 64px; }
  .sec--flip { grid-template-columns: auto minmax(0, 440px); }
  .sec:not(.sec--flip) { grid-template-columns: minmax(0, 440px) auto; }
  .sec:not(.sec--flip) .sec-stage { margin: 0 calc(var(--pw) * 0.62) 0 0; }
  .sec--flip .sec-stage { margin: 0 0 0 calc(var(--pw) * 0.62); }
  .sec--flip .fan--l { top: 8%; }
  .sec--flip .fan--r { left: 50%; top: 40%; transform: translateX(-132%) rotate(6deg); }
  .sticker--a { top: 6%; transform: translateX(calc(-50% + var(--pw) * 0.62)) rotate(14deg); }
  .sticker--b { top: 40%; transform: translateX(calc(-50% + var(--pw) * 0.7)) rotate(-10deg); }
  .sticker--c { bottom: 12%; transform: translateX(calc(-50% + var(--pw) * 0.6)) rotate(8deg); }
  /* Chapters: one more card peeks out on the caption side, so the cards fan around the phone, not just behind it. */
  .sec--flip { column-gap: 40px; }
  .sec--flip .sec-stage { margin: 0 calc(var(--pw) * 0.28) 0 calc(var(--pw) * 0.62); }
  .sec--flip .fan--n { display: block; left: 50%; top: 30%; transform: translateX(-10%) rotate(8deg); }
}
.fan--n { display: none; }

/* ---- the closing: a spread of finds on the table around the last call to install (wide screens only) ---- */
.end-cards { display: none; }
@media (min-width: 1280px) {
  .end-main { position: relative; overflow: hidden; }
  .end-main > :not(.end-cards) { position: relative; z-index: 1; }
  .end-cards { display: block; position: absolute; inset: var(--nav-h) 0 0; pointer-events: none; }
  .end-card { position: absolute; left: var(--x); top: var(--y); width: calc(min(10vw, 170px) * var(--w)); border-radius: 4.5% / 3.2%; box-shadow: 0 14px 30px rgba(29, 49, 36, 0.2); transform: rotate(var(--r)); }
  .end-card--r { left: auto; right: var(--x); }
}
/* The cards settle onto the table as the closing comes into view, a beat apart. */
@media (min-width: 1280px) and (prefers-reduced-motion: no-preference) {
  .end-card { opacity: 0; transform: translate(-40px, 24px) rotate(calc(var(--r) - 10deg)); transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.3, 1.3, 0.5, 1); }
  .end-card--r { transform: translate(40px, 24px) rotate(calc(var(--r) + 10deg)); }
  body.at-end .end-card { opacity: 1; transform: rotate(var(--r)); }
  .end-card:nth-child(4n + 2) { transition-delay: 0.08s; }
  .end-card:nth-child(4n + 3) { transition-delay: 0.16s; }
  .end-card:nth-child(4n) { transition-delay: 0.24s; }
}

/* ---- each step, pointed out: the screen zooms to where it happens, and every tap leaves a ripple ---- */
.screen { position: relative; width: 100%; height: 100%; overflow: hidden; border-radius: calc(var(--pw) * 0.12); background: #17211a; -webkit-mask-image: -webkit-radial-gradient(white, black); }
.zoom { position: absolute; inset: 0; transform: scale(var(--s, 1)); transform-origin: var(--ox, 50%) var(--oy, 50%); transition: transform 0.8s cubic-bezier(0.3, 0.7, 0.2, 1); }
.zoom .phone-video { border-radius: 0; }
.tap { position: absolute; z-index: 1; width: 15%; aspect-ratio: 1; margin: -7.5% 0 0 -7.5%; pointer-events: none; }
.tap::before { content: ''; position: absolute; inset: 28%; border-radius: 50%; background: rgba(255, 255, 255, 0.88); box-shadow: 0 0 0 1.5px rgba(29, 49, 36, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25); }
.tap::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px rgba(29, 49, 36, 0.35); animation: tap-ring 0.75s ease-out forwards; }
.tap::before { animation: tap-dot 0.75s ease-out forwards; }
@keyframes tap-ring { from { transform: scale(0.35); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
@keyframes tap-dot { 0% { transform: scale(0.6); opacity: 0; } 15% { transform: scale(1); opacity: 1; } 55% { opacity: 1; } 100% { transform: scale(0.85); opacity: 0; } }
/* the heart beside the phone answers the heart tapped inside it */
.sticker.pop { animation: sticker-pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes sticker-pop { 0% { scale: 1; } 35% { scale: 1.35; } 70% { scale: 0.94; } 100% { scale: 1; } }
/* the caption's key words get the orange underline as their moment comes up */
.beats em { font-style: normal; background: linear-gradient(var(--orange), var(--orange)) no-repeat left bottom / 0% 0.12em; padding-bottom: 0.04em; transition: background-size 0.6s ease 0.2s; }
.beats li.on em { background-size: 100% 0.12em; }
