'use client' // MagneticButton — isolated client component (rerender-no-inline-components rule) // Never define this inside HeroSection or any parent component // Uses framer-motion useMotionValue + useSpring for magnetic pull // useMotionValue lives OUTSIDE render cycle — no useState performance collapse import { useRef } from 'react' import { motion, useMotionValue, useSpring } from 'framer-motion' interface MagneticButtonProps { children: React.ReactNode href: string className?: string } export function MagneticButton({ children, href, className }: MagneticButtonProps) { const ref = useRef(null) // useMotionValue is outside render — no re-renders on mouse move const x = useMotionValue(0) const y = useMotionValue(0) const springX = useSpring(x, { stiffness: 150, damping: 15 }) const springY = useSpring(y, { stiffness: 150, damping: 15 }) const handleMouseMove = (e: React.MouseEvent) => { if (!ref.current) return const rect = ref.current.getBoundingClientRect() const cx = rect.left + rect.width / 2 const cy = rect.top + rect.height / 2 x.set((e.clientX - cx) * 0.3) y.set((e.clientY - cy) * 0.3) } const handleMouseLeave = () => { x.set(0) y.set(0) } return ( {children} {/* Button-in-button trailing icon — icon wrapped in its own circle */} ) }