"use client";

import { useEffect, useState } from "react";
import SmoothScroll from "@/components/SmoothScroll";
import EntranceExperience from "@/components/EntranceExperience";
import RestaurantStory from "@/components/RestaurantStory";
import ChefShowcase from "@/components/ChefShowcase";
import SpatialSanctuary from "@/components/SpatialSanctuary";
import EventsAccordion from "@/components/EventsAccordion";
import MenuPreview from "@/components/MenuPreview";
import CulinaryCategories from "@/components/CulinaryCategories";
import Footer from "@/components/Footer";

import CustomCursor from "@/components/CustomCursor";
import SoundManager from "@/components/SoundManager";
import Header from "@/components/Header";

export default function Home() {
  const [mounted, setMounted] = useState(false);
  const [headerVisible, setHeaderVisible] = useState(false);

  useEffect(() => {
    setMounted(true);
  }, []);

  return (
    <main className="w-full relative bg-darkbg text-foreground overflow-hidden select-none">
      {/* Isolated wrapper for client-only widgets to prevent hydration insertion conflicts */}
      <div id="client-only-widgets">
        {mounted && <SoundManager />}
        {mounted && <CustomCursor />}
        {mounted && <Header visible={headerVisible} />}
      </div>

      {/* Lenis Scroll syncing with GSAP triggers */}
      <SmoothScroll>
        
        {/* Sections 1 & 2: Landing Exterior Zoom & Door opening into Welcome reception */}
        <EntranceExperience onProgress={(p) => {
          console.log("[DEBUG onProgress]", p, "headerVisible:", p > 0.95);
          setHeaderVisible(p > 0.95);
        }} />

        {/* Section 3: Heritage Story timeline */}
        <RestaurantStory />

        {/* Section 3.5: Culinary Categories */}
        <CulinaryCategories />

        {/* Section 4: Premium Breakfast Menu Card Section */}
        <MenuPreview />

        {/* Section 5: Chef Sundaram showcase with canvas heat waves */}
        <ChefShowcase />

        {/* Section 5.5: The Spatial Sanctuary details */}
        <SpatialSanctuary />

        {/* Section 8: Expanding Special Events Accordion */}
        <EventsAccordion />

        {/* Section 12: Footer with hanging Toran, contact logs and floating diyas */}
        <Footer />

      </SmoothScroll>
    </main>
  );
}
