// shared.jsx — Nav and Footer used on all pages
const SOCIAL = {
  instagram: 'https://instagram.com/itshannahzhang',
  linkedin: 'https://linkedin.com/in/hannahzhang0',
  tiktok: 'https://tiktok.com/@itshannahzhang',
  youtube: 'https://youtube.com/@itshannahzhang',
  newsletter: 'https://nonlinearnews.com',
};

// Inline SVG icons — Lucide style, stroke-width 1.75
const IconInstagram = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <rect x="3" y="3" width="18" height="18" rx="5" />
    <circle cx="12" cy="12" r="4" />
    <circle cx="17.5" cy="6.5" r="0.6" fill="currentColor" />
  </svg>
);
const IconLinkedIn = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <rect x="3" y="3" width="18" height="18" rx="3" />
    <line x1="8" y1="10" x2="8" y2="17" />
    <circle cx="8" cy="7.2" r="0.7" fill="currentColor" />
    <path d="M12 17v-4.5a2.5 2.5 0 0 1 5 0V17" />
    <line x1="12" y1="10" x2="12" y2="17" />
  </svg>
);
const IconTikTok = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <path d="M14 4v9.5a3.5 3.5 0 1 1-3.5-3.5" />
    <path d="M14 4c.4 2.4 2.1 4 4.5 4.4" />
  </svg>
);
const IconYouTube = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <rect x="2.5" y="6" width="19" height="12" rx="3" />
    <polygon points="10.5,9.5 15,12 10.5,14.5" fill="currentColor" stroke="none" />
  </svg>
);
const IconMail = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <rect x="3" y="5" width="18" height="14" rx="2.5" />
    <path d="M3.5 7l8.5 6 8.5-6" />
  </svg>
);
const IconMenu = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <line x1="4" y1="7" x2="20" y2="7" />
    <line x1="4" y1="12" x2="20" y2="12" />
    <line x1="4" y1="17" x2="20" y2="17" />
  </svg>
);
const IconClose = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    <line x1="6" y1="6" x2="18" y2="18" />
    <line x1="18" y1="6" x2="6" y2="18" />
  </svg>
);
const IconArrow = () => (
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" width="14" height="14" aria-hidden="true">
    <line x1="4" y1="12" x2="19" y2="12" />
    <polyline points="13,6 19,12 13,18" />
  </svg>
);

function Nav({ contactHref = '#contact', homeHref = 'index.html' }) {
  const resolvedContact = contactHref === '#contact' ? (typeof window !== 'undefined' && window.location.pathname.endsWith('index.html') || window.location.pathname.endsWith('/') ? '#contact' : 'index.html#contact') : contactHref;
  const [open, setOpen] = React.useState(false);
  return (
    <header className={'nav' + (open ? ' nav-mobile-open' : '')}>
      <a className="nav-brand" href="index.html">
        <span className="wm-blue">Hannah</span><span className="wm-burgundy">Zhang</span>
      </a>
      <button className="nav-toggle" aria-label="Menu" onClick={() => setOpen(!open)}>
        {open ? <IconClose /> : <IconMenu />}
      </button>
      <div className="nav-right">
        <div className="nav-icons">
          <a href={SOCIAL.instagram} target="_blank" rel="noopener" aria-label="Instagram"><IconInstagram /></a>
          <a href={SOCIAL.linkedin} target="_blank" rel="noopener" aria-label="LinkedIn"><IconLinkedIn /></a>
          <a href={SOCIAL.tiktok} target="_blank" rel="noopener" aria-label="TikTok"><IconTikTok /></a>
          <a href={SOCIAL.youtube} target="_blank" rel="noopener" aria-label="YouTube"><IconYouTube /></a>
        </div>
        <span className="nav-divider" />
        <div className="nav-text-links">
          <a href={SOCIAL.newsletter} target="_blank" rel="noopener">Newsletter</a>
          <a className="contact-link" href={resolvedContact}>Contact</a>
        </div>
      </div>
    </header>
  );
}

function Footer() {
  return (
    <footer className="footer">
      <div className="footer-inner">
        <div className="footer-row">
          <a className="footer-brand" href="index.html"><span className="wm-blue">Hannah</span><span className="wm-burgundy">Zhang</span></a>
          <div className="nav-icons" style={{ gap: 18 }}>
            <a href={SOCIAL.instagram} target="_blank" rel="noopener" aria-label="Instagram"><IconInstagram /></a>
            <a href={SOCIAL.linkedin} target="_blank" rel="noopener" aria-label="LinkedIn"><IconLinkedIn /></a>
            <a href={SOCIAL.tiktok} target="_blank" rel="noopener" aria-label="TikTok"><IconTikTok /></a>
            <a href={SOCIAL.youtube} target="_blank" rel="noopener" aria-label="YouTube"><IconYouTube /></a>
            <a href={SOCIAL.newsletter} target="_blank" rel="noopener" aria-label="Newsletter"><IconMail /></a>
          </div>
        </div>
        <div className="footer-base">
          <span>© 2026 Hannah Zhang</span>
          <span style={{ display: 'flex', gap: 24, flexWrap: 'wrap' }}>
            <a href="brand-partnerships.html" style={{ color: 'inherit', textDecoration: 'none' }}>Brand partnerships</a>
            <a href="press.html" style={{ color: 'inherit', textDecoration: 'none' }}>Press &amp; speaking</a>
            <a href="mailto:hannah@careerhannah.com?subject=Hello" style={{ color: 'inherit', textDecoration: 'none' }}>Email me</a>
          </span>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, {
  Nav, Footer, SOCIAL,
  IconInstagram, IconLinkedIn, IconTikTok, IconYouTube, IconMail, IconArrow, IconMenu, IconClose,
});
