// Main app
useReveal; // ensure parsed

const LanguageContext = React.createContext();

const App = () => {
  const [lang, setLang] = React.useState('uz');
  
  const t = (key) => {
    return window.dict[lang][key] || key;
  };

  useReveal();
  // Smooth-scroll for anchor links
  React.useEffect(()=>{
    const onClick = (e)=>{
      const a = e.target.closest && e.target.closest('a[href^="#"]');
      if (!a) return;
      const id = a.getAttribute('href').slice(1);
      if (!id) return;
      const el = document.getElementById(id);
      if (el){ e.preventDefault(); window.scrollTo({ top: el.offsetTop - 20, behavior:'smooth' }); }
    };
    document.addEventListener('click', onClick);
    return ()=>document.removeEventListener('click', onClick);
  },[]);

  const value = { lang, setLang, t };

  return (
    <LanguageContext.Provider value={value}>
      <Cursor/>
      <Nav/>
      <main>
        <Hero/>
        <About/>
        <Stats/>
        <Skills/>
        <Work/>
        <Clients/>
        <Testimonials/>
        <Pricing/>
        <Contact/>
        <Footer/>
      </main>
    </LanguageContext.Provider>
  );
};

// Export context for components
window.LanguageContext = LanguageContext;

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