/* "This page builds itself": the home hero goes sketch → wireframe → design system → code → motion → live
   as you scroll (desktop: the wheel walks the steps before moving on; phone: the hero is pinned while you scroll).
   Stage classes s0…s5 sit on <html class="story">. The real text is always in the page; only its look changes.
   The hand-drawn wobble (filter:url(#skw)) is applied from an inline <style> in index.html, because an
   SVG filter id can't be referenced from an external stylesheet. */

:root{--pencil:#6f6f74;--pencil-soft:#a3a3a8;--wire:#e3e3e0;--wire-2:#d6d6d2}
html.dark{--pencil:#b9b9c0;--pencil-soft:#7c7c84;--wire:#26262a;--wire-2:#303035}

/* smooth hand-over between looks */
.story .title .sweep,.story .hero .role,.story .hero .role span,.story .mo-say,.story .mo-ghost,.story .mo-tag,.story .mo-tag span,.story .mo-tag svg,
.story .hero .cta,.story .mo-dev,.story .mo-phone,.story .mo-tab,.story .mo-win,.story .mo-lab{
  transition:color .7s ease,background-color .7s ease,border-color .7s ease,box-shadow .7s ease,opacity .6s ease,-webkit-text-stroke-color .7s ease,filter .5s ease}

/* paper with a dot grid (sketch + wireframe), and column guides in the wireframe */
.story-paper{position:fixed;inset:0;z-index:-1;pointer-events:none;opacity:0;transition:opacity .8s ease;
  background-image:radial-gradient(circle,color-mix(in srgb,var(--ink) 16%,transparent) 1px,transparent 1.4px);background-size:22px 22px}
.story-cols{position:fixed;inset:0;z-index:-1;pointer-events:none;opacity:0;transition:opacity .8s ease;margin:0 var(--pad);
  background:repeating-linear-gradient(90deg,color-mix(in srgb,var(--fill-a) 4%,transparent) 0 calc((100% - 11*20px)/12),transparent calc((100% - 11*20px)/12) calc((100% - 11*20px)/12 + 20px));
  border-left:1px dashed color-mix(in srgb,var(--fill-a) 25%,transparent);border-right:1px dashed color-mix(in srgb,var(--fill-a) 25%,transparent)}
.story.s0 .story-paper,.story.s1 .story-paper{opacity:1}
.story.s1 .story-cols{opacity:1}
.story:is(.s0,.s1,.s2,.s3) .mo-glow{opacity:0!important}
.story .mo-glow{transition:opacity 1.4s ease}

/* ---------- 0. sketch ---------- */
.story.s0 .title .sweep{background:none!important;-webkit-text-fill-color:transparent!important;color:transparent!important;-webkit-text-stroke:1.4px var(--pencil);animation:none!important}
.story.s0 .hero .role,.story.s0 .hero .role span{color:var(--pencil)!important;-webkit-text-fill-color:var(--pencil)!important;background:none!important}
.story.s0 .mo-say{color:var(--pencil)}
.story:is(.s0,.s1,.s2,.s3) .mo-say .mo-typed{opacity:0}
.story:is(.s0,.s1,.s2,.s3) .mo-say .mo-ghost{visibility:visible}
.story.s0 .mo-tag{background:transparent!important;border:1.4px dashed var(--pencil-soft)!important;color:var(--pencil)!important;box-shadow:none!important}
.story.s0 .mo-tag svg{color:var(--pencil-soft)!important;fill:none!important;stroke:currentColor!important}
.story.s0 .mo-tag .mo-num{background:none;color:var(--pencil);-webkit-text-fill-color:var(--pencil)}
.story.s0 .mo-tag .tip{color:var(--pencil);-webkit-text-fill-color:var(--pencil)}
.story.s0 .hero .cta{background:transparent!important;color:var(--pencil)!important;-webkit-text-fill-color:var(--pencil)!important;border:1.6px solid var(--pencil)!important;box-shadow:none!important}
.story.s0 .hero .cta svg{stroke:var(--pencil)!important}
.story.s0 .mo-phone,.story.s0 .mo-tab{background:transparent!important;border:1.8px solid var(--pencil);box-shadow:none!important}
.story.s0 .mo-phone .mo-isl,.story.s0 .mo-tab .mo-tcam{background:var(--pencil-soft)}
.story.s0 .mo-win{background:transparent!important;border:1.6px solid var(--pencil)!important;box-shadow:none!important}
.story.s0 .mo-bar{background:transparent!important;border-bottom:1.4px dashed var(--pencil-soft)!important}
.story.s0 .mo-bar i{background:transparent!important;border:1.2px solid var(--pencil-soft)}
.story.s0 .mo-addr{background:transparent!important;border:1.2px dashed var(--pencil-soft)!important;color:transparent!important}
.story.s0 .mo-addr b{display:none}
.story.s0 .mo-scr,.story.s0 .mo-body{background:transparent!important}
.story.s0 .mo-sb{opacity:0}
.story.s0 .mo-dev::after{content:"";position:absolute;inset:16% 14%;background:
  linear-gradient(var(--pencil-soft),var(--pencil-soft)) 0 0/60% 1.4px no-repeat,
  linear-gradient(var(--pencil-soft),var(--pencil-soft)) 0 14%/42% 1.4px no-repeat,
  linear-gradient(var(--pencil-soft),var(--pencil-soft)) 0 28%/50% 1.4px no-repeat,
  linear-gradient(to top right,transparent calc(50% - .8px),var(--pencil-soft) 50%,transparent calc(50% + .8px)) 100% 100%/48% 58% no-repeat,
  linear-gradient(to top left,transparent calc(50% - .8px),var(--pencil-soft) 50%,transparent calc(50% + .8px)) 100% 100%/48% 58% no-repeat;
  outline:1.2px dashed var(--pencil-soft);outline-offset:-1px;opacity:.9}
.story.s0 .mo-phone::after{inset:12% 12% 20%}
.story.s0 .mo-lab,.story.s1 .mo-lab{opacity:.0!important}

/* notes in the margin (sketch only) */
.story-notes{position:absolute;inset:0;pointer-events:none;z-index:6}
.story-notes svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.story-notes path{fill:none;stroke:var(--fill-b,#8a3cff);stroke-width:1.6;stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:1}
.story-note{position:absolute;font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:12.5px;line-height:1.3;color:var(--fill-b,#8a3cff);white-space:nowrap;
  transform:rotate(var(--rot,-2deg)) translateY(6px);opacity:0}
.story.s0 .story-note{opacity:1;transform:rotate(var(--rot,-2deg));transition:opacity .5s ease calc(.3s + var(--n)*.18s),transform .6s cubic-bezier(.3,1.5,.5,1) calc(.3s + var(--n)*.18s)}
.story.s0 .story-notes path{stroke-dashoffset:0;transition:stroke-dashoffset .7s ease calc(.45s + var(--n)*.18s)}
.story:not(.s0) .story-note,.story:not(.s0) .story-notes path{transition:opacity .25s ease,stroke-dashoffset .25s ease}

/* ---------- 1. wireframe: grey blocks, content first ---------- */
.story.s1 .title .sweep{background:none!important;-webkit-text-fill-color:var(--wire-2)!important;color:var(--wire-2)!important;-webkit-text-stroke:0;animation:none!important}
.story.s1 .hero .role span,.story.s1 .mo-say .mo-ghost{color:transparent!important;-webkit-text-fill-color:transparent!important;background:var(--wire)!important;border-radius:4px;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.story.s1 .mo-tag{background:var(--wire)!important;border-color:transparent!important;color:transparent!important;box-shadow:none!important}
.story.s1 .mo-tag *{color:transparent!important;-webkit-text-fill-color:transparent!important;background:none!important}
.story.s1 .mo-tag svg{opacity:0}
.story.s1 .hero .cta{background:var(--wire-2)!important;color:transparent!important;-webkit-text-fill-color:transparent!important;box-shadow:none!important}
.story.s1 .hero .cta svg{opacity:0}

/* ---------- 2–3. design system and code: the real look, no glow yet ---------- */
.story.s3 .sc-hl{outline:2px solid var(--fill-b,#8a3cff);outline-offset:6px;border-radius:10px;transition:outline-color .3s}
.story .title .sc-hl,.story .title.sc-hl{outline-offset:2px}

/* ---------- the story card ---------- */
.story-card{
  position:absolute;z-index:7;pointer-events:auto;
  border-radius:18px;padding:16px 18px 14px;
  background:color-mix(in srgb,var(--bg) 94%,transparent);
  border:1px solid color-mix(in srgb,var(--ink) 10%,transparent);box-shadow:0 24px 50px -28px rgba(40,30,120,.45);
  font-family:Inter,system-ui,sans-serif;color:var(--ink);
  transition:opacity .5s ease,transform .6s cubic-bezier(.2,.8,.2,1);
}
.story-card.out{opacity:0;transform:translateY(-10px);pointer-events:none}
/* Replay button: play icon; on the open card it reads "Replay", folded it's a small outlined pill */
.sc-replay{display:inline-flex;align-items:center;gap:6px}
.sc-replay svg{width:10px;height:10px;fill:currentColor;flex:none}
.sc-replay .sc-r-mini{display:none}
.story-card.mini{background:transparent;border-color:transparent;box-shadow:none;padding:0;pointer-events:none}
.story-card.mini>:not(.sc-foot){display:none}
.story-card.mini .sc-foot{margin-top:0;justify-content:flex-end}
.story-card.mini .sc-replay{pointer-events:auto;text-decoration:none;text-transform:none;letter-spacing:0;font-family:Inter,system-ui,sans-serif;font-size:13px;font-weight:500;
  padding:8px 14px 8px 11px;border:1px solid color-mix(in srgb,var(--ink) 18%,transparent);border-radius:99px;background:color-mix(in srgb,var(--bg) 92%,transparent);
  animation:sc-mini-in .45s cubic-bezier(.2,.8,.2,1) both;transition:border-color .2s,background-color .2s}
.story-card.mini .sc-replay:hover,.story-card.mini .sc-replay:focus-visible{border-color:var(--fill-b,#8a3cff)}
.story-card.mini .sc-replay svg{width:11px;height:11px;fill:var(--fill-b,#8a3cff)}
.story-card.mini .sc-r-full{display:none}.story-card.mini .sc-r-mini{display:inline}
.story-piling .story-notes,.story-piling .story-notes *{opacity:0!important;transition:none!important}
@media (max-width:1023px){ .story-card.idle{position:static;order:3;align-self:flex-start;margin-top:18px;left:auto;right:auto;bottom:auto} }
@keyframes sc-mini-in{from{opacity:0;transform:translateY(-6px) scale(.96)}to{opacity:1;transform:none}}
.sc-top{display:flex;align-items:center;gap:12px;font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-soft)}
.sc-bar{display:flex;gap:4px;flex:1}
.sc-bar i{flex:1;height:3px;border-radius:2px;background:color-mix(in srgb,var(--ink) 12%,transparent);position:relative;overflow:hidden}
.sc-bar i::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,var(--fill-a,#2f5bff),var(--fill-b,#8a3cff),var(--fill-c,#ff3dae));transform:scaleX(0);transform-origin:left;transition:transform .6s ease}
.sc-bar i.on::after{transform:none}
.sc-t{margin:10px 0 4px;font-size:clamp(18px,1.6vw,24px);font-weight:600;letter-spacing:-.02em;line-height:1.15}
.sc-s{font-size:13.5px;line-height:1.5;color:var(--ink-soft);max-width:44ch}
.sc-body{margin-top:12px}
.sc-body:empty{display:none}
.sc-foot{display:flex;align-items:center;gap:12px;margin-top:14px;font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink-soft)}
.sc-foot .sc-hint{display:inline-flex;align-items:center;gap:6px}
.sc-foot .sc-hint i{display:inline-block;width:10px;height:14px;border:1.4px solid currentColor;border-radius:6px;position:relative}
.sc-foot .sc-hint i::after{content:"";position:absolute;left:50%;top:2px;width:2px;height:3px;margin-left:-1px;border-radius:1px;background:currentColor;animation:sc-wheel 1.4s ease-in-out infinite}
@keyframes sc-wheel{0%{transform:translateY(0);opacity:1}70%{transform:translateY(5px);opacity:0}100%{opacity:0}}
.sc-foot button,.sc-foot a{margin-left:auto;background:none;border:0;cursor:pointer;font:inherit;letter-spacing:inherit;text-transform:inherit;color:var(--ink);text-decoration:underline;text-underline-offset:3px;padding:6px 0}
.sc-foot .sc-go{margin-left:0;text-decoration:none;text-transform:none;letter-spacing:0;font-family:Inter,system-ui,sans-serif;font-size:14px;font-weight:600;color:#fff;
  padding:9px 16px;border-radius:99px;background:linear-gradient(100deg,var(--fill-a,#2f5bff),var(--fill-b,#8a3cff),var(--fill-c,#ff3dae));box-shadow:0 10px 22px -12px rgba(90,60,255,.7)}

/* design system tokens */
.sc-tokens{display:grid;gap:10px}
.sc-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.sc-lab{width:62px;flex:none;font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--ink-soft)}
.sc-sw{display:flex;flex-direction:column;align-items:center;gap:3px;font-family:"IBM Plex Mono",monospace;font-size:9.5px;color:var(--ink-soft)}
.sc-sw i{width:28px;height:28px;border-radius:50%;border:1px solid color-mix(in srgb,var(--ink) 12%,transparent);box-shadow:0 6px 14px -8px rgba(0,0,0,.4)}
.sc-type b{font-size:24px;font-weight:800;letter-spacing:-.04em;line-height:1}
.sc-type span{font-family:"IBM Plex Mono",monospace;font-size:18px;line-height:1}
.sc-type em{font-style:normal;font-family:"IBM Plex Mono",monospace;font-size:10px;color:var(--ink-soft)}
.sc-btn{font-size:12px;font-weight:600;color:#fff;padding:6px 12px;border-radius:99px;background:linear-gradient(100deg,var(--fill-a,#2f5bff),var(--fill-b,#8a3cff),var(--fill-c,#ff3dae))}
.sc-pill{font-size:12px;padding:5px 10px;border-radius:99px;border:1px solid color-mix(in srgb,var(--ink) 14%,transparent)}
.sc-space{display:flex;align-items:flex-end;gap:5px}
.sc-space i{display:block;width:8px;border-radius:2px;background:linear-gradient(var(--fill-c,#ff3dae),var(--fill-b,#8a3cff),var(--fill-a,#2f5bff))}
.sc-tokens > *{opacity:0;transform:translateY(10px) scale(.96)}
.sc-tokens.in > *{opacity:1;transform:none;transition:opacity .45s ease calc(var(--n)*.14s),transform .55s cubic-bezier(.3,1.5,.5,1) calc(var(--n)*.14s)}

/* code */
.sc-code{margin:0;padding:12px 14px;border-radius:12px;background:#121218;color:#e8e8f0;font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:12px;line-height:1.55;white-space:pre;overflow:hidden;min-height:9.6em}
.sc-code .c-s{color:#9fb4ff}.sc-code .c-p{color:#d6b4ff}.sc-code .c-v{color:#ffd7a8}.sc-code .c-c{color:#7d7d8c}
.sc-code .mo-key{height:1.05em;vertical-align:-.15em}

/* ---------- placement ---------- */
@media (min-width:1024px){
  .story-card{width:var(--sc-w,420px);left:var(--sc-x,auto);top:var(--sc-y,90px)}
  body.away .story-card,body.away .story-notes{opacity:0!important;pointer-events:none!important}
}
@media (max-width:1023px){
  /* the hero is pinned while the page builds itself */
  /* body must not be its own scroll box, or sticky has nothing to stick to (clip still stops sideways scroll) */
  html.story body{overflow-x:clip!important;overflow-y:visible!important}
  .story-wrap{position:relative}
  .story-pin{position:sticky;top:var(--hdr,54px);height:calc(100svh - var(--hdr,54px));overflow:hidden}
  .story-fit{transform-origin:50% 0;will-change:transform}
  .story-card{left:12px;right:12px;bottom:12px;padding:12px 14px 10px}
  /* step arrows (phones) */
  .sc-foot .sc-arr{margin:0;flex:none;width:36px;height:36px;padding:0;border-radius:50%;display:grid;place-items:center;text-decoration:none;
    border:1px solid color-mix(in srgb,var(--ink) 16%,transparent);color:var(--ink);background:transparent;transition:opacity .2s,transform .2s}
  .sc-foot .sc-arr svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .sc-foot .sc-next{border:0;color:#fff;background:linear-gradient(100deg,var(--fill-a,#2f5bff),var(--fill-b,#8a3cff),var(--fill-c,#ff3dae));box-shadow:0 8px 18px -10px rgba(90,60,255,.7);animation:sc-nudge 2.4s ease-in-out 1.5s infinite}
  .sc-foot .sc-arr:active{transform:scale(.9)}
  .sc-foot .sc-arr:disabled{opacity:.3}
  .sc-foot .sc-swipe{margin-left:4px}
  @keyframes sc-nudge{0%,70%,100%{transform:none}80%{transform:translateX(4px)}90%{transform:translateX(-1px)}}
  .sc-t{font-size:17px;margin-top:8px}
  .sc-s{font-size:12.5px}
  .sc-code{font-size:10.5px;min-height:8.6em;padding:10px 12px}
  .sc-tokens{gap:7px}
  .sc-sw i{width:22px;height:22px}
  .sc-type b{font-size:19px}.sc-type span{font-size:15px}
  .story-note{font-size:11px}
  .story .hero{padding-bottom:0!important}
}

@media print{
  .story-card,.story-paper,.story-cols,.story-notes{display:none!important}
}
/* the play button waits until the cursor has finished putting the page together, then fades in once */
html.asm .story-card.idle,html.asm-run .story-card.idle{opacity:0;transition:none}
/* "Watch this page build" is desktop-only: no button, card or notes on phones and tablets */
@media (max-width:1023px){ .story-card,.story-notes{display:none!important} }
