/* The "how it works" page of a plant care app, with the line that lights the phone. Colours in :root (the Playground
   palette): one green for the line, the lit step and the app, the rest warm neutrals on a light page.
   GSAP moves .phone-wrap, the CSS styles .phone inside it; GSAP moves the panes and their parts, the CSS styles the
   children. The script draws the line (.wire) in pixels and redraws it on every resize. */
:root {
  --page: #f4f2ec;          /* the page */
  --ink: #17201b;           /* the words */
  --muted: #8a8f88;         /* the small words and the steps still off */
  --line: #dcd9d0;          /* the rail before the line runs */
  --green: #1d8a5a;         /* the accent: the line, the lit step, the app */
  --metal: #c9ccc8;         /* the phone frame */
  --cam: #101713;           /* the viewfinder */
  --app: #fbfaf6;           /* the app screens */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--page); }
html, body { overflow-x: clip; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.how { position: relative; height: 400vh; }
.stage {
  --ph: min(78vh, 640px, 92vw);           /* the phone's height */
  --pw: calc(var(--ph) * 0.49);           /* and its width */
  --gap: clamp(26px, 7vw, 120px);         /* the room for the rail between the steps and the phone */
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 0 clamp(10px, 3vw, 48px);
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(90% 70% at 62% 50%, #fbfaf6, var(--page) 70%);
}
@supports (height: 100lvh) {
  .stage { height: 100lvh; }
}
.light {
  position: absolute;
  z-index: -1;
  right: calc(50% - var(--pw) * 1.3);
  top: 50%;
  width: calc(var(--ph) * 0.9);
  height: calc(var(--ph) * 0.9);
  margin-top: calc(var(--ph) * -0.45);
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--green) 20%, transparent), color-mix(in srgb, var(--green) 5%, transparent) 62%, transparent);
  filter: blur(40px);
  pointer-events: none;
}
.grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.35;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.layout {
  display: flex;
  align-items: center;
  gap: var(--gap);
  max-width: 100%;
}

/* ---------------------------------------------------------------- the steps */
.side { width: min(330px, calc(100vw - var(--pw) - var(--gap) - 24px)); flex: none; }
.kicker {
  font-size: clamp(9px, min(1.1vw, 1.7vh), 12px);
  font-weight: 560;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: clamp(10px, 3.4vh, 30px);
}
.steps { list-style: none; display: grid; gap: clamp(10px, 4.6vh, 44px); }
.step { position: relative; }
.step__btn { display: grid; gap: clamp(3px, 0.9vh, 8px); width: 100%; padding: 2px 0; }
.step__btn:focus-visible { outline: 2px solid var(--green); outline-offset: 6px; border-radius: 6px; }
.step__title {
  font-size: clamp(12px, min(2.2vw, 3.2vh), 26px);
  line-height: 1.12;
  font-weight: 540;
  font-variation-settings: 'wdth' 100;
  letter-spacing: -0.015em;
  color: var(--muted);
  transition: color 0.5s ease, font-variation-settings 0.6s cubic-bezier(0.2, 0.9, 0.2, 1.2);
}
.step__text {
  font-size: clamp(9.5px, min(1.2vw, 1.9vh), 15px);
  line-height: 1.42;
  color: var(--muted);
  opacity: 0.7;
  transition: opacity 0.5s ease, color 0.5s ease;
}
.step.on .step__title { color: var(--ink); font-variation-settings: 'wdth' 112; }
.step.on .step__text { color: #4c524d; opacity: 1; }
.step.done .step__title { color: #5d635e; }
@media (hover: hover) {
  .step__btn:hover .step__title { color: var(--ink); }
}
/* the node on the rail, at the step's right in the middle of the gap */
.step__node {
  position: absolute;
  top: calc(clamp(12px, min(2.2vw, 3.2vh), 26px) * 0.56 + 2px);
  right: calc(var(--gap) / -2);
  width: 9px;
  height: 9px;
  margin: -4.5px -4.5px 0 0;
  border-radius: 50%;
  background: var(--page);
  box-shadow: inset 0 0 0 1.2px var(--line);
}
.step__node::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--green);
  transform: scale(var(--fill, 0));
}

/* ---------------------------------------------------------------- the line */
.wire { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.wire path { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.wire__rail { stroke: var(--line); stroke-width: 1.2; }
.wire__run { stroke: var(--green); stroke-width: 1.4; }
.wire__branch { stroke: var(--green); stroke-width: 1.2; }

/* ---------------------------------------------------------------- the phone */
.phone-wrap { flex: none; position: relative; z-index: 1; }
.phone {
  position: relative;
  width: var(--pw);
  height: var(--ph);
  border-radius: calc(var(--ph) * 0.078);
  padding: calc(var(--ph) * 0.011);
  background: linear-gradient(135deg, #eef0ed, var(--metal) 26%, #a9ada9 52%, #e2e4e1 74%, #b5b9b5);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.7),
    inset 0 0 0 calc(var(--ph) * 0.004) rgba(0, 0, 0, 0.12),
    0 1px 1px rgba(23, 32, 27, 0.06),
    0 calc(var(--ph) * 0.02) calc(var(--ph) * 0.04) rgba(23, 32, 27, 0.08),
    0 calc(var(--ph) * 0.07) calc(var(--ph) * 0.12) rgba(23, 32, 27, 0.12);
}
.phone__key { position: absolute; width: 2px; border-radius: 2px; background: linear-gradient(90deg, #9ea29e, #d6d9d6); }
.phone__key--a { left: -2px; top: 19%; height: 4%; }
.phone__key--b { left: -2px; top: 27%; height: 8%; }
.phone__key--c { right: -2px; top: 25%; height: 11%; background: linear-gradient(270deg, #9ea29e, #d6d9d6); }
/* where the line touches the frame, a glint runs along the metal */
.phone__glint {
  position: absolute;
  left: -1px;
  top: 0;
  width: 3px;
  height: calc(var(--ph) * 0.16);
  margin-top: calc(var(--ph) * -0.08);
  border-radius: 3px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.95), color-mix(in srgb, var(--green) 60%, #fff), rgba(255, 255, 255, 0.95), transparent);
  opacity: 0;
  filter: blur(0.4px);
}
.screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: calc(var(--ph) * 0.068);
  overflow: hidden;
  background: var(--app);
  container-type: size;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.glass {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background: linear-gradient(118deg, transparent 38%, rgba(255, 255, 255, 0.09) 46%, rgba(255, 255, 255, 0.03) 52%, transparent 60%);
  background-size: 220% 100%;
  background-position: var(--sheen, 60%) 0;
  mix-blend-mode: screen;
}
.status {
  position: absolute;
  z-index: 6;
  top: 2.6cqh;
  left: 9cqw;
  right: 8cqw;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 4.3cqw;
  font-weight: 600;
  color: var(--status, #fff);
  transition: color 0.5s ease;
}
.status__icons { display: flex; gap: 1.6cqw; align-items: flex-end; }
.status__icons i { display: block; width: 1.3cqw; border-radius: 0.4cqw; background: currentColor; }
.status__icons i:nth-child(1) { height: 1.6cqw; }
.status__icons i:nth-child(2) { height: 2.4cqw; }
.status__icons i:nth-child(3) { height: 3.2cqw; width: 5.4cqw; border-radius: 0.9cqw; }

/* the island, which opens into the reminder */
.island {
  position: absolute;
  z-index: 8;
  top: 1.9cqh;
  left: 50%;
  width: 30cqw;
  height: 8.4cqw;
  margin-left: -15cqw;
  border-radius: 6cqw;
  background: #050605;
  overflow: hidden;
}
.note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 3cqw;
  padding: 0 4cqw;
  opacity: 0;
  white-space: nowrap;
}
.note__mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 9cqw;
  height: 9cqw;
  border-radius: 2.6cqw;
  background: var(--green);
}
.note__mark svg { width: 62%; fill: none; stroke: #fff; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.note__text { display: grid; color: #fff; font-size: 4cqw; line-height: 1.2; }
.note__text small { color: #9aa39d; font-size: 3.4cqw; }

.pane { position: absolute; inset: 0; }

/* screen one: the viewfinder */
.pane--cam {
  z-index: 3;
  background: radial-gradient(80% 60% at 50% 42%, #1d2a22, var(--cam) 75%);
  clip-path: circle(150% at 50% 36%);
}
.cam__view { position: absolute; left: 14cqw; right: 14cqw; top: 22cqh; height: 44cqh; }
.leaf { position: absolute; inset: 10% 6%; width: 88%; height: 80%; overflow: visible; }
.leaf path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.leaf__shape { stroke: #cfe7d8; stroke-width: 1.6; fill: color-mix(in srgb, var(--green) 22%, transparent); fill-opacity: var(--leaf-fill, 0); }
.leaf__vein { stroke: #9fc9b0; stroke-width: 1; }
.corner { position: absolute; width: 11cqw; height: 11cqw; border: 0 solid #fff; }
.corner--tl { left: 0; top: 0; border-top-width: 2px; border-left-width: 2px; border-top-left-radius: 4cqw; }
.corner--tr { right: 0; top: 0; border-top-width: 2px; border-right-width: 2px; border-top-right-radius: 4cqw; }
.corner--bl { left: 0; bottom: 0; border-bottom-width: 2px; border-left-width: 2px; border-bottom-left-radius: 4cqw; }
.corner--br { right: 0; bottom: 0; border-bottom-width: 2px; border-right-width: 2px; border-bottom-right-radius: 4cqw; }
.beam {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 0;
  height: 18%;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--green) 30%, transparent) 80%, color-mix(in srgb, #8ff0bd 90%, transparent) 99%, transparent);
  border-radius: 2px;
  opacity: 0.8;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}
.cam__tag {
  position: absolute;
  left: 50%;
  top: 71cqh;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 0.6cqh;
  padding: 2.6cqw 5cqw;
  border-radius: 6cqw;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 4.4cqw;
  font-weight: 560;
  white-space: nowrap;
}
.cam__tag small { font-size: 3.4cqw; color: #8ff0bd; font-weight: 500; }
.shutter {
  position: absolute;
  left: 50%;
  bottom: 5cqh;
  width: 16cqw;
  height: 16cqw;
  margin-left: -8cqw;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: grid;
  place-items: center;
}
.shutter i { width: 76%; height: 76%; border-radius: 50%; background: #fff; }

/* screen two: the check-up */
.pane--check { z-index: 1; padding: 15cqh 8cqw 0; background: var(--app); transform-origin: 50% 0; }
.app-title { font-size: 8cqw; font-weight: 620; letter-spacing: -0.02em; }
.app-sub { font-size: 3.9cqw; color: var(--muted); margin-top: 0.6cqh; }
.ring { position: relative; width: 52cqw; height: 52cqw; margin: 5cqh auto 4cqh; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; stroke-linecap: round; }
.ring__track { stroke: #ebe9e2; }
.ring__fill { stroke: var(--green); stroke-dasharray: 1; stroke-dashoffset: 1; }
.ring__num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring__num b { font-size: 14cqw; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.ring__num small { font-size: 3.6cqw; color: var(--green); font-weight: 560; margin-top: 0.6cqh; }
.meters { list-style: none; display: grid; gap: 2.6cqh; }
.meter { display: grid; grid-template-columns: 22cqw 1fr 12cqw; align-items: center; gap: 3cqw; font-size: 3.8cqw; }
.meter small { color: var(--muted); font-size: 3.4cqw; text-align: right; }
.meter i { position: relative; height: 1.6cqw; border-radius: 1cqw; background: #ebe9e2; overflow: hidden; }
.meter em { position: absolute; inset: 0; width: calc(var(--v) * 100%); border-radius: inherit; background: var(--green); transform-origin: 0 50%; }

/* screen three: the plan, a sheet over the check-up */
.pane--plan { z-index: 4; background: rgba(16, 23, 19, 0.28); opacity: 0; pointer-events: none; }
.sheet {
  position: absolute;
  left: 2.4cqw;
  right: 2.4cqw;
  bottom: 2.4cqw;
  padding: 3cqh 7cqw 6cqw;
  border-radius: 9cqw;
  background: #fff;
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.04), 0 -10px 30px rgba(16, 23, 19, 0.14);
}
.sheet__grip { display: block; width: 11cqw; height: 1.2cqw; margin: 0 auto 2.6cqh; border-radius: 1cqw; background: #dedbd2; }
.sheet__title { font-size: 6.4cqw; font-weight: 620; letter-spacing: -0.02em; }
.sheet__sub { font-size: 3.8cqw; color: var(--muted); margin-top: 0.4cqh; }
.week { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 1.6cqw; margin: 3.4cqh 0 3cqh; }
.week li {
  display: grid;
  place-items: center;
  height: 11cqw;
  border-radius: 3.4cqw;
  background: #f2f0ea;
  font-size: 3.7cqw;
  font-weight: 560;
  color: #5d635e;
}
.week li.lit { background: var(--green); color: #fff; }
.row { display: flex; justify-content: space-between; align-items: center; font-size: 4.2cqw; font-weight: 520; padding: 2.2cqh 0; border-top: 1px solid #efede7; }
.toggle { position: relative; width: 13cqw; height: 7.6cqw; border-radius: 4cqw; background: #e3e1da; transition: background 0.35s ease; }
.toggle i { position: absolute; left: 0.8cqw; top: 0.8cqw; width: 6cqw; height: 6cqw; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.toggle.lit { background: var(--green); }
.cta {
  display: grid;
  place-items: center;
  height: 12cqw;
  margin-top: 1.6cqh;
  border-radius: 6cqw;
  background: var(--ink);
  color: #fff;
  font-size: 4.2cqw;
  font-weight: 560;
}

@media (max-width: 420px) {
  .step__text { line-height: 1.32; }
}
@media (prefers-reduced-motion: reduce) {
  .how { height: 100vh; }
}
