// utils.jsx — shared hooks
const { useEffect, useRef } = React;

function useReveal(ref) {
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const targets = el.querySelectorAll('.reveal');
    if (!targets.length) return;
    const observer = new IntersectionObserver(
      (entries) => entries.forEach(e => {
        if (e.isIntersecting) { e.target.classList.add('visible'); observer.unobserve(e.target); }
      }),
      { threshold: 0.10 }
    );
    targets.forEach(t => observer.observe(t));
    return () => observer.disconnect();
  }, []);
}

Object.assign(window, { useReveal });
