// Arise Helix — main App.

function App() {
  // Intercept in-page anchor clicks (href="#…") so the URL stays clean
  // (no "#section-id" added to the address bar) — smooth-scroll manually.
  React.useEffect(() => {
    const onClick = (e) => {
      const a = e.target.closest && e.target.closest('a[href^="#"]');
      if (!a) return;
      const hash = a.getAttribute("href");
      if (!hash || hash === "#") {
        e.preventDefault();
        window.scrollTo({ top: 0, behavior: "smooth" });
        return;
      }
      const id = hash.slice(1);
      const el = document.getElementById(id);
      if (!el) return;
      e.preventDefault();
      el.scrollIntoView({ behavior: "smooth", block: "start" });
    };
    document.addEventListener("click", onClick);

    // Strip any pre-existing hash that arrived via direct URL.
    if (window.location.hash) {
      history.replaceState(null, "", window.location.pathname + window.location.search);
    }
    return () => document.removeEventListener("click", onClick);
  }, []);

  return (
    <div className="relative" style={{ color: "#1F1F1F" }}>
      <ScrollVideoBg src="assets/dna-bg.mp4" />
      <CursorGlow />
      <HelixNav />
      <main className="relative z-10">
        <HeroSection />
        <AboutSection />
        <WhyChooseSection />
        <ProgramsSection />
        <LabSection />
        <TestimonialsSection />
        <FinalCTASection />
      </main>
    </div>
  );
}

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