{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"numbered-process-steps-stacking-with-peeking-headers","type":"registry:block","title":"Numbered Process Steps Stacking With Peeking Headers","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/numbered-process-steps-stacking-with-peeking-headers.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\nconst steps = [\n  { title: \"Roof survey\", time: \"One visit\", text: \"An installer climbs up, measures every face of the roof and checks the rafters and the fuse board before anything is drawn.\", gets: [\"Photos of each roof face\", \"A note on any repairs needed first\"] },\n  { title: \"Panel layout\", time: \"About three days\", text: \"We draw where each panel sits, how the cables run and where the inverter hangs, then walk you through it on a call.\", gets: [\"A drawn layout you can mark up\", \"A fixed price that will not change\"] },\n  { title: \"Permits and grid sign-off\", time: \"Two to four weeks\", text: \"We file the paperwork with the council and the network operator and chase it, so you only hear from us when it is approved.\", gets: [\"Every form filed for you\", \"A date for install day\"] },\n  { title: \"Install day\", time: \"One day\", text: \"Scaffold goes up early, panels are fixed by lunch and the system is switched on and tested with you before the team leaves.\", gets: [\"A live system and handover pack\", \"The monitoring app set up on your phone\"] },\n];\nconst BASE = 24; // pin line of the first card, in px\nconst PEEK = 64; // how much of each earlier card stays visible\nconst FADE = 0.7; // how far a covered card's body fades\nconst AUTO_PX_PER_SEC = 32; // demo scroll speed; 0 turns it off\n\nexport default function NumberedProcessStepsStackingWithPeekingHeaders() {\n  const reduce = useReducedMotion();\n  const boxRef = useRef<HTMLElement>(null);\n\n  useEffect(() => {\n    const box = boxRef.current;\n    if (!box || reduce) return;\n    const cards = Array.from(box.querySelectorAll<HTMLElement>(\".w4nps-card\"));\n    let raf = 0;\n    const paint = () => {\n      raf = 0;\n      const top = box.getBoundingClientRect().top;\n      const cover = cards.map((c) => {\n        const d = c.getBoundingClientRect().top - top - parseFloat(getComputedStyle(c).top);\n        return Math.min(1, Math.max(0, 1 - d / (c.offsetHeight - PEEK)));\n      });\n      cards.forEach((c, i) => {\n        const under = i + 1 < cards.length ? cover[i + 1] : 0;\n        c.querySelector<HTMLElement>(\".w4nps-body\")!.style.opacity = String(1 - FADE * under);\n        c.querySelector<HTMLElement>(\".w4nps-shade\")!.style.opacity = String(under);\n      });\n      box.toggleAttribute(\"data-scrolled\", box.scrollTop > 8);\n    };\n    const onScroll = () => { if (!raf) raf = requestAnimationFrame(paint); };\n    box.addEventListener(\"scroll\", onScroll, { passive: true });\n    paint();\n\n    let demo = 0, last = 0, pos = box.scrollTop, seen = true, done = !AUTO_PX_PER_SEC;\n    const step = (now: number) => {\n      const dt = last ? Math.min(now - last, 50) : 0;\n      last = now;\n      pos += (AUTO_PX_PER_SEC * dt) / 1000;\n      if (pos >= box.scrollHeight - box.clientHeight) { done = true; demo = 0; return; }\n      box.scrollTop = pos;\n      demo = requestAnimationFrame(step);\n    };\n    const start = () => { if (!done && seen && !demo) { last = 0; demo = requestAnimationFrame(step); } };\n    const stop = () => { cancelAnimationFrame(demo); demo = 0; };\n    const handOver = () => { done = true; stop(); };\n    const io = new IntersectionObserver(([e]) => { seen = e.isIntersecting; if (seen) start(); else stop(); });\n    io.observe(box);\n    const evs = [\"wheel\", \"touchstart\", \"pointerdown\", \"keydown\"] as const;\n    evs.forEach((ev) => box.addEventListener(ev, handOver, { passive: true }));\n    start();\n    return () => {\n      stop();\n      cancelAnimationFrame(raf);\n      io.disconnect();\n      box.removeEventListener(\"scroll\", onScroll);\n      evs.forEach((ev) => box.removeEventListener(ev, handOver));\n    };\n  }, [reduce]);\n\n  return (\n    <section ref={boxRef} tabIndex={0} aria-label=\"How an install works, scrollable\" className=\"w4nps-root\">\n      <style>{`\n        .w4nps-root { height: 640px; overflow-y: auto; position: relative; background: #0f1d33; color: #eef1f6; scrollbar-width: thin; scrollbar-color: #2c3e5c transparent; }\n        .w4nps-root:focus-visible { outline: 3px solid #f2b84b; outline-offset: -3px; }\n        .w4nps-hint { position: sticky; top: 0; z-index: 20; height: 0; display: flex; justify-content: center; pointer-events: none; transition: opacity .4s ease; }\n        .w4nps-hint span { margin-top: 6px; padding: 3px 12px; border-radius: 999px; background: #f2b84b; color: #0f1d33; font-size: 12px; font-weight: 600; letter-spacing: .04em; }\n        .w4nps-root[data-scrolled] .w4nps-hint { opacity: 0; }\n        .w4nps-card { position: sticky; }\n        .w4nps-shade { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(#0f1d3300 ${PEEK}px, #0f1d3324); opacity: 0; pointer-events: none; }\n        @media (prefers-reduced-motion: reduce) { .w4nps-body { opacity: 1 !important; } .w4nps-shade { opacity: 0 !important; } .w4nps-hint { display: none; } }\n      `}</style>\n      <div className=\"w4nps-hint\" aria-hidden=\"true\"><span>Scroll inside</span></div>\n      <div className=\"mx-auto max-w-3xl px-5 pb-28 pt-12 sm:px-8\">\n        <div className=\"flex flex-wrap items-end justify-between gap-4\">\n          <div>\n            <p className=\"text-xs font-semibold uppercase tracking-[0.2em] text-[#f2b84b]\">Northpoint Solar</p>\n            <h2 className=\"mt-3 text-3xl font-semibold tracking-tight sm:text-4xl\">From first visit to switch on</h2>\n          </div>\n          <a href=\"#\" className=\"inline-flex min-h-[44px] items-center rounded-lg bg-[#f2b84b] px-5 text-sm font-semibold text-[#0f1d33] transition hover:bg-[#f6c96f] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-[#0f1d33]\">Book a roof survey</a>\n        </div>\n        <ol className=\"mt-10 grid gap-6\">\n          {steps.map((s, i) => (\n            <li key={s.title} className=\"w4nps-card\" style={{ top: BASE + i * PEEK }}>\n              <article className=\"relative rounded-2xl bg-[#f4f1ea] text-[#13223b] shadow-[0_-12px_30px_-18px_rgba(0,0,0,0.6),0_24px_40px_-24px_rgba(0,0,0,0.6)]\">\n                <header className=\"flex h-16 items-center gap-4 border-b border-[#ddd6c8] px-6 sm:px-8\">\n                  <span className=\"font-mono text-sm font-semibold text-[#a05f00]\">{String(i + 1).padStart(2, \"0\")}</span>\n                  <h3 className=\"min-w-0 flex-1 truncate text-lg font-semibold\">{s.title}</h3>\n                  <span className=\"hidden text-sm text-[#4a5568] sm:inline\">{s.time}</span>\n                </header>\n                <div className=\"w4nps-body grid gap-6 px-6 py-6 sm:grid-cols-[1.3fr_1fr] sm:px-8 sm:py-7\">\n                  <div>\n                    <p className=\"text-sm font-medium text-[#4a5568] sm:hidden\">{s.time}</p>\n                    <p className=\"mt-1 text-[15px] leading-relaxed sm:mt-0\">{s.text}</p>\n                  </div>\n                  <div className=\"rounded-xl bg-[#e9e3d6] p-4\">\n                    <p className=\"text-xs font-semibold uppercase tracking-[0.14em] text-[#4a5568]\">You get</p>\n                    <ul className=\"mt-2 grid gap-1.5 text-sm\">\n                      {s.gets.map((g) => <li key={g}>{g}</li>)}\n                    </ul>\n                  </div>\n                </div>\n                <span className=\"w4nps-shade\" aria-hidden=\"true\" />\n              </article>\n            </li>\n          ))}\n        </ol>\n      </div>\n    </section>\n  );\n}\n"}]}
