// Shared layout: head + shell with Nav + Footer + WhatsApp.
// Each page calls: renderPage(<PageContent/>, { current: 'nosotras' })

function Shell({ children, current }) {
  return (
    <>
      <Nav current={current}/>
      <main>{children}</main>
      <Footer/>
      <WhatsApp/>
    </>
  );
}

function renderPage(content, opts = {}) {
  ReactDOM.createRoot(document.getElementById('root')).render(
    <Shell current={opts.current}>{content}</Shell>
  );

  // reveal-on-scroll
  const io = new IntersectionObserver((entries) => {
    entries.forEach(e => { if (e.isIntersecting) e.target.classList.add('in'); });
  }, { threshold: 0.12 });
  setTimeout(() => {
    document.querySelectorAll('.reveal').forEach(el => io.observe(el));
  }, 100);
}

window.Shell = Shell;
window.renderPage = renderPage;
