// Header.jsx — sticky header with wordmark + nav
function Header({ route, onNav, cartCount }) {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 8);
    window.addEventListener('scroll', onScroll);
    return () => window.removeEventListener('scroll', onScroll);
  }, []);

  const link = (id, label) => (
    <a
      className={route === id ? 'is-active' : ''}
      onClick={() => onNav(id)}
    >{label}</a>
  );

  return (
    <header className={'mys-header' + (scrolled ? ' is-scrolled' : '')}>
      <div className="mys-header-brand" onClick={() => onNav('home')}>
        <svg viewBox="0 0 320 80" style={{ height: 38 }}>
          <text x="10" y="50" fill="#3B2A14" style={{ fontFamily: "'Cormorant Garamond','EB Garamond',Georgia,serif", fontStyle: 'italic', fontWeight: 600, fontSize: 44 }}>Made Yours</text>
          <line x1="12" y1="62" x2="80" y2="62" stroke="#C8956C" strokeWidth="1.5"/>
          <text x="12" y="74" fill="#B4B2A9" style={{ fontFamily: "'Inter',system-ui,sans-serif", fontWeight: 500, fontSize: 9, letterSpacing: '2px' }}>EST. 2026 · OTTAWA</text>
        </svg>
      </div>
      <nav className="mys-nav">
        {link('home', 'Shop')}
        {link('custom', 'Custom')}
        {link('about', 'Our Story')}
        {link('contact', 'Contact')}
      </nav>
      <div className="mys-header-actions">
        <i data-lucide="search" style={{ width: 18, height: 18, color: 'var(--walnut)', strokeWidth: 1.5, cursor: 'pointer' }} />
        <button className="mys-btn mys-btn-ghost mys-btn-sm" onClick={() => onNav('cart')}>
          <i data-lucide="package" style={{ width: 16, height: 16, strokeWidth: 1.5 }} />
          Cart {cartCount > 0 && <span style={{ color: 'var(--ember)', fontWeight: 600 }}>· {cartCount}</span>}
        </button>
      </div>
    </header>
  );
}

window.Header = Header;
