/* Shared reveal hook. The Opportunity block was removed 2026-08-01: it was never
   mounted in app.jsx, duplicated the forecast.jsx headline (drift risk), and held a
   phantom "Figure 01" that made the live figure sequence start at 02. */

/* Section eyebrow + reveal hook */
function useReveal() {
  const ref = React.useRef(null);
  React.useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const nodes = [...el.querySelectorAll('.reveal')];
    const show = (n) => { n.classList.add('in'); n.style.opacity = '1'; n.style.transform = 'none'; };
    if (!('IntersectionObserver' in window)) { nodes.forEach(show); return; }
    const obs = new IntersectionObserver((entries) => {
      entries.forEach(e => { if (e.isIntersecting) { show(e.target); obs.unobserve(e.target); } });
    }, { threshold: 0, rootMargin: '0px 0px -8% 0px' });
    nodes.forEach(n => {
      obs.observe(n);
      const r = n.getBoundingClientRect();
      if (r.top < window.innerHeight * 0.95 && r.bottom > 0) show(n);
    });
    // safety net: never leave content hidden even if IO is unreliable
    const t = setTimeout(() => nodes.forEach(show), 1500);
    return () => { obs.disconnect(); clearTimeout(t); };
  }, []);
  return ref;
}

window.useReveal = useReveal;
