/* ── Shared Hooks ── */

function useInView(ref, threshold) {
  const [vis, setVis] = React.useState(false);
  React.useEffect(() => {
    if (!ref.current) return;
    const obs = new IntersectionObserver(
      ([e]) => { if (e.isIntersecting) { setVis(true); obs.disconnect(); } },
      { threshold: threshold || 0.1 }
    );
    obs.observe(ref.current);
    return () => obs.disconnect();
  }, []);
  return vis;
}

window.useInView = useInView;
