/* Upscale Homepage Hi-Fi — Nav + App entry (production build, no Tweaks panel) */

// Map nav label -> route hash
const navHrefFor = (label) => {
  const l = label.toLowerCase();
  if (l === 'use cases') return '#/use-cases';
  if (l === 'ressources' || l === 'resources') return '#/ressources';
  return '#';
};
const navigateTo = (e, href) => {
  if (href && href !== '#') {
    e.preventDefault();
    window.location.hash = href.replace(/^#/, '');
    window.scrollTo({ top: 0, behavior: 'auto' });
  }
};

const IconArticle = () => (
  <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/>
    <polyline points="14 2 14 8 20 8"/>
    <line x1="16" x2="8" y1="13" y2="13"/>
    <line x1="16" x2="8" y1="17" y2="17"/>
    <line x1="10" x2="8" y1="9" y2="9"/>
  </svg>
);

const NAV_DROPDOWN_ITEMS = (lang) => [
  {
    label: 'ARTICLES',
    title: lang === 'fr' ? 'Articles' : 'Articles',
    desc: lang === 'fr' ? 'Guides GTM, outbound et RevOps rédigés par notre équipe.' : 'GTM, outbound and RevOps guides written by our team.',
    tint: '#C8E6C9',
    icon: <IconArticle />,
    href: '#/ressources',
    isRoute: true,
  },
  {
    label: 'TOOLING',
    title: 'Best GTM Stack 2026',
    desc: lang === 'fr' ? 'Les meilleurs outils GTM testés chez nos clients.' : 'Best GTM tools tested in real client environments.',
    tint: '#E1FF6C',
    icon: <IconStack />,
    href: '#',
    badge: lang === 'fr' ? 'Bientôt disponible' : 'Coming soon',
  },
  {
    label: 'NEWSLETTER',
    title: lang === 'fr' ? 'Newsletter Upscale' : 'Upscale Newsletter',
    desc: lang === 'fr' ? 'Les meilleurs insights GTM chaque semaine.' : 'Top GTM insights every week.',
    tint: '#F4E89B',
    icon: <IconMail />,
    href: '#/newsletter',
    isRoute: true,
  },
  {
    label: lang === 'fr' ? 'VIDÉOS' : 'VIDEOS',
    title: lang === 'fr' ? 'Vidéos GTM' : 'GTM Videos',
    desc: lang === 'fr' ? 'Formats courts sur l\'outbound et le RevOps.' : 'Short formats on outbound and RevOps.',
    tint: '#D6CFC2',
    icon: <IconPlay />,
    href: 'https://www.youtube.com/@antoine_Guine/videos',
  },
];

const NavDropdown = ({ lang, onEnter, onLeave, onClose }) => {
  const items = NAV_DROPDOWN_ITEMS(lang);
  return (
    <div
      onMouseEnter={onEnter}
      onMouseLeave={onLeave}
      style={{
        position: 'fixed',
        top: 68,
        left: '50%',
        transform: 'translateX(-50%)',
        width: 'min(980px, calc(100vw - 48px))',
        display: 'flex',
        background: 'var(--paper)',
        border: '1px solid var(--line)',
        borderRadius: 20,
        boxShadow: '0 8px 16px -4px rgba(28,29,31,0.06), 0 32px 72px -20px rgba(28,29,31,0.24)',
        overflow: 'hidden',
        zIndex: 200,
        animation: 'dropdownEnter .22s cubic-bezier(0.22, 0.9, 0.32, 1) both',
      }}
    >
      {/* ── Left: resource links ── */}
      <div style={{ flex: 1, display: 'flex', flexDirection: 'column' }}>
        <p style={{
          fontSize: 10, fontFamily: 'var(--font-mono)', textTransform: 'uppercase',
          letterSpacing: '0.1em', color: 'var(--gray-3)',
          padding: '18px 24px 14px',
          borderBottom: '1px solid var(--line)',
        }}>{lang === 'fr' ? 'Ressources' : 'Resources'}</p>

        {items.map((it, i) => (
          <a
            key={i}
            href={it.href}
            onClick={it.isRoute ? (e) => { e.preventDefault(); window.location.hash = it.href.replace(/^#/, ''); window.scrollTo({ top: 0, behavior: 'auto' }); onClose && onClose(); } : undefined}
            style={{
              display: 'flex', alignItems: 'center', gap: 16,
              padding: '16px 24px',
              borderBottom: i < items.length - 1 ? '1px solid var(--line)' : 'none',
              textDecoration: 'none', color: 'inherit',
              transition: 'background .13s ease',
              flex: 1,
            }}
            onMouseEnter={(e) => { e.currentTarget.style.background = 'var(--bg-2)'; }}
            onMouseLeave={(e) => { e.currentTarget.style.background = 'transparent'; }}
          >
            <div style={{
              width: 32, height: 32, borderRadius: 8,
              background: 'var(--bg)',
              border: '1px solid var(--line-strong)',
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              flexShrink: 0, color: 'var(--gray-4)',
            }}>
              <span style={{ display: 'flex', transform: 'scale(0.78)' }}>{it.icon}</span>
            </div>
            <div style={{ flex: 1, minWidth: 0 }}>
              <p style={{ fontSize: 15, fontWeight: 600, color: 'var(--ink)', marginBottom: 3, display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
                {it.title}
                {it.badge && (
                  <span style={{
                    fontSize: 10.5, fontWeight: 700, letterSpacing: '0.02em',
                    textTransform: 'uppercase',
                    color: 'var(--accent-on)', background: 'var(--accent)',
                    border: '1px solid var(--accent-edge)',
                    padding: '2px 8px', borderRadius: 999, lineHeight: 1.4,
                  }}>{it.badge}</span>
                )}
              </p>
              <p style={{ fontSize: 13, color: 'var(--gray-3)', lineHeight: 1.4 }}>{it.desc}</p>
            </div>
            <span style={{ fontSize: 14, color: 'var(--gray-2)', flexShrink: 0 }}>→</span>
          </a>
        ))}
      </div>

      {/* ── Right: featured video ── */}
      <div style={{
        width: '44%',
        flexShrink: 0,
        background: 'var(--ink)',
        padding: '18px 20px 20px',
        display: 'flex', flexDirection: 'column', gap: 14,
      }}>
        <p style={{
          fontSize: 10, fontFamily: 'var(--font-mono)', textTransform: 'uppercase',
          letterSpacing: '0.1em', color: 'rgba(244,241,234,0.38)',
          paddingBottom: 14,
          borderBottom: '1px solid rgba(244,241,234,0.08)',
        }}>{lang === 'fr' ? 'À la une' : 'Featured Content'}</p>

        <div style={{
          borderRadius: 12, overflow: 'hidden',
          width: '100%', aspectRatio: '16/9',
          background: '#000', flexShrink: 0,
          position: 'relative',
        }}>
          <iframe
            src="https://www.youtube.com/embed/vhkt6vcSYDM?start=1&rel=0&modestbranding=1"
            title="Antoine Guiné"
            frameBorder="0"
            allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
            allowFullScreen
            style={{ display: 'block', width: '100%', height: '100%', position: 'absolute', inset: 0 }}
          ></iframe>
        </div>

      </div>
    </div>
  );
};

const Nav = ({ lang, onLangSwitch, hiddenByScroll }) => {
  const t = COPY[lang];
  const [scrolled, setScrolled] = useState(false);
  const [open, setOpen] = useState(false);
  const [dropOpen, setDropOpen] = useState(false);
  const dropTimer = useRef(null);
  const handleDropEnter = () => { clearTimeout(dropTimer.current); setDropOpen(true); };
  const handleDropLeave = () => { dropTimer.current = setTimeout(() => setDropOpen(false), 180); };
  useEffect(() => {
    const onHash = () => setDropOpen(false);
    window.addEventListener('hashchange', onHash);
    return () => window.removeEventListener('hashchange', onHash);
  }, []);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 20);
    window.addEventListener('scroll', onScroll);
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  useEffect(() => {
    document.body.style.overflow = open ? 'hidden' : '';
    return () => { document.body.style.overflow = ''; };
  }, [open]);

  return (
    <header style={{
      position: 'sticky', top: 0, zIndex: 50,
      padding: '14px 0',
      background: scrolled || open ? 'rgba(244,241,234,0.92)' : 'transparent',
      backdropFilter: scrolled || open ? 'blur(12px)' : 'none',
      WebkitBackdropFilter: scrolled || open ? 'blur(12px)' : 'none',
      borderBottom: scrolled && !hiddenByScroll ? '1px solid var(--line)' : '1px solid transparent',
      transform: hiddenByScroll && !open ? 'translateY(-110%)' : 'translateY(0)',
      opacity: hiddenByScroll && !open ? 0 : 1,
      transition: 'transform .4s cubic-bezier(0.22, 0.9, 0.32, 1), opacity .25s ease, background .2s, border-color .2s',
    }}>
      <div className="u-container" style={{ display: 'flex', alignItems: 'center', gap: 20 }}>
        <a href="#" onClick={(e) => { e.preventDefault(); window.location.hash = ''; window.scrollTo({ top: 0, behavior: 'auto' }); }} style={{ display: 'flex', alignItems: 'center', gap: 10, cursor: 'pointer', textDecoration: 'none', color: 'inherit' }}>
          <img src="https://img.logo.dev/up-scale.fr?token=pk_LbhDh0o7S7SEtCE7aOlL5Q&retina=true" width="32" height="32" alt="Upscale" style={{ borderRadius: 6, objectFit: 'contain' }}/>
          <span style={{ fontSize: 20, fontWeight: 600, letterSpacing: '-0.02em' }}>upscale</span>
        </a>
        <nav style={{ display: 'flex', gap: 28, marginLeft: 40, flex: 1 }}>
          {t.nav.map((n, i) => {
            const href = navHrefFor(n);
            const isRessources = href === '#/ressources';
            if (isRessources) {
              return (
                <div
                  key={i}
                  style={{ position: 'relative', display: 'flex', alignItems: 'center' }}
                  onMouseEnter={handleDropEnter}
                  onMouseLeave={handleDropLeave}
                >
                  <span
                    style={{ fontSize: 14, color: 'var(--gray-4)', cursor: 'default', display: 'flex', alignItems: 'center', gap: 4, userSelect: 'none' }}
                  >
                    {n}
                    <svg width="10" height="10" viewBox="0 0 10 10" fill="none" style={{ opacity: 0.5, transition: 'transform .2s ease', transform: dropOpen ? 'rotate(180deg)' : 'rotate(0deg)' }}>
                      <path d="M2 3.5L5 6.5L8 3.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round"/>
                    </svg>
                  </span>
                  {dropOpen && ReactDOM.createPortal(
                    <NavDropdown lang={lang} onEnter={handleDropEnter} onLeave={handleDropLeave} onClose={() => setDropOpen(false)} />,
                    document.body
                  )}
                </div>
              );
            }
            return (
              <a
                key={i}
                href={href}
                onClick={(e) => navigateTo(e, href)}
                style={{ fontSize: 14, color: 'var(--gray-4)', cursor: 'pointer' }}
              >{n}</a>
            );
          })}
        </nav>
        <a className="u-btn u-btn-ghost u-nav-desktop" href="https://upscale-platform.vercel.app/" target="_blank" rel="noopener noreferrer" style={{ padding: '8px 16px', fontSize: 14 }}>{t.cta.signin}</a>
        <a className="u-btn u-btn-primary u-nav-desktop" data-cal-link="antoineguine/appel-de-decouverte-website" data-cal-namespace="appel-de-decouverte-website" data-cal-config='{"layout":"month_view","useSlotsViewOnSmallScreen":"true"}' style={{ padding: '10px 20px', fontSize: 14, cursor: 'pointer' }}>{t.cta.book} →</a>

        {/* Hamburger — visible on tablet/mobile only */}
        <button
          type="button"
          aria-label={open ? 'Fermer le menu' : 'Ouvrir le menu'}
          aria-expanded={open}
          onClick={() => setOpen(o => !o)}
          className="u-nav-hamburger"
          style={{
            marginLeft: 'auto',
            width: 44, height: 44,
            display: 'none',
            alignItems: 'center', justifyContent: 'center',
            background: 'transparent',
            border: 'none',
            borderRadius: 0,
            cursor: 'pointer',
            padding: 0,
            outline: 'none'
          }}
        >
          <span style={{
            position: 'relative', display: 'block',
            width: 18, height: 12
          }}>
            <span style={{
              position: 'absolute', left: 0, right: 0,
              height: 2, borderRadius: 2, background: 'var(--ink)',
              top: open ? 5 : 0,
              transform: open ? 'rotate(45deg)' : 'rotate(0)',
              transition: 'transform .2s ease, top .2s ease, opacity .2s ease'
            }}></span>
            <span style={{
              position: 'absolute', left: 0, right: 0, top: 5,
              height: 2, borderRadius: 2, background: 'var(--ink)',
              opacity: open ? 0 : 1,
              transition: 'opacity .15s ease'
            }}></span>
            <span style={{
              position: 'absolute', left: 0, right: 0,
              height: 2, borderRadius: 2, background: 'var(--ink)',
              top: open ? 5 : 10,
              transform: open ? 'rotate(-45deg)' : 'rotate(0)',
              transition: 'transform .2s ease, top .2s ease'
            }}></span>
          </span>
        </button>
      </div>

      {/* Mobile drawer */}
      <div
        className={`u-nav-drawer${open ? ' is-open' : ''}`}
        aria-hidden={!open}
      >
        {(() => {
          const entries = [];
          t.nav.forEach((n) => {
            if (n === 'Ressources' || n === 'Resources') {
              entries.push({ kind: 'header', label: n });
              NAV_DROPDOWN_ITEMS(lang).forEach((it) => entries.push({ kind: 'sub', it }));
            } else {
              entries.push({ kind: 'link', label: n, href: navHrefFor(n) });
            }
          });
          return entries.map((en, i) => {
            if (en.kind === 'header') {
              return (
                <span
                  key={i}
                  className="u-nav-drawer-link"
                  style={{ '--i': i, fontSize: 13, fontWeight: 600, color: 'var(--gray-3)', textTransform: 'uppercase', letterSpacing: '0.08em', fontFamily: 'var(--font-mono)', padding: '18px 4px 10px', borderBottom: 'none', cursor: 'default', pointerEvents: 'none' }}
                >{en.label}</span>
              );
            }
            if (en.kind === 'sub') {
              const it = en.it;
              const isComingSoon = it.href === '#';
              const handleClick = (e) => {
                if (it.isRoute) { e.preventDefault(); window.location.hash = it.href.replace(/^#/, ''); window.scrollTo({ top: 0, behavior: 'auto' }); setOpen(false); }
                else if (isComingSoon) { e.preventDefault(); }
                else { setOpen(false); }
              };
              return (
                <a
                  key={i}
                  href={isComingSoon ? undefined : it.href}
                  target={(it.isRoute || isComingSoon) ? undefined : '_blank'}
                  rel={(it.isRoute || isComingSoon) ? undefined : 'noopener noreferrer'}
                  onClick={handleClick}
                  className="u-nav-drawer-link"
                  style={{ '--i': i, fontSize: 18, paddingLeft: 16, display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap', opacity: isComingSoon ? 0.6 : undefined }}
                >
                  {it.title}
                  {it.badge && (
                    <span style={{
                      fontSize: 10, fontWeight: 700, letterSpacing: '0.02em', textTransform: 'uppercase',
                      color: 'var(--accent-on)', background: 'var(--accent)',
                      border: '1px solid var(--accent-edge)', padding: '2px 8px', borderRadius: 999, lineHeight: 1.5
                    }}>{it.badge}</span>
                  )}
                </a>
              );
            }
            return (
              <a
                key={i}
                href={en.href}
                onClick={(e) => { navigateTo(e, en.href); setOpen(false); }}
                className="u-nav-drawer-link"
                style={{ '--i': i }}
              >{en.label}</a>
            );
          });
        })()}
        <div className="u-nav-drawer-ctas" style={{ '--i': t.nav.length + 4 }}>
          <a className="u-btn u-btn-primary" data-cal-link="antoineguine/appel-de-decouverte-website" data-cal-namespace="appel-de-decouverte-website" data-cal-config='{"layout":"month_view","useSlotsViewOnSmallScreen":"true"}' style={{ padding: '14px 22px', fontSize: 16, justifyContent: 'center', cursor: 'pointer' }} onClick={() => setOpen(false)}>{t.cta.book} →</a>
          <a className="u-btn u-btn-ghost" href="https://upscale-platform.vercel.app/" target="_blank" rel="noopener noreferrer" style={{ padding: '14px 22px', fontSize: 16, justifyContent: 'center' }} onClick={() => setOpen(false)}>{t.cta.signin}</a>
        </div>
      </div>
    </header>
  );
};

// Lucide-style inline icons (24x24, stroke-width 2)
const IconCalendar = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <rect width="18" height="18" x="3" y="4" rx="2" />
    <path d="M16 2v4M8 2v4M3 10h18" />
  </svg>
);
const IconLogin = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4" />
    <polyline points="10 17 15 12 10 7" />
    <line x1="15" x2="3" y1="12" y2="12" />
  </svg>
);
const IconBriefcase = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <rect width="20" height="14" x="2" y="7" rx="2" />
    <path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16" />
  </svg>
);
const IconBook = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" />
    <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" />
  </svg>
);

const FloatingDock = ({ lang, visible }) => {
  const items = lang === 'fr' ? [
    { type: 'cal', label: 'Prendre RDV', icon: <IconCalendar /> },
    { type: 'link', label: 'Connexion', icon: <IconLogin />, href: 'https://upscale-platform.vercel.app/' },
    { type: 'route', label: 'Use Cases', icon: <IconBriefcase />, hash: '#/use-cases' },
    { type: 'route', label: 'Ressources', icon: <IconBook />, hash: '#/ressources' }
  ] : [
    { type: 'cal', label: 'Book a call', icon: <IconCalendar /> },
    { type: 'link', label: 'Sign in', icon: <IconLogin />, href: 'https://upscale-platform.vercel.app/' },
    { type: 'route', label: 'Use Cases', icon: <IconBriefcase />, hash: '#/use-cases' },
    { type: 'route', label: 'Resources', icon: <IconBook />, hash: '#/ressources' }
  ];

  return (
    <div className={`u-dock${visible ? ' is-visible' : ''}`} aria-hidden={!visible}>
      <div className="u-dock-inner">
        {items.map((it, i) => {
          const inner = (
            <>
              <span className="u-dock-icon">{it.icon}</span>
              <span className="u-dock-tip">{it.label}</span>
            </>
          );
          if (it.type === 'cal') {
            return (
              <a
                key={i}
                className="u-dock-item is-primary"
                aria-label={it.label}
                role="button"
                tabIndex={0}
                style={{ cursor: 'pointer' }}
                data-cal-link="antoineguine/appel-de-decouverte-website"
                data-cal-namespace="appel-de-decouverte-website"
                data-cal-config='{"layout":"month_view","useSlotsViewOnSmallScreen":"true"}'
              >{inner}</a>
            );
          }
          if (it.type === 'link') {
            return (
              <a
                key={i}
                className="u-dock-item"
                aria-label={it.label}
                href={it.href}
                target="_blank"
                rel="noopener noreferrer"
              >{inner}</a>
            );
          }
          if (it.type === 'route') {
            return (
              <a
                key={i}
                className="u-dock-item"
                aria-label={it.label}
                href={it.hash}
                onClick={(e) => navigateTo(e, it.hash)}
              >{inner}</a>
            );
          }
          return (
            <button key={i} type="button" className="u-dock-item" aria-label={it.label}>{inner}</button>
          );
        })}
      </div>
    </div>
  );
};

const HomePage = ({ lang }) => (
  <>
    <Hero variant="terminal" lang={lang} tone="pro" accent="lime" />
    <LogosStrip lang={lang} />
    {/* <ProblemSection lang={lang} /> — masquée temporairement, réactiver si besoin */}
    <SolutionSection lang={lang} />
    <AgentsHeroSection lang={lang} />
    <SetupAnimatedSection lang={lang} />
    <CasesSectionDark lang={lang} />
    <TeamCollectifSection lang={lang} />
    <ContenuSection lang={lang} />
    <FaqSection lang={lang} />
    <CtaFinal lang={lang} />
  </>
);

function App() {
  const [lang, setLang] = useState('fr');
  const [navHidden, setNavHidden] = useState(false);
  const [route, setRoute] = useState(window.location.hash || '');
  const [copyVersion, setCopyVersion] = useState(0);
  useEffect(() => {
    const onCopyUpdate = () => setCopyVersion(v => v + 1);
    window.addEventListener('copy-updated', onCopyUpdate);
    return () => window.removeEventListener('copy-updated', onCopyUpdate);
  }, []);
  useEffect(() => {
    let lastY = window.scrollY;
    let idleTimer = null;
    const show = () => setNavHidden(false);
    const resetIdle = () => { clearTimeout(idleTimer); idleTimer = setTimeout(show, 5000); };
    const onScroll = () => {
      const y = window.scrollY;
      if (y < 80) { setNavHidden(false); }
      else if (y < lastY) { setNavHidden(false); }   // scrolling up
      else if (y > lastY + 4) { setNavHidden(true); } // scrolling down (4px threshold to avoid jitter)
      lastY = y;
      resetIdle();
    };
    const onActivity = () => resetIdle();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('mousemove', onActivity, { passive: true });
    window.addEventListener('touchstart', onActivity, { passive: true });
    resetIdle();
    const onHash = () => {
      setRoute(window.location.hash || '');
      window.scrollTo({ top: 0, behavior: 'auto' });
    };
    window.addEventListener('hashchange', onHash);
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('mousemove', onActivity);
      window.removeEventListener('touchstart', onActivity);
      window.removeEventListener('hashchange', onHash);
      clearTimeout(idleTimer);
    };
  }, []);

  const caseSlugMatch = route.match(/^#\/use-cases\/([\w-]+)$/);
  const caseSlug = caseSlugMatch ? caseSlugMatch[1] : null;
  const isUseCasesList = route === '#/use-cases';
  const resourceSlugMatch = route.match(/^#\/ressources\/([\w-]+)$/);
  const resourceSlug = resourceSlugMatch ? resourceSlugMatch[1] : null;
  const isResourcesList = route === '#/ressources';
  const isNewsletter = route === '#/newsletter';
  const isLegalNotice = route === '#/mentions-legales';
  const isPrivacy = route === '#/politique-confidentialite';

  let page;
  if (caseSlug) page = <CaseStudyPage slug={caseSlug} lang={lang} />;
  else if (isUseCasesList) page = <UseCasesPage lang={lang} />;
  else if (resourceSlug) page = <ResourcePage slug={resourceSlug} lang={lang} />;
  else if (isResourcesList) page = <ResourcesPage lang={lang} />;
  else if (isNewsletter) page = <NewsletterPage lang={lang} />;
  else if (isLegalNotice) page = <LegalNoticePage lang={lang} />;
  else if (isPrivacy) page = <PrivacyPolicyPage lang={lang} />;
  else page = <HomePage lang={lang} />;

  return (
    <>
      <Nav lang={lang} onLangSwitch={() => setLang(lang === 'fr' ? 'en' : 'fr')} hiddenByScroll={navHidden} />
      {page}
      <Footer lang={lang} />
    </>
  );
}

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