/* ───────────────────────────────────────────────────────────
   Retold website — same paper, same pencil as the app.
   Tokens mirror retold-app/dom/tokens.css exactly.
   Rule of colour: red exists ONLY in the recording scene.
   ─────────────────────────────────────────────────────────── */
:root {
  --paper: #FCFBF6;
  --ink: #1B1813;
  --pencil: #A39D90;
  --pencil-soft: #CCC7BA;
  --pencil-text: #6E685C;
  --crayon: #D8402B;
  --cr-red: #D8402B;
  --cr-blue: #3D6FA8;
  --cr-yellow: #DFA83A;
  --cr-green: #5F8C4F;
  --ghost: rgba(27, 24, 19, 0.14);
  --desk: #EFECE2;

  --font-hand: 'Caveat', 'Bradley Hand', cursive;
  --font-body: 'Patrick Hand', 'Bradley Hand', cursive;

  --t-page: 560ms;
  --t-press: 140ms;
  --t-settle: 220ms;
  --t-boil-step: 340ms;
  --ease-pencil: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-enter: cubic-bezier(0.2, 0, 0, 1);
  --ease-exit: cubic-bezier(0.3, 0, 1, 1);
  --ease-settle: cubic-bezier(0.34, 1.3, 0.44, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16130E;
    --ink: #EFEAD9;
    --pencil: #5E574A;
    --pencil-soft: #463F33;
    --pencil-text: #A79E8B;
    --desk: #0F0D09;
    --ghost: rgba(239, 234, 217, 0.14);
    --crayon: #E2543C;
    --cr-red: #E2543C;
    --cr-blue: #5C8BC4;
    --cr-yellow: #E7B95A;
    --cr-green: #7BA468;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
svg { display: block; overflow: visible; }
svg path, svg line, svg circle, svg polyline, svg ellipse { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ── strokes: boiling lines (3 held frames, like the app) ── */
.boil { animation: boil calc(var(--t-boil-step) * 3) step-end infinite; }
@keyframes boil {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(0.35px, -0.3px) rotate(0.12deg); }
  66% { transform: translate(-0.3px, 0.3px) rotate(-0.12deg); }
}

/* handwriting write-on */
.word { display: inline-block; opacity: 0; animation: wordin 260ms var(--ease-enter) forwards; }
@keyframes wordin { from { opacity: 0; transform: translateY(3px) rotate(0.4deg); } to { opacity: 1; transform: none; } }

/* press feedback */
.press { transition: transform var(--t-settle) var(--ease-settle); display: inline-block; }
.press:active { transform: scale(0.96) rotate(-1deg); transition-duration: var(--t-press); }
.press:hover { transform: scale(1.02) rotate(0.4deg); }

/* scene life */
.bob { animation: bob 900ms ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
.walk-a { animation: walka 640ms ease-in-out infinite alternate; }
.walk-b { animation: walkb 640ms ease-in-out infinite alternate; }
@keyframes walka { from { transform: rotate(16deg); } to { transform: rotate(-16deg); } }
@keyframes walkb { from { transform: rotate(-16deg); } to { transform: rotate(16deg); } }
.splash-pop { animation: splashpop 2400ms ease-in-out infinite; }
@keyframes splashpop { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.06); } 24% { transform: scale(1); } }
.push-heave { animation: heave 1100ms ease-in-out infinite alternate; }
@keyframes heave { from { transform: translateX(0); } to { transform: translateX(4px) rotate(-0.4deg); } }
.pulse-red { animation: pulsered 1100ms ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes pulsered { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.05); opacity: 0.75; } }
.pencil-write { animation: penwiggle 700ms ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 90%; }
@keyframes penwiggle { from { transform: rotate(-3deg) translateX(0); } to { transform: rotate(2deg) translateX(3px); } }
.drift-a { animation: drift 9s ease-in-out infinite alternate; }
.drift-b { animation: drift 12s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translateX(-6px); } to { transform: translateX(8px); } }

@media (prefers-reduced-motion: reduce) {
  .leaf.turn-fwd, .leaf.turn-back { animation: none; }
  .boil, .bob, .walk-a, .walk-b, .splash-pop, .push-heave, .pulse-red, .pencil-write, .drift-a, .drift-b { animation: none; }
  html { scroll-behavior: auto; }
}

/* ── the book: a sheet of paper on a desk ────────────────
   You can see the page, so you can see it turn. The leaving
   sheet lifts from its bottom corner and swings away; the next
   sheet is already underneath, drawing itself on. Nothing fades.
   ──────────────────────────────────────────────────────── */
body.desk { overflow: hidden; height: 100svh; background: var(--desk); }

.book { position: fixed; inset: 0; overflow: hidden; perspective: 1800px; }

.leaf {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  visibility: hidden;
  padding: max(14px, 2.2vh) max(12px, 2vw);
}
.leaf.is-current { visibility: visible; z-index: 2; }
.leaf.turn-fwd, .leaf.turn-back { visibility: visible; z-index: 5; pointer-events: none; }

.sheet {
  position: relative;
  width: min(660px, 100%);
  height: min(880px, 100%);
  transform-origin: 6% 96%;
  will-change: transform;
}
/* a second sheet peeking underneath — it looks like a stack */
.sheet::after {
  content: ""; position: absolute; inset: 0;
  background: var(--paper); border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transform: rotate(-0.7deg) translate(3px, 4px);
  z-index: -1;
}
.leaf.turn-fwd .sheet::after, .leaf.turn-back .sheet::after { display: none; }
/* anything sitting outside the clipped face would survive the fold */
.leaf.turn-fwd .dogear, .leaf.turn-back .dogear { display: none; }
.sheet-edge { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.sheet-in {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  display: flex; flex-direction: column; justify-content: center;
  text-align: center;
  padding: clamp(26px, 5vh, 54px) clamp(20px, 5%, 46px);
}

/* ── the peel ───────────────────────────────────────────
   The bottom-right corner lifts and folds up-and-left across
   the page, like tearing a sheet away. Behind the fold you see
   the next chapter, already drawing itself on.
   One number drives it: --cut, the distance the crease has
   travelled from the corner.
   ─────────────────────────────────────────────────────── */
@property --cut { syntax: "<length>"; inherits: true; initial-value: 0px; }

.sheet-face {
  position: absolute; inset: 0;
  background: var(--paper);
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07), 0 14px 34px rgba(0,0,0,0.09);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);
}
.leaf.turn-back .sheet-face {
  clip-path: polygon(0 0, 100% 0, 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}

/* the underside of the paper, folded back over itself. It must read
   as a *different* surface from the page, or the fold is invisible
   (paper on paper). Tone + a drawn crease do that work. */
.peel {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(135deg,
      rgba(0,0,0,0.20) 0%,
      var(--desk) 10%,
      var(--desk) 30%,
      color-mix(in srgb, var(--desk) 55%, var(--paper)) 100%);
  clip-path: polygon(
    calc(100% - var(--cut)) 100%,
    100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) calc(100% - var(--cut))
  );
  filter: drop-shadow(-6px -6px 12px rgba(0,0,0,0.30));
}
.leaf.turn-back .peel {
  background:
    linear-gradient(45deg,
      rgba(0,0,0,0.20) 0%,
      var(--desk) 10%,
      var(--desk) 30%,
      color-mix(in srgb, var(--desk) 55%, var(--paper)) 100%);
  clip-path: polygon(var(--cut) 100%, 0 calc(100% - var(--cut)), var(--cut) calc(100% - var(--cut)));
  filter: drop-shadow(6px -6px 12px rgba(0,0,0,0.30));
}

/* the crease itself, in pencil — this is what makes it read as a fold */
.crease {
  position: absolute; left: calc(100% - var(--cut)); top: 100%;
  width: calc(var(--cut) * 1.4142); height: 0;
  border-top: 2px solid var(--pencil-text);
  transform-origin: 0 0; transform: rotate(-45deg);
  opacity: 0; pointer-events: none;
}
.leaf.turn-back .crease {
  left: var(--cut); transform-origin: 0 0; transform: rotate(-135deg);
}
.leaf.turn-fwd .peel, .leaf.turn-back .peel,
.leaf.turn-fwd .crease, .leaf.turn-back .crease { opacity: 1; }

/* The corner folds up-and-left, then the whole sheet swings away,
   uncovering the next chapter already drawing itself on. */
.leaf.turn-fwd .sheet {
  animation: peel var(--t-page) var(--ease-pencil) forwards,
             throwfwd var(--t-page) var(--ease-exit) forwards;
}
.leaf.turn-back .sheet {
  animation: peel var(--t-page) var(--ease-pencil) forwards,
             throwback var(--t-page) var(--ease-exit) forwards;
}
@keyframes peel {
  0%   { --cut: 0px; }
  46%  { --cut: var(--peel-mid, 300px); }
  100% { --cut: var(--peel-mid, 300px); }
}
@keyframes throwfwd {
  0%, 26% { transform: none; }
  100%    { transform: translateX(-124%) rotate(-13deg); }
}
@keyframes throwback {
  0%, 26% { transform: none; }
  100%    { transform: translateX(124%) rotate(13deg); }
}

/* the dog-ear: tap the corner to turn */
.dogear {
  position: absolute; right: 0; bottom: 0; width: 62px; height: 62px;
  padding: 0; opacity: 0.75;
  transition: transform var(--t-settle) var(--ease-settle), opacity var(--t-settle) var(--ease-enter);
}
.dogear svg { width: 100%; height: 100%; }
.dogear:hover { opacity: 1; transform: translate(-2px, -2px) scale(1.06); }
.dogear:active { transform: scale(0.94); }
.at-end .dogear { display: none; }

/* ── the spine of ticks ─────────────────────────────────── */
.spine {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 8;
}
.tick { width: 24px; height: 11px; padding: 0; opacity: 0.4; transition: opacity var(--t-settle) var(--ease-enter), transform var(--t-settle) var(--ease-settle); }
.tick svg { width: 100%; height: 100%; }
.tick svg path { stroke: var(--pencil-text); }
.tick.done { opacity: 0.7; }
.tick.here { opacity: 1; transform: scale(1.4) rotate(-2deg); }
.tick:hover { opacity: 1; }

/* ── type ───────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-hand); font-weight: 700; line-height: 1.15; }
h1, h2, .lead, .aside { text-wrap: balance; }
h1 { font-size: clamp(52px, 12vw, 92px); }
h2 { font-size: clamp(31px, 5.6vw, 48px); margin-bottom: 4px; }
.kicker { font-size: clamp(13px, 1.6vw, 15px); letter-spacing: 0.15em; text-transform: uppercase; color: var(--pencil-text); margin-bottom: 6px; }
.lead { font-size: clamp(17px, 2.3vw, 22px); color: var(--ink); max-width: 33ch; margin: 8px auto 0; }
.aside { font-family: var(--font-hand); font-size: clamp(19px, 2.6vw, 25px); color: var(--pencil-text); transform: rotate(-1.2deg); max-width: 30ch; margin: 10px auto 0; }
.small { font-size: clamp(13px, 1.6vw, 15px); color: var(--pencil-text); margin-top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.scene-slot svg { width: 100%; height: auto; }
.leaf .scene-slot { width: min(400px, 74%); margin: clamp(10px, 2.4vh, 26px) auto; }
.hero .scene-slot, [data-key="cover"] .scene-slot { width: min(360px, 68%); }

/* ── drawn chrome ───────────────────────────────────────── */
[data-ring] { position: relative; padding: 14px 32px; font-family: var(--font-hand); font-size: clamp(19px, 2.6vw, 25px); text-decoration: none; white-space: nowrap; display: inline-block; }
.ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
[data-underline] { position: relative; text-decoration: none; color: var(--pencil-text); font-size: 16px; padding-bottom: 5px; }
.ul-svg { position: absolute; left: 0; bottom: -2px; width: 100%; height: 8px; }
.ul-svg path { stroke: var(--pencil-text); }
.cta-row { display: flex; gap: 20px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: clamp(12px, 2.6vh, 28px); }

/* ── the shelf: an Embla carousel inside the page ───────── */
.rail { overflow: hidden; margin: clamp(8px, 2vh, 20px) 0 0; cursor: grab; }
.rail:active { cursor: grabbing; }
.rail-track { display: flex; touch-action: pan-y pinch-zoom; margin-left: -5%; }
.card { flex: 0 0 72%; min-width: 0; padding-left: 5%; }
.card .scene-slot { width: 100%; margin: 0 auto; }
.card figcaption { font-family: var(--font-hand); font-size: clamp(19px, 2.4vw, 25px); margin-top: 2px; transform: rotate(-0.7deg); }
.card .whisper { font-size: clamp(12px, 1.5vw, 14px); color: var(--pencil-text); margin-top: 2px; }
.rail-hint { opacity: 0.8; }
.card > * { user-select: none; }

/* ── the last page ──────────────────────────────────────── */








.plus-list { list-style: none; margin: clamp(8px, 1.6vh, 16px) auto 0; max-width: 30ch; text-align: left; }
.plus-list li { padding: 1px 0 1px 28px; position: relative; font-size: clamp(14px, 1.75vw, 17px); }
.plus-list li svg { position: absolute; left: 0; top: 4px; width: 20px; height: 20px; }

.price-cards { display: flex; gap: clamp(14px, 2.6vw, 26px); justify-content: center; flex-wrap: nowrap; margin-top: clamp(10px, 2vh, 20px); }
.price-card { position: relative; padding: 15px 20px 12px; width: clamp(140px, 44%, 200px); }
.price-card .plan { font-family: var(--font-hand); font-size: clamp(19px, 2.3vw, 23px); }
.price-card .amount { font-family: var(--font-hand); font-size: clamp(30px, 4.4vw, 40px); margin: 1px 0; }
.price-card .per { color: var(--pencil-text); font-size: clamp(12px, 1.5vw, 14px); }
.badge { position: absolute; top: -13px; left: 50%; transform: translateX(-50%) rotate(-2deg); font-family: var(--font-hand); font-size: 16px; color: var(--paper); background: var(--ink); padding: 2px 10px; border-radius: 4px; white-space: nowrap; }

.foot-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin: clamp(10px, 2vh, 20px) 0 8px; }
.foot-note { color: var(--pencil-text); font-size: 13px; }

@media (max-width: 720px) {
  :root { --t-page: 460ms; }   /* mobile 0.8x, per motion-design platform scaling */
  .spine { right: auto; left: 50%; bottom: max(8px, env(safe-area-inset-bottom)); top: auto; transform: translateX(-50%); flex-direction: row; }
  .sheet { height: 100%; }
  .sheet-in { padding-bottom: 40px; }
  .dogear { width: 52px; height: 52px; }
  .card { flex: 0 0 80%; }
}
@media (prefers-reduced-motion: reduce) {
  .leaf.turn-fwd .sheet, .leaf.turn-back .sheet { animation: none; }
}

/* ── legal / support pages (ordinary scrolling) ──────────── */
.page { max-width: 720px; margin: 0 auto; padding: 6vh 24px 12vh; position: relative; z-index: 1; }
.page-head { text-align: center; margin-bottom: 5vh; }
.page-head .home-link { display: inline-block; margin-bottom: 3vh; }
.page h1 { font-size: clamp(46px, 9vw, 64px); }
.page .updated { color: var(--pencil-text); font-size: 16px; margin-top: 4px; }
.page h2 { font-size: clamp(30px, 5vw, 38px); margin: 5vh 0 1.2vh; }
.page p, .page li { font-size: 19px; color: var(--ink); }
.page p { margin: 0 0 14px; }
.page ul { margin: 0 0 14px 26px; }
.page li { margin-bottom: 6px; }
.page .muted { color: var(--pencil-text); }
.page a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.divider-svg { width: 130px; margin: 1.4vh auto 0; }

@media (max-width: 560px) {
  body { font-size: 18px; }
  .price-cards { gap: 26px; }
}

/* the last page carries the most — let it breathe less */
[data-key="last"] .sheet-in { justify-content: flex-start; padding-top: clamp(20px, 3.4vh, 38px); }
[data-key="last"] .lead { margin-top: 6px; }
[data-key="last"] .cta-row { margin-top: clamp(10px, 2vh, 20px); }
[data-key="last"] .small { margin-top: 6px; }
@media (max-height: 720px) {
  [data-key="last"] .shelf-mini { display: none; }
}

/* the last page carries the whole ask — it must fit on one sheet */
[data-key="last"] .scene-slot { width: min(216px, 44%); margin: 2px auto 4px; }
[data-key="last"] h2 { margin-bottom: 2px; }
[data-key="last"] .plus-list { margin-top: 8px; }
[data-key="last"] .plus-list li { padding-top: 0; padding-bottom: 0; line-height: 1.42; }
[data-key="last"] .foot-note { margin-top: 2px; }
