"use client";

import AmbientScene from "./AmbientScene";
import HUD from "./HUD";
import ImmersiveFooter from "@/sections/immersive/Footer";
import { useLandingTheme } from "./useLandingTheme";

/**
 * Shell for marketing subpages styled after the immersive landing page:
 * the token scope, the ambient scene, the HUD header and the site footer,
 * without the landing page's preloader and ScrollSmoother — subpages scroll
 * natively, and the HUD's section links route back to the landing page.
 */
export default function ImmersivePage({ children }: { children: React.ReactNode }) {
  const { theme, toggleTheme } = useLandingTheme();

  return (
    <div
      className={`immersive relative min-h-screen${
        theme === "light" ? " immersive--light" : ""
      }`}
    >
      {/* Without JS the reveal animations never run, so everything they would
          have revealed must not be left sitting at opacity 0. */}
      <noscript>
        <style>{`.immersive [data-reveal],.immersive [data-reveal-text]{opacity:1!important}`}</style>
      </noscript>

      <AmbientScene theme={theme} />
      <HUD visible theme={theme} onToggleTheme={toggleTheme} />

      <main className="relative z-10 pt-24 lg:pt-[6.5rem]">
        {children}

        <div className="px-6 pb-12 lg:px-12">
          <div className="mx-auto w-full max-w-[88rem]">
            <ImmersiveFooter />
          </div>
        </div>
      </main>
    </div>
  );
}
