/* ==========================================================================
   Doone case study. Chapter 4 is a run of launch panels: each plays one
   journey, rebuilt live from Sham's Figma screens with her own motion, once as
   it arrives. Below: Testing (valence grid, drag to compare) and Reflection.
   ========================================================================== */

.case-page .solution.panel { min-height: 0; display: block; scroll-snap-align: none; } /* the panels inside it settle instead */

.step-kicker { font: 400 12px/1.4 var(--text); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.step-text { font-size: 17px; line-height: 1.7; color: var(--body-ink); margin: 0; }

/* ---------- The phone: a bare 393 x 852 screen ---------- */
.phone {
  --ph-w: min(300px, 38vh * .46);
  --pt: calc(var(--ph-w) / 393);
  position: relative; width: var(--ph-w); height: calc(var(--ph-w) * 852 / 393); margin-inline: auto;
  border-radius: calc(var(--pt) * 52); overflow: hidden; background: #F7F7F4; isolation: isolate;
  box-shadow: 0 30px 80px rgba(18, 19, 19, .18), 0 2px 6px rgba(18, 19, 19, .08);
}

/* Every layer is placed by doone.js from the panel's clock (transform, opacity, clip) */
.ly { position: absolute; inset: 0; will-change: transform, opacity; }
.ly img { display: block; width: 100%; height: auto; }
.scr { background: #F7F7F4; }
.scr::after { content: ""; position: absolute; inset: 0; background: #000; opacity: calc(var(--sh, 0) * .12); pointer-events: none; }
.pushed { box-shadow: -10px 0 30px rgba(0, 0, 0, .12); }
.sheet { inset: auto 0 0 0; border-radius: calc(var(--pt) * 28) calc(var(--pt) * 28) 0 0; overflow: hidden; }
.cover { box-shadow: 0 -10px 30px rgba(0, 0, 0, .12); }

/* A subtle touch dot before each screen change */
.tdot {
  inset: auto; left: calc(var(--pt) * var(--x)); top: calc(var(--pt) * var(--y)); z-index: 20;
  width: calc(var(--pt) * 44); height: calc(var(--pt) * 44); margin: calc(var(--pt) * -22) 0 0 calc(var(--pt) * -22);
  border-radius: 50%; background: rgba(18, 19, 19, .18); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .9), 0 4px 14px rgba(0, 0, 0, .18);
  opacity: 0; pointer-events: none;
}

/* ---------- Launch panels: one journey per screen ---------- */
.launch {
  min-height: calc(100svh - var(--nav-h)); display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  align-items: center; gap: var(--s8); padding-block: clamp(16px, 4vh, 48px); overflow-x: clip;
}
.launch-copy { max-width: 34ch; }
.launch-title { font: 400 clamp(26px, 2.6vw, 40px)/1.15 var(--display); letter-spacing: -.02em; margin: 0 0 16px; }
.launch-stage {
  --ph-w: min(300px, 62vh * .46); --pt: calc(var(--ph-w) / 393);
  position: relative; width: var(--ph-w); margin-inline: auto;
}
.phone.phone--launch { --ph-w: inherit; --pt: inherit; }

/* ---------- Walkthrough: Sham's onboarding screens as live UI ---------- */
.wt .phone--launch { background: #0f2318; }
/* The scene is laid out at Figma's 393 x 852 and scaled to the phone by doone.js */
.wt-scene {
  position: absolute !important; left: 0; top: 0; width: 393px !important; height: 852px !important;
  border-radius: 0 !important; transform-origin: 0 0; --pt: 1px;
}
/* Flowers grow out from behind the phone: the meadow without its ground, larger,
   a beat later and half the speed of the one inside (doone.js sets size and place) */
.wt .launch-stage { isolation: isolate; }
.wt .phone--launch { z-index: 1; }
.wt-bloom { position: absolute; left: 50%; bottom: 0; width: 393px; height: 385px; translate: -50% 0; transform-origin: 50% 100%; z-index: 0; pointer-events: none; }
.wt-bloom > div { top: 0 !important; overflow: visible !important; }
/* stems fade out where they meet the page, so the flowers seem rooted behind the phone */
.wt-bloom { -webkit-mask-image: linear-gradient(to bottom, #000 50%, transparent 60%); mask-image: linear-gradient(to bottom, #000 50%, transparent 60%); }
.wt .wt-bloom * { animation-duration: 36s !important; animation-delay: 1.4s !important; }
.wt:not(.is-playing) .wt-bloom * { animation-play-state: paused !important; }

/* Keep the site's own text styles out of the app's UI (inline styles from Figma win) */
.wt-scene p { margin: 0; color: inherit; font: inherit; letter-spacing: inherit; max-width: none; }
.wt-scene img { max-width: none; }
.wt-scene [data-type].is-typing::after {
  content: ""; display: inline-block; width: 1.5px; height: 18px; margin-left: 1px; vertical-align: -3px;
  background: #141414; animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* Figma's code assumes Tailwind's reset: no borders unless a class adds one */
.wt-scene *, .hub-scene * { box-sizing: border-box; border-width: 0; border-style: solid; }
.panel .wt-scene p, .panel .hub-scene p { margin: 0; } /* not the case study's paragraph spacing */

/* ---------- Home journey: home as the hub (J01, J06) ---------- */
.hub-scene {
  position: absolute; left: 0; top: 0; width: 393px; height: 852px; transform-origin: 0 0; --pt: 1px;
  background: #f6f6f2; overflow: hidden;
}
/* each screen is laid out at Figma's 393 x 852 */
.hub-scene .hs:not(.hs-overlay) > div:not(.ly) { position: absolute !important; inset: 0; width: 393px !important; height: 852px !important; border-radius: 0 !important; }
.hub-scene .hs-overlay > div { position: absolute; }
.hub-scene .hs-overlay { background: transparent; }
.hub-scene p { margin: 0; color: inherit; font: inherit; letter-spacing: inherit; max-width: none; }
.hub-scene img { max-width: none; }
.hub .phone--launch { background: #f6f6f2; }

/* Figma's character-by-character text entrances (16 h, 30) */
.hub .hs .ch { display: inline-block; opacity: 0; }
.hub .hs.is-live .ch { animation: chIn .5s cubic-bezier(0, 0, .58, 1) calc(var(--i) * 111ms) both; }
.hub .hs.is-live .k3049_528 .ch { animation-duration: .55s; animation-delay: calc(var(--i) * 157ms); }
@keyframes chIn { from { opacity: 0; translate: 0 24px; filter: blur(6px); } to { opacity: 1; translate: 0 0; filter: none; } }
.hub .hs .k3023_172, .hub .hs .k3023_181 { opacity: 0; }
.hub .hs.is-live .k3023_172 { animation: blockIn .55s cubic-bezier(0, 0, .58, 1) both; }
.hub .hs.is-live .k3023_181 { animation: blockIn .9s cubic-bezier(0, 0, .58, 1) .35s both; }
@keyframes blockIn { from { opacity: 0; translate: 0 12px; filter: blur(6px); } to { opacity: 1; translate: 0 0; filter: none; } }

/* Outside the frame: seeds earned or spent drift out, leaves fall past the phone */
.hub-out { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.hub-out .ly { inset: auto; left: calc(var(--pt) * var(--x)); top: calc(var(--pt) * var(--y)); opacity: 0; }
.seedchip { width: calc(var(--pt) * var(--w)); height: calc(var(--pt) * 34); display: grid; place-items: center; }
.seedchip span {
  display: inline-block; padding: calc(var(--pt) * 7) calc(var(--pt) * 14); border-radius: 999px; white-space: nowrap;
  font: 600 calc(var(--pt) * 16)/1.2 var(--text); box-shadow: 0 12px 30px rgba(18, 19, 19, .16);
}
.seedchip--earn span { background: #eef9cc; color: #2d6a3e; }
.seedchip--spend span { background: #141414; color: #fff; }
.leafout { width: calc(var(--pt) * 22); }
/* Friends' reactions floating out beside the phone (Read together) */
.react-out {
  display: flex; align-items: center; gap: .45em; width: max-content; height: fit-content;
  background: #fff; border-radius: 99px; padding: .4em 1em .4em .4em; box-shadow: 0 14px 34px rgba(18, 19, 19, .16);
  font: 500 calc(var(--pt) * 17)/1 var(--text); color: #141414;
}
.react-ava { width: 1.9em; height: 1.9em; border-radius: 50%; display: inline-grid; place-items: center; font-size: .85em; font-weight: 600; }
.leafout img { display: block; width: 100%; height: auto; }

/* The chapter list beside the phone follows the journey */
.hub-steps { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 10px; }
.hub-steps li {
  position: relative; padding-left: 22px; font-size: 15px; line-height: 1.4; color: var(--muted);
  transition: color 300ms ease;
}
.hub-steps li::before {
  content: ""; position: absolute; left: 0; top: .55em; width: 10px; height: 2px; border-radius: 2px;
  background: currentColor; opacity: .5; transition: width 300ms var(--ease-out), opacity 300ms ease;
}
.hub-steps li.is-current { color: var(--ink); }
.hub-steps li.is-current::before { width: 14px; opacity: 1; background: var(--accent); }
.hub-steps li.is-past { color: var(--body-ink); }
.hub-replay {
  margin-top: var(--s4); font: 500 14px/1 var(--text); color: var(--ink); background: none; border: 0; padding: 8px 0;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

/* ---------- Find, keep, you: one phone, three flows, a tab for each ---------- */
.trio-tabs { gap: 4px; }
.trio-tabs li { padding: 0; }
.trio-tabs li::before { top: 1.05em; }
.trio-tab {
  display: block; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 6px 0 6px 22px; margin: 0; font: 500 16px/1.35 var(--text); color: inherit;
  transition: transform 160ms var(--ease-out);
}
.trio-tab:active { transform: scale(.98); }
.trio-tab span { display: block; font-weight: 400; font-size: 14px; color: var(--muted); }
.trio-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.hub-scene .banner { height: auto; }
.banner-in {
  width: 377px; background: rgba(255, 255, 255, .96); border-radius: 22px; padding: 0 14px;
  box-shadow: 0 18px 44px rgba(18, 19, 19, .18); backdrop-filter: blur(12px);
}
.banner-in > div { border-bottom: 0 !important; }

/* ---------- Process proof: letters, gaps, and which insight each panel answers ---------- */
.letter {
  margin: 16px 0 0; padding: 14px 16px; border-radius: 4px; rotate: -.6deg;
  font-size: 14px; line-height: 1.5; color: #1d1d1f; box-shadow: 0 6px 16px rgba(18, 19, 19, .08);
}
.amap-insights li:nth-child(2) .letter { rotate: .5deg; }
.letter--love { background: #FCC8F1; }
.letter--break-up { background: #B4BED2; }
.panel .letter p { margin: 0; max-width: none; color: inherit; }
.panel .letter p + p { margin-top: 4px; }
.letter-to { font-size: 13px; opacity: .7; }
.letter footer { margin-top: 10px; font: 500 12px/1 var(--text); opacity: .65; }
.gaps { margin-top: var(--s8); }
.gap-rows { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.gap-rows li {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 5fr) auto; gap: var(--s4); align-items: baseline;
  padding: 16px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.5;
}
.g-who { color: var(--muted); }
.g-gap { color: var(--body-ink); }
.g-bet { font: 400 18px/1.3 var(--display); color: var(--accent); white-space: nowrap; }
.g-bet::before { content: "→ "; color: var(--muted); }
.panel .gaps-src { margin-top: 12px; font-size: 13px; color: var(--muted); }
.answers {
  display: inline-block; margin: -4px 0 12px; font: 500 13px/1 var(--text); color: var(--accent);
  text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 2px;
}
@media (max-width: 900px) {
  .gap-rows li { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Testing: the valence grid, one dot per reader per task ---------- */
.testing-split { align-items: start; }
.valence { margin: 0; --good: var(--accent); --bad: #D2603F; }
.valence-grid { border-collapse: collapse; }
.valence-grid th { font: 500 13px/1 var(--text); color: var(--muted); text-align: center; padding: 0 0 12px; }
.valence-grid tbody th { text-align: left; padding: 0 20px 0 0; white-space: nowrap; color: var(--body-ink); font-weight: 400; font-size: 14px; }
.valence-grid thead th:first-child { text-align: left; }
.valence-grid td { padding: 6px; }
.vd { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--line); }
.vd--g { --c: var(--good); }
.vd--r { --c: var(--bad); }
.vd--m { --c: linear-gradient(90deg, var(--good) 50%, var(--bad) 50%); }
.valence-grid .vd { position: relative; }
.valence-grid .vd::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--c);
  opacity: 0; scale: .5; transition: opacity 260ms ease, scale 420ms var(--ease-out);
  transition-delay: calc(var(--i) * 34ms);
}
.valence.is-on .valence-grid .vd::after { opacity: 1; scale: 1; }
.valence-key {
  list-style: none; margin: var(--s4) 0 0; padding: var(--s3) 0 0; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 0 44px;
}
.valence-key li { display: grid; grid-template-columns: auto auto; align-items: center; gap: 8px 8px; font-size: 14px; color: var(--body-ink); }
.valence-key b { grid-column: 1 / -1; font: 400 34px/1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.valence-key .vd { grid-row: 2; width: 12px; height: 12px; background: var(--c); }
@media (max-width: 900px) {
  .valence-grid td { padding: 4px; }
  .vd { width: 22px; height: 22px; }
  .valence-grid tbody th { padding-right: 12px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .valence-grid .vd::after { transition: none; }
}

/* ---------- Testing: drag to compare Sham's before and after screens ---------- */
.compare { margin-top: var(--s8); }
.compare-tabs .trio-tab span { max-width: 34ch; }
.cmp-phone { touch-action: pan-y; }
.cmp-pair { position: absolute; inset: 0; opacity: 0; transition: opacity 300ms ease; }
.cmp-pair.is-current { opacity: 1; }
.cmp-pair img { position: absolute; left: 0; width: 100%; height: auto; display: block; }
.cmp-before { top: calc(var(--shift) / 812 * -100%); }
.cmp-after { position: absolute; inset: 0; overflow: hidden; background: #FCF9F1; clip-path: inset(0 0 0 var(--cut)); }
.cmp-after img { top: 0; }
.cmp-handle {
  position: absolute; top: 0; bottom: 0; left: var(--cut); width: 2px; margin-left: -1px; background: #fff;
  box-shadow: 0 0 0 1px rgba(18, 19, 19, .12); pointer-events: none; z-index: 2;
}
.cmp-handle span {
  position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; translate: -50% -50%; border-radius: 50%;
  background: #fff; box-shadow: 0 6px 18px rgba(18, 19, 19, .22);
  transition: scale 160ms var(--ease-out);
}
.cmp-handle span::before, .cmp-handle span::after {
  content: ""; position: absolute; top: 50%; width: 7px; height: 7px; border: solid var(--ink); border-width: 0 0 1.6px 1.6px;
}
.cmp-handle span::before { left: 10px; translate: 0 -50%; rotate: 45deg; }
.cmp-handle span::after { right: 10px; translate: 0 -50%; rotate: -135deg; }
.cmp-phone:active .cmp-handle span { scale: .94; }
.cmp-range {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; z-index: 3;
  -webkit-appearance: none; appearance: none; touch-action: pan-y;
}
.cmp-range:focus-visible + * , .cmp-phone:has(.cmp-range:focus-visible) .cmp-handle span { outline: 2px solid var(--accent); outline-offset: 2px; }
.cmp-chip {
  position: absolute; bottom: calc(var(--pt) * 44); z-index: 2; padding: 5px 10px; border-radius: 99px;
  font: 500 12px/1 var(--text); background: rgba(18, 19, 19, .72); color: #fff; backdrop-filter: blur(6px); pointer-events: none;
}
.cmp-chip--before { left: 12px; }
.cmp-chip--after { right: 12px; background: var(--accent); }

/* ---------- Reflection: what I'd measure, and a streak that forgives a missed day ---------- */
.measures { list-style: none; margin: var(--s6) 0 var(--s8); padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.measures li { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: var(--s3); }
.measures span { font: 500 13px/1 var(--text); color: var(--accent); }
.measures h3 { font: 400 22px/1.2 var(--display); letter-spacing: -.01em; margin: var(--s3) 0 6px; }
.panel .measures p { font-size: 15px; line-height: 1.5; color: var(--muted); margin: 0; }
.reflect-split { align-items: center; }
.reflect-sub { font: 400 clamp(22px, 2vw, 28px)/1.2 var(--display); letter-spacing: -.01em; margin: 0 0 var(--s2); }

/* Sham's garden colours (J06): bed #1A3325, stem #B8D4A6, leaf #8FB77E */
.streak {
  --bed: #1A3325; --stem: #B8D4A6; --leaf: #8FB77E;
  margin: 0; width: min(100%, 380px); justify-self: center; background: var(--bed); color: var(--stem);
  border-radius: 28px; padding: 22px 22px 20px; box-shadow: 0 24px 60px rgba(18, 19, 19, .16);
}
.streak-top { display: flex; justify-content: space-between; align-items: center; font: 500 14px/1 var(--text); color: #fff; }
.streak-chip {
  font-size: 12px; padding: 6px 10px; border-radius: 99px; background: rgba(184, 212, 166, .16); color: var(--stem);
  opacity: 0; translate: 0 4px; transition: opacity 300ms ease, translate 400ms var(--ease-out);
}
.streak-plant { display: block; width: 48%; margin: 4px auto 0; overflow: visible; }
.streak-plant .soil { stroke: rgba(184, 212, 166, .28); stroke-width: .6; }
.streak-plant .sp { transform-box: fill-box; }
.streak-plant .stem { fill: none; stroke: var(--stem); stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; transition: stroke-dashoffset 700ms var(--ease-out), opacity 120ms ease; }
.streak-plant .lf { fill: var(--leaf); scale: 0; transition: scale 600ms cubic-bezier(.34, 1.4, .64, 1); }
.streak-plant .lf1 { transform-origin: 100% 70%; }
.streak-plant .lf2, .streak-plant .lf3 { transform-origin: 0% 70%; }
.streak-plant .ghost { fill: none; stroke: var(--stem); stroke-width: .7; stroke-dasharray: 1.4 1.2; opacity: 0; transition: opacity 400ms ease; }
.streak-plant .bud { fill: var(--bed); stroke: var(--stem); stroke-width: 1.4; transform-origin: 50% 100%; scale: 0; transition: scale 600ms cubic-bezier(.34, 1.4, .64, 1); }
.streak-week { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font: 500 12px/1 var(--text); color: rgba(184, 212, 166, .7); }
.streak-week li { display: grid; justify-items: center; gap: 8px; }
.streak-week .sd { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid rgba(184, 212, 166, .3); transition: background 300ms ease, border-color 300ms ease, scale 300ms var(--ease-out); }
.streak-week .rest .sd { border-style: dashed; }
.streak-note { margin: 16px 0 0; text-align: center; font-size: 14px; color: var(--stem); opacity: 0; transition: opacity 400ms ease; }
.panel .streak-note { color: var(--stem); max-width: none; }

.streak .stem.is-on { stroke-dashoffset: 0; opacity: 1; }
.streak .lf.is-on, .streak .bud.is-on { scale: 1; }
.streak .ghost.is-on { opacity: .9; }
.streak .lf3.is-on ~ .ghost, .streak .ghost.is-on.is-filled { opacity: 0; }
.streak-week li.is-on:not(.rest) .sd { background: var(--leaf); border-color: var(--leaf); }
.streak-week li.is-on.rest .sd { border-color: var(--stem); }
.streak-week li.is-on { color: var(--stem); }
.streak-note.is-on, .streak-chip.is-on { opacity: 1; translate: 0 0; }
@media (max-width: 900px) {
  .measures { grid-template-columns: 1fr; margin-bottom: var(--s6); }
  .reflect-split { gap: var(--s6); }
}
@media (prefers-reduced-motion: reduce) {
  .streak * { transition: none !important; }
}

/* ---------- Phones: phone sticks to the top, steps scroll under it ---------- */
@media (max-width: 900px) {
  .launch { grid-template-columns: 1fr; gap: var(--s6); align-content: center; }
  /* phones: the chapter list and tabs sit right under the phone, where the eye is */
  .launch .launch-copy { display: contents; }
  .launch .launch-copy > * { order: 0; }
  .launch .launch-stage { order: 1; margin-top: calc(var(--s4) - var(--s6)); }
  .launch .hub-steps, .launch .hub-replay { order: 2; margin: calc(var(--s3) - var(--s6)) 0 0; justify-self: center; text-align: center; }
  .launch .hub-steps:not(.trio-tabs) li { display: none; padding-left: 0; }
  .launch .hub-steps:not(.trio-tabs) li.is-current { display: block; }
  .launch .hub-steps:not(.trio-tabs) li::before { display: none; }
  .launch .trio-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
  .launch .trio-tabs li::before { display: none; }
  .launch .trio-tab { padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; font-size: 14px; }
  .launch .trio-tabs li.is-current .trio-tab { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  .launch .trio-tab span { display: none; }
  .launch-stage { --ph-w: min(220px, 56vw); }
}

@media (max-width: 900px) {
  .leafout { display: none; }
  .seedchip span { font-size: max(12px, calc(var(--pt) * 16)); padding: .45em .9em; }
  .react-out { font-size: max(12px, calc(var(--pt) * 17)); }
}

@media (prefers-reduced-motion: reduce) {
  .tdot { display: none; }
  .wt-scene [data-type].is-typing::after { animation: none; }
}
