/// file: public/assets/js/modules/magnetic.js

export function initMagnetic() {
  if (window.matchMedia('(max-width: 768px)').matches) return;
  document.querySelectorAll('.magnetic-button').forEach((btn) => {
    btn.addEventListener('pointermove', (e) => {
      const r = btn.getBoundingClientRect();
      const x = e.clientX - (r.left + r.width / 2);
      const y = e.clientY - (r.top + r.height / 2);
      btn.style.transform = `translate3d(${x * 0.15}px, ${y * 0.15}px, 0)`;
    });
    btn.addEventListener('pointerleave', () => {
      btn.style.transform = '';
    });
  });
}
