// landing.jsx — RoStealth landing (filen.io-style)
const { useState, useEffect, useRef } = React;

// ─── SCROLL REVEAL ────────────────────────────────────────────────────────────
function useReveal(delay = 0) {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current; if (!el) return;
    el.classList.add('reveal');
    if (delay) el.style.transitionDelay = `${delay}ms`;
    let done = false;
    const show = () => { if (done) return; done = true; el.classList.add('in'); };
    let io;
    try { io = new IntersectionObserver(e => e.forEach(e => { if (e.isIntersecting) show(); }), { threshold: 0.08 }); io.observe(el); } catch (e) { show(); }
    const t = setTimeout(show, 1400);
    return () => { io && io.disconnect(); clearTimeout(t); };
  }, [delay]);
  return ref;
}

function useStaggerReveal() {
  const ref = useRef(null);
  useEffect(() => {
    const el = ref.current; if (!el) return;
    const children = Array.from(el.children);
    children.forEach((c, i) => { c.classList.add('reveal'); c.style.transitionDelay = `${i * 70}ms`; });
    let done = false;
    const show = () => { if (done) return; done = true; children.forEach(c => c.classList.add('in')); };
    let io;
    try { io = new IntersectionObserver(e => e.forEach(e => { if (e.isIntersecting) show(); }), { threshold: 0.05 }); io.observe(el); } catch (e) { show(); }
    const t = setTimeout(show, 1500);
    return () => { io && io.disconnect(); clearTimeout(t); };
  }, []);
  return ref;
}

// gradient word like filen.io "Individuals"
const GRADIENT_TEXT = {
  background: 'linear-gradient(90deg, #22D3EE 0%, #2DD4BF 38%, #5EEAD4 62%, #34D399 100%)',
  WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent', backgroundClip: 'text',
};

// white primary button (filen style)
const WhiteBtn = ({ children, onClick, style = {} }) => (
  <button onClick={onClick} style={{
    display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 8,
    padding: '14px 28px', background: '#fff', border: 'none', borderRadius: 12,
    cursor: 'pointer', color: '#000', fontSize: 15.5, fontFamily: 'var(--font)',
    fontWeight: 600, letterSpacing: '-0.01em', transition: 'all 0.18s var(--ease-out-expo)', ...style,
  }}
    onMouseEnter={e => { e.currentTarget.style.transform = 'translateY(-1px)'; e.currentTarget.style.boxShadow = '0 8px 30px rgba(255,255,255,0.15)'; }}
    onMouseLeave={e => { e.currentTarget.style.transform = 'none'; e.currentTarget.style.boxShadow = 'none'; }}
  >{children}</button>
);

// ─── SECTION HEADER (centered, filen style) ───────────────────────────────────
const SectionHead = ({ title, sub, gradientWord }) => {
  const r = useReveal();
  return (
    <div ref={r} style={{ textAlign: 'center', maxWidth: 760, margin: '0 auto', marginBottom: 64 }}>
      <h2 style={{ fontSize: 'clamp(30px,4.5vw,52px)', fontWeight: 700, letterSpacing: '-0.035em', lineHeight: 1.08, color: 'var(--t1)', textWrap: 'balance' }}>
        {title}{gradientWord && <> <span style={GRADIENT_TEXT}>{gradientWord}</span></>}
      </h2>
      {sub && <p style={{ fontSize: 17, color: 'var(--t2)', lineHeight: 1.65, marginTop: 18, maxWidth: 620, margin: '18px auto 0', textWrap: 'pretty' }}>{sub}</p>}
    </div>
  );
};

const Eyebrow = ({ children }) => (
  <div style={{ display: 'inline-flex', alignItems: 'center', gap: 8, fontSize: 13, color: 'var(--p4)', fontWeight: 500 }}>{children}</div>
);

// ─── NAV (floating pill, filen style) ─────────────────────────────────────────
const LandingNav = ({ onLogin, onSignup }) => {
  const links = [['Features', '#features'], ['How it works', '#how'], ['Pricing', '#pricing'], ['FAQ', '#faq']];
  const go = (e, href) => { e.preventDefault(); const el = document.querySelector(href); if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 100, behavior: 'smooth' }); };
  return (
    <div style={{ position: 'fixed', top: 16, left: 0, right: 0, zIndex: 100, display: 'flex', justifyContent: 'center', padding: '0 16px', pointerEvents: 'none' }}>
      <nav style={{
        pointerEvents: 'auto', position: 'relative', width: '100%', maxWidth: 1040, height: 58,
        display: 'flex', alignItems: 'center', padding: '0 10px 0 18px',
        background: 'rgba(10,10,10,0.7)', backdropFilter: 'blur(22px) saturate(1.6)',
        border: '1px solid rgba(255,255,255,0.08)', borderRadius: 14,
        boxShadow: '0 10px 40px rgba(0,0,0,0.5)',
      }}>
        {/* logo */}
        <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
          <LogoMark size={28} />
          <span style={{ fontSize: 16, fontWeight: 700, letterSpacing: '-0.03em', color: 'var(--t1)' }}>RoStealth</span>
        </div>
        {/* centered links */}
        <div className="nav-links" style={{ position: 'absolute', left: '50%', transform: 'translateX(-50%)', display: 'flex', gap: 2 }}>
          {links.map(([l, href]) => (
            <a key={l} href={href} onClick={e => go(e, href)} style={{ color: 'var(--t2)', fontSize: 14, fontWeight: 500, textDecoration: 'none', padding: '8px 14px', borderRadius: 9, transition: 'color 0.15s, background 0.15s' }}
              onMouseEnter={e => { e.currentTarget.style.color = 'var(--t1)'; e.currentTarget.style.background = 'rgba(255,255,255,0.05)'; }}
              onMouseLeave={e => { e.currentTarget.style.color = 'var(--t2)'; e.currentTarget.style.background = 'transparent'; }}>{l}</a>
          ))}
        </div>
        {/* actions */}
        <div style={{ marginLeft: 'auto', display: 'flex', alignItems: 'center', gap: 4 }}>
          <button onClick={onLogin} style={{ background: 'transparent', border: 'none', cursor: 'pointer', color: 'var(--t2)', fontSize: 14, fontWeight: 500, fontFamily: 'var(--font)', padding: '9px 16px', borderRadius: 10, transition: 'all 0.15s' }} onMouseEnter={e => { e.currentTarget.style.color = 'var(--t1)'; e.currentTarget.style.background = 'rgba(255,255,255,0.05)'; }} onMouseLeave={e => { e.currentTarget.style.color = 'var(--t2)'; e.currentTarget.style.background = 'transparent'; }}>Log in</button>
          <button onClick={onSignup} style={{ background: '#fff', border: 'none', cursor: 'pointer', color: '#000', fontSize: 14, fontWeight: 600, fontFamily: 'var(--font)', padding: '9px 18px', borderRadius: 10, letterSpacing: '-0.01em', transition: 'all 0.15s' }} onMouseEnter={e => e.currentTarget.style.filter = 'brightness(0.92)'} onMouseLeave={e => e.currentTarget.style.filter = 'none'}>Sign up</button>
        </div>
      </nav>
    </div>
  );
};

// ─── BROWSER CHROME WRAPPER ───────────────────────────────────────────────────
const BrowserFrame = ({ children, url = 'app.rostealth.site', maxWidth = 1080, glow = true }) => (
  <div style={{ position: 'relative', width: '100%', maxWidth, margin: '0 auto' }}>
    {glow && <div style={{ position: 'absolute', bottom: -50, left: '12%', right: '12%', height: 120, background: 'radial-gradient(ellipse at center, rgba(6,182,212,0.18) 0%, transparent 70%)', filter: 'blur(34px)', pointerEvents: 'none' }} />}
    <div style={{ position: 'relative', borderRadius: 14, overflow: 'hidden', border: '1px solid var(--border2)', boxShadow: '0 40px 120px rgba(0,0,0,0.8)' }}>
      <div style={{ background: '#121212', padding: '10px 16px', display: 'flex', alignItems: 'center', gap: 12, borderBottom: '1px solid var(--border)' }}>
        <div style={{ display: 'flex', gap: 6 }}>{['#FF5F57', '#FFBD2E', '#28C840'].map(c => <div key={c} style={{ width: 11, height: 11, borderRadius: '50%', background: c, opacity: 0.85 }} />)}</div>
        <div style={{ flex: 1, maxWidth: 320, margin: '0 auto', background: '#000', border: '1px solid var(--border)', borderRadius: 6, height: 24, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6 }}>
          <svg width="9" height="9" viewBox="0 0 14 14" fill="none"><rect x="2.5" y="6" width="9" height="6.5" rx="1.5" stroke="var(--t4)" strokeWidth="1.2"/><path d="M4.5 6V4.5a2.5 2.5 0 0 1 5 0V6" stroke="var(--t4)" strokeWidth="1.2"/></svg>
          <span style={{ fontSize: 11, color: 'var(--t4)' }}>{url}</span>
        </div>
      </div>
      {children}
    </div>
  </div>
);

// mini sidebar used in the snapshots
const SnapSidebar = ({ active = 'Dashboard', width = 192 }) => {
  const items = [['Dashboard', Icon.Dashboard], ['Tracking', Icon.Tracking], ['Analytics', Icon.Analytics], ['Alerts', Icon.Alerts], ['Pricing', Icon.Pricing], ['Settings', Icon.Settings]];
  return (
    <div style={{ width, background: '#000', borderRight: '1px solid var(--border)', display: 'flex', flexDirection: 'column', flexShrink: 0 }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 9, padding: '13px 15px', borderBottom: '1px solid var(--border)' }}>
        <LogoMark size={26} />
        <div><div style={{ fontSize: 13, fontWeight: 700, color: 'var(--t1)', letterSpacing: '-0.02em', lineHeight: 1 }}>RoStealth</div><div style={{ fontSize: 9, color: 'var(--t4)', marginTop: 2 }}>rostealth.site</div></div>
      </div>
      <div style={{ padding: '8px 7px', display: 'flex', flexDirection: 'column', gap: 2 }}>
        {items.map(([label, I]) => {
          const on = label === active;
          return (
            <div key={label} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '8px 11px', borderRadius: 8, background: on ? 'var(--p-dim)' : 'transparent', border: `1px solid ${on ? 'rgba(6,182,212,0.2)' : 'transparent'}`, color: on ? 'var(--p4)' : 'var(--t3)' }}>
              <I /><span style={{ fontSize: 13, fontWeight: 500 }}>{label}</span>
              {label === 'Alerts' && <span style={{ marginLeft: 'auto', minWidth: 16, height: 16, borderRadius: 8, background: 'var(--p5)', color: '#fff', fontSize: 9.5, display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 600 }}>3</span>}
            </div>
          );
        })}
      </div>
      <div style={{ marginTop: 'auto', padding: '11px 14px', borderTop: '1px solid var(--border)', display: 'flex', alignItems: 'center', gap: 9 }}>
        <Avatar name="admin" size={26} />
        <div><div style={{ fontSize: 12, fontWeight: 600, color: 'var(--t1)' }}>admin</div><div style={{ fontSize: 10, color: 'var(--p4)' }}>Pro</div></div>
      </div>
    </div>
  );
};

const SNAP_MEMBERS = [
  { n: 'xShadowReaper', s: 'online', g: 'Da Hood' },
  { n: 'FrostClan_Leader', s: 'in-game', g: 'Arsenal', flagged: true },
  { n: 'VelocityX99', s: 'offline', g: null },
  { n: 'Phantom_Wolf', s: 'online', g: 'Bloxburg' },
  { n: 'DarkMatter_X', s: 'in-game', g: 'Da Hood' },
  { n: 'NightOwl_99', s: 'online', g: 'Bloxburg' },
];

// ─── FULL DASHBOARD SNAPSHOT (hero) ───────────────────────────────────────────
const DashboardPlaceholder = () => {
  const stats = [
    { label: 'Online now', value: '4', color: 'var(--green)', bg: 'rgba(52,211,153,0.07)', border: 'rgba(52,211,153,0.18)' },
    { label: 'Tracked total', value: '6', color: 'var(--p4)', bg: 'var(--p-dim)', border: 'rgba(6,182,212,0.2)' },
    { label: 'In-game', value: '2', color: 'var(--amber)', bg: 'rgba(251,191,36,0.07)', border: 'rgba(251,191,36,0.18)' },
    { label: 'Flagged', value: '1', color: 'var(--red)', bg: 'rgba(248,113,113,0.07)', border: 'rgba(248,113,113,0.18)' },
  ];
  const bars = [42, 68, 30, 88, 56, 100, 64];
  return (
    <BrowserFrame>
      <div style={{ background: '#0A0A0A', display: 'flex', height: 560 }}>
        <SnapSidebar active="Dashboard" />
        <div style={{ flex: 1, display: 'flex', flexDirection: 'column', minWidth: 0 }}>
          {/* topbar */}
          <div style={{ height: 52, borderBottom: '1px solid var(--border)', display: 'flex', alignItems: 'center', gap: 12, padding: '0 18px' }}>
            <span style={{ fontSize: 14, fontWeight: 600, color: 'var(--t1)', flex: 1 }}>Dashboard</span>
            <div style={{ display: 'flex', alignItems: 'center', gap: 7, padding: '6px 11px', background: 'var(--bg3)', border: '1px solid var(--border)', borderRadius: 8, color: 'var(--t4)', fontSize: 12.5 }}><Icon.Search /> Search <kbd style={{ fontSize: 9.5, background: 'var(--bg4)', borderRadius: 4, padding: '1px 4px', fontFamily: 'var(--mono)' }}>⌘K</kbd></div>
            <span style={{ color: 'var(--t3)' }}><Icon.Bell /></span>
          </div>
          {/* content */}
          <div style={{ flex: 1, padding: 22, display: 'flex', flexDirection: 'column', gap: 16, overflow: 'hidden' }}>
            <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between' }}>
              <div>
                <div style={{ fontSize: 20, fontWeight: 700, color: 'var(--t1)', letterSpacing: '-0.03em' }}>admin</div>
                <div style={{ fontSize: 12.5, color: 'var(--t3)', marginTop: 4 }}><span style={{ color: 'var(--green)', fontWeight: 600 }}>4 members</span> online right now</div>
              </div>
              <div style={{ display: 'inline-flex', alignItems: 'center', gap: 6, padding: '4px 11px 4px 8px', background: 'rgba(52,211,153,0.07)', border: '1px solid rgba(52,211,153,0.16)', borderRadius: 40 }}>
                <span style={{ width: 6, height: 6, borderRadius: '50%', background: 'var(--green)' }} /><span style={{ fontSize: 10, color: 'var(--green)', fontFamily: 'var(--mono)', letterSpacing: '0.08em' }}>LIVE</span>
              </div>
            </div>
            {/* stat cards */}
            <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4,1fr)', gap: 12 }}>
              {stats.map(s => (
                <div key={s.label} style={{ background: s.bg, border: `1px solid ${s.border}`, borderRadius: 12, padding: '14px 16px' }}>
                  <div style={{ fontSize: 10, color: 'var(--t3)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 8 }}>{s.label}</div>
                  <div style={{ fontSize: 28, fontWeight: 700, color: s.color, letterSpacing: '-0.04em', lineHeight: 1 }}>{s.value}</div>
                </div>
              ))}
            </div>
            {/* two-col */}
            <div style={{ display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: 14, flex: 1, minHeight: 0 }}>
              {/* members */}
              <div className="panel-base" style={{ padding: 16, display: 'flex', flexDirection: 'column' }}>
                <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 14 }}>
                  <span style={{ fontSize: 13, fontWeight: 600, color: 'var(--t1)' }}>Members</span>
                  <span style={{ fontSize: 11.5, color: 'var(--p4)' }}>Manage →</span>
                </div>
                <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 9 }}>
                  {SNAP_MEMBERS.map(m => (
                    <div key={m.n} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 7, padding: '12px 6px', borderRadius: 10, position: 'relative', background: m.s === 'online' ? 'rgba(52,211,153,0.04)' : m.s === 'in-game' ? 'rgba(251,191,36,0.04)' : 'var(--bg3)', border: `1px solid ${m.s === 'online' ? 'rgba(52,211,153,0.16)' : m.s === 'in-game' ? 'rgba(251,191,36,0.16)' : 'var(--border)'}` }}>
                      {m.flagged && <span style={{ position: 'absolute', top: 6, right: 6, width: 6, height: 6, borderRadius: '50%', background: 'var(--amber)' }} />}
                      <Avatar name={m.n} size={34} status={m.s} />
                      <div style={{ textAlign: 'center' }}>
                        <div style={{ fontSize: 10.5, fontWeight: 600, color: 'var(--t1)', maxWidth: 70, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{m.n.split('_')[0]}</div>
                        <div style={{ fontSize: 9, color: m.s === 'online' ? 'var(--green)' : m.s === 'in-game' ? 'var(--amber)' : 'var(--t4)', fontFamily: 'var(--mono)', marginTop: 2 }}>{m.s === 'in-game' ? m.g : m.s}</div>
                      </div>
                    </div>
                  ))}
                </div>
              </div>
              {/* chart + feed */}
              <div style={{ display: 'flex', flexDirection: 'column', gap: 14, minHeight: 0 }}>
                <div className="panel-base" style={{ padding: 16 }}>
                  <div style={{ fontSize: 13, fontWeight: 600, color: 'var(--t1)', marginBottom: 4 }}>Activity this week</div>
                  <div style={{ fontSize: 11, color: 'var(--t3)', marginBottom: 14 }}>Tracked sessions per day</div>
                  <div style={{ display: 'flex', alignItems: 'flex-end', gap: 8, height: 80 }}>
                    {bars.map((h, i) => (
                      <div key={i} style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 6 }}>
                        <div style={{ width: '100%', height: `${h}%`, borderRadius: '3px 3px 0 0', background: i === 5 ? 'linear-gradient(180deg,#22D3EE,#0E7490)' : 'linear-gradient(180deg,#06B6D4,#0E7490)', opacity: i === 5 ? 1 : 0.65, boxShadow: i === 5 ? '0 0 10px rgba(6,182,212,0.5)' : 'none' }} />
                        <span style={{ fontSize: 8.5, color: 'var(--t4)', fontFamily: 'var(--mono)' }}>{['M','T','W','T','F','S','S'][i]}</span>
                      </div>
                    ))}
                  </div>
                </div>
                <div className="panel-base" style={{ flex: 1, minHeight: 0, overflow: 'hidden' }}>
                  <div style={{ display: 'flex', alignItems: 'center', gap: 7, padding: '11px 13px', borderBottom: '1px solid var(--border)' }}>
                    <span style={{ width: 5, height: 5, borderRadius: '50%', background: 'var(--green)' }} /><span style={{ fontSize: 12, fontWeight: 600, color: 'var(--t1)' }}>Live</span>
                  </div>
                  {[['xShadow', 'came online', 'online'], ['FrostClan', 'joined Arsenal', 'in-game'], ['Phantom', 'came online', 'online']].map(([n, e, s], i) => (
                    <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '8px 13px', opacity: 1 - i * 0.18 }}>
                      <GlowDot status={s} size={5} />
                      <span style={{ fontSize: 11, color: 'var(--t1)', fontWeight: 600 }}>{n}</span>
                      <span style={{ fontSize: 11, color: 'var(--t3)' }}>{e}</span>
                      <span style={{ marginLeft: 'auto', fontSize: 9, color: 'var(--t4)', fontFamily: 'var(--mono)' }}>{i * 2}m</span>
                    </div>
                  ))}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </BrowserFrame>
  );
};

// ─── FEATURE-ROW SNAPSHOTS ────────────────────────────────────────────────────
const MockPanel = ({ variant = 'tracking' }) => {
  if (variant === 'discord') {
    return (
      <BrowserFrame url="discord.com" maxWidth={520} glow={false}>
        <div style={{ background: '#0A0A0A', minHeight: 360, padding: 18 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 14 }}>
            <span style={{ color: 'var(--t2)' }}><Icon.Discord /></span>
            <span style={{ fontSize: 13, fontWeight: 600, color: 'var(--t1)' }}>#clan-watch</span>
            <span style={{ marginLeft: 'auto', fontSize: 10.5, color: 'var(--t4)', fontFamily: 'var(--mono)' }}>via webhook</span>
          </div>
          {[['xShadowReaper', 'is now online', 'var(--green)', '14:02'], ['FrostClan_Leader', 'joined Arsenal', 'var(--amber)', '14:09'], ['Phantom_Wolf', 'is now online', 'var(--green)', '14:21'], ['DarkMatter_X', 'joined Da Hood', 'var(--amber)', '14:33']].map(([n, e, c, t], i) => (
            <div key={i} style={{ display: 'flex', gap: 11, padding: '11px 13px', background: 'var(--bg2)', border: '1px solid var(--border)', borderRadius: 10, marginBottom: 8 }}>
              <LogoMark size={30} />
              <div style={{ flex: 1 }}>
                <div style={{ display: 'flex', alignItems: 'baseline', gap: 7 }}>
                  <span style={{ fontSize: 12.5, fontWeight: 700, color: 'var(--t1)' }}>RoStealth</span>
                  <span style={{ fontSize: 9, background: 'var(--p6)', color: '#fff', padding: '1px 5px', borderRadius: 3, fontWeight: 600 }}>BOT</span>
                  <span style={{ fontSize: 10, color: 'var(--t4)' }}>{t}</span>
                </div>
                <div style={{ fontSize: 12.5, color: 'var(--t2)', marginTop: 3 }}><b style={{ color: c }}>{n}</b> {e}</div>
              </div>
            </div>
          ))}
        </div>
      </BrowserFrame>
    );
  }
  if (variant === 'analytics') {
    const bars = [38, 60, 28, 80, 52, 96, 70, 44, 66];
    return (
      <BrowserFrame url="app.rostealth.site/analytics" maxWidth={560} glow={false}>
        <div style={{ background: '#0A0A0A', minHeight: 360, padding: 18 }}>
          <div style={{ fontSize: 13, fontWeight: 600, color: 'var(--t1)', marginBottom: 2 }}>Session trend</div>
          <div style={{ fontSize: 11, color: 'var(--t3)', marginBottom: 16 }}>Activity over the last 30 days</div>
          <div style={{ display: 'flex', alignItems: 'flex-end', gap: 6, height: 110, marginBottom: 18 }}>
            {bars.map((h, i) => (
              <div key={i} style={{ flex: 1, height: `${h}%`, borderRadius: '3px 3px 0 0', background: i === 5 ? 'linear-gradient(180deg,#22D3EE,#0E7490)' : 'linear-gradient(180deg,#06B6D4,#0E7490)', opacity: i === 5 ? 1 : 0.6, boxShadow: i === 5 ? '0 0 10px rgba(6,182,212,0.5)' : 'none' }} />
            ))}
          </div>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 10 }}>
            {[['Total', '482', 'var(--t1)'], ['Peak day', '96', 'var(--p4)'], ['Avg / day', '16', 'var(--green)']].map(([l, v, c]) => (
              <div key={l} style={{ background: 'var(--bg2)', border: '1px solid var(--border)', borderRadius: 10, padding: '12px 14px' }}>
                <div style={{ fontSize: 9.5, color: 'var(--t4)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 7 }}>{l}</div>
                <div style={{ fontSize: 22, fontWeight: 700, color: c, letterSpacing: '-0.04em', lineHeight: 1 }}>{v}</div>
              </div>
            ))}
          </div>
        </div>
      </BrowserFrame>
    );
  }
  // default: tracking table
  return (
    <BrowserFrame url="app.rostealth.site/tracking" maxWidth={560} glow={false}>
      <div style={{ background: '#0A0A0A', minHeight: 360, padding: 18 }}>
        <div style={{ display: 'flex', gap: 8, marginBottom: 14 }}>
          <div style={{ flex: 1, display: 'flex', alignItems: 'center', gap: 8, padding: '8px 12px', background: 'var(--bg3)', border: '1px solid var(--border)', borderRadius: 8, color: 'var(--t4)', fontSize: 12.5 }}><Icon.Search /> Filter by username or ID…</div>
          <div style={{ padding: '8px 14px', background: 'var(--p5)', borderRadius: 8, color: '#fff', fontSize: 12.5, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 6 }}><Icon.Plus /> Add</div>
        </div>
        <div className="panel-base" style={{ overflow: 'hidden' }}>
          {SNAP_MEMBERS.map((m, i) => (
            <div key={m.n} style={{ display: 'flex', alignItems: 'center', gap: 11, padding: '11px 14px', borderBottom: i < SNAP_MEMBERS.length - 1 ? '1px solid rgba(255,255,255,0.04)' : 'none', background: m.flagged ? 'rgba(251,191,36,0.025)' : 'transparent' }}>
              <Avatar name={m.n} size={30} status={m.s} />
              <div style={{ flex: 1, minWidth: 0 }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
                  <span style={{ fontSize: 12.5, fontWeight: 600, color: 'var(--t1)' }}>{m.n}</span>
                  {m.flagged && <Badge color="amber" size="xs">Flagged</Badge>}
                </div>
                <div style={{ fontSize: 9.5, color: 'var(--t4)', fontFamily: 'var(--mono)', marginTop: 1 }}>{m.g || '—'}</div>
              </div>
              <StatusDot status={m.s} />
            </div>
          ))}
        </div>
      </div>
    </BrowserFrame>
  );
};

// ─── HERO (centered, filen style) ─────────────────────────────────────────────
const Hero = ({ onSignup }) => {
  const content = useReveal();
  const mockup = useReveal(220);
  return (
    <section style={{ position: 'relative', overflowX: 'hidden', padding: 'clamp(120px,16vh,200px) max(24px,5vw) 0' }}>
      {/* radial glow */}
      <div style={{ position: 'absolute', top: '0%', left: '50%', transform: 'translateX(-50%)', width: 1000, height: 760, background: 'radial-gradient(ellipse at 50% 25%, rgba(6,182,212,0.13) 0%, rgba(124,58,237,0.05) 45%, transparent 68%)', pointerEvents: 'none' }} />
      {/* dot grid */}
      <div style={{ position: 'absolute', inset: 0, backgroundImage: 'radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px)', backgroundSize: '34px 34px', pointerEvents: 'none', maskImage: 'radial-gradient(ellipse 70% 55% at 50% 35%, black 5%, transparent 100%)' }} />

      <div ref={content} style={{ position: 'relative', textAlign: 'center', maxWidth: 880, margin: '0 auto', display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
        <h1 style={{ fontSize: 'clamp(40px,6.5vw,80px)', fontWeight: 700, letterSpacing: '-0.04em', lineHeight: 1.04, color: 'var(--t1)', marginBottom: 26, animation: 'fadein 0.7s var(--ease-out-expo) 0.05s both', textWrap: 'balance' }}>
          Community Intelligence for{' '}
          <span style={GRADIENT_TEXT}>Roblox Groups</span>
        </h1>
        <p style={{ fontSize: 18.5, color: 'var(--t2)', lineHeight: 1.6, maxWidth: 600, marginBottom: 40, textWrap: 'pretty', animation: 'fadein 0.7s var(--ease-out-expo) 0.15s both' }}>
          Reliable live status, session history, and smart alerts you can trust.
          Track your whole community without bots, passwords, or guesswork.
        </p>
        <div style={{ display: 'flex', gap: 20, alignItems: 'center', justifyContent: 'center', flexWrap: 'wrap', animation: 'fadein 0.7s var(--ease-out-expo) 0.25s both' }}>
          <WhiteBtn onClick={onSignup}>Get started</WhiteBtn>
          <button onClick={() => { const el = document.querySelector('#how'); if (el) window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 100, behavior: 'smooth' }); }} style={{ display: 'inline-flex', alignItems: 'center', gap: 7, background: 'none', border: 'none', cursor: 'pointer', color: 'var(--t2)', fontSize: 15, fontFamily: 'var(--font)', fontWeight: 500, transition: 'color 0.15s' }} onMouseEnter={e => e.currentTarget.style.color = 'var(--t1)'} onMouseLeave={e => e.currentTarget.style.color = 'var(--t2)'}>
            See how it works <span style={{ color: 'var(--p4)' }}>›</span>
          </button>
        </div>
        <p style={{ fontSize: 13, color: 'var(--t4)', marginTop: 18, animation: 'fadein 0.7s var(--ease-out-expo) 0.35s both' }}>No subscription required</p>
      </div>

      <div ref={mockup} style={{ position: 'relative', marginTop: 72, padding: '0 max(24px,3vw)', animation: 'fadein 0.9s var(--ease-out-expo) 0.4s both' }}>
        <DashboardPlaceholder />
        <div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, height: 200, background: 'linear-gradient(to bottom, transparent 0%, var(--bg0) 92%)', pointerEvents: 'none' }} />
      </div>
    </section>
  );
};

// ─── "FEATURES TO MEET ALL YOUR NEEDS" — alternating rows ──────────────────────
const FeatureRow = ({ icon, title, body, flip, shot }) => {
  const r = useReveal();
  return (
    <div ref={r} style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'clamp(40px,6vw,90px)', alignItems: 'center' }} className="step-row">
      <div style={{ order: flip ? 2 : 1 }}>
        <div style={{ width: 44, height: 44, borderRadius: 12, background: 'var(--bg2)', border: '1px solid var(--border)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: 'var(--p4)', marginBottom: 22 }}>{icon}</div>
        <h3 style={{ fontSize: 'clamp(24px,2.8vw,34px)', fontWeight: 700, letterSpacing: '-0.03em', color: 'var(--t1)', lineHeight: 1.12 }}>{title}</h3>
        <p style={{ fontSize: 16, color: 'var(--t2)', lineHeight: 1.7, marginTop: 16, maxWidth: 420 }}>{body}</p>
      </div>
      <div style={{ order: flip ? 1 : 2 }}><MockPanel variant={shot} /></div>
    </div>
  );
};

const HowItWorks = () => (
  <section id="how" style={{ padding: 'clamp(80px,12vh,140px) max(24px,5vw)' }}>
    <div style={{ maxWidth: 1080, margin: '0 auto' }}>
      <SectionHead title="Features to meet all your" gradientWord="needs" sub="RoStealth offers a robust suite of features, providing all the tools you need to monitor, track, and stay ahead of your community." />
      <div style={{ display: 'flex', flexDirection: 'column', gap: 'clamp(80px,10vw,130px)' }}>
        <FeatureRow flip={false} shot="tracking" icon={<Icon.Tracking />} title="Seamlessly track your community" body="Get a complete overview of every member with flexible list and detail views. Online, in-game, or offline — the board is always current, refreshed automatically every 30 seconds." />
        <FeatureRow flip={true} shot="discord" icon={<Icon.Bell />} title="Smart alerts, where you live" body="Pipe any status change straight into Discord via webhook. Set conditions — a member coming online, joining a rival's favorite game — and RoStealth fires the moment they trigger." />
        <FeatureRow flip={false} shot="analytics" icon={<Icon.Analytics />} title="Session history that sticks" body="Every session is logged and kept for 30 days. Scrub back through days of activity to spot patterns, no-shows, and suspicious behavior at a glance." />
      </div>
    </div>
  </section>
);

Object.assign(window, { useReveal, useStaggerReveal, Eyebrow, SectionHead, GRADIENT_TEXT, WhiteBtn, BrowserFrame, SnapSidebar, DashboardPlaceholder, MockPanel, LandingNav, Hero, HowItWorks, FeatureRow });
