{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ink-dot-cursor-trail-fading-over-stationery-hero","type":"registry:block","title":"Ink Dot Cursor Trail","description":"Free cursor trail of fading ink dots behind a stationery hero. Plain HTML, CSS and JS or React, with touch ink blots, keyboard handling and reduced motion support.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/ink-dot-cursor-trail-fading-over-stationery-hero.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\nconst DOTS = 20; // how many ink dots make up the trail\nconst HEAD_EASE = 0.26; // how quickly the first dot catches the pointer (0 to 1)\nconst TAIL_EASE = 0.3; // how tightly each dot follows the one ahead of it\nconst notes = [\n  { k: \"Paper\", v: \"120 gsm cream, fountain pen safe\" },\n  { k: \"Binding\", v: \"Thread sewn, opens flat\" },\n  { k: \"Made in\", v: \"A two-room bindery by the canal\" },\n];\n\nexport default function InkDotCursorTrailFadingOverStationeryHero() {\n  const reduce = useReducedMotion();\n  const rootRef = useRef<HTMLElement>(null);\n  const layerRef = useRef<HTMLDivElement>(null);\n  const blotRef = useRef<HTMLSpanElement>(null);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    const layer = layerRef.current;\n    if (!root || !layer || reduce) return;\n    const fine = matchMedia(\"(hover: hover) and (pointer: fine)\").matches;\n    if (!fine) {\n      // Touch: a tap leaves a soft ink blot instead of a trail.\n      const blot = blotRef.current!;\n      const onDown = (e: PointerEvent) => {\n        const r = root.getBoundingClientRect();\n        blot.style.transform = `translate(${e.clientX - r.left}px, ${e.clientY - r.top}px)`;\n        blot.classList.remove(\"w2ink-go\");\n        void blot.offsetWidth;\n        blot.classList.add(\"w2ink-go\");\n      };\n      root.addEventListener(\"pointerdown\", onDown);\n      return () => root.removeEventListener(\"pointerdown\", onDown);\n    }\n    root.setAttribute(\"data-on\", \"\");\n    const dots = Array.from(layer.children) as HTMLElement[];\n    const pts = dots.map(() => ({ x: -50, y: -50 }));\n    let tx = 0, ty = 0, live = false, frame = 0, idle = 0, t0 = performance.now();\n    const loop = (now: number) => {\n      if (!live) {\n        const t = (now - t0) / 1000;\n        tx = root.clientWidth * (0.5 + 0.34 * Math.sin(t * 0.85));\n        ty = root.clientHeight * (0.52 + 0.24 * Math.sin(t * 1.7));\n      }\n      pts.forEach((p, i) => {\n        const lead = i ? pts[i - 1] : { x: tx, y: ty };\n        const k = i ? TAIL_EASE : HEAD_EASE;\n        p.x += (lead.x - p.x) * k;\n        p.y += (lead.y - p.y) * k;\n        dots[i].style.transform = `translate(${p.x}px, ${p.y}px) scale(${1 - (i / DOTS) * 0.82})`;\n      });\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 = root.getBoundingClientRect();\n      tx = e.clientX - r.left; ty = e.clientY - r.top;\n      live = true; clearTimeout(idle);\n      root.removeAttribute(\"data-kb\");\n    };\n    const onLeave = () => { idle = window.setTimeout(() => { live = false; t0 = performance.now() - 2000; }, 1400); };\n    const onFocus = () => { if (root.querySelector(\":focus-visible\")) root.setAttribute(\"data-kb\", \"\"); };\n    const onBlur = () => root.removeAttribute(\"data-kb\");\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    root.addEventListener(\"focusin\", onFocus);\n    root.addEventListener(\"focusout\", onBlur);\n    return () => {\n      stop(); io.disconnect(); clearTimeout(idle);\n      root.removeAttribute(\"data-on\");\n      root.removeEventListener(\"pointermove\", onMove);\n      root.removeEventListener(\"pointerleave\", onLeave);\n      root.removeEventListener(\"focusin\", onFocus);\n      root.removeEventListener(\"focusout\", onBlur);\n    };\n  }, [reduce]);\n\n  return (\n    <section ref={rootRef} className=\"w2ink-root relative overflow-hidden px-5 py-14 sm:px-10 sm:py-20\">\n      <style>{`\n        .w2ink-root { background: radial-gradient(120% 90% at 20% 0%, #fbf7ef 0%, #f1e9da 60%, #e9dfcc 100%); color: #1d2433; }\n        .w2ink-layer { position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: 0; transition: opacity .4s ease; }\n        .w2ink-root[data-on] .w2ink-layer { opacity: 1; }\n        .w2ink-root[data-kb] .w2ink-layer { opacity: 0; }\n        .w2ink-dot { position: absolute; left: -7px; top: -7px; width: 14px; height: 14px; border-radius: 50%;\n          background: radial-gradient(circle at 38% 35%, #3b4a6b 0%, #1b2540 70%); will-change: transform; }\n        .w2ink-blot { position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; opacity: 0;\n          background: radial-gradient(circle, rgba(27,37,64,.35) 0%, rgba(27,37,64,0) 70%); pointer-events: none; }\n        .w2ink-blot.w2ink-go { animation: w2ink-spread .9s ease-out forwards; }\n        @keyframes w2ink-spread { from { opacity: 1; scale: .3 } to { opacity: 0; scale: 1.6 } }\n        @media (prefers-reduced-motion: reduce) { .w2ink-layer, .w2ink-blot { display: none; } }\n      `}</style>\n      <div ref={layerRef} className=\"w2ink-layer\" aria-hidden=\"true\">\n        {Array.from({ length: DOTS }, (_, i) => (\n          <span key={i} className=\"w2ink-dot\" style={{ opacity: 0.9 - (i / DOTS) * 0.8 }} />\n        ))}\n      </div>\n      <span ref={blotRef} className=\"w2ink-blot\" aria-hidden=\"true\" />\n      <div className=\"relative z-10 mx-auto max-w-5xl\">\n        <nav aria-label=\"Marlow and Finch\" className=\"flex flex-wrap items-center justify-between gap-4 text-sm\">\n          <a href=\"#\" className=\"rounded font-serif text-lg font-semibold tracking-tight focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#8a4b2a] focus-visible:ring-offset-4 focus-visible:ring-offset-[#f4eee2]\">Marlow &amp; Finch</a>\n          <ul className=\"flex gap-1 text-[#4a4f5c]\">\n            {[\"Notebooks\", \"Ink\", \"Workshop\"].map((l) => (\n              <li key={l}><a href=\"#\" className=\"inline-flex min-h-[40px] items-center rounded px-3 hover:text-[#1d2433] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#8a4b2a]\">{l}</a></li>\n            ))}\n          </ul>\n        </nav>\n        <div className=\"mt-14 max-w-2xl sm:mt-20\">\n          <p className=\"text-xs font-semibold uppercase tracking-[0.24em] text-[#8a4b2a]\">Spring stock, bound by hand</p>\n          <h1 className=\"mt-4 font-serif text-4xl leading-[1.08] tracking-tight sm:text-6xl\">Paper that holds a thought until you are ready for it.</h1>\n          <p className=\"mt-6 max-w-xl text-base leading-relaxed text-[#4a4f5c] sm:text-lg\">Notebooks and letter sets cut from heavy cotton stock, sewn in small runs and sent out wrapped in plain brown paper.</p>\n          <div className=\"mt-8 flex flex-wrap gap-3\">\n            <a href=\"#\" className=\"inline-flex min-h-[44px] items-center rounded-full bg-[#1d2433] px-6 text-sm font-semibold text-[#f6f1e7] shadow-[0_8px_24px_-12px_rgba(29,36,51,.6)] transition hover:bg-[#2c3550] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#8a4b2a] focus-visible:ring-offset-2 focus-visible:ring-offset-[#f4eee2]\">Browse the notebooks</a>\n            <a href=\"#\" className=\"inline-flex min-h-[44px] items-center rounded-full border border-[#1d2433]/25 bg-[#fbf8f2] px-6 text-sm font-semibold transition hover:border-[#1d2433]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#8a4b2a] focus-visible:ring-offset-2 focus-visible:ring-offset-[#f4eee2]\">Visit the shop</a>\n          </div>\n        </div>\n        <dl className=\"mt-14 grid gap-6 border-t border-[#1d2433]/15 pt-6 sm:grid-cols-3\">\n          {notes.map((n) => (\n            <div key={n.k}>\n              <dt className=\"text-xs font-semibold uppercase tracking-[0.18em] text-[#8a4b2a]\">{n.k}</dt>\n              <dd className=\"mt-1 text-sm text-[#3a3f4c]\">{n.v}</dd>\n            </div>\n          ))}\n        </dl>\n      </div>\n    </section>\n  );\n}\n"}]}
