// Moisturising L3 — app

function MoistApp() {
  const [t, setTweak] = useTweaks(window.TWEAK_DEFAULTS);

  React.useEffect(() => {
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting) { e.target.classList.add("in"); io.unobserve(e.target); } });
    }, { threshold: 0.08, rootMargin: "0px 0px -40px 0px" });
    const scan = () => {
      document.querySelectorAll(".reveal:not(.in)").forEach((el) => {
        const r = el.getBoundingClientRect();
        if (r.top < window.innerHeight && r.bottom > 0) el.classList.add("in");
        else io.observe(el);
      });
    };
    scan();
    const mo = new MutationObserver(scan);
    mo.observe(document.body, { childList: true, subtree: true });
    return () => { io.disconnect(); mo.disconnect(); };
  }, []);

  React.useEffect(() => {
    const b = document.body;
    b.classList.remove("fp-playfair-dmsans", "fp-dmserif-dmsans", "fp-fraunces-inter");
    b.classList.add(`fp-${t.fontPairing}`);
    b.classList.remove("ac-coral", "ac-oxblood", "ac-champagne", "ac-terracotta", "ac-bronze");
    b.classList.add(`ac-${t.accent}`);
    b.classList.toggle("dark", !!t.dark);
    b.classList.remove("cs-editorial", "cs-rounded", "cs-framed", "cs-minimal");
    b.classList.add(`cs-${t.cardStyle || "editorial"}`);
  }, [t.fontPairing, t.accent, t.dark, t.cardStyle]);

  return (
    <>
      <Header onDark={false} />

      <nav className="crumb" aria-label="Breadcrumb">
        <a href="Landing Page.html">Home</a>
        <span className="sl">/</span>
        <a href="Skin.html">Skin</a>
        <span className="sl">/</span>
        <span className="cur">Moisturising</span>
      </nav>

      <div className="l2" data-screen-label="Moisturising L3">
        <MoistSidebar activeId="moisturising" />
        <main className="l2-main">
          <MoistHero />
          <SiblingRail />

          <SectionHead n="I." eyebrow="By skin type · Four sub-chapters" h={<>Start with the skin you <em>have</em> today.</>} link="Jump to ↓" />
          <TypeSpreads />

          <SectionHead n="II." eyebrow="Order of operations" h={<>The <em>layering</em> technique.</>} />
          <LayerTechnique />

          <SectionHead n="III." eyebrow="You've asked" h={<>Four <em>honest</em> answers.</>} />
          <MoistFAQ />

          <SectionHead n="IV." eyebrow="Related" h={<>Everything else in <em>moisturising.</em></>} link="Full index" />
          <MoistRelated />

          <SectionHead n="V." eyebrow="From the desk" h={<>More <em>reading.</em></>} link="All from Nelly" />
          <MoistReads />

          <MoistNext />
        </main>
      </div>

      <NellyTop3 category="moisturising" />
      <Newsletter />
      <Footer />
    </>
  );
}

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