import React from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Link, useLocation } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; import logo from '../assets/logo.png'; import { useTranslation } from 'react-i18next'; import { getLandingCopy } from '../features/landing/landingCopy'; const Layout = ({ children }) => { const { user } = useAuth(); const location = useLocation(); const isLanding = location.pathname === '/'; const [isMobileMenuOpen, setIsMobileMenuOpen] = React.useState(false); const { i18n } = useTranslation(); const copy = getLandingCopy(i18n.language).nav; const isUk = i18n.language?.startsWith('uk'); const toggleLanguage = () => { const next = isUk ? 'en' : 'uk'; i18n.changeLanguage(next); try { localStorage.setItem('language', next); } catch { /* ignore */ } }; const navItems = [ { name: copy.product, href: '#product' }, { name: copy.how, href: '#how-it-works' }, { name: copy.templates, href: '#templates' }, { name: copy.pricing, href: '#pricing' } ]; const [activeSection, setActiveSection] = React.useState('#product'); React.useEffect(() => { if (!isLanding) return; const timer = setTimeout(() => { const observerOptions = { root: null, rootMargin: '-30% 0px -60% 0px', threshold: 0 }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { if (entry.target.id === 'hero') { setActiveSection('#product'); } else { setActiveSection(`#${entry.target.id}`); } } }); }, observerOptions); const sectionsToObserve = ['hero', 'product', 'how-it-works', 'templates', 'pricing']; sectionsToObserve.forEach(id => { const el = document.getElementById(id); if (el) observer.observe(el); }); return () => observer.disconnect(); }, 100); return () => clearTimeout(timer); }, [isLanding]); return (