// app.jsx — composes the landing page; CTAs scroll to the integrated contact form
function App() {
  // smooth-scroll to the contact section (no scrollIntoView)
  const goToContact = React.useCallback(() => {
    const el = document.getElementById("contact");
    if (!el) return;
    const y = el.getBoundingClientRect().top + window.pageYOffset - 12;
    window.scrollTo({ top: y, behavior: "smooth" });
    const first = el.querySelector("input, textarea");
    if (first) setTimeout(() => first.focus({ preventScroll: true }), 520);
  }, []);

  // scroll-reveal (getBoundingClientRect based — robust in all preview frames)
  React.useEffect(() => {
    const els = Array.from(document.querySelectorAll(".reveal"));
    const check = () => {
      const vh = window.innerHeight || document.documentElement.clientHeight;
      for (let i = els.length - 1; i >= 0; i--) {
        const el = els[i];
        const top = el.getBoundingClientRect().top;
        if (top < vh * 0.92) {
          el.classList.add("in");
          els.splice(i, 1);
        }
      }
      if (els.length === 0) {
        window.removeEventListener("scroll", check);
        window.removeEventListener("resize", check);
      }
    };
    check();
    window.addEventListener("scroll", check, { passive: true });
    window.addEventListener("resize", check);
    return () => {
      window.removeEventListener("scroll", check);
      window.removeEventListener("resize", check);
    };
  }, []);

  // (re)draw lucide icons after each render
  React.useEffect(() => {
    if (window.lucide) window.lucide.createIcons();
  });

  return (
    <React.Fragment>
      <Nav onCta={goToContact} />
      <main>
        <Hero onCta={goToContact} />
        <div className="wrap"><hr className="rule" /></div>
        <Distinguish />
        <Spine />
        <Deliverables />
        <Format />
        <Intervenants />
        <ClosingCTA onCta={goToContact} />
        <Contact />
      </main>
      <Footer />
    </React.Fragment>
  );
}

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