{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"dark-product-feature-cards-stacking-on-scroll","type":"registry:block","title":"Dark Product Feature Cards Stacking on Scroll","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/dark-product-feature-cards-stacking-on-scroll.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\nconst WAVE = [18, 34, 52, 40, 70, 88, 60, 46, 74, 96, 80, 58, 42, 66, 84, 62, 38, 54, 72, 50];\nconst features = [\n  { kicker: \"Inputs\", title: \"Two microphones, one clean take\", text: \"Plug in a lapel mic and a shotgun at once. Each one records to its own track, so a cough on one never ruins the other.\", spec: \"2 locking XLR inputs\", visual: \"wave\" },\n  { kicker: \"Control\", title: \"A gain dial you can find blind\", text: \"The large knob clicks in half-decibel steps and stays where you left it, even in a coat pocket on a windy walk.\", spec: \"Detented, 60 steps\", visual: \"dial\" },\n  { kicker: \"Battery\", title: \"A long day on one charge\", text: \"Record from first light to the last interview and charge from any USB-C brick while it keeps running.\", spec: \"USB-C, records while charging\", visual: \"battery\" },\n  { kicker: \"Files\", title: \"Takes named the way you think\", text: \"Say a short label after you press stop and the file is named for it, ready to drag into your editor.\", spec: \"WAV and MP3 side by side\", visual: \"files\" },\n];\nconst SCALE_STEP = 0.05; // shrink per covering card\nconst LIFT = 16; // px each buried card rises so its top edge shows\nconst AUTO_PX_PER_SEC = 30; // demo scroll speed; 0 turns it off\n\nfunction Visual({ kind }: { kind: string }) {\n  if (kind === \"wave\")\n    return (\n      <div className=\"flex h-full items-center justify-center gap-1.5 px-6 py-[15%]\">\n        {WAVE.map((h, i) => <span key={i} className=\"w-1.5 rounded-full bg-[#d9895a]\" style={{ height: `${h}%`, opacity: 0.8 }} />)}\n      </div>\n    );\n  if (kind === \"dial\")\n    return (\n      <div className=\"grid h-full place-items-center\">\n        <div className=\"relative h-40 w-40\">\n          <div className=\"absolute inset-0 rounded-full\" style={{ background: \"repeating-conic-gradient(#6b6660 0 1.5deg, transparent 1.5deg 10deg)\", WebkitMask: \"radial-gradient(circle, transparent 64%, #000 65%)\", mask: \"radial-gradient(circle, transparent 64%, #000 65%)\" }} />\n          <div className=\"absolute inset-6 rounded-full bg-gradient-to-b from-[#3a3733] to-[#201e1c] shadow-[inset_0_1px_0_rgba(255,255,255,0.12),0_12px_24px_rgba(0,0,0,0.5)]\">\n            <div className=\"absolute inset-0 rotate-[38deg]\"><span className=\"absolute left-1/2 top-2 -ml-0.5 h-8 w-1 rounded-full bg-[#d9895a]\" /></div>\n          </div>\n        </div>\n      </div>\n    );\n  if (kind === \"battery\")\n    return (\n      <div className=\"grid h-full place-items-center\">\n        <div className=\"flex items-center\">\n          <div className=\"flex gap-1.5 rounded-xl border-2 border-[#6b6660] p-2\">\n            {[1, 1, 1, 1, 0].map((on, i) => <span key={i} className={`h-14 w-7 rounded-md ${on ? \"bg-[#d9895a]\" : \"bg-[#2e2b28]\"}`} />)}\n          </div>\n          <span className=\"ml-1 h-6 w-1.5 rounded-r bg-[#6b6660]\" />\n        </div>\n      </div>\n    );\n  return (\n    <ul className=\"grid h-full content-center gap-2 px-6 text-sm\">\n      {[[\"Bakery owner, part 1\", \"18:42\"], [\"Street ambience\", \"04:10\"], [\"Bakery owner, part 2\", \"22:05\"]].map(([n, t], i) => (\n        <li key={n} className={`flex items-center justify-between rounded-lg px-3 py-2.5 ${i === 0 ? \"bg-[#d9895a] text-[#1a1816]\" : \"bg-[#262321] text-[#d8d1c6]\"}`}>\n          <span className=\"truncate\">{n}.wav</span><span className=\"font-mono text-xs\">{t}</span>\n        </li>\n      ))}\n    </ul>\n  );\n}\n\nexport default function DarkProductFeatureCardsStackingOnScroll() {\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>(\".w4dpf-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));\n      });\n      cards.forEach((c, i) => {\n        let depth = 0;\n        for (let j = i + 1; j < cards.length; j++) depth += cover[j];\n        (c.firstElementChild as HTMLElement).style.transform = `translateY(${-LIFT * depth}px) scale(${1 - SCALE_STEP * depth})`;\n        c.querySelector<HTMLElement>(\".w4dpf-shade\")!.style.opacity = String(Math.min(0.7, 0.35 * depth));\n        c.querySelector<HTMLElement>(\".w4dpf-glow\")!.style.opacity = String(cover[i] * Math.max(0, 1 - depth));\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=\"Recorder features, scrollable\" className=\"w4dpf-root\">\n      <style>{`\n        .w4dpf-root { height: 640px; overflow-y: auto; position: relative; background: #121212; color: #ece6dc; scrollbar-width: thin; scrollbar-color: #3a3632 transparent; }\n        .w4dpf-root:focus-visible { outline: 3px solid #d9895a; outline-offset: -3px; }\n        .w4dpf-hint { position: sticky; top: 0; z-index: 20; height: 0; display: flex; justify-content: center; pointer-events: none; transition: opacity .4s ease; }\n        .w4dpf-hint span { margin-top: 10px; padding: 4px 12px; border-radius: 999px; background: #2a2724; color: #ece6dc; font-size: 12px; letter-spacing: .04em; }\n        .w4dpf-root[data-scrolled] .w4dpf-hint { opacity: 0; }\n        .w4dpf-card { position: sticky; top: 72px; }\n        .w4dpf-face { transform-origin: 50% 0; will-change: transform; }\n        .w4dpf-shade { position: absolute; inset: 0; border-radius: inherit; background: #050505; opacity: 0; pointer-events: none; }\n        .w4dpf-glow { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; box-shadow: inset 0 1px 0 rgba(217,137,90,.55), 0 30px 80px -30px rgba(217,137,90,.45); }\n        @media (prefers-reduced-motion: reduce) { .w4dpf-face { transform: none !important; } .w4dpf-shade { opacity: 0 !important; } .w4dpf-glow { opacity: .6 !important; } .w4dpf-hint { display: none; } }\n      `}</style>\n      <div className=\"w4dpf-hint\" aria-hidden=\"true\"><span>Scroll inside</span></div>\n      <div className=\"mx-auto max-w-5xl px-5 pb-28 pt-12 sm:px-8\">\n        <p className=\"text-xs font-semibold uppercase tracking-[0.22em] text-[#d9895a]\">Wrenfield R2 field recorder</p>\n        <h2 className=\"mt-3 max-w-xl text-3xl font-semibold tracking-tight sm:text-4xl\">Built for interviews that happen outdoors</h2>\n        <ul className=\"mt-10 grid gap-8\">\n          {features.map((f) => (\n            <li key={f.title} className=\"w4dpf-card\">\n              <article className=\"w4dpf-face relative grid overflow-hidden rounded-3xl border border-white/10 bg-gradient-to-b from-[#1f1d1b] to-[#171615] md:grid-cols-2\">\n                <div className=\"flex flex-col p-7 sm:p-9\">\n                  <p className=\"text-xs font-semibold uppercase tracking-[0.18em] text-[#d9895a]\">{f.kicker}</p>\n                  <h3 className=\"mt-3 text-2xl font-semibold leading-snug sm:text-[28px]\">{f.title}</h3>\n                  <p className=\"mt-3 text-[15px] leading-relaxed text-[#b9b1a5]\">{f.text}</p>\n                  <p className=\"mt-6 inline-flex self-start rounded-full border border-white/15 px-3 py-1 font-mono text-xs text-[#d8d1c6] md:mt-auto\">{f.spec}</p>\n                </div>\n                <div className=\"h-48 border-t border-white/10 bg-[#141312] md:h-auto md:min-h-[300px] md:border-l md:border-t-0\" aria-hidden=\"true\">\n                  <div className=\"relative h-full\"><Visual kind={f.visual} /></div>\n                </div>\n                <span className=\"w4dpf-glow\" aria-hidden=\"true\" />\n                <span className=\"w4dpf-shade\" aria-hidden=\"true\" />\n              </article>\n            </li>\n          ))}\n        </ul>\n        <a href=\"#\" className=\"mt-14 inline-flex min-h-[44px] items-center rounded-full bg-[#ece6dc] px-6 text-sm font-semibold text-[#121212] transition hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#d9895a] focus-visible:ring-offset-2 focus-visible:ring-offset-[#121212]\">See the full spec sheet</a>\n      </div>\n    </section>\n  );\n}\n"}]}
