/* ───────────────────────────────────────────── AcquireNow — Shared React Nav Used by all secondary pages (services, about, case-studies, industries, contact, book-a-call) Rendered into ───────────────────────────────────────────── */ (function () { const { useState, useEffect, useRef } = React; const LINKS = [ { label: 'Services', href: 'services.html' }, { label: 'Case Studies', href: 'case-studies.html' }, { label: 'Industries', href: 'industries.html' }, { label: 'About', href: 'about.html' }, { label: 'Contact', href: 'contact.html' }, ]; function SiteNav() { const [open, setOpen] = useState(false); const [mobile, setMobile] = useState(window.innerWidth < 900); const navRef = useRef(null); const page = (window.location.pathname.split('/').pop() || '') .replace('.html', '') || 'home'; /* track viewport width */ useEffect(() => { const fn = () => setMobile(window.innerWidth < 900); window.addEventListener('resize', fn); return () => window.removeEventListener('resize', fn); }, []); /* close mobile menu on outside click */ useEffect(() => { if (!open) return; const fn = (e) => { if (navRef.current && !navRef.current.contains(e.target)) setOpen(false); }; document.addEventListener('mousedown', fn); return () => document.removeEventListener('mousedown', fn); }, [open]); /* lock body scroll when menu is open */ useEffect(() => { document.body.style.overflow = open ? 'hidden' : ''; return () => { document.body.style.overflow = ''; }; }, [open]); const isActive = (href) => page === href.replace('.html', ''); /* ── styles ── */ const linkStyle = (href) => ({ color: isActive(href) ? '#fff' : 'rgba(255,255,255,0.68)', fontSize: 13, fontFamily: 'Inter, sans-serif', fontWeight: isActive(href) ? 500 : 400, letterSpacing: '0.01em', padding: '7px 14px', borderRadius: 100, background: isActive(href) ? 'rgba(255,255,255,0.10)' : 'transparent', textDecoration: 'none', transition: 'all 0.2s', whiteSpace: 'nowrap', }); const mobileLinkStyle = (href) => ({ display: 'block', color: isActive(href) ? '#fff' : 'rgba(255,255,255,0.75)', fontSize: 17, fontFamily: 'Inter, sans-serif', fontWeight: isActive(href) ? 600 : 400, padding: '14px 20px', borderRadius: 10, background: isActive(href) ? 'rgba(255,255,255,0.09)' : 'transparent', textDecoration: 'none', borderBottom: '1px solid rgba(255,255,255,0.06)', transition: 'background 0.15s', }); return ( ); } /* Render into #nav-root on each secondary page */ const root = document.getElementById('nav-root'); if (root) { ReactDOM.createRoot(root).render(React.createElement(SiteNav)); } })();