{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"pointer-spotlight-revealing-a-dimmed-cellar-photo","type":"registry:block","title":"Pointer Spotlight Over a Dimmed Photo","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/pointer-spotlight-revealing-a-dimmed-cellar-photo.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\nconst EASE = 0.1; // how softly the light trails the pointer (0 to 1)\nconst RADIUS = 260; // spotlight radius in px\nconst PHOTO = \"https://images.pexels.com/photos/2946621/pexels-photo-2946621.jpeg?auto=compress&cs=tinysrgb&w=1600\";\n\nexport default function PointerSpotlightRevealingADimmedCellarPhoto() {\n  const reduce = useReducedMotion();\n  const rootRef = useRef<HTMLElement>(null);\n  const shadeRef = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const root = rootRef.current, shade = shadeRef.current;\n    if (!root || !shade || reduce) return;\n    let W = root.clientWidth, H = root.clientHeight, x = W * 0.7, y = H * 0.4, tx = x, ty = y;\n    let live = false, frame = 0, idle = 0, t0 = performance.now();\n    const place = () => { shade.style.transform = `translate(${x}px, ${y}px)`; };\n    const at = (e: PointerEvent) => { const r = root.getBoundingClientRect(); tx = e.clientX - r.left; ty = e.clientY - r.top; };\n    place();\n    if (!matchMedia(\"(hover: hover) and (pointer: fine)\").matches) {\n      // Touch: the light rests in one spot and moves to wherever someone taps.\n      const onTap = (e: PointerEvent) => { at(e); x = tx; y = ty; shade.style.transition = \"transform .6s ease\"; place(); };\n      root.addEventListener(\"pointerdown\", onTap);\n      return () => root.removeEventListener(\"pointerdown\", onTap);\n    }\n    const loop = (now: number) => {\n      W = root.clientWidth; H = root.clientHeight;\n      if (!live) {\n        const t = (now - t0) / 1000;\n        tx = W * (0.68 + 0.2 * Math.sin(t * 0.5)); ty = H * (0.45 + 0.25 * Math.sin(t * 0.8 + 1));\n      }\n      x += (tx - x) * EASE; y += (ty - y) * EASE; place();\n      frame = requestAnimationFrame(loop);\n    };\n    const start = () => { if (!frame) frame = requestAnimationFrame(loop); };\n    const stop = () => { cancelAnimationFrame(frame); frame = 0; };\n    const onMove = (e: PointerEvent) => { if (e.pointerType !== \"touch\") { at(e); live = true; clearTimeout(idle); } };\n    const onLeave = () => { idle = window.setTimeout(() => { live = false; t0 = performance.now(); }, 1500); };\n    const io = new IntersectionObserver(([e]) => (e.isIntersecting ? start() : stop()));\n    io.observe(root);\n    root.addEventListener(\"pointermove\", onMove);\n    root.addEventListener(\"pointerleave\", onLeave);\n    return () => {\n      stop(); io.disconnect(); clearTimeout(idle);\n      root.removeEventListener(\"pointermove\", onMove);\n      root.removeEventListener(\"pointerleave\", onLeave);\n    };\n  }, [reduce]);\n\n  const btn = \"inline-flex min-h-[44px] items-center rounded px-[22px] text-sm font-semibold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#f5ede2] focus-visible:ring-offset-2 focus-visible:ring-offset-[#0e0907]\";\n\n  return (\n    <section ref={rootRef} className=\"relative flex min-h-[600px] items-end overflow-hidden bg-[#0e0907] text-[#f5ede2]\">\n      <style>{`\n        .w2spt-shade { position: absolute; left: -100%; top: -100%; width: 200%; height: 200%; pointer-events: none; will-change: transform;\n          background: radial-gradient(circle ${RADIUS}px at 50% 50%, rgba(14,9,7,0) 0%, rgba(14,9,7,.2) 45%, rgba(14,9,7,.9) 100%); }\n        @media (prefers-reduced-motion: reduce) { .w2spt-shade { display: none; } }\n      `}</style>\n      <img src={PHOTO} alt=\"Oak wine barrels with red wine stains racked four high on steel frames in a cellar\" loading=\"lazy\" width={1600} height={1084} className=\"absolute inset-0 h-full w-full object-cover\" />\n      <div ref={shadeRef} className=\"w2spt-shade\" aria-hidden=\"true\" />\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0 bg-[linear-gradient(0deg,rgba(14,9,7,.95)_0%,rgba(14,9,7,.85)_55%,rgba(14,9,7,.1)_100%)] sm:bg-[linear-gradient(90deg,rgba(14,9,7,.92)_0%,rgba(14,9,7,.6)_38%,rgba(14,9,7,0)_62%)]\" />\n      <div className=\"relative max-w-[30rem] px-5 py-12 sm:px-12 sm:py-16\">\n        <p className=\"text-xs font-semibold uppercase tracking-[0.22em] text-[#e6c48f]\">Harrow Ridge Cellars</p>\n        <h2 className=\"mt-3.5 font-serif text-[clamp(2rem,4.6vw,3rem)] font-normal leading-[1.1]\">The barrel room opens for evening tastings</h2>\n        <p className=\"mt-4 leading-relaxed text-[#e3d8ca]\">Walk the racks by lamplight with our cellar hand, then taste three wines drawn straight from the cask.</p>\n        <div className=\"mt-7 flex flex-wrap gap-3\">\n          <a href=\"#\" className={`${btn} bg-[#e6c48f] text-[#1c130d] hover:bg-[#f0d4a6]`}>Book an evening</a>\n          <a href=\"#\" className={`${btn} border border-[#f5ede2]/40 bg-[#140d0a]/55 hover:bg-[#140d0a]/80`}>See the wines</a>\n        </div>\n        <p className=\"mt-5 text-[13px] text-[#cfc2b2]\">Thursday to Saturday, from six</p>\n      </div>\n    </section>\n  );\n}\n"}]}
