/* How it works: one reel, taken apart and put back. Scroll drives --share, --lift,
   --explode, --read, --gather, --back and --seal (0..1) on .hiw-stage; JS only sets them. */
.hiw{--scene-w:760px;--scene-h:620px;--scene-scale:1;padding-block:var(--section-padding,48px)}
.hiw-lede{max-width:560px;color:var(--muted);margin:32px 0 0}
.hiw-track{position:relative;height:620vh}
.hiw-pin{position:sticky;top:var(--pin-top,24px);display:grid;grid-template-columns:minmax(300px,380px) 1fr;gap:clamp(24px,5vw,80px);align-items:center}
.hiw-pin.wrap{width:min(1240px,calc(100% - 96px));margin-inline:auto}

/* Beat list: the whole sequence stays visible; the active beat opens. */
.hiw-beats{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}
.hiw-beat{border-left:2px solid var(--line);padding:10px 0 10px 22px;transition:border-color .3s}
.hiw-beat button{all:unset;display:block;width:100%;cursor:pointer;font-weight:600;font-size:var(--text-lead);letter-spacing:-.03em;line-height:1.2;color:var(--muted);transition:color .3s,font-size .3s}
.hiw-beat button:focus-visible{outline:3px solid var(--blue);outline-offset:6px;border-radius:4px}
.hiw-beat p{display:grid;grid-template-rows:0fr;margin:0;color:var(--muted);transition:grid-template-rows .4s cubic-bezier(.22,1,.36,1),margin .4s,opacity .3s;opacity:0}
.hiw-beat p>span{overflow:hidden;display:block}
.hiw-beat[aria-current="step"]{border-color:var(--blue)}
.hiw-beat[aria-current="step"] button{color:var(--ink);font-size:var(--text-title)}
.hiw-beat[aria-current="step"] p{grid-template-rows:1fr;margin-top:10px;opacity:1}
.hiw-beat small{display:block;color:var(--muted);font-size:var(--text-caption);margin-top:6px}

/* Stage: a fixed 760x620 scene, uniformly scaled to fit. */
.hiw-stage{position:relative;height:min(80svh,var(--scene-h));width:100%;border-radius:28px;background:var(--surface);overflow:hidden}
.hiw-scene{position:absolute;left:50%;top:50%;width:var(--scene-w);height:var(--scene-h);transform:translate(-50%,-50%) scale(var(--scene-scale));transform-origin:center;perspective:1400px}
.hiw-badge{position:absolute;top:24px;left:28px;display:flex;align-items:center;gap:8px;font-size:var(--text-small);font-weight:600;z-index:4}
.hiw-badge svg{width:18px;height:22px;color:var(--blue)}

/* Phone */
.hiw-phone{position:absolute;left:250px;top:30px;width:260px;height:565px;transform-origin:top left;transform:translate(calc(-230px * var(--lift)),calc(60px * var(--lift) - 60px * var(--back))) scale(calc(1 - .2 * var(--lift) + .2 * var(--back)));z-index:1;border:3px solid #363638;border-radius:40px;background:#000;overflow:hidden;box-shadow:0 30px 60px -30px var(--scrim)}
.hiw-phone .hiw-island{position:absolute;top:12px;left:50%;width:76px;height:22px;transform:translateX(-50%);border-radius:999px;background:#000;z-index:5}
.hiw-phone .hiw-home{position:absolute;bottom:7px;left:34%;width:32%;height:4px;border-radius:999px;background:#f5f5f7;z-index:5}
.hiw-reel-screen{position:absolute;inset:0;background:#000;color:#fff;font-size:12px;opacity:calc(1 - clamp(0,var(--lift) * 2,1))}
.hiw-home-screen{position:absolute;inset:0;background:#1c1c1c;opacity:calc(clamp(0,var(--lift) * 2,1) * (1 - var(--back)))}
.hiw-home-screen img{position:absolute;width:105%;max-width:none;left:-2.5%;top:-.5%}
.hiw-reel-screen>img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.hiw-reel-shade{position:absolute;inset:auto 0 0 0;height:55%;background:linear-gradient(transparent,rgba(0,0,0,.85))}
.hiw-reel-status{position:absolute;top:14px;left:0;right:0;display:flex;justify-content:space-between;padding:0 24px;font-weight:600;font-size:12px}
.hiw-reel-meta{position:absolute;left:16px;right:60px;bottom:28px;line-height:1.35;opacity:calc(1 - var(--lift))}
.hiw-reel-meta strong{display:flex;align-items:center;gap:8px;font-weight:600;margin-bottom:6px}
.hiw-reel-meta strong i{width:22px;height:22px;border-radius:50%;background:url('/assets/frame-tomato-pasta.webp') center/cover}
.hiw-reel-icons{position:absolute;right:12px;bottom:40px;display:flex;flex-direction:column;gap:18px;opacity:calc(1 - var(--lift))}
.hiw-reel-icons svg{width:24px;height:24px;fill:none;stroke:#fff;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.hiw-reel-icons .hiw-share-icon{stroke:var(--blue);filter:drop-shadow(0 0 6px color-mix(in srgb,var(--blue) 70%,transparent))}
.hiw-details-screen{position:absolute;inset:0;opacity:clamp(0,(var(--back) - .5) * 2,1)}
.hiw-details-screen img{position:absolute;width:105%;max-width:none;left:-2.5%;top:-.5%}

/* Share sheet rises with --share, then the Saved pill. */
.hiw-sheet{position:absolute;left:0;right:0;bottom:0;background:#1c1c1e;color:#fff;border-radius:18px 18px 0 0;padding:12px 14px 20px;font-size:11px;transform:translateY(calc(100% - 100% * clamp(0,var(--share) * 2,1)));opacity:calc(1 - var(--lift) * 3)}
.hiw-sheet-grab{width:36px;height:4px;border-radius:999px;background:#5a5a5e;margin:0 auto 12px}
.hiw-sheet-preview{display:flex;align-items:center;gap:10px;padding-bottom:12px;border-bottom:1px solid #3a3a3c}
.hiw-sheet-preview img{width:40px;height:40px;border-radius:8px;object-fit:cover}
.hiw-sheet-preview strong{display:block;font-weight:600}
.hiw-sheet-preview span{color:#8e8e93}
.hiw-sheet-apps{display:flex;gap:14px;padding-top:12px}
.hiw-sheet-apps span{display:flex;flex-direction:column;align-items:center;gap:6px;width:50px;color:#d1d1d6;text-align:center;font-size:10px}
.hiw-sheet-apps i{width:44px;height:44px;border-radius:11px;background:#3a3a3c;display:block}
.hiw-sheet-apps .hiw-app-valin i{background:url('/assets/app-icon-small.png') center/cover;outline:2px solid var(--blue);outline-offset:3px;transform:scale(calc(1 + .12 * clamp(0,(var(--share) - .45) * 4,1) * (1 - clamp(0,(var(--share) - .7) * 4,1))))}
.hiw-sheet-apps .hiw-app-valin{color:#fff;font-weight:600}
.hiw-saved{position:absolute;left:50%;top:220px;transform:translate(-50%,calc(12px - 12px * clamp(0,(var(--share) - .7) * 3.4,1)));display:flex;align-items:center;gap:8px;background:#fff;color:var(--ink);font-weight:600;font-size:12px;padding:8px 14px 8px 8px;border-radius:999px;white-space:nowrap;box-shadow:0 10px 30px -10px var(--scrim);opacity:calc(clamp(0,(var(--share) - .7) * 3.4,1) * (1 - var(--lift) * 3));z-index:6}
.hiw-saved img{width:22px;height:22px;border-radius:6px}

/* The reel leaves the phone and splits into three slabs. */
.hiw-reel{position:absolute;left:calc(270px + 130px * var(--lift));top:calc(140px - 50px * var(--lift));width:220px;height:330px;transform-style:preserve-3d;transform:rotateY(calc(-14deg * var(--lift))) rotateX(calc(6deg * var(--lift)));opacity:calc(clamp(0,var(--lift) * 6,1) * (1 - var(--gather)));pointer-events:none;z-index:2}
.hiw-slab{position:absolute;inset:0;border-radius:16px;background:#fff;color:var(--ink);box-shadow:0 24px 50px -24px var(--scrim),0 0 0 1px var(--line);overflow:hidden;backface-visibility:hidden;transition:none}
.hiw-slab-label{position:absolute;z-index:2;top:10px;left:12px;padding:3px 8px;border-radius:999px;background:#fff;box-shadow:0 0 0 1px var(--line);font-size:12px;font-weight:600;color:var(--blue);opacity:var(--explode);white-space:nowrap}
.hiw-slab-frames{transform:translate3d(calc(-150px * var(--explode)),calc(-60px * var(--explode)),calc(-140px * var(--explode)));background:#111;color:#fff}
.hiw-slab-audio{transform:translate3d(calc(90px * var(--explode)),calc(-20px * var(--explode)),calc(-10px * var(--explode)))}
.hiw-slab-caption{transform:translate3d(calc(-20px * var(--explode)),calc(190px * var(--explode)),calc(120px * var(--explode)));height:calc(330px - 130px * var(--explode))}
/* Before the split the top slab shows the reel; the others sit underneath. */
.hiw-slab-caption{opacity:calc(.0 + 1 * clamp(0,var(--explode) * 3,1))}
.hiw-slab-audio{opacity:clamp(0,var(--explode) * 3,1)}

.hiw-frames{display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;height:100%}
.hiw-frames figure{position:relative;margin:0;overflow:hidden;border-radius:10px;background:#222}
.hiw-frames img{width:100%;height:100%;object-fit:cover;filter:saturate(calc(.4 + .6 * var(--read)))}
.hiw-frames figcaption{position:absolute;left:6px;bottom:6px;font-size:10px;font-weight:600;background:rgba(0,0,0,.6);padding:2px 6px;border-radius:6px}
.hiw-cover{position:absolute;inset:0;background:url('/assets/frame-tomato-pasta.webp') center/cover;opacity:calc(1 - clamp(0,var(--explode) * 2,1))}
.hiw-scan{position:absolute;left:0;right:0;top:calc(-6px + 106% * var(--read));height:3px;background:var(--blue);box-shadow:0 0 18px 4px color-mix(in srgb,var(--blue) 60%,transparent);opacity:calc(clamp(0,var(--read) * 10,1) * (1 - clamp(0,(var(--read) - .9) * 10,1)))}
.hiw-found{position:absolute;padding:3px 8px;border-radius:8px;background:var(--blue);color:#fff;font-size:10px;font-weight:600;white-space:nowrap;box-shadow:0 6px 16px -6px var(--scrim);opacity:var(--found);transform:translateY(calc(6px - 6px * var(--found)))}

.hiw-slab-audio{display:flex;flex-direction:column;justify-content:center;gap:16px;padding:18px}
.hiw-wave{display:flex;align-items:center;gap:3px;height:54px}
.hiw-wave i{flex:1;height:calc(var(--bar) * (.25 + .75 * var(--read)));border-radius:3px;background:var(--blue);opacity:calc(.35 + .65 * var(--read))}
.hiw-transcript{font-family:var(--serif);font-size:17px;line-height:1.3;margin:0}
.hiw-transcript span{opacity:calc(.22 + .78 * var(--word))}
.hiw-transcript mark{background:color-mix(in srgb,var(--blue) 14%,transparent);color:var(--ink);border-radius:3px;padding:0 2px}
.hiw-audio-meta{font-size:11px;color:var(--muted);margin:0}

.hiw-slab-caption{padding:42px 14px 14px;font-size:12px;line-height:1.45}
.hiw-slab-caption header{display:flex;align-items:center;gap:8px;font-weight:600;margin-bottom:10px}
.hiw-slab-caption header i{width:24px;height:24px;border-radius:50%;background:url('/assets/frame-tomato-pasta.webp') center/cover}
.hiw-slab-caption p{margin:0 0 8px}
.hiw-slab-caption .hiw-tags{color:var(--blue)}
.hiw-slab-caption mark{background:color-mix(in srgb,var(--blue) 14%,transparent);color:var(--ink);border-radius:3px;padding:0 2px;opacity:calc(.3 + .7 * var(--read))}

/* Chips: start over the slab that produced them, fly to the card. */
.hiw-chip{position:absolute;left:0;top:0;padding:6px 10px;border-radius:999px;background:var(--ink);color:#fff;font-size:12px;font-weight:600;white-space:nowrap;box-shadow:0 10px 24px -10px var(--scrim);opacity:calc(var(--chip-in) * (1 - clamp(0,(var(--gather) - .85) * 7,1)));transform:translate(calc(var(--x0) + (var(--x1) - var(--x0)) * var(--chip-go)),calc(var(--y0) + (var(--y1) - var(--y0)) * var(--chip-go))) scale(calc(1 - .12 * var(--chip-go)));z-index:4}
.hiw-chip[data-from="frames"]{background:var(--blue)}
.hiw-chip[data-from="audio"]{background:#fff;color:var(--ink);box-shadow:0 10px 24px -10px var(--scrim),0 0 0 1px var(--line)}

/* Memory card forms where the reel was, then drops back into the phone. */
.hiw-card{position:absolute;left:calc(440px - 410px * var(--back));top:calc(110px - 60px * var(--back));width:290px;border-radius:20px;background:#1c1c1e;color:#fff;padding:18px;box-shadow:0 30px 60px -24px var(--scrim);opacity:calc(clamp(0,var(--gather) * 2,1) * (1 - clamp(0,(var(--back) - .45) * 2.2,1)));transform:scale(calc(.9 + .1 * var(--gather) - .25 * var(--back)));transform-origin:top left;z-index:3}
.hiw-card-head{display:flex;gap:12px;align-items:center;margin-bottom:14px}
.hiw-card-head img{width:52px;height:52px;border-radius:12px;object-fit:cover}
.hiw-card-head small{display:block;color:var(--blue);font-size:11px;font-weight:600}
.hiw-card-head strong{display:block;font-size:15px;line-height:1.2;letter-spacing:-.02em}
.hiw-card-section{font-size:10px;font-weight:600;color:#98989d;letter-spacing:.04em;margin:0 0 8px;display:flex;gap:6px;align-items:center}
.hiw-card-section::before{content:"";width:12px;height:12px;border-radius:3px;background:var(--blue)}
.hiw-card-slots{display:flex;flex-wrap:wrap;gap:6px;min-height:72px;margin-bottom:12px}
.hiw-card-slots i{display:block;height:28px;line-height:28px;padding:0 10px;border-radius:999px;background:#2c2c2e;font-style:normal;font-size:12px;font-weight:600;white-space:nowrap;color:transparent;background-color:color-mix(in srgb,#2c2c2e calc(100% - 100% * clamp(0,(var(--gather) - .85) * 7,1)),var(--blue))}
.hiw-card-slots i{color:rgb(255 255 255 / clamp(0,(var(--gather) - .85) * 7,1))}
.hiw-card-slots i[data-from="audio"]{background-color:color-mix(in srgb,#2c2c2e calc(100% - 100% * clamp(0,(var(--gather) - .85) * 7,1)),#fff);color:rgb(29 29 31 / clamp(0,(var(--gather) - .85) * 7,1))}
.hiw-card-steps{margin:0;padding:0;list-style:none;font-size:12px;line-height:1.45;color:#e5e5ea}
.hiw-card-steps li{opacity:var(--gather);transform:translateY(calc(6px - 6px * var(--gather)))}
.hiw-card-foot{margin-top:14px;padding:8px;border-radius:12px;background:#2c2c2e;color:var(--blue);font-weight:600;font-size:12px;text-align:center;opacity:var(--gather)}

/* Seal: the outline draws around the phone; nothing else remains on stage. */
.hiw-seal{position:absolute;left:6px;top:16px;width:288px;height:593px;overflow:visible;pointer-events:none}
.hiw-seal rect{fill:none;stroke:var(--blue);stroke-width:2.5;stroke-dasharray:1760;stroke-dashoffset:calc(1760 - 1760 * var(--seal));opacity:clamp(0,var(--seal) * 4,1)}
.hiw-seal-note{position:absolute;left:calc(50% - 50px * var(--scene-scale));top:calc(50% - 160px * var(--scene-scale));width:360px;opacity:var(--seal);transform:translateY(calc((16px - 16px * var(--seal)) * var(--scene-scale))) scale(var(--scene-scale));transform-origin:top left}
.hiw-seal-note h3{font-size:var(--text-title);letter-spacing:-.04em;margin:0 0 12px;line-height:1.1}
.hiw-seal-note p{color:var(--muted);margin:0 0 18px;font-size:var(--text-small)}
.hiw-seal-note ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px}
.hiw-seal-note li{display:flex;align-items:center;gap:10px;font-weight:600;font-size:var(--text-small)}
.hiw-seal-note li svg{width:22px;height:22px;color:var(--blue);fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}

/* Static fallback: no JavaScript or reduced motion shows the finished state and all copy. */
.hiw:not(.hiw-live) .hiw-track{height:auto}
.hiw:not(.hiw-live) .hiw-pin{position:static;align-items:start}
.hiw:not(.hiw-live) .hiw-beat p{grid-template-rows:1fr;opacity:1;margin-top:10px}
.hiw:not(.hiw-live) .hiw-beat button{color:var(--ink);cursor:default}
.hiw:not(.hiw-live) .hiw-stage{--share:1;--lift:1;--explode:1;--read:1;--gather:1;--back:1;--seal:1;--found:1;--word:1;--chip-in:0;--chip-go:1;height:var(--scene-h)}
.hiw:not(.hiw-live) .hiw-reel{opacity:0}

@media(max-width:1100px){.hiw-pin.wrap{width:calc(100% - 64px)}}
@media(max-width:800px){
  .hiw-pin.wrap{width:calc(100% - 40px)}
  .hiw-pin{grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto;gap:16px;align-content:start;align-items:start}
  .hiw-stage-wrap{order:-1}
  .hiw-stage{height:min(56svh,var(--scene-h));border-radius:20px}
  .hiw-live .hiw-stage{min-height:calc(340px * var(--seal))}
  .hiw-live .hiw-scene{opacity:calc(1 - var(--seal))}
  .hiw-seal-note{left:20px;right:20px;top:50%;width:auto;transform:translateY(calc(-50% + 16px - 16px * var(--seal)))}
  .hiw-seal-note h3{font-size:22px;line-height:1.2}
  .hiw-seal-note p,.hiw-seal-note li{font-size:16px;line-height:1.45}
  .hiw-beats{flex-direction:row;gap:0;overflow:hidden}
  .hiw-beat{flex:0 0 100%;border-left:0;border-top:0;padding:12px 0 0;transform:translateX(calc(-100% * var(--beat)));transition:transform .4s cubic-bezier(.22,1,.36,1)}
  .hiw-beat button,.hiw-beat[aria-current="step"] button{font-size:22px}
  .hiw-beat p{font-size:16px}
  .hiw-beat small{font-size:13px}
  .hiw-dots{display:flex;gap:6px;margin-bottom:8px}
  .hiw-dots i{height:3px;flex:1;border-radius:999px;background:var(--line)}
  .hiw-dots i[data-on]{background:var(--blue)}
  .hiw:not(.hiw-live) .hiw-beats{flex-direction:column}
  .hiw:not(.hiw-live) .hiw-beat{transform:none}
  .hiw:not(.hiw-live) .hiw-stage{height:min(80svh,var(--scene-h))}
}
@media(min-width:801px){.hiw-dots{display:none}}

/* Keep the static result readable without scroll pinning or JavaScript. */
.hiw:not(.hiw-live) .hiw-stage{--back:1!important;height:620px!important}
.hiw:not(.hiw-live) .hiw-scene{width:100%;transform:translate(-50%,-50%)}
.hiw:not(.hiw-live) .hiw-phone{left:calc(50% - 130px);transform:none}
.hiw:not(.hiw-live) .hiw-reel-screen,.hiw:not(.hiw-live) .hiw-home-screen,.hiw:not(.hiw-live) .hiw-card,.hiw:not(.hiw-live) .hiw-chip,.hiw:not(.hiw-live) .hiw-seal-note{display:none}
.hiw:not(.hiw-live) .hiw-beat p,.hiw:not(.hiw-live) .hiw-beat button{transition:none}
@media(max-width:800px){.hiw-live .hiw-beat:not([aria-current="step"]){visibility:hidden}}

.hiw-sheet-apps i:has(svg){display:grid;place-items:center;background:#087cff;color:white}.hiw-sheet-apps i.hiw-app-messages{background:#27bf42}.hiw-sheet-apps i svg{width:30px;height:30px}
