{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"magnifier-loupe-cursor-over-a-seed-catalogue-price-list","type":"registry:block","title":"Magnifier Loupe Over a Price List","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/magnifier-loupe-cursor-over-a-seed-catalogue-price-list.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\nconst ZOOM = 1.8; // magnification inside the loupe\nconst LENS = 240; // loupe diameter in px\nconst seeds = [\n  { name: \"Broad bean, Winter Lantern\", note: \"Sow Feb to Apr. Thirty seeds.\", price: \"$3.40\" },\n  { name: \"Pea, Hedgerow Sugar\", note: \"Sweet flat pods, climbs to 5 ft.\", price: \"$3.10\" },\n  { name: \"Beetroot, Cellar Blood\", note: \"Deep red globes that store well.\", price: \"$2.80\" },\n  { name: \"Carrot, Long Barn\", note: \"Tapered roots for heavy soil.\", price: \"$2.60\" },\n  { name: \"Lettuce, Velvet Oak\", note: \"Pick-again leaves, bronze tips.\", price: \"$2.90\" },\n  { name: \"Chard, Five Lamps\", note: \"Stems in gold, pink and white.\", price: \"$3.00\" },\n  { name: \"Tomato, Ridge Cherry\", note: \"Small fruit, early, very sweet.\", price: \"$3.80\" },\n  { name: \"Squash, Pale Moon\", note: \"Grey-blue skin, dense orange flesh.\", price: \"$3.60\" },\n  { name: \"Leek, Frost Hold\", note: \"Stands all winter in the bed.\", price: \"$2.70\" },\n  { name: \"Kale, Black Crow\", note: \"Crinkled leaves, sweeter after frost.\", price: \"$2.90\" },\n  { name: \"Sweet pea, Old Parlour\", note: \"Strong scent, mixed soft colours.\", price: \"$3.50\" },\n  { name: \"Calendula, Ember Mix\", note: \"Edible petals, self-seeds gently.\", price: \"$2.40\" },\n];\n\nfunction SeedList() {\n  return (\n    <div className=\"w2lup-list px-5 py-6 sm:px-8 sm:py-8\">\n      <div className=\"flex flex-wrap items-baseline justify-between gap-2 border-b-2 border-[#3b2f22] pb-3\">\n        <h3 className=\"font-serif text-xl font-semibold\">Spring sowing list</h3>\n        <p className=\"text-xs font-semibold uppercase tracking-[0.18em] text-[#6b5641]\">Price per packet</p>\n      </div>\n      <ul className=\"mt-2 grid gap-x-10 md:grid-cols-2\">\n        {seeds.map((s) => (\n          <li key={s.name} className=\"flex items-baseline gap-3 border-b border-dotted border-[#b9a68c] py-2.5\">\n            <span className=\"min-w-0 flex-1\">\n              <span className=\"block text-[15px] font-semibold\">{s.name}</span>\n              <span className=\"block text-[13px] italic text-[#5c4a37]\">{s.note}</span>\n            </span>\n            <span className=\"text-[15px] font-semibold tabular-nums\">{s.price}</span>\n          </li>\n        ))}\n      </ul>\n    </div>\n  );\n}\n\nexport default function MagnifierLoupeCursorOverASeedCataloguePriceList() {\n  const reduce = useReducedMotion();\n  const rootRef = useRef<HTMLElement>(null);\n  const sheetRef = useRef<HTMLDivElement>(null);\n  const lensRef = useRef<HTMLDivElement>(null);\n  const cloneRef = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const root = rootRef.current, sheet = sheetRef.current, lens = lensRef.current, clone = cloneRef.current;\n    if (!root || !sheet || !lens || !clone || reduce || !matchMedia(\"(hover: hover) and (pointer: fine)\").matches) return;\n    root.setAttribute(\"data-on\", \"\");\n    const R = LENS / 2;\n    let x = 0, y = 0, tx = 0, ty = 0, live = false, frame = 0, idle = 0;\n    const t0 = performance.now();\n    const fit = () => { clone.style.width = `${sheet.clientWidth}px`; };\n    const loop = (now: number) => {\n      if (!live) {\n        const t = (now - t0) / 1000;\n        tx = sheet.clientWidth * (0.5 + 0.38 * Math.sin(t * 0.42)); ty = sheet.clientHeight * (0.5 + 0.36 * Math.sin(t * 0.9 + 0.5));\n      }\n      x += (tx - x) * 0.18; y += (ty - y) * 0.18;\n      lens.style.transform = `translate(${x - R}px, ${y - R}px)`;\n      clone.style.transform = `translate(${R - x * ZOOM}px, ${R - y * ZOOM}px) scale(${ZOOM})`;\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) => {\n      if (e.pointerType === \"touch\") return;\n      const r = sheet.getBoundingClientRect();\n      tx = e.clientX - r.left; ty = e.clientY - r.top;\n      live = true; clearTimeout(idle); root.removeAttribute(\"data-kb\");\n    };\n    const onLeave = () => { idle = window.setTimeout(() => { live = false; }, 1500); };\n    const onFocus = () => { if (root.querySelector(\":focus-visible\")) root.setAttribute(\"data-kb\", \"\"); };\n    const onBlur = () => root.removeAttribute(\"data-kb\");\n    fit();\n    const ro = new ResizeObserver(fit);\n    ro.observe(sheet);\n    const io = new IntersectionObserver(([e]) => (e.isIntersecting ? start() : stop()));\n    io.observe(root);\n    sheet.addEventListener(\"pointermove\", onMove);\n    sheet.addEventListener(\"pointerleave\", onLeave);\n    root.addEventListener(\"focusin\", onFocus);\n    root.addEventListener(\"focusout\", onBlur);\n    return () => {\n      stop(); io.disconnect(); ro.disconnect(); clearTimeout(idle);\n      root.removeAttribute(\"data-on\");\n      sheet.removeEventListener(\"pointermove\", onMove);\n      sheet.removeEventListener(\"pointerleave\", onLeave);\n      root.removeEventListener(\"focusin\", onFocus);\n      root.removeEventListener(\"focusout\", onBlur);\n    };\n  }, [reduce]);\n\n  return (\n    <section ref={rootRef} className=\"w2lup-root bg-[#e9dfcd] px-5 py-14 text-[#2b2117] sm:px-10 sm:py-16\">\n      <style>{`\n        .w2lup-lens { position: absolute; left: 0; top: 0; width: ${LENS}px; height: ${LENS}px; border-radius: 50%; overflow: hidden; pointer-events: none;\n          background: #fbf6ec; opacity: 0; transition: opacity .35s ease; will-change: transform;\n          box-shadow: 0 0 0 5px #3b2f22, 0 0 0 6px rgba(255,255,255,.25), 0 18px 40px -10px rgba(43,33,23,.55); }\n        .w2lup-lens::after { content: \"\"; position: absolute; inset: 0; border-radius: 50%;\n          background: radial-gradient(circle at 32% 26%, rgba(255,255,255,.45), rgba(255,255,255,0) 42%), radial-gradient(circle, rgba(0,0,0,0) 62%, rgba(43,33,23,.18) 100%); }\n        .w2lup-clone { position: absolute; left: 0; top: 0; transform-origin: 0 0; }\n        .w2lup-root[data-on] .w2lup-lens { opacity: 1; }\n        .w2lup-root[data-kb] .w2lup-lens { opacity: 0; }\n        @media (prefers-reduced-motion: reduce) { .w2lup-lens { display: none; } }\n      `}</style>\n      <div className=\"mx-auto max-w-5xl\">\n        <div className=\"mb-8 flex flex-wrap items-end justify-between gap-4\">\n          <div>\n            <p className=\"text-xs font-semibold uppercase tracking-[0.22em] text-[#7a4b22]\">Aldergrove Seed Co.</p>\n            <h2 className=\"mt-2 font-serif text-[clamp(1.8rem,4vw,2.6rem)] leading-tight\">The fine print, up close</h2>\n          </div>\n          <a href=\"#\" className=\"inline-flex min-h-[44px] items-center rounded-md bg-[#2b2117] px-5 text-sm font-semibold text-[#f6efe2] hover:bg-[#3e3022] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#7a4b22] focus-visible:ring-offset-2 focus-visible:ring-offset-[#e9dfcd]\">Order a seed box</a>\n        </div>\n        <div ref={sheetRef} className=\"relative overflow-hidden rounded-sm bg-[#fbf6ec] shadow-[0_1px_0_rgba(43,33,23,.12),0_24px_50px_-30px_rgba(43,33,23,.6)]\">\n          <SeedList />\n          <div ref={lensRef} className=\"w2lup-lens\" aria-hidden=\"true\">\n            <div ref={cloneRef} className=\"w2lup-clone\">\n              <SeedList />\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
