'use client'; import React, { useEffect, useRef, useState } from 'react'; export function CursorAura() { const [mounted, setMounted] = useState(false); const posRef = useRef({ targetX: -500, targetY: -500, currentX: -500, currentY: -500 }); const auraRef = useRef(null); useEffect(() => { try { if (typeof window === 'undefined') return; if (window.matchMedia && window.matchMedia('(pointer: coarse)').matches) return; if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; setMounted(true); } catch { return; } const onMouseMove = (e: MouseEvent) => { posRef.current.targetX = e.clientX; posRef.current.targetY = e.clientY; }; window.addEventListener('mousemove', onMouseMove, { passive: true }); let animId: number; const render = () => { const pos = posRef.current; // Damped lerp follower pos.currentX += (pos.targetX - pos.currentX) * 0.08; pos.currentY += (pos.targetY - pos.currentY) * 0.08; if (auraRef.current) { auraRef.current.style.transform = `translate3d(${pos.currentX - 250}px, ${pos.currentY - 250}px, 0)`; } animId = requestAnimationFrame(render); }; animId = requestAnimationFrame(render); return () => { cancelAnimationFrame(animId); window.removeEventListener('mousemove', onMouseMove); }; }, []); if (!mounted) return null; return (