/* ============================================================
   EDITORIAL INDEX — app (production: no tweaks panel)
   ============================================================ */

function App() {
  const [lang, setLang] = useState(() => {
    try { return localStorage.getItem("ema_lang") || "lt"; } catch(e) { return "lt"; }
  });
  const setLangPersist = (l) => {
    setLang(l);
    try { localStorage.setItem("ema_lang", l); } catch(e) {}
    document.documentElement.lang = l;
  };
  const c = window.EMA_COPY[lang] || window.EMA_COPY["lt"];

  const [indexOpen, setIndexOpen] = useState(false);

  useEffect(() => { document.documentElement.lang = lang; }, [lang]);
  useEffect(() => { document.body.style.overflow = indexOpen ? "hidden" : ""; }, [indexOpen]);

  return (
    <React.Fragment>
      <RunningHead lang={lang} setLang={setLangPersist} onOpenIndex={() => setIndexOpen(true)} />
      <IndexOverlay lang={lang} open={indexOpen} onClose={() => setIndexOpen(false)} />

      <main>
        <Cover c={c} lang={lang} variant="fullbleed" />
        <CredentialMarquee c={c} />
        <About c={c} lang={lang} />
        <Reflections c={c} lang={lang} />
        <HowItWorks c={c} />
        <Services c={c} />
        <Voices c={c} />
        <Investment c={c} lang={lang} />
        <FinalCta c={c} lang={lang} />
      </main>
      <Colophon c={c} lang={lang} setLang={setLangPersist} />
    </React.Fragment>
  );
}

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