// NextGen Ranking — minimal animation helpers.
const { useEffect, useRef, useState } = React;

// Stagger fade-in on scroll
function StaggerIn({ children, delay = 0, className = "" }) {
  const [shown, setShown] = useState(false);
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    const obs = new IntersectionObserver((entries) => {
      entries.forEach((ent) => { if (ent.isIntersecting) setShown(true); });
    }, { threshold: 0.05 });
    obs.observe(el);
    return () => obs.disconnect();
  }, []);
  return (
    <div
      ref={ref}
      className={"stagger-in " + className + (shown ? " stagger-in--on" : "")}
      style={{ transitionDelay: delay + "ms" }}
    >
      {children}
    </div>
  );
}

Object.assign(window, { StaggerIn });
