/* MarketingNav.jsx — sticky bilingual top nav with KO|EN toggle + Admin dropdown
   Change from DS reference:
   - 6 KR link labels (domain mapping)
   - KO|EN toggle pill (Year 2 multilingual prep)
   - "Admin ▾" dropdown that lets a visitor jump straight to either the
     Parent dashboard (sriki-parent/) or the Teacher dashboard (sriki-teacher/)
     — the bridge between marketing surface and authenticated surfaces.
   - Mobile menu (hamburger) added for sub-820px viewports.
   Rationale: spec §1.1. */

const MarketingNav = ({ onCta, onSignin, parentHref, teacherHref }) => {
  const t = window.useT();
  const { lang, setLang } = React.useContext(window.LangContext);

  const [adminOpen, setAdminOpen] = React.useState(false);
  const [mobileOpen, setMobileOpen] = React.useState(false);
  const [scrolled, setScrolled] = React.useState(false);
  /* True while the nav strip is still painted over the dark cosmic hero.
     Flips to false the moment the hero scrolls off the top — at which point
     the nav swaps from "white text on glass" to "dark text on white" so it
     stays readable over the light content below. */
  const [overHero, setOverHero] = React.useState(true);
  const [activeId, setActiveId] = React.useState('');
  const adminRef = React.useRef(null);

  /* Track scroll for shadow + over-hero adaptive theming */
  React.useEffect(() => {
    const NAV_H = 72;
    const onScroll = () => {
      setScrolled(window.scrollY > 8);
      const hero = document.getElementById('top');
      if (!hero) { setOverHero(window.scrollY < 120); return; }
      const bottom = hero.getBoundingClientRect().bottom;
      /* Still dark while the hero covers more than the nav strip; flip
         a few pixels before the seam to avoid mid-transition flicker. */
      setOverHero(bottom > NAV_H - 4);
    };
    onScroll();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll, { passive: true });
    return () => {
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
    };
  }, []);

  /* Scroll-spy — highlight the nav item whose section is currently in view.
     Trigger-line approach: pick the last section whose top has scrolled
     above the trigger line (80px nav + 22% of viewport). Smoother and
     more predictable than IntersectionObserver here, because section
     heights vary (some are taller than viewport, some shorter) and a
     single trigger line gives one unambiguous answer per scroll position.
     rAF-throttled to keep scroll handler cheap. */
  React.useEffect(() => {
    const ids = ['programs', 'curriculum', 'system', 'schedule', 'app', 'reviews'];
    let rafId = 0;

    const update = () => {
      rafId = 0;

      /* Hero zone — no active state until user scrolls into the first section. */
      if (window.scrollY < 120) {
        setActiveId(prev => (prev === '' ? prev : ''));
        return;
      }

      /* If user has reached the bottom, force the last section.
         Catches the case where the last section is shorter than the
         trigger band and its top never crosses the trigger line. */
      const atBottom =
        window.innerHeight + window.scrollY >=
        document.documentElement.scrollHeight - 4;
      if (atBottom) {
        setActiveId(prev => (prev === ids[ids.length - 1] ? prev : ids[ids.length - 1]));
        return;
      }

      const triggerY = 80 + window.innerHeight * 0.22;
      let current = '';
      for (const id of ids) {
        const el = document.getElementById(id);
        if (!el) continue;
        if (el.getBoundingClientRect().top <= triggerY) current = id;
      }
      setActiveId(prev => (prev === current ? prev : current));
    };

    const onScroll = () => {
      if (rafId) return;
      rafId = requestAnimationFrame(update);
    };

    update();
    window.addEventListener('scroll', onScroll, { passive: true });
    window.addEventListener('resize', onScroll, { passive: true });
    return () => {
      if (rafId) cancelAnimationFrame(rafId);
      window.removeEventListener('scroll', onScroll);
      window.removeEventListener('resize', onScroll);
    };
  }, []);

  /* Close the dropdown on outside click and on Escape */
  React.useEffect(() => {
    if (!adminOpen) return;
    const onDoc = (e) => {
      if (!adminRef.current?.contains(e.target)) setAdminOpen(false);
    };
    const onKey = (e) => { if (e.key === 'Escape') setAdminOpen(false); };
    document.addEventListener('pointerdown', onDoc);
    document.addEventListener('keydown', onKey);
    return () => {
      document.removeEventListener('pointerdown', onDoc);
      document.removeEventListener('keydown', onKey);
    };
  }, [adminOpen]);

  const links = [
    ['nav.programs',   '#programs'],
    ['nav.curriculum', '#curriculum'],
    ['nav.system',     '#system'],
    ['nav.schedule',   '#schedule'],
    ['nav.app',        '#app'],
    ['nav.reviews',    '#reviews'],
  ];

  /* Mobile-only section indicator — slim band rendered under the main nav
     row, showing the current section name + a 6-dot progress strip.
     -1 / empty string while still over the hero (no active section yet). */
  const activeIdx = activeId ? links.findIndex(([, href]) => href === `#${activeId}`) : -1;
  const activeLabel = activeIdx >= 0 ? t(links[activeIdx][0]) : '';

  return (
    <nav className={overHero ? 'nav--dark' : 'nav--light'} style={{
      position: 'sticky', top: 0, zIndex: 50,
      /* Over hero: solid near-black matching the cosmic gradient's darkest
         stop (#02040C). Going translucent here would let the body's white
         background bleed through and turn the strip gray.
         Over content: translucent white glass. */
      background: overHero
        ? '#02040C'
        : (scrolled ? 'rgba(255,255,255,0.92)' : 'rgba(255,255,255,0.80)'),
      backdropFilter: overHero ? 'none' : 'blur(14px)',
      WebkitBackdropFilter: overHero ? 'none' : 'blur(14px)',
      borderBottom: overHero
        ? '1px solid rgba(255,255,255,0.06)'
        : (scrolled ? '1px solid #E2E8F0' : '1px solid rgba(226,232,240,0.6)'),
      boxShadow: overHero
        ? 'none'
        : (scrolled ? '0 1px 0 rgba(15,23,42,0.04), 0 8px 24px -16px rgba(15,23,42,0.10)' : 'none'),
      padding: '0 24px',
      paddingTop: 'env(safe-area-inset-top, 0)',
      transition: 'background 260ms ease, border-color 260ms ease, box-shadow 260ms ease',
    }}>
      <div style={{
        maxWidth: 1080, margin: '0 auto',
        padding: '14px 0',
        display: 'flex', alignItems: 'center', gap: 24,
      }}>
        <a href="#top" style={{
          display: 'flex', alignItems: 'center', gap: 11,
          height: 44, marginRight: 4, textDecoration: 'none',
        }}>
          {/* Inline height/width override the global `img, svg { height: auto }`
              rule in sriki-brand.css that would otherwise render the SVG at
              its 280×340 intrinsic size, overflowing the nav into the hero. */}
          <img src="assets/sriki-mark.svg" alt="" style={{
            height: 40, width: 'auto',
          }} />
          <span className="nav-sriki-wordmark" style={{
            fontFamily: '"Jua", var(--font-sans)',
            fontSize: 24, fontWeight: 400, letterSpacing: '-0.02em',
            color: overHero ? '#FFFFFF' : '#0B1727', lineHeight: 1,
            /* Game-app glow — matches ConstellationLogo in C:\dev\sriki\app.
               Only painted over the dark hero, fades out as we cross into
               the white content area. */
            textShadow: overHero
              ? '0 0 4px #FFFFFF, 0 0 8px #C084FC, 0 0 14px #A855F7, 0 0 24px #A855F7, 0 0 36px #9333EACC, 0 0 55px #7E22CE99, 0 2px 0 #000'
              : 'none',
            transition: 'color 260ms ease, text-shadow 260ms ease',
          }}>SRIKI</span>
        </a>

        {/* Desktop links */}
        <div className="nav-links" style={{ display: 'flex', gap: 4, alignItems: 'center' }}>
          {links.map(([key, href]) => {
            const isActive = activeId && href === `#${activeId}`;
            return (
              <a key={key} href={href}
                className={`nav-link ${isActive ? 'nav-link-active' : ''}`}
                aria-current={isActive ? 'page' : undefined}
                style={{
                  position: 'relative',
                  fontFamily: 'var(--font-sans)',
                  fontFeatureSettings: '"ss01"',
                  fontSize: 14, fontWeight: 600, lineHeight: 1,
                  color: overHero
                    ? (isActive ? '#DDD6FE' : 'rgba(255,255,255,0.82)')
                    : (isActive ? '#6D28D9' : '#0B1727'),
                  background: isActive
                    ? (overHero ? 'rgba(196,181,253,0.16)' : 'rgba(109,40,217,0.08)')
                    : 'transparent',
                  textDecoration: 'none',
                  padding: '10px 14px', borderRadius: 8,
                  transition: 'color 220ms ease, background 220ms ease',
                }}>{t(key)}</a>
            );
          })}
        </div>

        <div style={{ marginLeft: 'auto', display: 'flex', gap: 10, alignItems: 'center' }}>
          {/* Admin dropdown — moved into utility area (right) so it's not in the main nav */}
          <div ref={adminRef} className="nav-admin" style={{ position: 'relative' }}>
            <button
              type="button"
              onClick={() => setAdminOpen(o => !o)}
              aria-haspopup="menu"
              aria-expanded={adminOpen}
              style={{
                border: overHero ? '1px solid rgba(255,255,255,0.18)' : '1px solid #E2E8F0',
                background: overHero ? 'rgba(255,255,255,0.06)' : '#fff',
                cursor: 'pointer',
                padding: '7px 12px', borderRadius: 6,
                display: 'inline-flex', alignItems: 'center', gap: 6,
                fontFamily: 'var(--font-sans)', fontFeatureSettings: '"ss01"',
                fontSize: 13, fontWeight: 600, lineHeight: 1,
                color: adminOpen
                  ? (overHero ? '#DDD6FE' : '#6D28D9')
                  : (overHero ? 'rgba(255,255,255,0.85)' : '#475569'),
                transition: 'background 200ms ease, border-color 200ms ease, color 200ms ease',
              }}
            >
              {t('nav.signin.menu')}
              <svg width="12" height="12" viewBox="0 0 24 24" fill="none"
                stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"
                style={{
                  transform: adminOpen ? 'rotate(180deg)' : 'rotate(0)',
                  transition: 'transform 160ms cubic-bezier(0.2,0.6,0.25,1)',
                }}>
                <polyline points="6 9 12 15 18 9"/>
              </svg>
            </button>

            {adminOpen && (
              <div role="menu" style={{
                position: 'absolute', top: 'calc(100% + 10px)', right: 0,
                width: 320, maxWidth: 'calc(100vw - 32px)',
                background: '#fff',
                border: '1px solid #E2E8F0', borderRadius: 10,
                padding: 6,
                boxShadow:
                  '0 4px 12px rgba(15,23,42,0.06),' +
                  '0 24px 56px -20px rgba(15,23,42,0.22)',
                zIndex: 60,
              }}>
                <div className="eyebrow" style={{ padding: '8px 10px 4px' }}>
                  {t('nav.signin.menu.desc')}
                </div>

                <button type="button" role="menuitem" style={{ ...menuItem, background: 'transparent', border: 0, width: '100%', cursor: 'pointer', textAlign: 'left' }}
                   onClick={() => { setAdminOpen(false); onSignin?.('parent'); }}>
                  <span style={iconBubble}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none"
                      stroke="#6D28D9" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
                      <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/>
                      <circle cx="9" cy="7" r="4"/>
                      <path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
                      <path d="M16 3.13a4 4 0 0 1 0 7.75"/>
                    </svg>
                  </span>
                  <span style={{ flex: 1, minWidth: 0 }}>
                    <span style={menuTitle}>{t('nav.signin.parent')}</span>
                    <span style={menuSub}>{t('nav.signin.parent.sub')}</span>
                  </span>
                  <svg width="14" height="14" viewBox="0 0 24 24" fill="none"
                    stroke="#6D28D9" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                    <polyline points="9 18 15 12 9 6"/>
                  </svg>
                </button>

                <button type="button" role="menuitem" style={{ ...menuItem, background: 'transparent', border: 0, width: '100%', cursor: 'pointer', textAlign: 'left' }}
                   onClick={() => { setAdminOpen(false); onSignin?.('teacher'); }}>
                  <span style={iconBubble}>
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none"
                      stroke="#6D28D9" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round">
                      <path d="M2 7l10-4 10 4-10 4z"/>
                      <path d="M5 9v6c0 1 3 3 7 3s7-2 7-3V9"/>
                    </svg>
                  </span>
                  <span style={{ flex: 1, minWidth: 0 }}>
                    <span style={menuTitle}>{t('nav.signin.teacher')}</span>
                    <span style={menuSub}>{t('nav.signin.teacher.sub')}</span>
                  </span>
                  <svg width="14" height="14" viewBox="0 0 24 24" fill="none"
                    stroke="#6D28D9" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
                    <polyline points="9 18 15 12 9 6"/>
                  </svg>
                </button>
              </div>
            )}
          </div>

          {/* Language toggle */}
          <div className="lang-toggle nav-langtoggle" role="group" aria-label="Language">
            <button
              aria-pressed={lang === 'ko'}
              onClick={() => setLang('ko')}
            >KO</button>
            <button
              aria-pressed={lang === 'en'}
              onClick={() => setLang('en')}
              style={{ borderLeft: '1px solid #E2E8F0' }}
            >EN</button>
          </div>

          <Button variant="primary" size="sm" onClick={onCta}>{t('nav.cta')} →</Button>

          {/* Mobile hamburger */}
          <button
            className="nav-burger"
            type="button"
            onClick={() => setMobileOpen(o => !o)}
            aria-label={mobileOpen ? (lang === 'ko' ? '메뉴 닫기' : 'Close menu') : (lang === 'ko' ? '메뉴 열기' : 'Open menu')}
            aria-expanded={mobileOpen}
            style={{
              display: 'none', // shown via media query below
              border: overHero ? '1px solid rgba(255,255,255,0.18)' : '1px solid #E2E8F0',
              background: overHero ? 'rgba(255,255,255,0.06)' : '#fff',
              width: 38, height: 38, borderRadius: 8,
              alignItems: 'center', justifyContent: 'center',
              cursor: 'pointer', padding: 0,
              transition: 'background 200ms ease, border-color 200ms ease',
            }}>
            <svg width="18" height="18" viewBox="0 0 24 24" fill="none"
              stroke={overHero ? '#FFFFFF' : '#0B1727'} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
              {mobileOpen ? (
                <>
                  <line x1="18" y1="6" x2="6" y2="18"/>
                  <line x1="6" y1="6" x2="18" y2="18"/>
                </>
              ) : (
                <>
                  <line x1="3" y1="6" x2="21" y2="6"/>
                  <line x1="3" y1="12" x2="21" y2="12"/>
                  <line x1="3" y1="18" x2="21" y2="18"/>
                </>
              )}
            </svg>
          </button>
        </div>
      </div>

      {/* ─── Mobile-only section indicator ───────────────────────────
          Slim band painted directly under the main nav row. Carries
          "현재 · <섹션명>" on the left and a 6-dot progress strip on
          the right (one dot per content section, traversed dots in
          brand purple). Hidden entirely on desktop and over the hero. */}
      {activeIdx >= 0 && (
        <div className="nav-indicator">
          <div className="nav-indicator-inner">
            <span key={activeId} className="nav-indicator-name">{activeLabel}</span>
            <div className="nav-indicator-dots" role="tablist">
              {links.map(([key, href], i) => (
                <a key={href}
                   href={href}
                   role="tab"
                   aria-label={t(key)}
                   aria-selected={i === activeIdx}
                   className={'nav-indicator-dot' + (i <= activeIdx ? ' is-active' : '') + (i === activeIdx ? ' is-current' : '')}
                />
              ))}
            </div>
          </div>
        </div>
      )}

      {/* Mobile drawer */}
      {mobileOpen && (
        <div className="nav-drawer" style={{
          display: 'none', // shown via media query
          borderTop: overHero ? '1px solid rgba(255,255,255,0.08)' : '1px solid #E2E8F0',
          padding: '12px 4px 18px',
        }}>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
            {links.map(([key, href]) => {
              const isActive = activeId && href === `#${activeId}`;
              return (
                <a key={key} href={href}
                  className={isActive ? 'nav-link-active' : ''}
                  aria-current={isActive ? 'page' : undefined}
                  onClick={() => setMobileOpen(false)}
                  style={{
                    fontFamily: 'var(--font-sans)', fontFeatureSettings: '"ss01"',
                    fontSize: 16, fontWeight: 600,
                    color: overHero
                      ? (isActive ? '#DDD6FE' : 'rgba(255,255,255,0.85)')
                      : (isActive ? '#6D28D9' : '#0B1727'),
                    textDecoration: 'none',
                    padding: '12px 16px', borderRadius: 8,
                    display: 'block',
                  }}>{t(key)}</a>
              );
            })}
            <div style={{
              height: 1,
              background: overHero ? 'rgba(255,255,255,0.08)' : '#EEF2F7',
              margin: '8px 16px',
            }} />
            <button type="button"
              onClick={() => { setMobileOpen(false); onSignin?.('parent'); }}
              style={{
                ...mobileSubLink,
                background: 'transparent', border: 0, width: '100%', textAlign: 'left', cursor: 'pointer',
                color: overHero ? 'rgba(255,255,255,0.65)' : '#475569',
              }}>{t('nav.signin.parent')} →</button>
            <button type="button"
              onClick={() => { setMobileOpen(false); onSignin?.('teacher'); }}
              style={{
                ...mobileSubLink,
                background: 'transparent', border: 0, width: '100%', textAlign: 'left', cursor: 'pointer',
                color: overHero ? 'rgba(255,255,255,0.65)' : '#475569',
              }}>{t('nav.signin.teacher')} →</button>

            {/* Language toggle inside the mobile drawer — the desktop
                .nav-langtoggle is hidden on mobile, so we expose KO|EN
                here as a labelled row so users can switch languages
                without leaving the hamburger menu. */}
            <div style={{
              height: 1,
              background: overHero ? 'rgba(255,255,255,0.08)' : '#EEF2F7',
              margin: '8px 16px',
            }} />
            <div style={{
              display: 'flex', alignItems: 'center', justifyContent: 'space-between',
              padding: '8px 16px 4px',
            }}>
              <span style={{
                fontFamily: 'var(--font-sans)', fontFeatureSettings: '"ss01"',
                fontSize: 13, fontWeight: 600,
                color: overHero ? 'rgba(255,255,255,0.65)' : '#475569',
              }}>{lang === 'ko' ? '언어' : 'Language'}</span>
              <div className="lang-toggle" role="group" aria-label="Language">
                <button
                  aria-pressed={lang === 'ko'}
                  onClick={() => setLang('ko')}
                >KO</button>
                <button
                  aria-pressed={lang === 'en'}
                  onClick={() => setLang('en')}
                  style={{ borderLeft: '1px solid #E2E8F0' }}
                >EN</button>
              </div>
            </div>
          </div>
        </div>
      )}

      <style>{`
        /* Light mode (default — over white content) */
        .nav--light .nav-link:hover { background: #F8FAFC; color: #6D28D9; }
        .nav--light .nav-link-active:hover { background: rgba(109,40,217,0.12); }
        .nav--light .nav-link-active::after {
          background: linear-gradient(90deg, #6D28D9, #A78BFA);
        }

        /* Dark mode (over the cosmic hero) — hover lifts via translucent
           white film, active underline keeps the brand violet but brighter
           so it reads on the deep blue/violet background. */
        .nav--dark .nav-link:hover {
          background: rgba(255,255,255,0.08);
          color: #FFFFFF;
        }
        .nav--dark .nav-link-active:hover { background: rgba(196,181,253,0.22); }
        .nav--dark .nav-link-active::after {
          background: linear-gradient(90deg, #DDD6FE, #A78BFA);
          box-shadow: 0 0 10px rgba(196,181,253,0.55);
        }

        /* Animated underline indicator for active nav link */
        .nav-link-active::after {
          content: "";
          position: absolute;
          left: 14px; right: 14px; bottom: -1px;
          height: 2px; border-radius: 2px;
          animation: navUnderline 280ms cubic-bezier(0.2,0.6,0.25,1);
        }
        @keyframes navUnderline {
          from { transform: scaleX(0.4); opacity: 0; }
          to   { transform: scaleX(1);   opacity: 1; }
        }
        /* Mobile drawer active indicator */
        .nav--light .nav-drawer a.nav-link-active {
          background: rgba(109,40,217,0.08);
          color: #6D28D9 !important;
        }
        .nav--dark .nav-drawer a.nav-link-active {
          background: rgba(196,181,253,0.14);
          color: #DDD6FE !important;
        }
        /* Lang toggle — brand.css defaults to light. In dark mode pull it
           into translucent-glass with white labels for parity with the
           admin button. */
        .nav--dark .nav-langtoggle {
          background: rgba(255,255,255,0.06) !important;
          border-color: rgba(255,255,255,0.18) !important;
        }
        .nav--dark .nav-langtoggle button {
          color: rgba(255,255,255,0.70) !important;
        }
        .nav--dark .nav-langtoggle button[aria-pressed="true"] {
          color: #FFFFFF !important;
          background: rgba(255,255,255,0.10) !important;
        }
        .nav--dark .nav-langtoggle button + button { border-color: rgba(255,255,255,0.18) !important; }
        @media (max-width: 880px) {
          .nav-links { display: none !important; }
          .nav-admin { display: none !important; }
          .nav-langtoggle { display: none !important; }
          .nav-burger {
            display: inline-flex !important;
            min-width: 44px !important; min-height: 44px !important;
            width: 44px !important; height: 44px !important;
          }
          .nav-drawer {
            display: block !important;
            max-height: calc(100dvh - 80px);
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
          }
          /* Section indicator band — only on mobile (≤880px), only after
             the user has scrolled into a content section. */
          .nav-indicator { display: block !important; }
        }

        /* Desktop / tablet ≥881px — never render the indicator band. */
        @media (min-width: 881px) {
          .nav-indicator { display: none !important; }
        }

        /* ── Indicator band itself (mobile only) ────────────────────── */
        .nav-indicator {
          display: none; /* hidden by default; media query above opts in */
          background: rgba(248, 250, 252, 0.96);
          backdrop-filter: blur(10px);
          -webkit-backdrop-filter: blur(10px);
          border-top: 1px solid rgba(226, 232, 240, 0.6);
          border-bottom: 1px solid #E2E8F0;
          /* Bleed past the nav's own 24px horizontal padding so the band
             runs edge-to-edge on phones — feels like one continuous strip
             instead of a floating chip with side gaps. */
          margin-left: -24px;
          margin-right: -24px;
        }
        .nav--dark .nav-indicator {
          background: rgba(11, 14, 26, 0.85);
          border-top-color: rgba(255,255,255,0.06);
          border-bottom-color: rgba(255,255,255,0.06);
        }
        .nav-indicator-inner {
          max-width: 1080px;
          margin: 0 auto;
          /* Re-apply the nav's 24px gutter inside the bleed so the label
             and dots don't kiss the viewport edges. */
          padding: 8px 20px;
          display: flex;
          align-items: center;
          gap: 10px;
        }
        .nav-indicator-now {
          font-family: var(--font-mono);
          font-size: 9.5px;
          font-weight: 700;
          letter-spacing: 0.14em;
          text-transform: uppercase;
          color: #94A3B8;
          flex-shrink: 0;
        }
        .nav--dark .nav-indicator-now { color: rgba(255,255,255,0.55); }
        .nav-indicator-name {
          font-family: var(--font-ko, var(--font-sans));
          font-size: 14px;
          font-weight: 700;
          letter-spacing: -0.2px;
          color: #6D28D9;
          line-height: 1;
          flex-shrink: 1;
          min-width: 0;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          animation: navIndFade 320ms cubic-bezier(0.2,0.6,0.25,1);
        }
        .nav--dark .nav-indicator-name { color: #DDD6FE; }
        .nav-indicator-dots {
          margin-left: auto;
          display: inline-flex;
          gap: 5px;
          align-items: center;
          flex-shrink: 0;
        }
        .nav-indicator-dot {
          width: 14px; height: 4px;
          border-radius: 2px;
          background: #E2E8F0;
          display: inline-block;
          transition: background 200ms ease, box-shadow 200ms ease, transform 200ms ease;
        }
        .nav--dark .nav-indicator-dot { background: rgba(255,255,255,0.14); }
        .nav-indicator-dot.is-active { background: #6D28D9; }
        .nav--dark .nav-indicator-dot.is-active { background: #C4B5FD; }
        .nav-indicator-dot.is-current {
          width: 22px;
          box-shadow: 0 0 8px rgba(109,40,217,0.35);
        }
        .nav--dark .nav-indicator-dot.is-current {
          box-shadow: 0 0 10px rgba(196,181,253,0.55);
        }

        @keyframes navIndFade {
          from { opacity: 0; transform: translateY(-3px); }
          to   { opacity: 1; transform: translateY(0); }
        }

        /* iOS Safari extra safety — some Safari builds drop position:sticky
           if any descendant uses backdrop-filter without explicit will-change.
           Force GPU layer + ensure top:0 wins over any inherited offset. */
        nav.nav--dark, nav.nav--light {
          will-change: background, border-color;
          top: 0 !important;
        }
      `}</style>
    </nav>
  );
};

const menuItem = {
  display: 'flex', alignItems: 'center', gap: 12,
  padding: '10px 10px', borderRadius: 8,
  textDecoration: 'none', color: 'inherit',
  transition: 'background 120ms cubic-bezier(0.25,0.1,0.25,1)',
  cursor: 'pointer',
};
const iconBubble = {
  width: 36, height: 36, borderRadius: 9,
  background: 'rgba(109,40,217,0.10)',
  display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
  flexShrink: 0,
};
const menuTitle = {
  display: 'block',
  fontFamily: 'var(--font-sans)', fontFeatureSettings: '"ss01"',
  fontSize: 14, fontWeight: 600, color: '#0B1727',
  lineHeight: 1.25,
};
const menuSub = {
  display: 'block',
  fontSize: 11, color: '#475569', marginTop: 4,
  lineHeight: 1.45, fontWeight: 400,
};
const mobileSubLink = {
  fontFamily: 'var(--font-sans)', fontFeatureSettings: '"ss01"',
  fontSize: 13, fontWeight: 500, color: '#475569',
  textDecoration: 'none',
  padding: '10px 16px', borderRadius: 8,
  display: 'block',
};

window.MarketingNav = MarketingNav;
