{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"difference-blend-dot-cursor-inverting-big-type","type":"registry:block","title":"Difference Blend Dot Cursor","description":"","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/difference-blend-dot-cursor-inverting-big-type.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\nconst EASE = 0.2; // how quickly the dot follows (0 to 1)\nconst REST = 0.3; // dot scale away from the type and links\nconst SIZE = 132; // full dot diameter in px\n\nexport default function DifferenceBlendDotCursorInvertingBigType() {\n  const reduce = useReducedMotion();\n  const rootRef = useRef<HTMLElement>(null);\n  const dotRef = useRef<HTMLSpanElement>(null);\n  const bigRef = useRef<HTMLHeadingElement>(null);\n\n  useEffect(() => {\n    const root = rootRef.current, dot = dotRef.current, big = bigRef.current;\n    if (!root || !dot || !big || reduce || !matchMedia(\"(hover: hover) and (pointer: fine)\").matches) return;\n    root.setAttribute(\"data-on\", \"\");\n    let x = -200, y = -200, s = REST, tx = 0, ty = 0, ts = REST, live = false, frame = 0, idle = 0;\n    const t0 = performance.now();\n    const loop = (now: number) => {\n      if (!live) {\n        // Idle demo: drift over the big word, swelling as it crosses the letters.\n        const t = (now - t0) / 1000, o = root.getBoundingClientRect(), b = big.getBoundingClientRect();\n        tx = b.left - o.left + b.width * (0.3 + 0.24 * Math.sin(t * 0.6));\n        ty = b.top - o.top + b.height * (0.5 + 0.45 * Math.sin(t * 1.3));\n        ts = 1;\n      }\n      x += (tx - x) * EASE; y += (ty - y) * EASE; s += (ts - s) * 0.14;\n      dot.style.transform = `translate(${x}px, ${y}px) scale(${s})`;\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 o = root.getBoundingClientRect();\n      tx = e.clientX - o.left; ty = e.clientY - o.top;\n      ts = (e.target as HTMLElement).closest(\"[data-grow]\") ? 1 : REST;\n      live = true; clearTimeout(idle); root.removeAttribute(\"data-kb\");\n    };\n    const onLeave = () => { ts = REST; 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    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=\"w2dif-root relative isolate overflow-hidden bg-[#ece6da] px-5 py-12 text-[#121212] sm:px-12 sm:py-14\">\n      <style>{`\n        .w2dif-dot { position: absolute; left: 0; top: 0; width: ${SIZE}px; height: ${SIZE}px; margin: ${-SIZE / 2}px 0 0 ${-SIZE / 2}px; border-radius: 50%;\n          background: #fff; mix-blend-mode: difference; pointer-events: none; opacity: 0; transition: opacity .3s ease; will-change: transform; }\n        .w2dif-root[data-on] .w2dif-dot { opacity: 1; }\n        .w2dif-root[data-kb] .w2dif-dot { opacity: 0; }\n        @media (prefers-reduced-motion: reduce) { .w2dif-dot { display: none; } }\n      `}</style>\n      <div className=\"mx-auto max-w-6xl\">\n        <div className=\"flex flex-wrap items-center justify-between gap-4\">\n          <p className=\"text-xs font-semibold uppercase tracking-[0.2em]\">Orrery Type, specimen sheet</p>\n          <a href=\"#\" data-grow className=\"inline-flex min-h-[40px] items-center text-sm font-semibold underline underline-offset-4 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-[#c2410c] focus-visible:ring-offset-4 focus-visible:ring-offset-[#ece6da]\">Download trial fonts</a>\n        </div>\n        <h2 ref={bigRef} data-grow className=\"my-8 text-[clamp(3rem,14vw,11.5rem)] font-black uppercase leading-[0.86] tracking-[-0.05em]\">\n          <span className=\"block\">Hollis</span> <span className=\"block sm:pl-[0.5em]\">Grotesk</span> <span className=\"block\">Heavy</span>\n        </h2>\n        <div className=\"flex flex-wrap items-center justify-between gap-4\">\n          <p className=\"max-w-[26rem] leading-relaxed\">A wide, low-contrast sans drawn for signage, posters and anything read from across a room.</p>\n          <a href=\"#\" data-grow className=\"inline-flex min-h-[48px] items-center rounded-full bg-[#121212] px-[26px] text-[15px] font-bold text-[#ece6da] focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-[#c2410c] focus-visible:ring-offset-4 focus-visible:ring-offset-[#ece6da]\">License the family</a>\n        </div>\n      </div>\n      <span ref={dotRef} className=\"w2dif-dot\" aria-hidden=\"true\" />\n    </section>\n  );\n}\n"}]}
