// Nav — Apple glass bar with ASEPTIC wordmark on the left
function Nav({ lang, setLang }) {
  const links = [
    { id: 'solutions',    label: COPY.nav.products },
    { id: 'capabilities', label: COPY.nav.capabilities },
    { id: 'about',        label: COPY.nav.about },
    { id: 'contact',      label: COPY.nav.contact },
  ];

  const go = (e, id) => {
    e.preventDefault();
    const el = document.getElementById(id);
    if (el) window.scrollTo({ top: el.offsetTop - 48, behavior: 'smooth' });
  };

  const onLang = (e, next) => {
    e.preventDefault();
    if (setLang) setLang(next);
  };

  return (
    <nav className="apple-nav" aria-label="Primary">
      <div className="apple-nav-inner" style={{maxWidth: 1180}}>
        <a href="#top" onClick={(e)=>{e.preventDefault(); window.scrollTo({top:0, behavior:'smooth'});}}
           aria-label="Aseptic Healthcare — home"
           style={{display:'inline-flex', alignItems:'center', textDecoration:'none'}}>
          <img src="assets/aseptic-wordmark-white.png" alt="ASEPTIC"
               style={{height: 16, width: 'auto', display:'block', opacity: 0.96}} />
        </a>

        <div style={{display:'flex', alignItems:'center', gap: 2}}>
          {links.map(l => (
            <a key={l.id} href={`#${l.id}`} onClick={(e)=>go(e, l.id)} className="apple-nav-link">
              {pick(l.label, lang)}
            </a>
          ))}
          <a href="mailto:aseptichc@gmail.com" className="apple-nav-link"
             style={{marginLeft: 4, paddingLeft: 10, opacity: 0.96}}
             aria-label="Email Aseptic Healthcare">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
                 strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"
                 style={{verticalAlign:'-2px'}}>
              <rect x="3" y="5" width="18" height="14" rx="2"></rect>
              <path d="M3 7l9 6 9-6"></path>
            </svg>
          </a>

          <div className="apple-lang-switch" role="group" aria-label="Language">
            <a href="?lang=ko" onClick={(e)=>onLang(e, 'ko')}
               className={`apple-lang-link ${lang === 'ko' ? 'is-active' : ''}`}
               aria-current={lang === 'ko' ? 'true' : undefined}
               aria-label="한국어">KO</a>
            <span className="apple-lang-sep" aria-hidden="true">·</span>
            <a href="?lang=en" onClick={(e)=>onLang(e, 'en')}
               className={`apple-lang-link ${lang === 'en' ? 'is-active' : ''}`}
               aria-current={lang === 'en' ? 'true' : undefined}
               aria-label="English">EN</a>
          </div>
        </div>
      </div>
    </nav>
  );
}

Object.assign(window, { Nav });
