// Trivan v3 — application : révélation au scroll, assemblage

function useV3Reveal(deps) {
  React.useEffect(() => {
    const els = Array.from(document.querySelectorAll("[data-reveal]"));
    let ticking = false;
    const check = () => {
      ticking = false;
      const vh = window.innerHeight;
      els.forEach((el) => {
        if (el.classList.contains("in")) return;
        const r = el.getBoundingClientRect();
        if (r.top < vh - 40 && r.bottom > 0) el.classList.add("in");
      });
    };
    const onScroll = () => {
      if (!ticking) {
        ticking = true;
        requestAnimationFrame(check);
      }
    };
    check();
    const t = setTimeout(check, 120);
    window.addEventListener("scroll", onScroll, { passive: true });
    window.addEventListener("resize", onScroll);
    return () => {
      clearTimeout(t);
      window.removeEventListener("scroll", onScroll);
      window.removeEventListener("resize", onScroll);
    };
  }, deps);
}

function TrivanV3App() {
  useV3Reveal([]);

  return (
    <div>
      <TrivanNav page="home" />
      <V3Hero />
      <V3Band />
      <main>
        <V3Clients />
        <V3Router />
        <V3Features />
        <V3Steps />
        <V3Numbers />
        <V3Integrations />
        <V3Testimonials />
        <V3Faq />
      </main>
      <V3Contact />
      <TrivanFooter />
    </div>
  );
}

ReactDOM.createRoot(document.getElementById("root")).render(<TrivanV3App />);
