/* Sharpline — marketing site sections, built on the Aave design system. */
const { Button, Badge, FeatureCard } = window.AaveDesignSystem_b9d957;
const Icon = window.Icon; // lucide helper from the DS bundle

const VIOLET = '#97CDFF';
const OBSIDIAN = 'var(--color-obsidian)';
const INK = 'var(--color-inkwell)';
const ASH = 'var(--color-ash)';
const MONO = 'var(--font-aave-repro-mono)';

/* Dark sections render as rounded panels inset 40px from the page edges,
   floating on the light page with a small vertical gap. */
const DARK_PANEL = { margin: '40px', borderRadius: 24, overflow: 'hidden',
  border: '1px solid rgba(255,255,255,0.08)' };

/* ---------- Brand mark ---------- */
function SharplineLogo({ onDark = false, size = 28 }) {
  return (
    <span style={{ display: 'inline-flex', alignItems: 'center', gap: 10 }}>
      <svg width={size} height={size} viewBox="0 0 28 28" fill="none" aria-hidden="true">
        <rect x="1" y="1" width="26" height="26" rx="8" fill="#97CDFF" />
        <polyline points="6,18.5 11,13 15,16 22,8.5" fill="none" stroke="#fff"
          strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" />
        <circle cx="22" cy="8.5" r="2.5" fill="#fff" />
      </svg>
      <img src="uploads/snewj logo.svg" alt="snewj"
        style={{ height: 21, width: 'auto', display: 'block',
          filter: onDark ? 'none' : 'invert(1)', transition: 'filter .25s ease' }} />
    </span>
  );
}

/* ---------- shared layout ---------- */
function LiquidBtn({ href, children, block }) {
  // Wraps any DS Button in an animated metallic border ring.
  return (
    <a href={href} className={'liquid-btn-wrap' + (block ? ' liquid-btn-block' : '')}
      style={{ display: block ? 'block' : 'inline-block', verticalAlign:'middle' }}>
      {children}
    </a>
  );
}
/* CTA label that compacts to just "Access" on mobile (CSS-toggled). */
function CtaLabel() {
  return (
    <React.Fragment>
      <span className="lbl-full">Claim bot access</span>
      <span className="lbl-mini">Access</span>
    </React.Fragment>
  );
}
function Container({ children, style }) {
  return <div style={{ maxWidth: 1160, margin: '0 auto', padding: '0 24px', width: '100%', ...style }}>{children}</div>;
}
function Eyebrow({ children, style }) {
  return <span style={{ fontFamily: MONO, fontSize: 13, fontWeight: 500, letterSpacing: 1.6,
    textTransform: 'uppercase', color: VIOLET, ...style }}>{children}</span>;
}
function CheckIcon() {
  return <span style={{ flex: 'none', width: 20, height: 20, borderRadius: '50%',
    background: 'rgba(143,201,255,0.16)', display: 'inline-flex', alignItems: 'center',
    justifyContent: 'center', marginTop: 1 }}>
    <Icon name="check" size={12} color={VIOLET} strokeWidth={2.2} /></span>;
}

/* ===================================================================== NAV */
function Nav() {
  // Invert nav contents (logo wordmark + CTA) when the bar overlays a dark panel.
  const [onDark, setOnDark] = React.useState(true);
  React.useEffect(() => {
    const probe = 36; // ~vertical center of the bar
    const update = () => {
      let dark = false;
      document.querySelectorAll('.dark-panel, [data-nav-dark]').forEach(p => {
        const r = p.getBoundingClientRect();
        if (r.top <= probe && r.bottom >= probe) dark = true;
      });
      setOnDark(dark);
    };
    update();
    window.addEventListener('scroll', update, { passive: true });
    window.addEventListener('resize', update);
    return () => { window.removeEventListener('scroll', update); window.removeEventListener('resize', update); };
  }, []);
  React.useEffect(() => { if (window.lucide) window.lucide.createIcons({ attrs: { 'stroke-width': 1.5 } }); }, [onDark]);
  return (
    <nav className="nav-bar" style={{ position: 'sticky', top: 0, zIndex: 50, background: 'transparent', marginBottom: -88 }}>
      <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
        gap: 24, padding: '22px 40px', maxWidth: 1320, margin: '0 auto' }}>
        <SharplineLogo onDark={onDark} />
        <LiquidBtn href="#pricing">
          <span className="gradient-cta">
            <Button variant="violet"
              leadingIcon={<Icon name="zap" size={15} color="#fff" />}><CtaLabel /></Button>
          </span>
        </LiquidBtn>
      </div>
    </nav>
  );
}

/* ============================================================ HERO MOCKUPS */
function ScannerPanel() {
  const rows = [
    ['NBA · Lakers @ Celtics', '0.42', '0.51', 0.62],
    ['MLB · Dodgers ML', '0.58', '0.55', 0.30],
    ['NFL · Chiefs -3.5', '0.47', '0.53', 0.48],
    ['UFC · Makhachev', '0.71', '0.76', 0.40],
  ];
  return (
    <div style={{ width: 320, background: 'var(--color-paper)', borderRadius: 20,
      boxShadow: 'var(--shadow-lg)', padding: 18, transform: 'rotate(-3deg)',
      border: '1px solid rgba(34,29,29,0.05)' }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 14 }}>
        <span style={{ width: 8, height: 8, borderRadius: '50%', background: '#1f8a5b',
          boxShadow: '0 0 0 4px rgba(31,138,91,0.14)' }} />
        <span style={{ fontSize: 13, fontWeight: 500, letterSpacing: -0.16, color: OBSIDIAN }}>Scanning Polymarket</span>
        <span style={{ marginLeft: 'auto', fontFamily: MONO, fontSize: 11, color: 'var(--color-graphite)' }}>live</span>
      </div>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
        {rows.map((r, i) => (
          <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ fontSize: 12.5, color: OBSIDIAN, whiteSpace: 'nowrap', overflow: 'hidden',
                textOverflow: 'ellipsis', letterSpacing: -0.16 }}>{r[0]}</div>
              <div style={{ height: 4, borderRadius: 999, background: 'var(--color-bone)', marginTop: 6, overflow: 'hidden' }}>
                <div style={{ width: `${r[3] * 100}%`, height: '100%', background: VIOLET }} />
              </div>
            </div>
            <div style={{ fontFamily: MONO, fontSize: 12, color: 'var(--color-iron)', width: 30, textAlign: 'right' }}>{r[1]}</div>
            <div style={{ fontFamily: MONO, fontSize: 12, color: VIOLET, width: 30, textAlign: 'right', fontWeight: 500 }}>{r[2]}</div>
          </div>
        ))}
      </div>
    </div>
  );
}

function AlertCard() {
  return (
    <div style={{ width: 360, background: '#1e1f22', borderRadius: 16,
      boxShadow: '0 24px 60px rgba(34,29,29,0.28)', padding: '16px 16px 18px',
      transform: 'rotate(2.5deg)', border: '1px solid rgba(0,0,0,0.2)' }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 12 }}>
        <span style={{ width: 36, height: 36, borderRadius: '50%', background: VIOLET, flex: 'none',
          display: 'inline-flex', alignItems: 'center', justifyContent: 'center' }}>
          <Icon name="activity" size={18} color="#fff" /></span>
        <span style={{ fontSize: 14.5, fontWeight: 500, color: '#fff' }}>Sharpline</span>
        <span style={{ fontFamily: MONO, fontSize: 9.5, fontWeight: 500, color: '#fff', background: VIOLET,
          borderRadius: 4, padding: '2px 5px', letterSpacing: 0.5 }}>BOT</span>
        <span style={{ marginLeft: 'auto', fontSize: 11, color: '#b5bac1' }}>Today at 7:42 PM</span>
      </div>
      <div style={{ borderLeft: `3px solid ${VIOLET}`, background: '#2b2d31', borderRadius: '4px 8px 8px 4px',
        padding: '12px 14px' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 7, marginBottom: 10 }}>
          <Icon name="trophy" size={14} color={VIOLET} />
          <span style={{ fontSize: 13, fontWeight: 500, color: '#fff', letterSpacing: -0.16 }}>NBA · Lakers @ Celtics — Moneyline</span>
        </div>
        <div style={{ display: 'flex', gap: 10, marginBottom: 12 }}>
          <div style={{ flex: 1, background: '#1e1f22', borderRadius: 8, padding: '9px 11px' }}>
            <div style={{ fontSize: 10.5, color: '#b5bac1', letterSpacing: 0.4, textTransform: 'uppercase' }}>Polymarket</div>
            <div style={{ fontFamily: MONO, fontSize: 22, fontWeight: 500, color: '#fff', marginTop: 2 }}>0.42</div>
          </div>
          <div style={{ flex: 1, background: '#1e1f22', borderRadius: 8, padding: '9px 11px' }}>
            <div style={{ fontSize: 10.5, color: VIOLET, letterSpacing: 0.4, textTransform: 'uppercase' }}>Fair value</div>
            <div style={{ fontFamily: MONO, fontSize: 22, fontWeight: 500, color: '#fff', marginTop: 2 }}>0.51</div>
          </div>
          <div style={{ flex: 'none', alignSelf: 'stretch', display: 'flex', flexDirection: 'column',
            justifyContent: 'center', alignItems: 'center', background: 'rgba(143,201,255,0.16)',
            borderRadius: 8, padding: '0 12px' }}>
            <div style={{ fontFamily: MONO, fontSize: 18, fontWeight: 500, color: VIOLET }}>+9¢</div>
            <div style={{ fontSize: 9.5, color: VIOLET, letterSpacing: 0.4 }}>EDGE</div>
          </div>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, color: '#fff' }}>
          <Icon name="arrow-right" size={14} color={VIOLET} />
          <span>Buy <b style={{ fontWeight: 500 }}>YES</b> at <span style={{ fontFamily: MONO }}>0.42</span> or lower</span>
        </div>
      </div>
      <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginTop: 10 }}>
        <Icon name="timer" size={13} color="#b5bac1" />
        <span style={{ fontSize: 11.5, color: '#b5bac1' }}>Act fast — the market is closing this gap.</span>
      </div>
    </div>
  );
}

/* ================================================================== REVIEWS */
/* Five filled stars — sky-blue, the system's single accent (no gold second hue). */
function StarRow({ size = 16, gap = 3, color = VIOLET }) {
  const STAR = "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z";
  return (
    <span style={{ display: 'inline-flex', gap }} role="img" aria-label="Rated 5 out of 5">
      {[0, 1, 2, 3, 4].map(i => (
        <svg key={i} width={size} height={size} viewBox="0 0 24 24" fill={color} aria-hidden="true"><path d={STAR} /></svg>
      ))}
    </span>
  );
}

/* Compact inline social-proof strip — number + label, no card, no icon.
   Sits directly under the hero video. */
function HeroStats() {
  const stats = [
    ['153,000+', 'active members'],
    ['1,500+', 'verified reviews'],
    ['Verified', 'Whop status'],
  ];
  return (
    <div className="hero-stats" style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', flexWrap: 'wrap',
      gap: '12px 26px', marginTop: 26, position: 'relative', zIndex: 1 }}>
      {stats.map(([v, l], i) => (
        <React.Fragment key={l}>
          {i > 0 && <span aria-hidden="true" className="hero-stat-dot" style={{ width: 4, height: 4, borderRadius: '50%',
            background: 'rgba(255,255,255,0.22)' }} />}
          <span style={{ display: 'inline-flex', alignItems: 'baseline', gap: 8, fontSize: 14,
            color: ASH, letterSpacing: -0.2 }}>
            <span style={{ fontFamily: 'var(--font-heading)', fontWeight: 600, fontSize: 19,
              color: '#fff', letterSpacing: -0.6 }}>{v}</span>
            {l}
          </span>
        </React.Fragment>
      ))}
    </div>
  );
}

/* One testimonial. Stars + quote-mark up top, quote leads, reviewer anchors the base. */
function ReviewCard({ name, initials, tint, quote }) {
  const [hover, setHover] = React.useState(false);
  return (
    <article data-review-card onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}
      style={{ flex: 'none', width: 'min(340px, 82vw)', scrollSnapAlign: 'start',
        background: hover ? '#171d26' : '#13181F',
        border: `1px solid ${hover ? 'rgba(151,205,255,0.5)' : 'rgba(255,255,255,0.09)'}`,
        borderRadius: 20, padding: 26, display: 'flex', flexDirection: 'column', minHeight: 232,
        transform: hover ? 'translateY(-4px)' : 'translateY(0)',
        transition: 'transform .25s ease, border-color .25s ease, background .25s ease' }}>
      <div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between' }}>
        <StarRow size={16} />
        <Icon name="quote" size={20} color="rgba(151,205,255,0.30)" />
      </div>
      <p style={{ margin: '18px 0 0', flex: 1, fontSize: 'clamp(18px,1.35vw,20px)', lineHeight: 1.45,
        fontWeight: 500, letterSpacing: -0.3, color: '#fff', textWrap: 'pretty' }}>{quote}</p>
      <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginTop: 22, paddingTop: 18,
        borderTop: '1px solid rgba(255,255,255,0.08)' }}>
        <span style={{ width: 40, height: 40, borderRadius: '50%', flex: 'none', background: tint,
          color: '#06121f', display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
          fontFamily: 'var(--font-heading)', fontWeight: 700, fontSize: 14 }}>{initials}</span>
        <div style={{ minWidth: 0 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 15, fontWeight: 500,
            color: '#fff', letterSpacing: -0.2 }}>
            <span style={{ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{name}</span>
            <Icon name="badge-check" size={14} color={VIOLET} />
          </div>
          <div style={{ fontSize: 12.5, color: ASH, marginTop: 1 }}>Verified member</div>
        </div>
      </div>
    </article>
  );
}

/* Pointer drag-to-scroll for the slider; suppresses the click that ends a drag. */
function useDragScroll() {
  const ref = React.useRef(null);
  React.useEffect(() => {
    const el = ref.current; if (!el) return;
    let down = false, sx = 0, sl = 0, moved = false;
    const onDown = e => { down = true; moved = false; sx = e.pageX; sl = el.scrollLeft; };
    const onMove = e => { if (!down) return; const dx = e.pageX - sx; if (Math.abs(dx) > 4) moved = true; el.scrollLeft = sl - dx; };
    const onUp = () => { down = false; };
    const onClick = e => { if (moved) { e.preventDefault(); e.stopPropagation(); } };
    el.addEventListener('pointerdown', onDown);
    window.addEventListener('pointermove', onMove, { passive: true });
    window.addEventListener('pointerup', onUp, { passive: true });
    el.addEventListener('click', onClick, true);
    return () => {
      el.removeEventListener('pointerdown', onDown);
      window.removeEventListener('pointermove', onMove);
      window.removeEventListener('pointerup', onUp);
      el.removeEventListener('click', onClick, true);
    };
  }, []);
  return ref;
}

function ArrowBtn({ dir, onClick }) {
  const [h, setH] = React.useState(false);
  return (
    <button onClick={onClick} onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)}
      aria-label={dir < 0 ? 'Previous reviews' : 'Next reviews'}
      style={{ width: 48, height: 48, borderRadius: '50%', cursor: 'pointer',
        border: `1px solid ${h ? 'rgba(151,205,255,0.55)' : 'rgba(255,255,255,0.15)'}`,
        background: h ? 'rgba(151,205,255,0.16)' : 'rgba(255,255,255,0.04)',
        display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
        transition: 'background .2s ease, border-color .2s ease' }}>
      <Icon name={dir < 0 ? 'arrow-left' : 'arrow-right'} size={19} color="#fff" />
    </button>
  );
}

/* Social-proof band that lives at the foot of the hero: header, stat cards,
   and a horizontally scrollable testimonial slider. */
function Reviews() {
  const scroller = useDragScroll();
  const nudge = dir => {
    const el = scroller.current; if (!el) return;
    const card = el.querySelector('[data-review-card]');
    const amt = card ? card.getBoundingClientRect().width + 16 : 356;
    el.scrollBy({ left: dir * amt, behavior: 'smooth' });
  };
  const reviews = [
    ['Samuel Porterfield', 'SP', '#97CDFF', 'SnewJ is the man when it comes to picking winners.'],
    ['T. Flem', 'TF', '#bfe0ff', 'Great way to build your bankroll. Simple straight plays that deliver.'],
    ['Dervarick Tyson', 'DT', '#9fc3e8', 'Consistency is key. Straight plays are fire.'],
    ["J's StraightPlays", 'JS', '#cdd7e2', 'Picks working here.'],
    ['Novacito23', 'NV', '#97CDFF', 'They do hit.'],
    ['HuyT', 'HY', '#bfe0ff', 'The best.'],
  ];
  return (
    <div style={{ position: 'relative', zIndex: 1, marginTop: 96 }}>
      <style>{`
        .review-scroller { scrollbar-width: none; -ms-overflow-style: none; cursor: grab; }
        .review-scroller:active { cursor: grabbing; }
        .review-scroller::-webkit-scrollbar { display: none; }
      `}</style>
      <Container>
        <div style={{ textAlign: 'center' }}>
          <Eyebrow>Reviews</Eyebrow>
          <h2 style={{ margin: '14px 0 0', fontSize: 'clamp(28px,3.4vw,40px)', fontWeight: 500,
            letterSpacing: -1.8, lineHeight: 1.14, color: '#fff', textWrap: 'balance' }}>
            What members are saying.
          </h2>
        </div>
      </Container>

      <div className="review-scroller" ref={scroller} style={{ display: 'flex', gap: 16,
        overflowX: 'auto', scrollSnapType: 'x proximity', marginTop: 28,
        padding: '8px max(24px, calc((100% - 1160px) / 2 + 24px)) 16px',
        WebkitMaskImage: 'linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 96px), transparent 100%)',
        maskImage: 'linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 96px), transparent 100%)' }}>
        {reviews.map(([n, ini, t, q]) => <ReviewCard key={n} name={n} initials={ini} tint={t} quote={q} />)}
      </div>

      <Container>
        <div style={{ display: 'flex', justifyContent: 'center', gap: 12, marginTop: 24 }}>
          <ArrowBtn dir={-1} onClick={() => nudge(-1)} />
          <ArrowBtn dir={1} onClick={() => nudge(1)} />
        </div>
      </Container>
    </div>
  );
}

/* ===================================================================== HERO */
/* Hero VSL — Vimeo-hosted embed in a 16:9 frame with the brand glow border. */
function HeroVideo() {
  return (
    <div style={{ position: 'relative', paddingBottom: '56.25%',
      borderRadius: 18, overflow: 'hidden',
      border: '1.5px solid rgba(143,201,255,0.4)',
      boxShadow: '0 0 56px rgba(143,201,255,0.16), 0 28px 80px rgba(0,0,0,0.6)' }}>
      <iframe
        src="https://player.vimeo.com/video/1205617804?badge=0&autopause=0&player_id=0&app_id=58479"
        title="SnewJ Polymarket" frameBorder="0"
        allow="autoplay; fullscreen; picture-in-picture; clipboard-write; encrypted-media; web-share"
        referrerPolicy="strict-origin-when-cross-origin"
        style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%', border: 0 }} />
    </div>
  );
}

function Hero() {
  return (
    <section data-screen-label="Hero" data-nav-dark="true" style={{
      position: 'relative',
      background: '#070A0D',
      backgroundImage: "url('uploads/background image.png')",
      backgroundSize: '100% auto',
      backgroundPosition: 'center top',
      backgroundRepeat: 'no-repeat',
      overflow: 'visible', paddingBottom: 96 }}>
      <style>{`
        @keyframes poly-flow {
          0%   { background-position: 0% 50%; }
          50%  { background-position: 100% 50%; }
          100% { background-position: 0% 50%; }
        }
        .poly-gradient {
          background: linear-gradient(90deg, #97CDFF, #257DD0, #5BA8E8, #257DD0, #97CDFF);
          background-size: 300% 100%;
          -webkit-background-clip: text;
          background-clip: text;
          -webkit-text-fill-color: transparent;
          color: transparent;
          animation: poly-flow 3s ease infinite;
        }
        .gradient-cta button {
          background: linear-gradient(90deg, #97CDFF, #257DD0, #5BA8E8, #257DD0, #97CDFF) !important;
          background-size: 300% 100% !important;
          animation: poly-flow 3s ease infinite !important;
          border: none !important;
          color: #fff !important;
        }
        .gradient-cta button svg, .gradient-cta button [data-lucide] {
          color: #fff !important;
          stroke: #fff !important;
        }
      `}</style>
      <div className="hero-aurora" aria-hidden="true"></div>
      <Container style={{ paddingTop: 88, textAlign: 'center', position: 'relative', zIndex: 1 }}>
        <h1 className="sl-fade" style={{ margin: '0 auto', maxWidth: 920, fontSize: 'clamp(40px, 6vw, 64px)',
          fontWeight: 500, letterSpacing: -3, lineHeight: 1.125, color: '#ffffff', textWrap: 'balance' }}>
          <span className="poly-gradient">AI</span> finds the trades. You collect.
        </h1>

        <p className="sl-fade hero-desc" style={{ margin: '24px auto 0', maxWidth: 720, fontSize: 18,
          fontWeight: 450, lineHeight: '28px', letterSpacing: -0.2, color: 'var(--color-ash)', textWrap: 'pretty' }}>
          Our AI runs the numbers on Polymarket around the clock — the one market where the odds aren't stacked against you. The second it finds a trade worth taking, you get a ping. Place it in 60 seconds, then collect.. That's the whole system.
        </p>

        <div className="sl-fade hero-cta-row" style={{ display: 'flex', gap: 16, justifyContent: 'center', marginTop: 34, flexWrap: 'wrap' }}>
          <LiquidBtn href="#pricing">
            <span className="gradient-cta"><Button variant="violet" leadingIcon={<Icon name="zap" size={16} color="#fff" />}><CtaLabel /></Button></span>
          </LiquidBtn>
        </div>
      </Container>

      {/* Hero video with flanking graphics — composed at 1440px / 16:9.
         Side images are flush (0px) against the video and scale as a % of its width. */}
      <div className="hero-video-wrap" style={{ margin: '52px auto 0', maxWidth: 860, padding: '0 24px', position: 'relative', zIndex: 1 }}>
        <div style={{ position: 'relative' }}>
          <img src="uploads/left.png" alt="" aria-hidden="true"
            style={{ position: 'absolute', right: '100%', top: '50%', transform: 'translateY(-50%)',
              width: '40%', height: 'auto', pointerEvents: 'none', userSelect: 'none' }} />
          <img src="uploads/right.png" alt="" aria-hidden="true"
            style={{ position: 'absolute', left: '100%', top: '50%', transform: 'translateY(-50%)',
              width: '40%', height: 'auto', pointerEvents: 'none', userSelect: 'none' }} />
          <HeroVideo />
        </div>
      </div>
      <HeroStats />
      <Reviews />
    </section>
  );
}

/* ===================================================================== DEMO */
function Demo() {
  const captions = [
    ['radar', 'What the bot scans', 'Polymarket prices vs sharp Vegas lines, side by side.'],
    ['bell', 'What the alert looks like', 'One clean Discord ping with price, fair value, and edge.'],
    ['mouse-pointer-click', 'How you act', 'Open Polymarket, buy YES or NO at the suggested price.'],
  ];
  return (
    <section id="demo" data-screen-label="Demo" className="dark-panel" style={{ ...DARK_PANEL, background: OBSIDIAN, padding: '88px 0' }}>
      <Container>
        <div style={{ textAlign: 'center', maxWidth: 680, margin: '0 auto' }}>
          <h2 style={{ margin: 0, fontSize: 'clamp(34px,4.5vw,48px)', fontWeight: 500,
            letterSpacing: -2, lineHeight: 1.167, color: '#fff' }}>
            See the machine, the signal, the trade.
          </h2>

        </div>

        <div style={{ position: 'relative', marginTop: 48, borderRadius: 20, overflow: 'hidden',
          border: '1px solid rgba(255,255,255,0.08)', boxShadow: 'var(--shadow-lg)' }}>
          <image-slot id="demo-video" style={{ display: 'block', width: '100%', aspectRatio: '16 / 9' }}
            shape="rect" placeholder="Drop your demo video poster" fit="cover"></image-slot>
          <div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center',
            justifyContent: 'center', pointerEvents: 'none' }}>
            <span style={{ width: 76, height: 76, borderRadius: '50%', background: VIOLET,
              display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
              boxShadow: '0 12px 40px rgba(143,201,255,0.5)' }}>
              <Icon name="play" size={28} color="#fff" /></span>
          </div>
          <div style={{ position: 'absolute', left: 16, bottom: 16, display: 'inline-flex',
            alignItems: 'center', gap: 7, background: 'rgba(15,15,16,0.6)', backdropFilter: 'blur(6px)',
            borderRadius: 999, padding: '6px 12px', pointerEvents: 'none' }}>
            <span style={{ width: 7, height: 7, borderRadius: '50%', background: '#ff5c5c' }} />
            <span style={{ fontFamily: MONO, fontSize: 11, color: '#fff', letterSpacing: 0.4 }}>DEMO · 2:04</span>
          </div>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
          gap: 20, marginTop: 32 }}>
          {captions.map(([ic, t, d]) => (
            <div key={t} style={{ display: 'flex', gap: 12 }}>
              <span style={{ flex: 'none', width: 36, height: 36, borderRadius: 10,
                background: 'rgba(143,201,255,0.14)', display: 'inline-flex', alignItems: 'center',
                justifyContent: 'center' }}><Icon name={ic} size={17} color={VIOLET} /></span>
              <div>
                <div style={{ fontSize: 15, fontWeight: 500, color: '#fff', letterSpacing: -0.2 }}>{t}</div>
                <div style={{ fontSize: 13.5, lineHeight: 1.5, color: ASH, marginTop: 3 }}>{d}</div>
              </div>
            </div>
          ))}
        </div>
      </Container>
    </section>
  );
}

/* ================================================================== PROCESS */
/* Dot indicators for a horizontal mobile slider. Tracks the nearest-centered
   child of `scrollerRef` and scrolls to a card when a dot is tapped. Hidden on
   desktop via the `mobile-dots` class (CSS media query). */
function SliderDots({ scrollerRef, count }) {
  const [active, setActive] = React.useState(0);
  React.useEffect(() => {
    const el = scrollerRef.current; if (!el) return;
    const onScroll = () => {
      const center = el.scrollLeft + el.clientWidth / 2;
      let best = 0, bestDist = Infinity;
      Array.from(el.children).forEach((c, i) => {
        const cc = c.offsetLeft + c.offsetWidth / 2;
        const d = Math.abs(cc - center);
        if (d < bestDist) { bestDist = d; best = i; }
      });
      setActive(best);
    };
    el.addEventListener('scroll', onScroll, { passive: true });
    onScroll();
    return () => el.removeEventListener('scroll', onScroll);
  }, []);
  const go = i => {
    const el = scrollerRef.current; if (!el) return;
    const child = el.children[i]; if (!child) return;
    el.scrollTo({ left: child.offsetLeft - (el.clientWidth - child.offsetWidth) / 2, behavior: 'smooth' });
  };
  return (
    <div className="mobile-dots" style={{ display: 'none', justifyContent: 'center', gap: 8, marginTop: 26 }}>
      {Array.from({ length: count }).map((_, i) => (
        <button key={i} onClick={() => go(i)} aria-label={`Go to slide ${i + 1}`}
          style={{ width: active === i ? 24 : 8, height: 8, borderRadius: 999, border: 'none',
            padding: 0, cursor: 'pointer', background: active === i ? VIOLET : 'rgba(34,29,29,0.18)',
            transition: 'width .25s ease, background .25s ease' }} />
      ))}
    </div>
  );
}
/* One "how it works" step: numbered badge, tinted media well, hover lift. */
function StepCard({ n, img, quote, title, body }) {
  const [hover, setHover] = React.useState(false);
  return (
    <div onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}
      style={{ position: 'relative', background: '#ffffff', borderRadius: 24, padding: 14,
        border: `1px solid ${hover ? 'rgba(151,205,255,0.9)' : 'rgba(34,29,29,0.09)'}`,
        display: 'flex', flexDirection: 'column',
        transform: hover ? 'translateY(-6px)' : 'translateY(0)',
        boxShadow: hover ? '0 24px 50px -24px rgba(37,125,208,0.5)' : '0 1px 2px rgba(34,29,29,0.03)',
        transition: 'transform .3s cubic-bezier(.4,0,.2,1), box-shadow .3s ease, border-color .3s ease' }}>
      <div style={{ position: 'relative', aspectRatio: '1 / 1', borderRadius: 18, overflow: 'hidden',
        background: 'linear-gradient(158deg, #e9f3ff 0%, #f6fbff 58%, #ffffff 100%)',
        border: '1px solid rgba(151,205,255,0.35)', marginBottom: 18,
        display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
        <span aria-hidden="true" style={{ position: 'absolute', inset: 0,
          background: 'radial-gradient(120% 88% at 50% 0%, rgba(151,205,255,0.24), transparent 62%)' }} />
        <span style={{ position: 'absolute', top: 12, left: 12, zIndex: 2, fontFamily: MONO, fontSize: 12,
          fontWeight: 500, letterSpacing: 0.4, color: '#fff', background: VIOLET, borderRadius: 8,
          padding: '4px 9px', boxShadow: '0 6px 16px rgba(37,125,208,0.4)' }}>{n}</span>
        <img src={img} alt={title} style={{ position: 'relative', zIndex: 1, width: '82%', height: '82%',
          objectFit: 'contain', borderRadius: 16, transform: hover ? 'scale(1.05)' : 'scale(1)', transition: 'transform .4s ease' }} />
      </div>
      <p style={{ margin: '0 0 10px', fontSize: 13.5, fontStyle: 'italic', color: 'var(--color-graphite)',
        lineHeight: '19px', letterSpacing: -0.2 }}>{quote}</p>
      <h3 style={{ margin: '0 0 12px', fontSize: 28, fontWeight: 500, letterSpacing: -1.2,
        lineHeight: 1.2, color: OBSIDIAN }}>{title}</h3>
      <p style={{ margin: 0, fontSize: 15.5, lineHeight: 1.5, color: 'var(--color-iron)' }}>{body}</p>
    </div>
  );
}
function Process() {
  const procRef = React.useRef(null);
  const steps = [
    ['uploads/process-1.png', '"I watch Polymarket 24/7."', 'Bot finds edge.', 'Our algorithm cross-references every contract against sharp Vegas lines. When it spots a mispricing, it flags it instantly.'],
    ['uploads/process-2.png', '"One notification."', 'Get a ping.', 'Contract name, direction (YES or NO), suggested entry price, confidence level. Keep notifications on.'],
    ['uploads/process-3.png', '"Open Polymarket. Trade."', 'Place a trade.', 'The signal tells you exactly what to buy and at what price. You just show up and click.'],
    ['uploads/process-4.png', '"You got in before everyone."', 'Grow bankroll.', 'As the price moves toward fair value, your position gains. When the event resolves, you collect.'],
  ];
  return (
    <section id="process" data-screen-label="Process" style={{ background: '#ffffff', padding: '116px 0' }}>
      <Container>
        <div style={{ textAlign: 'center', maxWidth: 760, margin: '0 auto' }}>
          <h2 style={{ margin: 0, fontSize: 'clamp(34px,4.5vw,48px)', fontWeight: 500,
            letterSpacing: -2, lineHeight: 1.167, color: OBSIDIAN }}>
            Four step process.
          </h2>
          <p style={{ margin: '20px 0 0', fontSize: 18, lineHeight: '28px', color: 'var(--color-iron)' }}>
            You don't need to understand how the scanner works. You just need to follow the signal.
          </p>
        </div>

        <div className="proc-scroller" ref={procRef} style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))',
          gap: 24, marginTop: 56 }}>
          {steps.map(([img, quote, title, body], i) => (
            <StepCard key={title} n={String(i + 1).padStart(2, '0')}
              img={img} quote={quote} title={title} body={body} />
          ))}
        </div>
        <SliderDots scrollerRef={procRef} count={steps.length} />

        <div className="hero-cta-row" style={{ display: 'flex', justifyContent: 'center', marginTop: 48 }}>
          <LiquidBtn href="#pricing">
            <span className="gradient-cta"><Button variant="violet" leadingIcon={<Icon name="zap" size={16} color="#fff" />}><CtaLabel /></Button></span>
          </LiquidBtn>
        </div>
      </Container>
    </section>
  );
}

/* =================================================================== LADDER */
function Ladder() {
  const nodes = [
    ['Free', '15-min delay', 'You see edges after the sharpest users.'],
    ['Pro', 'Under 1 second', 'Alerts land while the gap is still open.'],
    ['VIP', 'Under 100 ms', 'First in line, before the price corrects.'],
  ];
  const extras = [
    ['sliders-horizontal', 'Better filters'],
    ['message-circle', 'Priority Discord'],
    ['headset', 'Direct analyst access'],
    ['wallet', 'Bankroll guidance'],
  ];
  return (
    <section data-screen-label="Speed ladder" style={{ background: '#f1f6fb', padding: '116px 0' }}>
      <Container>
        <div style={{ textAlign: 'center', maxWidth: 640, margin: '0 auto 56px' }}>
          <h2 style={{ margin: 0, fontSize: 'clamp(34px,4.5vw,48px)', fontWeight: 500,
            letterSpacing: -2, lineHeight: 1.167, color: OBSIDIAN }}>
            In a mispriced market, speed is the edge.
          </h2>

        </div>

        <div className="ladder-grid" style={{ position: 'relative', display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 }}>
          <div className="ladder-line" style={{ position: 'absolute', left: '16%', right: '16%', top: 13, height: 2,
            background: 'linear-gradient(90deg, rgba(151,205,255,0.25), #97CDFF)' }} />
          {nodes.map(([tier, speed, line], i) => (
            <div key={tier} style={{ position: 'relative', textAlign: 'center', display: 'flex',
              flexDirection: 'column', alignItems: 'center', gap: 8 }}>
              <span style={{ width: 28, height: 28, borderRadius: '50%', background: '#f1f6fb',
                border: `2px solid ${VIOLET}`, display: 'inline-flex', alignItems: 'center',
                justifyContent: 'center', position: 'relative', zIndex: 1,
                boxShadow: i === 2 ? '0 0 0 6px rgba(143,201,255,0.18)' : 'none' }}>
                <span style={{ width: 9, height: 9, borderRadius: '50%', background: i === 0 ? 'transparent' : VIOLET,
                  border: i === 0 ? `2px solid ${VIOLET}` : 'none' }} /></span>
              <span style={{ fontFamily: MONO, fontSize: 12, letterSpacing: 1, textTransform: 'uppercase',
                color: 'var(--color-graphite)', marginTop: 4 }}>{tier}</span>
              <span style={{ fontSize: 'clamp(24px,3vw,32px)', fontWeight: 500, letterSpacing: -1, lineHeight: 1.25, color: OBSIDIAN }}>{speed}</span>
              <span style={{ fontSize: 14, lineHeight: '20px', color: 'var(--color-iron)', maxWidth: 200 }}>{line}</span>
            </div>
          ))}
        </div>

        <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: 12, marginTop: 56 }}>
          {extras.map(([ic, x]) => (
            <span key={x} style={{ display: 'inline-flex', alignItems: 'center', gap: 10,
              background: '#ffffff', border: '1px solid rgba(151,205,255,0.45)',
              borderRadius: 999, padding: '11px 20px', fontSize: 15.5, fontWeight: 500,
              color: OBSIDIAN, letterSpacing: -0.2, boxShadow: '0 1px 2px rgba(34,29,29,0.03)' }}>
              <span style={{ flex: 'none', width: 26, height: 26, borderRadius: 8,
                background: 'rgba(151,205,255,0.16)', display: 'inline-flex', alignItems: 'center',
                justifyContent: 'center' }}>
                <Icon name={ic} size={15} color={VIOLET} /></span>{x}</span>
          ))}
        </div>
      </Container>
    </section>
  );
}

/* ================================================================== PRICING
   Light "decision" band: billing toggle, animated price count-up, a fanned
   popular card, and a violet confetti burst when switching to annual. */
const PRICING_PLANS = [
  { name: 'Free', monthly: 0, yearly: 0, speed: '15-min delay', whop: 'plan_FcMKwstY1gYAI',
    blurb: 'Get started with basic automated sports signals on Polymarket.',
    features: [['radio', 'Basic trade signals feed'], ['message-circle', 'Access to Free Discord channels'], ['clock', 'Standard signal delay (15 mins)'], ['bell', 'Ultra-low latency instant pings'], ['sliders-horizontal', 'Custom filters and line alarms']],
    cta: 'Get started', variant: 'dark', popular: false },
  { name: 'Signal Pro', monthly: 99, yearly: 79, speed: 'Under 1 sec', whop: 'plan_3AHdcnsWsDkt0',
    blurb: 'Perfect for serious bettors looking to scale their signals and ROI.',
    features: [['cpu', 'Advanced trade signals engine'], ['message-circle', 'Access to Pro Discord channels'], ['zap', 'Low latency alerts (sub-1s)'], ['activity', 'Real-time line discrepancies'], ['wallet', 'Suggested bankroll allocation guides']],
    cta: 'Get started', variant: 'light', popular: true },
  { name: 'Signal Elite', monthly: 299, yearly: 239, speed: 'Under 100 ms', whop: 'plan_LtIEQsrxIA1Xp',
    blurb: 'For high-net-worth individuals wanting maximum speed and direct access.',
    features: [['gauge', 'Ultra-low latency instant alerts (sub-100ms)'], ['crown', 'Exclusive VIP Discord channels'], ['sliders-horizontal', 'Custom market filters and line alarms'], ['headset', 'Direct access to analyst team & SnewJ'], ['sparkles', 'Includes all Pro features and more']],
    cta: 'Get started', variant: 'dark', popular: false },
];

/* rAF drives the smooth count; a setTimeout safety guarantees the final value
   lands even if animation frames are throttled. */
function useCountUp(target, ms = 480) {
  const [val, setVal] = React.useState(target);
  const valRef = React.useRef(target);
  React.useEffect(() => { valRef.current = val; }, [val]);
  React.useEffect(() => {
    const from = valRef.current;
    if (from === target) return;
    let raf, start, done = false;
    const ease = t => 1 - Math.pow(1 - t, 3);
    const tick = now => {
      if (done) return;
      if (!start) start = now;
      const p = Math.min((now - start) / ms, 1);
      setVal(Math.round(from + (target - from) * ease(p)));
      if (p < 1) raf = requestAnimationFrame(tick);
    };
    raf = requestAnimationFrame(tick);
    const safety = setTimeout(() => { if (!done) setVal(target); }, ms + 140);
    return () => { done = true; cancelAnimationFrame(raf); clearTimeout(safety); };
  }, [target, ms]);
  return val;
}

function Price({ amount, onDark }) {
  const v = useCountUp(amount);
  return <span style={{ fontSize: 'clamp(46px, 5vw, 64px)', fontWeight: 500, letterSpacing: -3,
    color: onDark ? '#fff' : OBSIDIAN, lineHeight: 0.95, fontVariantNumeric: 'tabular-nums' }}>${v}</span>;
}

function BillingToggle({ annual, onChange, anchorRef }) {
  const opts = [['Monthly', false], ['Annual', true]];
  return (
    <div style={{ display: 'inline-flex', alignItems: 'center', gap: 14, flexWrap: 'wrap', justifyContent: 'center' }}>
      <div ref={anchorRef} style={{ position: 'relative', display: 'inline-flex', padding: 4, borderRadius: 999,
        background: '#13181F', border: '1px solid rgba(255,255,255,0.10)' }}>
        <span style={{ position: 'absolute', top: 4, bottom: 4, width: 'calc(50% - 4px)', borderRadius: 999,
          background: VIOLET, transform: annual ? 'translateX(100%)' : 'translateX(0)',
          transition: 'transform .28s cubic-bezier(.4,1.3,.5,1)' }} />
        {opts.map(([label, val]) => (
          <button key={label} onClick={() => onChange(val)} style={{ position: 'relative', zIndex: 1,
            border: 'none', background: 'transparent', cursor: 'pointer', padding: '9px 22px', borderRadius: 999,
            fontFamily: 'var(--font-aave-repro)', fontSize: 14.5, fontWeight: 450, letterSpacing: -0.16,
            color: annual === val ? OBSIDIAN : 'rgba(255,255,255,0.62)', transition: 'color .2s ease' }}>{label}</button>
        ))}
      </div>
      <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 13.5,
        color: ASH, letterSpacing: -0.16 }}>
        <Icon name="sparkles" size={14} color={VIOLET} />
        Save <b style={{ fontWeight: 500, color: VIOLET }}>20%</b> yearly
      </span>
    </div>
  );
}

function PlanCard({ plan, pos, onSelect }) {
  const amount = plan.monthly;
  const popular = plan.popular;
  const open = () => onSelect && onSelect(plan);
  // popular = violet fill with black text; others = dark card with white text
  const cardBg = popular ? VIOLET : '#13181F';
  const bodyText = popular ? OBSIDIAN : '#ffffff';
  const subText = popular ? 'rgba(0,0,0,0.6)' : 'rgba(255,255,255,0.62)';
  const dotColor = popular ? OBSIDIAN : VIOLET;
  const divider = popular ? 'rgba(0,0,0,0.18)' : 'rgba(255,255,255,0.12)';
  const lightText = !popular; // true → Price renders white
  return (
    <div className="plan-card" onClick={open} style={{
      position: 'relative', display: 'flex', flexDirection: 'column', cursor: 'pointer',
      background: cardBg, borderRadius: 28, padding: 30,
      border: popular ? 'none' : '1px solid rgba(255,255,255,0.10)',
      boxShadow: popular ? '0 30px 70px -28px rgba(143,201,255,0.7)' : '0 18px 50px -30px rgba(0,0,0,0.6)',
      zIndex: popular ? 10 : 1 }}>
      {/* title + tagline */}
      <h3 style={{ margin: 0, fontSize: 24, fontWeight: 500, letterSpacing: -1, lineHeight: 1.333, color: bodyText }}>{plan.name}</h3>
      <div style={{ display: 'flex', alignItems: 'flex-start', gap: 9, marginTop: 12 }}>
        <span style={{ fontSize: 14, lineHeight: '20px', color: subText, letterSpacing: -0.16 }}>{plan.blurb}</span>
      </div>
      <div style={{ height: 1, background: divider, margin: '20px 0 22px' }} />
      {/* features */}
      <ul style={{ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 13, flex: 1 }}>
        {plan.features.map(([ic, f]) => (
          <li key={f} style={{ display: 'flex', gap: 11, alignItems: 'flex-start', fontSize: 16,
            lineHeight: 1.5, fontWeight: 500, color: bodyText, letterSpacing: -0.2 }}>
            <span style={{ flex: 'none', display: 'inline-flex', marginTop: 1 }}>
              <Icon name={ic} size={18} color={dotColor} /></span>
            <span>{f}</span></li>
        ))}
      </ul>
      {/* price */}
      <div style={{ marginTop: 34, display: 'flex', alignItems: 'baseline', gap: 8 }}>
        <Price amount={amount} onDark={lightText} />
        <span style={{ fontSize: 16, fontWeight: 450, color: subText }}>{amount === 0 ? '' : '/mo'}</span>
      </div>
      <p style={{ margin: '8px 0 0', fontSize: 12, color: subText, lineHeight: '16px', letterSpacing: -0.1 }}>
        {amount === 0 ? 'Free with Polymarket deposit ($100+)' : 'billed monthly'}</p>
      {/* cta */}
      <div style={{ marginTop: 22 }} onClick={e => { e.stopPropagation(); open(); }}>
        {popular ? (
          <Button variant="light" style={{ width: '100%', justifyContent: 'center' }}>{plan.cta}</Button>
        ) : (
          <span className="liquid-btn-wrap liquid-btn-block" style={{ display: 'block' }}>
            <span className="gradient-cta"><Button variant="violet" style={{ width: '100%', justifyContent: 'center' }}>{plan.cta}</Button></span>
          </span>
        )}
      </div>
    </div>
  );
}

/* Slide-in checkout drawer — opens when a pricing card is selected. Trust
   header + plan summary + a Whop embed slot + the footer disclaimer.
   Full-width on mobile, 480px panel on desktop. */
function CheckoutDrawer({ plan, onClose }) {
  const [shown, setShown] = React.useState(false);
  const handleClose = React.useCallback(() => { setShown(false); setTimeout(onClose, 300); }, [onClose]);
  React.useEffect(() => {
    if (!plan) return undefined;
    const r = requestAnimationFrame(() => setShown(true));
    document.body.style.overflow = 'hidden';
    return () => { cancelAnimationFrame(r); document.body.style.overflow = ''; setShown(false); };
  }, [plan]);
  React.useEffect(() => {
    const onKey = e => { if (e.key === 'Escape') handleClose(); };
    window.addEventListener('keydown', onKey);
    return () => window.removeEventListener('keydown', onKey);
  }, [handleClose]);
  if (!plan) return null;

  const free = plan.monthly === 0;
  const slug = plan.name.toLowerCase().replace(/[^a-z0-9]+/g, '-');
  const badges = [
    ['zap', '153,000+ members already in'],
    ['clock', 'Instant access after checkout'],
    ['shield-check', 'Cancel anytime via Whop'],
  ];
  return (
    <div role="dialog" aria-modal="true" aria-label="Secure checkout"
      style={{ position: 'fixed', inset: 0, zIndex: 200, fontFamily: 'var(--font-aave-repro)' }}>
      {/* backdrop */}
      <div onClick={handleClose} style={{ position: 'absolute', inset: 0,
        background: 'rgba(7,10,13,0.55)', backdropFilter: 'blur(2px)',
        opacity: shown ? 1 : 0, transition: 'opacity .3s ease' }} />
      {/* panel */}
      <aside style={{ position: 'absolute', top: 0, right: 0, bottom: 0,
        width: 'min(480px, 100vw)', background: '#ffffff', display: 'flex', flexDirection: 'column',
        boxShadow: '-24px 0 60px rgba(7,10,13,0.35)',
        transform: shown ? 'translateX(0)' : 'translateX(100%)',
        transition: 'transform .34s cubic-bezier(.4,0,.2,1)' }}>
        {/* header */}
        <div style={{ flex: 'none', display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          padding: '18px 22px', borderBottom: '1px solid rgba(34,29,29,0.08)' }}>
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 9, fontSize: 17,
            fontWeight: 500, letterSpacing: -0.3, color: OBSIDIAN }}>
            <Icon name="lock" size={16} color={VIOLET} />Secure checkout
          </span>
          <button onClick={handleClose} aria-label="Close checkout"
            style={{ width: 36, height: 36, borderRadius: '50%', border: 'none', cursor: 'pointer',
              background: 'rgba(34,29,29,0.05)', display: 'inline-flex', alignItems: 'center',
              justifyContent: 'center', color: OBSIDIAN }}>
            <Icon name="x" size={18} color={OBSIDIAN} />
          </button>
        </div>

        {/* scroll body */}
        <div style={{ flex: 1, overflowY: 'auto', WebkitOverflowScrolling: 'touch' }}>
          {/* trust band */}
          <div style={{ background: 'linear-gradient(180deg, #f3f8ff 0%, #ffffff 100%)',
            padding: '26px 22px 24px', borderBottom: '1px solid rgba(34,29,29,0.06)' }}>
            <h2 style={{ margin: 0, fontSize: 'clamp(24px,5.5vw,28px)', fontWeight: 500, letterSpacing: -1.2,
              lineHeight: 1.18, color: OBSIDIAN, textWrap: 'balance' }}>
              You're seconds from seeing edges before the public.
            </h2>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 18 }}>
              {badges.map(([ic, t]) => (
                <span key={t} style={{ display: 'inline-flex', alignItems: 'center', gap: 10,
                  fontSize: 14.5, color: 'var(--color-iron)', letterSpacing: -0.16 }}>
                  <span style={{ flex: 'none', width: 26, height: 26, borderRadius: 8,
                    background: 'rgba(151,205,255,0.16)', display: 'inline-flex', alignItems: 'center',
                    justifyContent: 'center' }}>
                    <Icon name={ic} size={14} color={VIOLET} /></span>{t}</span>
              ))}
            </div>
          </div>

          <div style={{ padding: '22px' }}>
            {/* plan summary */}
            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
              gap: 14, padding: '16px 18px', borderRadius: 16,
              border: '1px solid rgba(34,29,29,0.10)', background: '#f6f7f4' }}>
              <div style={{ minWidth: 0 }}>
                <div style={{ fontSize: 16, fontWeight: 500, letterSpacing: -0.3, color: OBSIDIAN }}>{plan.name}</div>
                <div style={{ fontSize: 13, lineHeight: '18px', color: 'var(--color-iron)', marginTop: 3 }}>{plan.blurb}</div>
              </div>
              <div style={{ flex: 'none', textAlign: 'right' }}>
                <div style={{ fontFamily: 'var(--font-heading)', fontSize: 26, fontWeight: 600,
                  letterSpacing: -1, color: OBSIDIAN, lineHeight: 1 }}>{free ? 'Free' : '$' + plan.monthly}</div>
                <div style={{ fontSize: 12, color: 'var(--color-graphite)', marginTop: 3 }}>{free ? 'with deposit' : 'per month'}</div>
              </div>
            </div>

            {/* Whop embed slot */}
            <div style={{ fontFamily: MONO, fontSize: 11, fontWeight: 500, letterSpacing: 1.4,
              textTransform: 'uppercase', color: 'var(--color-graphite)', margin: '24px 0 12px' }}>
              Complete your order
            </div>
            {/* ── Whop embedded checkout. The loader.js in <head> auto-mounts an
                iframe into any [data-whop-checkout-plan-id] node, including ones
                added dynamically when this drawer opens. Light theme + blue accent
                to match the sky-blue brand (no orange). ── */}
            <div style={{ position: 'relative', minHeight: 320 }}>
              <div aria-hidden="true" style={{ position: 'absolute', inset: 0, display: 'flex',
                flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 12,
                borderRadius: 16, background: '#fafbfc', border: '1px solid rgba(34,29,29,0.08)' }}>
                <span style={{ width: 30, height: 30, borderRadius: '50%',
                  border: '3px solid rgba(151,205,255,0.30)', borderTopColor: VIOLET,
                  animation: 'whop-spin 0.8s linear infinite' }} />
                <span style={{ fontSize: 13, color: 'var(--color-iron)', letterSpacing: -0.16 }}>Loading secure checkout…</span>
              </div>
              <div
                id={'whop-embed-' + slug}
                data-whop-checkout-plan-id={plan.whop}
                data-whop-checkout-theme="light"
                data-whop-checkout-theme-accent-color="blue"
                data-whop-checkout-return-url="https://snewjsignal.com/checkout/complete"
                data-whop-checkout-style-container-padding-x="0"
                style={{ position: 'relative', width: '100%', height: 'fit-content', minHeight: 320, overflow: 'hidden' }}>
              </div>
            </div>

            {/* disclaimer (from footer) */}
            <p style={{ margin: '20px 0 0', fontSize: 11.5, lineHeight: 1.6, color: 'var(--color-graphite)' }}>
              <strong style={{ color: 'var(--color-iron)' }}>Disclaimer:</strong> Sharpline sends informational
              signals only and is not financial advice. Past performance does not guarantee future results.
              All trades involve risk. No guaranteed profits. Check whether Polymarket is permitted in your
              jurisdiction before using. Entertainment purposes only.
            </p>
          </div>
        </div>
      </aside>
    </div>
  );
}

function Pricing() {
  const [checkout, setCheckout] = React.useState(null);
  return (
    <section id="pricing" data-screen-label="Pricing" className="dark-panel" style={{
      ...DARK_PANEL, background: '#070A0D', padding: '116px 0 120px' }}>
      <Container>
        <div style={{ textAlign: 'center', maxWidth: 640, margin: '0 auto' }}>
          <h2 style={{ margin: 0, fontSize: 'clamp(34px,4.5vw,48px)', fontWeight: 500,
            letterSpacing: -2, lineHeight: 1.167, color: '#fff', textWrap: 'balance' }}>
            Choose your access.
          </h2>
          <p style={{ margin: '18px 0 0', fontSize: 18, lineHeight: '28px', letterSpacing: -0.2,
            color: ASH }}>
            Start free. Upgrade when you want faster alerts, custom filters, and direct access to the team.
          </p>

        </div>

        <div className="plan-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)',
          gap: 20, alignItems: 'stretch', marginTop: 56 }}>
          <PlanCard plan={PRICING_PLANS[0]} pos="left" onSelect={setCheckout} />
          <PlanCard plan={PRICING_PLANS[1]} pos="center" onSelect={setCheckout} />
          <PlanCard plan={PRICING_PLANS[2]} pos="right" onSelect={setCheckout} />
        </div>

        <p style={{ textAlign: 'center', marginTop: 28, fontSize: 14, lineHeight: '20px', color: ASH }}>
          Billing handled through Whop · Cancel anytime · Signals only, you trade
        </p>
      </Container>

      <style>{`
        @media (max-width: 880px) {
          #pricing .plan-grid { grid-template-columns: 1fr; max-width: 420px; margin-left: auto; margin-right: auto; }
          #pricing .plan-grid .plan-card { transform: none !important; }
        }
      `}</style>
      <CheckoutDrawer plan={checkout} onClose={() => setCheckout(null)} />
    </section>
  );
}

/* ====================================================================== FAQ */
function FaqChatRow({ q, a, open, onToggle }) {
  const [hover, setHover] = React.useState(false);
  const bubbleBg = open ? 'rgba(143,201,255,0.18)' : (hover ? 'rgba(143,201,255,0.10)' : 'rgba(255,255,255,0.06)');
  return (
    <div style={{ marginBottom: 14 }}>
      <button onClick={onToggle}
        onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}
        style={{ display: 'flex', width: '100%', alignItems: 'center', justifyContent: 'flex-start',
          gap: 14, background: 'transparent', border: 'none', cursor: 'pointer', textAlign: 'left',
          padding: 0, fontFamily: 'var(--font-aave-repro)' }}>
        <span style={{ display: 'inline-flex', alignItems: 'center', borderRadius: 18, borderBottomLeftRadius: 6,
          padding: '13px 18px', background: bubbleBg, color: open ? VIOLET : '#fff',
          transition: 'background .25s ease, color .25s ease' }}>
          <span style={{ fontSize: 16, fontWeight: 500, letterSpacing: -0.2 }}>{q}</span>
        </span>
        <span style={{ display: 'inline-flex', flex: 'none', color: open ? VIOLET : ASH, transition: 'color .25s ease' }}>
          <svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true">
            <line x1="4" y1="10" x2="16" y2="10" />
            <line x1="10" y1="4" x2="10" y2="16" style={{ transformOrigin: 'center', transform: open ? 'scaleY(0)' : 'scaleY(1)', transition: 'transform .3s cubic-bezier(.4,0,.2,1)' }} />
          </svg>
        </span>
      </button>
      <div style={{ display: 'grid', gridTemplateRows: open ? '1fr' : '0fr', opacity: open ? 1 : 0,
        transition: 'grid-template-rows .42s cubic-bezier(.4,0,.2,1), opacity .35s ease', marginLeft: 30 }}>
        <div style={{ overflow: 'hidden', minHeight: 0 }}>
          <div className="faq-answer" style={{ marginTop: 8, width: 'fit-content', maxWidth: 440, background: VIOLET, color: OBSIDIAN,
            borderRadius: 20, borderTopLeftRadius: 6, padding: '12px 18px', fontSize: 15, lineHeight: 1.55,
            letterSpacing: -0.16 }}>
            {a}
          </div>
        </div>
      </div>
    </div>
  );
}

function Faq() {
  const items = [
    ['Why is it free?', 'The free tier is funded by our Polymarket affiliate deal — we make money when you sign up and deposit, so basic signals cost you nothing.'],
    ['Is this a bot that trades for me?', 'No. Sharpline sends signals. You place every trade manually on Polymarket — you stay in full control of your money.'],
    ['What is the difference between the plans?', 'Speed, filters, access, and signal quality. Higher tiers get faster alerts, custom filters, and direct contact with the team.'],
    ['Can I cancel?', 'Yes. Billing and cancellation are managed through Whop — cancel anytime, no lock-in.'],
    ['What sports does it cover?', 'NBA, MLB, NFL, UFC, soccer, and player props — with more markets added over time.'],
    ['Is this legal?', 'It depends on your area. Check whether Polymarket is allowed where you live before signing up.'],
  ];
  const [open, setOpen] = React.useState(0);
  return (
    <section id="faq" data-screen-label="FAQ" className="dark-panel" style={{ ...DARK_PANEL, background: '#070A0D', padding: '88px 0' }}>
      <Container style={{ maxWidth: 720 }}>
        <div style={{ textAlign: 'center', marginBottom: 6 }}>
          <h2 style={{ margin: 0, fontSize: 'clamp(34px,4.5vw,48px)', fontWeight: 500,
            letterSpacing: -2, lineHeight: 1.167, color: '#fff' }}>
            Straight answers.
          </h2>
        </div>
        <div style={{ textAlign: 'center', margin: '18px 0 30px' }}>
          <span style={{ fontFamily: MONO, fontSize: 12, letterSpacing: 0.6, textTransform: 'uppercase',
            color: 'var(--color-graphite)' }}>Sharpline support · replies in minutes</span>
        </div>
        <div className="faq-list" style={{ paddingLeft: 110 }}>
          {items.map(([q, a], i) => (
            <FaqChatRow key={i} q={q} a={a} open={open === i} onToggle={() => setOpen(open === i ? -1 : i)} />
          ))}
        </div>
      </Container>
    </section>
  );
}

/* ============================================================== FINAL + FOOT */
function FinalCta() {
  return (
    <section data-screen-label="Final CTA" style={{
      background: 'linear-gradient(180deg, #f1f6fb 0%, #e6f3ff 52%, #f1f6fb 100%)', padding: '116px 0' }}>
      <Container style={{ textAlign: 'center', maxWidth: 720 }}>
        <h2 style={{ margin: 0, fontSize: 'clamp(34px,4.5vw,48px)', fontWeight: 500, letterSpacing: -2,
          lineHeight: 1.167, color: OBSIDIAN, textWrap: 'balance' }}>
          We find the bad prices. You get the ping. You act fast.
        </h2>
        <div className="hero-cta-row" style={{ display: 'flex', gap: 16, justifyContent: 'center', marginTop: 34, flexWrap: 'wrap' }}>
          <LiquidBtn href="#pricing">
            <span className="gradient-cta"><Button variant="violet" leadingIcon={<Icon name="zap" size={16} color="#fff" />}><CtaLabel /></Button></span>
          </LiquidBtn>
        </div>
        <p style={{ marginTop: 16, fontSize: 14, lineHeight: '20px', color: 'var(--color-iron)' }}>
          Free to start · Cancel anytime via Whop · Signals only, you trade
        </p>
      </Container>
    </section>
  );
}

function Footer() {
  return (
    <footer className="dark-panel" style={{ ...DARK_PANEL, background: '#070A0D', padding: '56px 0', color: ASH }}>
      <Container>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          flexWrap: 'wrap', gap: 20, paddingBottom: 28, borderBottom: '1px solid rgba(255,255,255,0.07)' }}>
          <SharplineLogo onDark />
          <div style={{ display: 'flex', gap: 24, fontSize: 14, letterSpacing: -0.16, flexWrap: 'wrap' }}>
            <a href="#process" style={{ color: ASH, textDecoration: 'none' }}>How it works</a>
            <a href="#pricing" style={{ color: ASH, textDecoration: 'none' }}>Pricing</a>
            <a href="#faq" style={{ color: ASH, textDecoration: 'none' }}>FAQ</a>
            <a href="#demo" style={{ color: ASH, textDecoration: 'none' }}>Discord</a>
          </div>
        </div>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          flexWrap: 'wrap', gap: 12, paddingTop: 24 }}>
          <p style={{ margin: 0, maxWidth: 620, fontSize: 12.5, lineHeight: 1.6, color: 'var(--color-graphite)' }}>
            Sharpline sends informational signals only and is not financial advice. Trading on prediction
            markets carries risk. Check whether Polymarket is permitted in your jurisdiction before using.
            <br /><br />
            <strong style={{ color: 'rgba(255,255,255,0.45)' }}>Disclaimer:</strong> Past performance does not guarantee future results. All trades involve risk. No guaranteed profits. Entertainment purposes only.
          </p>
          <span style={{ fontSize: 13, color: 'var(--color-graphite)' }}>© 2026 Sharpline</span>
        </div>
      </Container>
    </footer>
  );
}

Object.assign(window, {
  SharplineLogo, Nav, Hero, Demo, Process, Ladder, Pricing, Faq, FinalCta, Footer,
});
