{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ceramics-cards-revealed-through-falling-slats","type":"registry:block","title":"Ceramics Cards Revealed Through Falling Slats","description":"","dependencies":[],"files":[{"path":"components/we-inc/ceramics-cards-revealed-through-falling-slats.tsx","type":"registry:component","content":"import { useEffect, useRef, useState } from \"react\";\n\nconst DELAY = 2000; // ms between idle reveals while nobody is pointing or tabbing\nconst SLATS = 5; // vertical strips the photo drops in through\n\nconst pieces = [\n  { name: \"Ember vases\", detail: \"Wood-fired, painted lotus glaze\", price: \"$64\", glaze: \"#4f2216\", img: \"https://images.pexels.com/photos/28867382/pexels-photo-28867382.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Hand-painted ceramic vases and lidded jars on a dark shelf\" },\n  { name: \"Shoreline bowls\", detail: \"Stoneware, ink and sand glazes\", price: \"$38\", glaze: \"#3f5560\", img: \"https://images.pexels.com/photos/3847438/pexels-photo-3847438.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Ceramic bowls and plates in white, black and red seen from above\" },\n  { name: \"Bisque mugs\", detail: \"Thrown in batches, glazed to order\", price: \"$26\", glaze: \"#6b5a45\", img: \"https://images.pexels.com/photos/8063803/pexels-photo-8063803.jpeg?auto=compress&cs=tinysrgb&w=600\", alt: \"Rows of unglazed pale clay mugs on a workshop shelf\" },\n];\n\nconst css = `\n.w8cer-card { position: relative; display: block; overflow: hidden; aspect-ratio: 3 / 4; border-radius: 6px; color: #f6ece0; text-decoration: none; outline: none; }\n.w8cer-card:focus-visible { box-shadow: 0 0 0 3px #a9482a, 0 0 0 5px #f6ece0; }\n.w8cer-swatch { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; }\n.w8cer-slat { position: absolute; top: 0; bottom: 0; overflow: hidden; }\n.w8cer-drop { position: absolute; inset: 0; transform: translateY(-101%); transition: transform .7s cubic-bezier(.7,0,.2,1); }\n.w8cer-drop img { position: absolute; top: 0; height: 100%; max-width: none; object-fit: cover; }\n.w8cer-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 48px 22px 20px; background: linear-gradient(to top, rgba(20,10,6,.82), rgba(20,10,6,0)); opacity: 0; transition: opacity .4s ease .25s; }\n.w8cer-card[data-on] .w8cer-drop, .w8cer-card:hover .w8cer-drop, .w8cer-card:focus-visible .w8cer-drop { transform: none; }\n.w8cer-card[data-on] .w8cer-cap, .w8cer-card:hover .w8cer-cap, .w8cer-card:focus-visible .w8cer-cap { opacity: 1; }\n@media (max-width: 767px), (prefers-reduced-motion: reduce) {\n  .w8cer-drop { transform: none; transition: none; }\n  .w8cer-cap { opacity: 1; transition: none; }\n}\n`;\n\nexport default function CeramicsCardsRevealedThroughFallingSlats() {\n  const root = useRef<HTMLElement>(null);\n  const [on, setOn] = useState(0);\n\n  useEffect(() => {\n    const el = root.current;\n    if (!el || window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    let timer = 0, visible = true, live = true;\n    const run = () => {\n      window.clearInterval(timer);\n      timer = 0;\n      if (live && visible) timer = window.setInterval(() => setOn((n) => (n + 1) % pieces.length), DELAY);\n    };\n    // a real mouse or keyboard takes over from the idle demo\n    const stop = () => { live = false; setOn(-1); run(); };\n    const enter = (e: PointerEvent) => { if (e.pointerType === \"mouse\") stop(); };\n    const io = new IntersectionObserver(([en]) => { visible = en.isIntersecting; run(); });\n    io.observe(el);\n    el.addEventListener(\"pointerenter\", enter);\n    el.addEventListener(\"focusin\", stop);\n    run();\n    return () => {\n      window.clearInterval(timer);\n      io.disconnect();\n      el.removeEventListener(\"pointerenter\", enter);\n      el.removeEventListener(\"focusin\", stop);\n    };\n  }, []);\n\n  return (\n    <section ref={root} className=\"bg-[#a9482a] px-5 py-16 text-[#f6ece0] sm:py-20\">\n      <style>{css}</style>\n      <div className=\"mx-auto max-w-5xl\">\n        <p className=\"text-xs font-semibold uppercase tracking-[0.3em] text-[#f3d9c4]\">Kiln Row Pottery</p>\n        <h2 className=\"mt-3 font-serif text-3xl sm:text-4xl\">This month on the shelf</h2>\n        <p className=\"mt-3 max-w-md text-base text-[#f3dccb]\">Each card starts as its glaze colour. Point at one, or tab to it, and the piece drops in strip by strip.</p>\n        <ul className=\"mt-10 grid gap-6 sm:grid-cols-3\">\n          {pieces.map((p, i) => (\n            <li key={p.name}>\n              <a href=\"#\" className=\"w8cer-card\" style={{ background: p.glaze }} data-on={on === i ? \"\" : undefined}>\n                <span className=\"w8cer-swatch\">\n                  <span className=\"text-xs uppercase tracking-[0.25em] text-[#f3dccb]\">Glaze {i + 1}</span>\n                  <span className=\"font-serif text-2xl\">{p.name}</span>\n                </span>\n                {Array.from({ length: SLATS }, (_, s) => (\n                  <span key={s} className=\"w8cer-slat\" style={{ left: `${(s * 100) / SLATS}%`, width: `${100 / SLATS}%` }}>\n                    <span className=\"w8cer-drop\" style={{ transitionDelay: `${s * 70}ms` }}>\n                      <img src={p.img} alt={s === 0 ? p.alt : \"\"} width={600} height={800} loading=\"lazy\" decoding=\"async\" style={{ width: `${SLATS * 100}%`, left: `${-s * 100}%` }} />\n                    </span>\n                  </span>\n                ))}\n                <span className=\"w8cer-cap\">\n                  <span className=\"block font-serif text-2xl\">{p.name}</span>\n                  <span className=\"mt-1 flex justify-between text-sm text-[#f3dccb]\"><span>{p.detail}</span><span>{p.price}</span></span>\n                </span>\n              </a>\n            </li>\n          ))}\n        </ul>\n      </div>\n    </section>\n  );\n}\n"}]}
