/* ============================================================
   Asher Encounters — site chrome: sticky Nav + Footer
   Nav keeps the "Book a Tour" CTA visible at every viewport
   (never hidden behind the hamburger). Pass `current` = the
   page's filename to mark the active link.
   ============================================================ */
(function () {
  const DS = window.AsherEncountersDesignSystem_12251c;
  const { Button } = DS;
  const { BookButton } = window.Asher;
  const R = React;

  /* ---- Brand logo (new monogram lockup — mark · divider · stacked wordmark) ---- */
  function NewLockup({ onDark, scale = 1 }) {
    const markSrc = onDark ? 'assets/mark2-lavender.png' : 'assets/mark2-violet.png';
    const asherCol = onDark ? 'var(--lavender)' : '#5246C0';
    const enc = onDark ? 'var(--paper)' : '#5246C0';
    const divider = onDark ? 'var(--border-on-dark)' : 'rgba(82,70,192,0.40)';
    return R.createElement('span', { className: 'ae-newlogo', style: { display: 'inline-flex', alignItems: 'center', gap: 13 * scale } },
      R.createElement('img', { src: markSrc, alt: 'Asher Encounters', style: { height: 38 * scale, width: 'auto', display: 'block' } }),
      R.createElement('span', { 'aria-hidden': 'true', style: { width: 1.5, height: 34 * scale, background: divider, flex: 'none' } }),
      R.createElement('span', { style: { display: 'flex', flexDirection: 'column', lineHeight: 1.04, fontFamily: 'var(--font-display)', textTransform: 'uppercase' } },
        R.createElement('span', { style: { fontSize: 13 * scale, fontWeight: 600, letterSpacing: '0.2em', color: asherCol } }, 'asher'),
        R.createElement('span', { style: { fontSize: 18.5 * scale, fontWeight: 800, letterSpacing: '0.085em', color: enc } }, 'encounters'))
    );
  }

  /* BrandLogo — the Asher Encounters lockup. */
  function BrandLogo({ onDark = false, newScale = 1 }) {
    return R.createElement(NewLockup, { onDark, scale: newScale });
  }



  const NAV = [
    { label: 'Home', href: 'index.html' },
    { label: 'Why Tour With Us', href: 'why-us.html' },
    { label: 'For Sponsors', href: 'sponsors.html' },
    { label: 'AI Digest Newsletter', href: 'newsletter.html' },
  ];

  const PROGRAMS_NAV = [
    { name: 'Capital & Conviction', sub: 'AI Investor Tour', href: 'program-capital-conviction.html' },
    { name: 'AI Frontier', sub: 'Inside Silicon Valley', href: 'program-ai-frontier.html' },
    { name: 'Compass', sub: 'College & Career Camp', href: 'program-compass.html' },
  ];

  function ProgramsMenu({ current }) {
    const [open, setOpen] = R.useState(false);
    const t = R.useRef();
    const active = /^program-/.test(current || '');
    R.useEffect(() => { if (window.lucide) window.lucide.createIcons(); }, [open]);
    return R.createElement('div', { style: { position: 'relative' },
        onMouseEnter: () => { clearTimeout(t.current); setOpen(true); },
        onMouseLeave: () => { t.current = setTimeout(() => setOpen(false), 140); } },
      R.createElement('button', { className: 'ae-nav-link', 'aria-expanded': open, 'aria-current': active ? 'page' : undefined, onClick: () => setOpen((o) => !o),
        style: { display: 'inline-flex', alignItems: 'center', gap: 5, background: 'none', border: 'none', cursor: 'pointer', fontFamily: 'var(--font-sans)', fontSize: '0.92rem', fontWeight: 500 } },
        'Programs', R.createElement('i', { 'data-lucide': 'chevron-down', style: { width: 15, height: 15, transform: open ? 'rotate(180deg)' : 'none', transition: 'transform var(--dur-fast) var(--ease-out)' } })),
      open && R.createElement('div', { style: { position: 'absolute', top: '100%', left: '50%', transform: 'translateX(-50%)', paddingTop: 12, zIndex: 120 } },
        R.createElement('div', { style: { width: 300, background: 'var(--white)', border: '1px solid var(--border-soft)', borderRadius: 'var(--radius-lg)', boxShadow: 'var(--shadow-lg)', padding: 8, display: 'flex', flexDirection: 'column', gap: 2 } },
          PROGRAMS_NAV.map((p) => R.createElement('a', { key: p.href, href: p.href, className: 'ae-progitem',
            style: { display: 'block', padding: '12px 14px', borderRadius: 'var(--radius-md)', textDecoration: 'none' } },
            R.createElement('div', { style: { fontFamily: 'var(--font-sans)', fontWeight: 700, fontSize: '0.95rem', color: 'var(--text-strong)' } }, p.name),
            R.createElement('div', { style: { fontFamily: 'var(--font-mono)', fontSize: '0.62rem', letterSpacing: '0.1em', textTransform: 'uppercase', color: 'var(--slate)', marginTop: 3 } }, p.sub)))))
    );
  }

  function Nav({ current = 'index.html' }) {
    const [scrolled, setScrolled] = R.useState(false);
    const [menu, setMenu] = R.useState(false);
    R.useEffect(() => {
      const onScroll = () => setScrolled(window.scrollY > 16);
      onScroll();
      window.addEventListener('scroll', onScroll, { passive: true });
      return () => window.removeEventListener('scroll', onScroll);
    }, []);
    R.useEffect(() => { if (window.lucide) window.lucide.createIcons(); }, [menu, scrolled]);
    R.useEffect(() => { document.body.style.overflow = menu ? 'hidden' : ''; }, [menu]);

    const solid = scrolled || menu;
    return R.createElement(R.Fragment, null,
      R.createElement('header', { style: {
      position: 'sticky', top: 0, zIndex: 100,
      background: solid ? 'rgba(236,234,251,0.85)' : 'rgba(236,234,251,0)',
      backdropFilter: solid ? 'saturate(150%) blur(12px)' : 'none',
      borderBottom: '1px solid ' + (solid ? 'var(--border-soft)' : 'transparent'),
      transition: 'background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out)',
    } },
      R.createElement('div', { className: 'ae-container', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 24, paddingTop: 18, paddingBottom: 18 } },
        R.createElement('a', { href: 'index.html', 'aria-label': 'Asher Encounters home', className: 'ae-navlogo', style: { display: 'inline-flex', textDecoration: 'none' } },
          R.createElement(BrandLogo, { onDark: false, newScale: 0.92 })),
        /* desktop links */
        R.createElement('nav', { className: 'ae-desktop-links', style: { display: 'flex', alignItems: 'center', gap: 30 } },
          R.createElement('a', { key: 'home', href: 'index.html', className: 'ae-nav-link', 'aria-current': current === 'index.html' ? 'page' : undefined }, 'Home'),
          R.createElement(ProgramsMenu, { current }),
          NAV.slice(1).map((l) => R.createElement('a', { key: l.href, href: l.href, className: 'ae-nav-link', 'aria-current': current === l.href ? 'page' : undefined }, l.label))
        ),
        R.createElement('div', { style: { display: 'flex', alignItems: 'center', gap: 12 } },
          R.createElement(BookButton, { size: 'md', label: 'Book a Tour' }),
          R.createElement('button', { className: 'ae-hamburger', 'aria-label': 'Menu', onClick: () => setMenu((m) => !m),
            style: { width: 42, height: 42, borderRadius: 'var(--radius-md)', border: '1px solid var(--border-strong)', background: 'var(--white)', color: 'var(--ink)', cursor: 'pointer', alignItems: 'center', justifyContent: 'center' } },
            R.createElement('i', { 'data-lucide': menu ? 'x' : 'menu', style: { width: 20, height: 20 } }))
        )
      ),
      /* mobile drawer */
      menu && R.createElement('div', { className: 'ae-mobile-menu', style: { borderTop: '1px solid var(--border-soft)', background: 'var(--page)' } },
        R.createElement('div', { className: 'ae-container', style: { paddingTop: 12, paddingBottom: 20, display: 'flex', flexDirection: 'column' } },
          R.createElement('a', { key: 'home', href: 'index.html', 'aria-current': current === 'index.html' ? 'page' : undefined,
            style: { padding: '14px 4px', fontFamily: 'var(--font-sans)', fontSize: '1.05rem', fontWeight: 600, color: current === 'index.html' ? 'var(--violet)' : 'var(--text-strong)', textDecoration: 'none', borderBottom: '1px solid var(--border-soft)' } }, 'Home'),
          R.createElement('div', { style: { fontFamily: 'var(--font-mono)', fontSize: '0.64rem', letterSpacing: '0.14em', textTransform: 'uppercase', color: 'var(--slate)', padding: '18px 4px 4px' } }, 'Programs'),
          PROGRAMS_NAV.map((p) => R.createElement('a', { key: p.href, href: p.href, 'aria-current': current === p.href ? 'page' : undefined,
            style: { padding: '12px 4px 12px 16px', fontFamily: 'var(--font-sans)', fontSize: '1rem', fontWeight: 600, color: current === p.href ? 'var(--violet)' : 'var(--text-strong)', textDecoration: 'none', borderBottom: '1px solid var(--border-soft)' } }, p.name)),
          NAV.slice(1).map((l) => R.createElement('a', { key: l.href, href: l.href, 'aria-current': current === l.href ? 'page' : undefined,
            style: { padding: '14px 4px', fontFamily: 'var(--font-sans)', fontSize: '1.05rem', fontWeight: 600, color: current === l.href ? 'var(--violet)' : 'var(--text-strong)', textDecoration: 'none', borderBottom: '1px solid var(--border-soft)' } }, l.label))
        )
      )
    ));
  }

  /* ---- Footer ---------------------------------------------- */
  function Footer() {
    const cols = [
      { h: 'Programs', items: [
        { t: 'Capital & Conviction', href: 'program-capital-conviction.html' },
        { t: 'AI Frontier', href: 'program-ai-frontier.html' },
        { t: 'Compass', href: 'program-compass.html' },
      ] },
      { h: 'Company', items: [
        { t: 'Why Tour With Us', href: 'why-us.html' },
        { t: 'For Sponsors', href: 'sponsors.html' },
        { t: 'AI Digest Newsletter', href: 'newsletter.html' },
        { t: 'Contact', href: 'mailto:hello@asherencounters.com' },
      ] },
    ];
    const social = [
      { icon: 'share-2', label: 'LinkedIn' },
      { icon: 'message-circle', label: 'WeChat' },
      { icon: 'book-open', label: 'Xiaohongshu' },
      { icon: 'mail', label: 'Email' },
    ];
    R.useEffect(() => { if (window.lucide) window.lucide.createIcons(); }, []);
    return R.createElement('footer', { style: { background: 'var(--ink)', color: 'var(--paper)', marginTop: 'var(--section-y)' } },
      R.createElement('div', { className: 'ae-container ae-footer-grid', style: { display: 'grid', gridTemplateColumns: '1.6fr 1fr 1fr 1.1fr', gap: 36, paddingTop: 72, paddingBottom: 44 } },
        R.createElement('div', null,
          R.createElement(BrandLogo, { onDark: true, newScale: 0.92 }),
          R.createElement('p', { style: { color: 'rgba(243,242,239,0.6)', fontSize: '0.95rem', lineHeight: 1.6, maxWidth: '34ch', marginTop: 18 } },
            'The intelligence layer of the AI ecosystem — bridging global capital and talent with Silicon Valley’s frontier technology.'),
          R.createElement('div', { style: { marginTop: 22 } }, R.createElement(BookButton, { size: 'md', label: 'Book a Tour' }))
        ),
        cols.map((col) => R.createElement('div', { key: col.h },
          R.createElement('div', { style: { fontFamily: 'var(--font-mono)', fontSize: '0.64rem', letterSpacing: '0.16em', textTransform: 'uppercase', color: 'var(--lavender)', marginBottom: 16 } }, col.h),
          R.createElement('ul', { style: { listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 12 } },
            col.items.map((it) => R.createElement('li', { key: it.t },
              R.createElement('a', { href: it.href, style: { color: 'rgba(243,242,239,0.78)', fontSize: '0.92rem', textDecoration: 'none' } }, it.t))))
        )),
        R.createElement('div', null,
          R.createElement('div', { style: { fontFamily: 'var(--font-mono)', fontSize: '0.64rem', letterSpacing: '0.16em', textTransform: 'uppercase', color: 'var(--lavender)', marginBottom: 16 } }, 'Connect'),
          R.createElement('div', { style: { display: 'flex', gap: 10 } },
            social.map((s) => R.createElement('a', { key: s.label, href: '#', 'aria-label': s.label, title: s.label, onClick: (e) => e.preventDefault(),
              style: { width: 42, height: 42, borderRadius: 'var(--radius-md)', border: '1px solid var(--border-on-dark)', background: 'rgba(243,242,239,0.05)', color: 'var(--paper)', display: 'grid', placeItems: 'center', textDecoration: 'none' } },
              R.createElement('i', { 'data-lucide': s.icon, style: { width: 18, height: 18 } })))),
          R.createElement('p', { style: { color: 'rgba(243,242,239,0.4)', fontSize: '0.74rem', marginTop: 14, lineHeight: 1.5 } }, 'Menlo Park, California')
        )
      ),
      R.createElement('div', { style: { borderTop: '1px solid var(--border-on-dark)' } },
        R.createElement('div', { className: 'ae-container', style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 16, paddingTop: 20, paddingBottom: 20, flexWrap: 'wrap' } },
          R.createElement('span', { style: { fontFamily: 'var(--font-mono)', fontSize: '0.66rem', letterSpacing: '0.12em', textTransform: 'uppercase', color: 'rgba(243,242,239,0.5)' } }, '© 2026 Asher Encounters'),
          R.createElement('div', { style: { display: 'flex', gap: 22 } },
            ['Privacy', 'Terms'].map((t) => R.createElement('a', { key: t, href: '#', onClick: (e) => e.preventDefault(), style: { fontFamily: 'var(--font-mono)', fontSize: '0.66rem', letterSpacing: '0.12em', textTransform: 'uppercase', color: 'rgba(243,242,239,0.5)', textDecoration: 'none' } }, t)))
        )
      )
    );
  }

  window.Asher = Object.assign(window.Asher || {}, { Nav, Footer });
})();
