// ============================================================
// HOME PAGE
// ============================================================

const HomeHero = ({ onNav, user }) =>
<div className="hero">
    <div className="hero-bg">
      <div className="hero-bg-mask" />
    </div>

    {/* Floating proof chips */}
    <div className="hero-floats">
      <FloatChip brand="apex" color="indigo" line="Apex Payout" val="+$8,420"
        top="80px" left="160px" duration={7.5} />
      <FloatChip brand="tradeify" color="rose" line="Tradeify Payout" val="+$3,600"
        top="60px" right="160px" delay={2.4} duration={8} />
      <FloatChip brand="fundednext" color="blue" line="FundedNext Payout" val="+$4,290"
        bottom="60px" left="160px" delay={4} duration={9} />
      <FloatChip brand="tradeify" color="amber" line="Tradeify Payout" val="+$6,287"
        bottom="60px" right="200px" size="lg" delay={3} duration={8.5} />
    </div>

    <div className="container hero-inner">
      <h1 className="hero-title">
        Trading real.<br />
        <span className="hero-acid">Payout-uri transparente.</span>
      </h1>

      <p className="lead hero-sub">
        Învață NASDAQ, prop firms, risk management și psihologie printr-o
        comunitate activă, condusă de un trader profitabil.
      </p>

      <div className="hero-ctas">
        <Button variant="ghost" size="lg" onClick={() => window.open('https://discord.gg/f2ebpTdDJF', '_blank', 'noopener,noreferrer')}>
          <span style={{ color: '#1E3A8A' }}><Icon name="discord" size={16} /></span>
          Join Free Discord
        </Button>
        {!isEliteUser(user) && (
          <Button variant="acid" size="lg" onClick={() => onNav('elite')}>
            Apply for Elite
          </Button>
        )}
      </div>


      <div className="hero-meta">
        <div className="hero-meta-item">
          <Icon name="check" size={14} style={{ color: 'var(--acid)' }} />
          <span>Payout-uri verificate</span>
        </div>
        <div className="hero-meta-item">
          <Icon name="check" size={14} style={{ color: 'var(--acid)' }} />
          <span>Live calls săptămânale</span>
        </div>
        <div className="hero-meta-item">
          <Icon name="check" size={14} style={{ color: 'var(--acid)' }} />
          <span>Fără signals fake</span>
        </div>
      </div>
    </div>

    <div className="hero-scrollhint">
      <span>scroll</span>
      <Icon name="arrowDown" size={14} />
    </div>

    <style>{`
      .hero {
        position: relative;
        padding: 40px 0 120px;
        min-height: 0;
        overflow: hidden;
      }
      .hero-bg {
        position: absolute; inset: -20px -40px 0 -40px;
        z-index: 0;
        pointer-events: none;
      }
      .hero-bg .bg-chart { width: 100%; height: 100%; }
      .hero-bg-mask {
        position: absolute; inset: 0;
        background:
          radial-gradient(ellipse 55% 50% at 50% 50%, rgba(5,5,5,0.85) 0%, transparent 80%),
          linear-gradient(180deg, transparent 0%, var(--bg) 92%);
      }
      .hero-inner { position: relative; z-index: 2; text-align: center; padding-top: 40px; }
      .hero-eyebrow {
        display: inline-flex; align-items: center; gap: 12px;
        padding: 8px 16px;
        border-radius: 999px;
        background: rgba(255,255,255,0.04);
        border: 1px solid var(--line);
        font-family: 'JetBrains Mono', monospace;
        font-size: 11px;
        letter-spacing: 0.14em;
        color: var(--text-dim);
        margin-bottom: 28px;
        backdrop-filter: blur(8px);
      }
      .hero-eyebrow-dot {
        width: 7px; height: 7px; border-radius: 50%;
        background: var(--acid); box-shadow: 0 0 12px var(--acid-glow);
        animation: pulse-dot 2s infinite;
      }
      .hero-title {
        font-size: clamp(40px, 6.8vw, 96px);
        line-height: 0.98;
        letter-spacing: -0.045em;
        font-weight: 900;
        margin-bottom: 26px;
      }
      .hero-acid {
        background: linear-gradient(180deg, #DCFF7A 0%, #B7FF1A 60%, #8FE000 100%);
        -webkit-background-clip: text; background-clip: text;
        color: transparent;
        text-shadow: 0 0 80px rgba(183,255,26,0.4);
        filter: drop-shadow(0 0 30px rgba(183,255,26,0.25));
      }
      .hero-sub { max-width: 580px; margin: 0 auto; font-size: 17px; }
      .hero-ctas {
        display: flex; gap: 12px; justify-content: center; margin-top: 36px; flex-wrap: wrap;
      }
      .hero-meta {
        display: flex; gap: 28px; justify-content: center; margin-top: 36px; flex-wrap: wrap;
      }
      .hero-meta-item { display: flex; gap: 8px; align-items: center; color: var(--text-dim); font-size: 13px; }

      .hero-free-badge {
        margin: 28px auto 0;
        display: flex; flex-direction: column; align-items: center; gap: 10px;
        max-width: 520px;
      }
      .hero-free-badge .basics-free-pill {
        display: inline-flex; align-items: center; gap: 10px;
        padding: 10px 16px;
        border-radius: 999px;
        background:
          linear-gradient(180deg, rgba(183,255,26,0.10), rgba(183,255,26,0.04)),
          rgba(10,10,12,0.6);
        border: 1px solid rgba(183,255,26,0.32);
        color: var(--text);
        font-size: 13.5px;
        line-height: 1.3;
        box-shadow:
          0 8px 24px rgba(0,0,0,0.45),
          0 0 24px rgba(183,255,26,0.10),
          inset 0 1px 0 rgba(255,255,255,0.06);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
      }
      .hero-free-badge .basics-free-pill svg { color: var(--acid); flex-shrink: 0; }
      .hero-free-badge .basics-free-pill strong {
        color: var(--acid);
        font-weight: 700;
        text-shadow: 0 0 12px rgba(183,255,26,0.30);
      }
      .hero-free-badge .basics-free-actions {
        display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
      }

      .hero-floats { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
      .hero-float {
        position: absolute;
        display: flex; align-items: center; gap: 12px;
        padding: 11px 18px 11px 11px;
        border-radius: 999px;
        background:
          linear-gradient(180deg, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.02) 100%),
          rgba(10,10,12,0.55);
        border: 1px solid rgba(255,255,255,0.16);
        backdrop-filter: blur(22px) saturate(140%);
        -webkit-backdrop-filter: blur(22px) saturate(140%);
        box-shadow:
          0 22px 50px rgba(0,0,0,0.55),
          inset 0 1px 0 rgba(255,255,255,0.18),
          inset 0 -1px 0 rgba(0,0,0,0.4);
        animation: float-y 7s ease-in-out infinite;
        pointer-events: auto;
        cursor: pointer;
        transition: background 0.25s, border-color 0.25s, transform 0.25s, box-shadow 0.25s;
      }
      .hero-float:hover {
        background: linear-gradient(180deg, #3a3a3a 0%, #1f1f1f 100%);
        border-color: rgba(255,255,255,0.3);
        animation-play-state: paused;
      }
      .hero-float:hover .hf-line,
      .hero-float:hover .hf-val,
      .hero-float:hover .hf-val span { color: #F5F5F5; }
      .hero-float::before {
        content: '';
        position: absolute; inset: 0;
        border-radius: inherit;
        padding: 1px;
        background: linear-gradient(180deg, rgba(255,255,255,0.25), rgba(255,255,255,0) 60%);
        -webkit-mask:
          linear-gradient(#000 0 0) content-box,
          linear-gradient(#000 0 0);
        -webkit-mask-composite: xor;
                mask-composite: exclude;
        pointer-events: none;
      }
      .hf-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; }
      .hf-brand {
        width: 64px; height: 30px; border-radius: 8px;
        display: grid; place-items: center;
        border: 1px solid;
        overflow: hidden; flex-shrink: 0;
      }
      .hf-brand img { width: 88%; height: 80%; object-fit: contain; display: block; }
      .hf-brand-apex,
      .hf-brand-tradeify,
      .hf-brand-fundednext {
        width: 42px;
        height: 42px;
        border-radius: 10px;
        padding: 0;
      }
      .hf-brand-apex img,
      .hf-brand-tradeify img,
      .hf-brand-fundednext img {
        width: 86%;
        height: 86%;
        object-fit: contain;
      }
      .float-chip-wrap .scatter-chip-lg {
        padding: 14px 24px 14px 12px;
        gap: 12px;
      }
      .float-chip-wrap .scatter-chip-lg .hf-brand-tradeify {
        width: 42px;
        height: 42px;
        border-radius: 10px;
      }
      .float-chip-wrap .scatter-chip-lg .hf-brand-tradeify img {
        width: 86%;
        height: 86%;
        object-fit: contain;
      }
      .float-chip-wrap .scatter-chip-lg .hf-line { font-size: 10px; }
      .float-chip-wrap .scatter-chip-lg .hf-val { font-size: 13px; }
      .hf-text { display: flex; flex-direction: column; gap: 2px; }
      .hf-line { font-size: 10px; color: var(--text-mute); letter-spacing: 0.1em; text-transform: uppercase; transition: color 0.2s; }
      .hf-val { font-size: 13px; color: var(--text); font-weight: 600; transition: color 0.2s; }
      .hf-acid { box-shadow: 0 22px 50px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.18), 0 0 0 1px rgba(183,255,26,0.16), 0 0 36px rgba(183,255,26,0.18); }
      .hf-cyan { box-shadow: 0 22px 50px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.18), 0 0 0 1px rgba(79,231,213,0.16), 0 0 36px rgba(79,231,213,0.18); }
      .hf-blue { box-shadow: 0 22px 50px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.18), 0 0 0 1px rgba(90,200,255,0.18), 0 0 36px rgba(90,200,255,0.22); }
      .hero-float-1 { top: 80px; left: 36px; animation-duration: 7.5s; }
      .hero-float-2 { bottom: 96px; right: 36px; animation-delay: -2.4s; animation-duration: 8s; }
      .hero-float-3 {
        top: 18px; left: 50%; transform: translateX(-50%);
        animation-delay: -4s; animation-duration: 9s;
        padding: 8px 14px 8px 8px; gap: 9px;
      }
      .hero-float-3 .hf-icon { width: 26px; height: 26px; border-radius: 9px; }
      .hero-float-3 .hf-icon svg { width: 13px; height: 13px; }
      .hero-float-3 .hf-line { font-size: 9px; }
      .hero-float-3 .hf-val { font-size: 11.5px; }
      @keyframes float-x {
        0%, 100% { transform: translateX(-50%) translateY(0); }
        50%      { transform: translateX(-50%) translateY(-10px); }
      }
      .hero-float-3 { animation-name: float-x; }

      @keyframes float-y {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-14px); }
      }
      .hero-float-3 { animation-name: float-x; }
      @keyframes float-x {
        0%, 100% { transform: translate(-50%, 0); }
        50% { transform: translate(-50%, -8px); }
      }

      .hero-scrollhint {
        position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
        font-family: 'JetBrains Mono', monospace;
        font-size: 11px; letter-spacing: 0.2em; color: var(--text-mute);
        display: flex; align-items: center; gap: 8px;
        animation: scroll-bounce 2s infinite;
        z-index: 3;
      }
      @keyframes scroll-bounce {
        0%,100% { transform: translate(-50%, 0); opacity: 0.7; }
        50% { transform: translate(-50%, 6px); opacity: 1; }
      }

      @media (max-width: 900px) {
        .hero-float-1, .hero-float-2, .hero-float-3 { display: none; }
      }
    `}</style>
  </div>;


// ============================================================
// PROOF / STATS
// ============================================================
const HomeProof = () => {
  const sectionRef = React.useRef(null);
  const cardsRef = React.useRef([]);

  React.useLayoutEffect(() => {
    const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
    if (reduced || !window.gsap || !window.ScrollTrigger) return;

    const gsap = window.gsap;
    const ScrollTrigger = window.ScrollTrigger;
    gsap.registerPlugin(ScrollTrigger);

    const cards = cardsRef.current.filter(Boolean);
    if (cards.length === 0) return;
    const triggers = [];

    // Per-card entry vectors: [xStart, yOffset]
    // 1: left + above   |  2: left + below
    // 3: right + above  |  4: right + below
    const dirs = [
      { x: '-55vw', y: -55 },
      { x: '-55vw', y:  55 },
      { x:  '55vw', y: -55 },
      { x:  '55vw', y:  55 },
    ];

    cards.forEach((card, i) => {
      const d = dirs[i] || dirs[0];
      gsap.set(card, {
        x: d.x,
        y: d.y,
        opacity: 0,
        scale: 0.94,
        filter: 'blur(8px)',
        willChange: 'transform, opacity, filter',
      });
    });

    // Scroll-linked assembly — slightly different scrub per card for organic stagger
    cards.forEach((card, i) => {
      const tween = gsap.to(card, {
        x: 0,
        y: 0,
        opacity: 1,
        scale: 1,
        filter: 'blur(0px)',
        ease: 'power3.out',
        scrollTrigger: {
          trigger: sectionRef.current,
          start: 'top 80%',
          end: 'center 60%',
          scrub: 0.4 + i * 0.08,  // 0.4 / 0.48 / 0.56 / 0.64 — light cascade
        },
      });
      if (tween.scrollTrigger) triggers.push(tween.scrollTrigger);
    });

    // Soft premium glow — fires once when the row aligns, then loops every 10s
    let pulseInterval = null;
    const firePulse = () => {
      cards.forEach((card, i) => {
        setTimeout(() => {
          card.classList.add('stat-pulse');
          setTimeout(() => card.classList.remove('stat-pulse'), 1400);
        }, i * 80);
      });
    };
    const pulseST = ScrollTrigger.create({
      trigger: sectionRef.current,
      start: 'top 35%',
      once: true,
      onEnter: () => {
        firePulse();
        pulseInterval = setInterval(firePulse, 10000);
      },
    });
    triggers.push(pulseST);

    return () => {
      if (pulseInterval) clearInterval(pulseInterval);
      triggers.forEach((t) => t && t.kill && t.kill());
      cards.forEach((card) => card && gsap.set(card, { clearProps: 'all' }));
    };
  }, []);

  return (
    <section ref={sectionRef}>
      <FloatChip brand="apex" color="amber" line="Apex Payout" val="+$4,180"
        bottom="24px" left="150px" duration={9} />
      <div className="container">
        <SectionHeader
          eyebrow="TRANSPARENȚĂ"
          title="Numere reale. Comunitate reală."
          subtitle="Nicio promisiune fără dovadă. Aici găsești datele care fac diferența între un educator real și marketing." />

        <div className="grid grid-4 stat-grid">
          <div ref={(el) => { cardsRef.current[0] = el; }} className="stat-wrap">
            <Stat icon="users" color="acid" value="500+" label="Membri activi în comunitate" />
          </div>
          <div ref={(el) => { cardsRef.current[1] = el; }} className="stat-wrap">
            <Stat icon="chart" color="cyan" value="$109K" suffix="+" label="Payout-uri verificate (2023–2026)" />
          </div>
          <div ref={(el) => { cardsRef.current[2] = el; }} className="stat-wrap">
            <Stat icon="candle" color="blue" value="2×" label="Live calls săptămânale" />
          </div>
          <div ref={(el) => { cardsRef.current[3] = el; }} className="stat-wrap">
            <Stat icon="diamond" color="gold" value="47" label="Trade breakdowns publicate" />
          </div>
        </div>
      </div>
    </section>
  );
};


// ============================================================
// WHAT YOU LEARN
// ============================================================
const LEARN_ITEMS = [
{
  icon: 'candle', color: 'acid', tag: 'STRATEGY',
  title: 'NASDAQ Strategy',
  desc: 'Liquidity, order blocks, FVG/IFVG, breaker — aplicate strict pe NQ și sesiunile care contează.',
  points: ['Order flow real', 'Sesiunea London + NY', 'Setup-uri clare', 'Backtested live']
},
{
  icon: 'shield', color: 'cyan', tag: 'PROP FIRMS',
  title: 'Prop Firm Rules',
  desc: 'Cum treci evaluarea, cum păstrezi contul funded, ce reguli te elimină instant și ce firme merită.',
  points: ['EOD vs intraday DD', 'Consistency rules', 'Payout strategy', 'Risk per trade']
},
{
  icon: 'target', color: 'blue', tag: 'RISK',
  title: 'Risk Management',
  desc: 'Sizing-ul corect pe cont funded, gestiunea drawdown-ului și protejarea payout-urilor în lunile slabe.',
  points: ['Position sizing', 'Daily loss control', 'Multi-account', 'Capital allocation']
},
{
  icon: 'brain', color: 'gold', tag: 'PSYCHOLOGY',
  title: 'Trading Psychology',
  desc: 'Cum eviți revenge trading, FOMO, overconfidence și cum construiești o rutină de execuție disciplinată.',
  points: ['Pre-market routine', 'Journal & review', 'Drawdown psychology', 'Mental capital']
}];


const HomeLearn = ({ onNav, user, onLogin, onSignup }) => {
  const sectionRef = React.useRef(null);
  const cardsRef = React.useRef([]);

  React.useLayoutEffect(() => {
    const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
    if (reduced || !window.gsap || !window.ScrollTrigger) return;

    const gsap = window.gsap;
    const ScrollTrigger = window.ScrollTrigger;
    gsap.registerPlugin(ScrollTrigger);

    const cards = cardsRef.current.filter(Boolean);
    if (cards.length === 0) return;
    const triggers = [];

    // Set initial off-screen state BEFORE first paint to avoid flash
    cards.forEach((card, i) => {
      const fromLeft = (i % 2 === 0); // 0,2 = left col; 1,3 = right col (matches mobile alternation too)
      gsap.set(card, {
        x: fromLeft ? '-65vw' : '65vw',
        opacity: 0,
        scale: 0.92,
        filter: 'blur(8px)',
        willChange: 'transform, opacity, filter',
      });
    });

    // Scroll-linked puzzle assembly
    cards.forEach((card, i) => {
      const fromLeft = (i % 2 === 0);
      const tween = gsap.to(card, {
        x: 0,
        opacity: 1,
        scale: 1,
        filter: 'blur(0px)',
        ease: 'power3.out',
        scrollTrigger: {
          trigger: sectionRef.current,
          start: 'top 80%',
          end: 'center 60%',
          scrub: 0.6,
        },
      });
      if (tween.scrollTrigger) triggers.push(tween.scrollTrigger);
    });

    // Snap-in pulse on first entry, then loop every 10s
    let pulseInterval = null;
    const firePulse = () => {
      cards.forEach((card, i) => {
        setTimeout(() => {
          card.classList.add('glow-pulse');
          setTimeout(() => card.classList.remove('glow-pulse'), 1400);
        }, i * 80);
      });
    };
    const pulseST = ScrollTrigger.create({
      trigger: sectionRef.current,
      start: 'top 30%',
      once: true,
      onEnter: () => {
        firePulse();
        pulseInterval = setInterval(firePulse, 10000);
      },
    });
    triggers.push(pulseST);

    return () => {
      if (pulseInterval) clearInterval(pulseInterval);
      triggers.forEach((t) => t && t.kill && t.kill());
      cards.forEach((card) => card && gsap.set(card, { clearProps: 'all' }));
    };
  }, []);

  return (
    <section ref={sectionRef}>
      <FloatChip brand="fundednext" color="blue" line="FundedNext Payout" val="+$5,610"
        top="60px" right="150px" delay={2} duration={8.5} />
      <FloatChip brand="tradeify" color="indigo" line="Tradeify Payout" val="+$3,250"
        bottom="60px" right="150px" delay={4} duration={9.5} />
      <div className="container">
        <SectionHeader
          eyebrow="CE VEI ÎNVĂȚA"
          title="Patru piloni gratis. Zero teorie inutilă."
          accentWord="gratis"
          subtitle="Fiecare modul este construit din execuție reală pe NASDAQ futures — nu din slide-uri reciclate de pe YouTube." />

        {!user && (
          <div className="learn-free-banner">
            <div className="learn-free-banner-glow" />
            <div className="learn-free-banner-inner">
              <div className="learn-free-banner-left">
                <div className="learn-free-banner-icon">
                  <Icon name="unlock" size={18}/>
                </div>
                <div className="learn-free-banner-text">
                  <div className="learn-free-banner-title">
                    <strong>Cont gratuit</strong> = acces complet la toate materialele
                  </div>
                  <div className="learn-free-banner-sub">
                    Înregistrează-te în 30 de secunde și deblochezi toți cei 4 piloni.
                  </div>
                </div>
              </div>
              <div className="learn-free-banner-actions">
                <Button variant="acid" size="md" onClick={onSignup} icon="arrow">
                  Creează cont gratuit
                </Button>
                <Button variant="ghost" size="md" onClick={onLogin}>
                  Login
                </Button>
              </div>
            </div>
          </div>
        )}

        <div className="grid grid-2 learn-grid">
          {LEARN_ITEMS.map((item, i) =>
            <div key={item.title}
              ref={(el) => { cardsRef.current[i] = el; }}
              className="learn-card card card-pad-lg">
              <div className="learn-head">
                <IconChip icon={item.icon} color={item.color} size="lg" />
                <span className={`tag ${item.color}`}>{item.tag}</span>
              </div>
              <h3 style={{ marginTop: 26 }}>{item.title}</h3>
              <p style={{ marginTop: 14, lineHeight: 1.55 }}>{item.desc}</p>
              <div className="learn-points">
                {item.points.map((p) =>
                  <div key={p} className="learn-point">
                    <Icon name="check" size={12} style={{ color: `var(--${item.color})` }} />
                    <span>{p}</span>
                  </div>
                )}
              </div>
              <div className="learn-link" onClick={() => onNav('basics')}>
                <span>Vezi modulul</span>
                <Icon name="arrowUR" size={14} />
              </div>
            </div>
          )}
        </div>
      </div>
    <style>{`
      /* ===== Premium horizontal CTA banner — integrated above the grid ===== */
      .learn-free-banner {
        position: relative;
        margin: 28px 0 36px;
        padding: 22px 28px;
        border-radius: 20px;
        overflow: hidden;
        isolation: isolate;
        background:
          radial-gradient(ellipse at 0% 50%, rgba(183,255,26,0.10), transparent 55%),
          linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.012) 100%),
          rgba(10,10,12,0.6);
        border: 1px solid rgba(183,255,26,0.22);
        box-shadow:
          0 18px 50px rgba(0,0,0,0.45),
          0 0 60px rgba(183,255,26,0.08),
          inset 0 1px 0 rgba(255,255,255,0.06);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
      }
      /* Gradient top border accent — visually connects to the grid below */
      .learn-free-banner::before {
        content: '';
        position: absolute; left: 18%; right: 18%; top: 0;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(183,255,26,0.55), transparent);
        pointer-events: none;
      }
      /* Soft moving glow on the right side */
      .learn-free-banner-glow {
        position: absolute;
        right: -10%; top: -50%; bottom: -50%;
        width: 45%;
        background: radial-gradient(circle at center, rgba(79,231,213,0.10), transparent 60%);
        pointer-events: none;
        filter: blur(20px);
      }
      .learn-free-banner-inner {
        position: relative;
        display: flex; align-items: center; justify-content: space-between;
        gap: 24px;
        flex-wrap: wrap;
      }
      .learn-free-banner-left {
        display: flex; align-items: center; gap: 16px;
        flex: 1; min-width: 280px;
      }
      .learn-free-banner-icon {
        width: 44px; height: 44px;
        border-radius: 12px;
        display: grid; place-items: center;
        background:
          linear-gradient(180deg, rgba(183,255,26,0.18) 0%, rgba(183,255,26,0.06) 100%),
          rgba(0,0,0,0.4);
        border: 1px solid rgba(183,255,26,0.35);
        color: var(--acid);
        box-shadow: 0 0 18px rgba(183,255,26,0.20), inset 0 1px 0 rgba(255,255,255,0.10);
        flex-shrink: 0;
      }
      .learn-free-banner-title {
        font-size: 15px;
        line-height: 1.35;
        color: var(--text);
      }
      .learn-free-banner-title strong {
        color: var(--acid);
        font-weight: 700;
        text-shadow: 0 0 12px rgba(183,255,26,0.30);
      }
      .learn-free-banner-sub {
        margin-top: 4px;
        font-size: 12.5px;
        color: var(--text-mute);
        line-height: 1.4;
      }
      .learn-free-banner-actions {
        display: flex; gap: 10px; flex-shrink: 0;
      }
      @media (max-width: 720px) {
        .learn-free-banner { padding: 18px 20px; margin: 22px 0 32px; }
        .learn-free-banner-inner { gap: 18px; }
        .learn-free-banner-actions { width: 100%; }
        .learn-free-banner-actions > * { flex: 1; }
      }

      .learn-card { transition: transform 0.3s, border-color 0.3s; cursor: pointer; }
      .learn-card:hover { transform: translateY(-4px); border-color: var(--line-2); }
      .learn-head { display: flex; justify-content: space-between; align-items: center; }
      .learn-points {
        display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px;
        margin-top: 24px;
        padding-top: 24px;
        border-top: 1px dashed var(--line);
      }
      .learn-point { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
      .learn-link {
        margin-top: 26px;
        display: inline-flex; align-items: center; gap: 8px;
        color: var(--text); font-weight: 500; font-size: 13px;
        opacity: 0.7; transition: opacity 0.2s, gap 0.2s;
      }
      .learn-card:hover .learn-link { opacity: 1; gap: 12px; }
    `}</style>
    </section>
  );
};


// ============================================================
// WHY TYRONE — feature row
// ============================================================
const WHY_ITEMS = [
  { icon: 'book',   color: 'acid',   tag: 'PASUL 1',
    title: 'Studiază materialele free',
    desc: 'Dacă găsești valoare și înțelegi modul în care explic, înseamnă că putem avea o colaborare.',
    points: ['NASDAQ basics', 'Order flow', 'Setup-uri clare', 'Acces Discord'] },
  { icon: 'target', color: 'cyan',   tag: 'PASUL 2',
    title: 'Exersează pe conturi funded',
    desc: 'Exersează conceptele pe conturi funded și găsește problemele pe care le ai la înțelegerea conceptelor.',
    points: ['Apex / Tradeify', 'Sizing real', 'Live execuție', 'Journal disciplinat'] },
  { icon: 'crown',  color: 'gold',   tag: 'PASUL 3',
    title: 'Completează formularul pentru Elite',
    desc: 'Mentoratul pe care îl ofer în care îți dau răspuns la orice întrebare posibilă despre trading. Îți explic clar orice nelămurire.',
    points: ['1-on-1 mentorship', 'Răspuns rapid', 'Trade reviews', 'Plan personalizat'] },
  { icon: 'coin',   color: 'blue',   tag: 'PASUL 4',
    title: 'Payout-uri constante',
    desc: 'Felicitări, ai ajuns la profitabilitate spot la take profit. Nu a fost greu — doar ai avut nevoie de cineva care a trecut deja prin problemele pe care le ai tu ca să ți le explice.',
    points: ['Profit consistent', 'Mindset solid', 'Multi-account', 'Plan validat'] },
];

const HomeWhy = ({ onNav }) => {
  const sectionRef = React.useRef(null);
  const cardsRef = React.useRef([]);

  React.useLayoutEffect(() => {
    const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
    if (reduced || !window.gsap || !window.ScrollTrigger) return;

    const gsap = window.gsap;
    const ScrollTrigger = window.ScrollTrigger;
    gsap.registerPlugin(ScrollTrigger);

    const cards = cardsRef.current.filter(Boolean);
    if (cards.length === 0) return;
    const triggers = [];

    // Cards 0,2 from left (col 1); cards 1,3 from right (col 2)
    const config = [
      { x: '-65vw', y: 0 },
      { x:  '65vw', y: 0 },
      { x: '-65vw', y: 0 },
      { x:  '65vw', y: 0 },
    ];

    cards.forEach((card, i) => {
      const c = config[i] || config[0];
      gsap.set(card, {
        x: c.x,
        y: c.y,
        opacity: 0,
        scale: 0.92,
        filter: 'blur(8px)',
        willChange: 'transform, opacity, filter',
      });
    });

    cards.forEach((card, i) => {
      const tween = gsap.to(card, {
        x: 0,
        y: 0,
        opacity: 1,
        scale: 1,
        filter: 'blur(0px)',
        ease: 'power3.out',
        scrollTrigger: {
          trigger: sectionRef.current,
          start: 'top 80%',
          end: 'center 60%',
          scrub: 0.4 + i * 0.08,
        },
      });
      if (tween.scrollTrigger) triggers.push(tween.scrollTrigger);
    });

    // Snap-in pulse, then loop every 10s
    let pulseInterval = null;
    const firePulse = () => {
      cards.forEach((card, i) => {
        setTimeout(() => {
          card.classList.add('glow-pulse');
          setTimeout(() => card.classList.remove('glow-pulse'), 1400);
        }, i * 80);
      });
    };
    const pulseST = ScrollTrigger.create({
      trigger: sectionRef.current,
      start: 'top 30%',
      once: true,
      onEnter: () => {
        firePulse();
        pulseInterval = setInterval(firePulse, 10000);
      },
    });
    triggers.push(pulseST);

    return () => {
      if (pulseInterval) clearInterval(pulseInterval);
      triggers.forEach((t) => t && t.kill && t.kill());
      cards.forEach((card) => card && gsap.set(card, { clearProps: 'all' }));
    };
  }, []);

  return (
    <section ref={sectionRef}>
      <FloatChip brand="apex" color="rose" line="Apex Payout" val="+$5,720"
        top="140px" right="150px" delay={1.5} duration={8} />
      <FloatChip brand="tradeify" color="amber" line="Tradeify Payout" val="+$7,837"
        top="40px" left="80px" size="lg" delay={2.2} duration={8.5} boost={1.22} />
      <div className="container">
        <SectionHeader
          eyebrow="DE CE TYRONE TRADING"
          title="Dacă eu am reușit, și tu poți."
          subtitle="Diferența este că eu știu cum să profit de câteva puncte pe NASDAQ în profit cu ajutorul unor concepte pentru a face payout-uri constante." />

        <div className="grid grid-2 why-grid-v2 learn-grid">
          {WHY_ITEMS.map((item, i) =>
            <div key={item.title}
              ref={(el) => { cardsRef.current[i] = el; }}
              className="learn-card card card-pad-lg">
              <div className="learn-head">
                <IconChip icon={item.icon} color={item.color} size="lg" />
                <span className={`tag ${item.color}`}>{item.tag}</span>
              </div>
              <h3 style={{ marginTop: 26 }}>{item.title}</h3>
              <p style={{ marginTop: 14, lineHeight: 1.55 }}>{item.desc}</p>
              <div className="learn-points">
                {item.points.map((p) =>
                  <div key={p} className="learn-point">
                    <Icon name="check" size={12} style={{ color: `var(--${item.color})` }} />
                    <span>{p}</span>
                  </div>
                )}
              </div>
              <div className="learn-link" onClick={() => onNav && onNav('basics')}>
                <span>Vezi mai mult</span>
                <Icon name="arrowUR" size={14} />
              </div>
            </div>
          )}
        </div>
      </div>
      <style>{`
        .why-grid-v2 .why-card-wide { grid-column: 1 / -1; }
        .why-grid-v2 .why-card-wide .learn-points {
          grid-template-columns: repeat(4, 1fr);
        }
        @media (max-width: 760px) {
          .why-grid-v2 .why-card-wide .learn-points { grid-template-columns: 1fr 1fr; }
        }
      `}</style>
    </section>
  );
};

// ============================================================
// COMMUNITY
// ============================================================
const HomeCommunity = () =>
<section>
    <FloatChip brand="tradeify" color="amber" line="Tradeify Payout" val="+$4,620"
  bottom="80px" left="150px" delay={2.2} duration={9} />
    <div className="container">
      <div className="community-wrap card card-pad-xl eborder acid">
        <div className="community-grid">
          <div>
            <div className="eyebrow"><span className="dot" />FREE DISCORD</div>
            <h2 style={{ marginTop: 18, fontSize: 'clamp(36px, 5vw, 64px)' }}>
              500+ traderi.<br />
              <span className="acid">Un singur server.</span>
            </h2>
            <p className="lead" style={{ marginTop: 22, maxWidth: 480 }}>
              Resurse gratuite, discuții despre setup-uri, oferte prop firms, anunțuri și breakdown-uri zilnice. Începe de aici.
            </p>
            <div style={{ marginTop: 32, display: 'flex', gap: 12, flexWrap: 'wrap' }}>
              <Button variant="ghost" onClick={() => window.open('https://discord.gg/f2ebpTdDJF', '_blank', 'noopener,noreferrer')}>
                <span style={{ color: '#1E3A8A' }}><Icon name="discord" size={16} /></span>
                Join Free Discord
              </Button>
              <Button variant="ghost">
                Vezi ce conține
              </Button>
            </div>
          </div>
          <div className="community-feed">
            {[
          { name: 'Andrei M.', role: 'Funded · Apex', msg: 'Trecut evaluation în 4 zile. Mulțumesc pentru rule breakdown.', color: 'acid' },
          { name: 'Tyrone', role: 'admin', msg: 'NQ — vedem cum reacționează la 18,420 după CPI. Nu forțăm înainte de NY open.', color: 'gold', pin: true },
          { name: 'Cristian D.', role: 'Funded · Tradeify', msg: 'Payout #3 procesat. Sub 24h. Pentru oricine întreabă.', color: 'cyan' },
          { name: 'Mihai S.', role: 'member', msg: 'Backtest call de luni a fost gold. Setup-ul de London a funcționat azi.', color: 'blue' }].
          map((m, i) =>
          <div key={i} className={`feed-msg ${m.pin ? 'pinned' : ''}`}>
                <div className="feed-avatar" style={{ background: `var(--${m.color}-glow)`, color: `var(--${m.color})` }}>
                  {m.name.split(' ').map((n) => n[0]).join('')}
                </div>
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                    <span style={{ fontWeight: 600, fontSize: 13 }}>{m.name}</span>
                    <span className={`tag ${m.color}`} style={{ padding: '2px 8px', fontSize: 10 }}>{m.role}</span>
                    {m.pin && <Icon name="bolt" size={12} style={{ color: 'var(--gold)' }} />}
                  </div>
                  <p style={{ marginTop: 4, fontSize: 13, color: 'var(--text-dim)' }}>{m.msg}</p>
                </div>
              </div>
          )}
            <div className="feed-typing">
              <div className="feed-dots"><span /><span /><span /></div>
              <span>3 membri scriu...</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <style>{`
      .community-wrap { overflow: hidden; }
      .community-grid {
        display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: center;
      }
      @media (max-width: 920px) { .community-grid { grid-template-columns: 1fr; gap: 40px; } }
      .community-feed {
        display: flex; flex-direction: column; gap: 12px;
        padding: 22px;
        border-radius: 18px;
        background: rgba(0,0,0,0.4);
        border: 1px solid var(--line);
      }
      .feed-msg {
        display: flex; gap: 12px;
        padding: 12px 14px;
        border-radius: 12px;
        background: rgba(255,255,255,0.025);
        border: 1px solid var(--line);
      }
      .feed-msg.pinned { border-color: rgba(255,203,82,0.3); background: rgba(255,203,82,0.04); }
      .feed-avatar {
        width: 36px; height: 36px; border-radius: 50%;
        display: grid; place-items: center;
        font-size: 11px; font-weight: 700; flex-shrink: 0;
      }
      .feed-typing {
        display: flex; align-items: center; gap: 10px;
        padding: 8px 14px; font-size: 12px; color: var(--text-mute);
      }
      .feed-dots { display: flex; gap: 4px; }
      .feed-dots span {
        width: 5px; height: 5px; border-radius: 50%;
        background: var(--acid); animation: dot-bounce 1.4s infinite;
      }
      .feed-dots span:nth-child(2) { animation-delay: 0.2s; }
      .feed-dots span:nth-child(3) { animation-delay: 0.4s; }
      @keyframes dot-bounce { 0%,60%,100% { transform: translateY(0); opacity:0.4; } 30% { transform: translateY(-3px); opacity: 1; } }
    `}</style>
  </section>;


// ============================================================
// ELITE PREVIEW
// ============================================================
const EliteMainCard = ({ onApply, user }) => {
  const cardRef = React.useRef(null);
  const [hovered, setHovered] = React.useState(false);
  const [rot, setRot] = React.useState({ x: 0, y: 0 });

  const handleMove = (e) => {
    if (!cardRef.current) return;
    const rect = cardRef.current.getBoundingClientRect();
    const x = e.clientX - rect.left - rect.width / 2;
    const y = e.clientY - rect.top - rect.height / 2;
    setRot({
      x: -(y / rect.height) * 5,
      y:  (x / rect.width)  * 5,
    });
  };
  const handleLeave = () => { setHovered(false); setRot({ x: 0, y: 0 }); };

  const cardStyle = {
    transform: `perspective(1000px) rotateX(${rot.x}deg) rotateY(${rot.y}deg) translateY(${hovered ? -5 : 0}px)`,
    transformStyle: 'preserve-3d',
    transition: 'transform 0.4s cubic-bezier(0.22, 1, 0.36, 1)',
  };

  return (
    <div
      ref={cardRef}
      className={`elite-main ${hovered ? 'is-hovered' : ''}`}
      style={cardStyle}
      onMouseEnter={() => setHovered(true)}
      onMouseLeave={handleLeave}
      onMouseMove={handleMove}>
      {/* layer stack — bottom to top */}
      <div className="elite-base" />
      <div className="elite-noise" />
      <div className="elite-smudge" />
      <div className="elite-glow-side" />
      <div className="elite-glow-center" />
      <div className="elite-reflect" />
      <div className="elite-bborder" />
      <div className="elite-side elite-side-l" />
      <div className="elite-side elite-side-r" />
      <div className="elite-vline elite-vline-l" />
      <div className="elite-vline elite-vline-r" />

      <div className="elite-main-inner">
        <span className="elite-pill">
          <span className="dot" />
          BY APPLICATION
        </span>

        <h2 className="elite-feat-title">
          Elite <span className="acid">Plan</span>
        </h2>

        <p className="elite-feat-desc">
          Pentru traderii care vor mentorship serios și execuție disciplinată.
          Locuri limitate, doar prin aplicație.
        </p>

        <ul className="elite-benefits">
          <li><Icon name="check" size={14} /> 1-on-1 mentorship direct cu Tyrone</li>
          <li><Icon name="check" size={14} /> Live calls bi-săptămânale pe NQ</li>
          <li><Icon name="check" size={14} /> WhatsApp support în timp real</li>
          <li><Icon name="check" size={14} /> Trade reviews personalizate</li>
          <li><Icon name="check" size={14} /> Frameworks Elite exclusive</li>
          <li><Icon name="check" size={14} /> Discord VIP channel</li>
        </ul>

        {!isEliteUser(user) && (
          <Button variant="acid" size="lg" onClick={onApply}>
            Apply for Elite
          </Button>
        )}

        <span className="elite-fineprint">Răspuns în maxim 48h · 0 spam</span>
      </div>

      {/* Self-contained styles — keeps the card portable across pages */}
      <style>{`
        .elite-main {
          position: relative;
          z-index: 2;
          padding: 56px 56px 48px;
          border-radius: 32px;
          background-color: #050608;
          overflow: hidden;
          box-shadow:
            0 -10px 100px 10px rgba(183, 255, 26, 0.18),
            0 0 10px 0 rgba(0, 0, 0, 0.5),
            0 40px 120px rgba(0,0,0,0.65);
          will-change: transform;
        }
        .elite-main.is-hovered {
          box-shadow:
            0 -10px 100px 10px rgba(183, 255, 26, 0.28),
            0 0 10px 0 rgba(0, 0, 0, 0.5),
            0 40px 120px rgba(0,0,0,0.7);
        }
        .elite-base {
          position: absolute; inset: 0;
          background: linear-gradient(180deg, #000000 0%, #000000 70%);
          z-index: 0; pointer-events: none;
        }
        .elite-noise {
          position: absolute; inset: 0;
          opacity: 0.30; mix-blend-mode: overlay; z-index: 10; pointer-events: none;
          background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
        }
        .elite-smudge {
          position: absolute; inset: 0;
          opacity: 0.10; mix-blend-mode: soft-light; z-index: 11; pointer-events: none;
          background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='smudge'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.01' numOctaves='3' seed='5' stitchTiles='stitch'/%3E%3CfeGaussianBlur stdDeviation='10'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23smudge)'/%3E%3C/svg%3E");
        }
        .elite-glow-side {
          position: absolute; top: 0; left: 0; right: 0; height: 50%;
          z-index: 20; pointer-events: none; filter: blur(40px); opacity: 0.80;
          background:
            radial-gradient(ellipse at top right, rgba(183, 255, 26, 0.55) -10%, rgba(143, 224, 0, 0) 70%),
            radial-gradient(ellipse at top left,  rgba(79, 231, 213, 0.55) -10%, rgba(43, 201, 181, 0) 70%);
          transition: opacity 0.4s ease;
        }
        .elite-main.is-hovered .elite-glow-side { opacity: 0.95; }
        .elite-glow-center {
          position: absolute; top: 0; left: 0; right: 0; height: 50%;
          z-index: 21; pointer-events: none; filter: blur(45px); opacity: 0.75;
          transform: translateY(-10%);
          background: radial-gradient(ellipse at top center, rgba(183, 255, 26, 0.6) -20%, rgba(183, 255, 26, 0) 65%);
          transition: opacity 0.4s ease;
        }
        .elite-main.is-hovered .elite-glow-center { opacity: 0.95; }
        .elite-reflect {
          position: absolute; inset: 0; z-index: 35; pointer-events: none; opacity: 0.5;
          background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 40%, rgba(255,255,255,0) 80%, rgba(255,255,255,0.05) 100%);
          backdrop-filter: blur(2px);
          -webkit-backdrop-filter: blur(2px);
          transition: opacity 0.4s ease;
        }
        .elite-main.is-hovered .elite-reflect { opacity: 0.75; }
        .elite-bborder {
          position: absolute; top: 0; left: 0; right: 0; height: 2px;
          z-index: 25; pointer-events: none;
          background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 255, 255, 0.05) 100%);
          box-shadow:
            0 0 15px 3px rgba(183, 255, 26, 0.80),
            0 0 25px 5px rgba(143, 224, 0, 0.55),
            0 0 35px 7px rgba(79, 231, 213, 0.40);
          opacity: 0.9;
          transition: box-shadow 0.4s ease, opacity 0.4s ease;
        }
        .elite-main.is-hovered .elite-bborder {
          opacity: 1;
          box-shadow:
            0 0 20px 4px rgba(183, 255, 26, 0.9),
            0 0 30px 6px rgba(143, 224, 0, 0.7),
            0 0 40px 8px rgba(79, 231, 213, 0.5);
        }
        .elite-vline {
          position: absolute; top: 0; width: 1px; height: 25%;
          z-index: 25; border-radius: 999px; pointer-events: none;
          background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.5) 20%, rgba(255, 255, 255, 0.3) 40%, rgba(255, 255, 255, 0.1) 60%, rgba(255, 255, 255, 0) 80%);
          box-shadow:
            0 0 15px 3px rgba(183, 255, 26, 0.80),
            0 0 25px 5px rgba(143, 224, 0, 0.55),
            0 0 35px 7px rgba(79, 231, 213, 0.40);
          opacity: 0.9;
          transition: box-shadow 0.4s ease, opacity 0.4s ease;
        }
        .elite-vline-l { left: 0; }
        .elite-vline-r { right: 0; }
        .elite-main.is-hovered .elite-vline {
          opacity: 1;
          box-shadow:
            0 0 20px 4px rgba(183, 255, 26, 0.9),
            0 0 30px 6px rgba(143, 224, 0, 0.7),
            0 0 40px 8px rgba(79, 231, 213, 0.5);
        }
        .elite-side { position: absolute; top: 0; width: 25%; z-index: 25; pointer-events: none; }
        .elite-side-l {
          left: 0; height: 25%;
          background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.55) 15%, rgba(255, 255, 255, 0.4) 30%, rgba(255, 255, 255, 0.25) 45%, rgba(255, 255, 255, 0.1) 70%, rgba(255, 255, 255, 0) 85%);
          mask: linear-gradient(to right, #000 0%, transparent 90%);
          -webkit-mask: linear-gradient(to right, #000 0%, transparent 90%);
        }
        .elite-side-r {
          right: 0; height: 33%;
          background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.55) 15%, rgba(255, 255, 255, 0.4) 30%, rgba(255, 255, 255, 0.25) 45%, rgba(255, 255, 255, 0.1) 70%, rgba(255, 255, 255, 0) 85%);
          mask: linear-gradient(to left, #000 0%, transparent 90%);
          -webkit-mask: linear-gradient(to left, #000 0%, transparent 90%);
        }
        .elite-main-inner {
          position: relative; z-index: 40;
          display: flex; flex-direction: column;
          align-items: center; text-align: center;
        }
        @media (prefers-reduced-motion: reduce) {
          .elite-main { transition: none !important; transform: none !important; }
        }
      `}</style>
    </div>
  );
};

// Export for reuse on the Elite subpage
Object.assign(window, { EliteMainCard });

const HomeElitePreview = ({ onNav, user }) => {
  const sectionRef = React.useRef(null);
  const cornersRef = React.useRef([]);

  React.useLayoutEffect(() => {
    const reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
    const isMobile = window.matchMedia('(max-width: 760px)').matches;
    if (reduced || isMobile || !window.gsap || !window.ScrollTrigger) return;

    const gsap = window.gsap;
    const ScrollTrigger = window.ScrollTrigger;
    gsap.registerPlugin(ScrollTrigger);

    const corners = cornersRef.current.filter(Boolean);
    if (corners.length === 0) return;
    const triggers = [];

    // [direction, final-rotation-deg]
    const config = [
      { side: 'left',  rot: -5 },  // tl
      { side: 'right', rot:  4 },  // tr
      { side: 'left',  rot:  3 },  // bl
      { side: 'right', rot: -4 },  // br
    ];

    corners.forEach((card, i) => {
      const c = config[i] || config[0];
      gsap.set(card, {
        x: c.side === 'left' ? '-70vw' : '70vw',
        rotation: c.side === 'left' ? c.rot - 12 : c.rot + 12,
        opacity: 0,
        scale: 0.92,
        filter: 'blur(8px)',
        willChange: 'transform, opacity, filter',
      });
    });

    corners.forEach((card, i) => {
      const c = config[i] || config[0];
      const tween = gsap.to(card, {
        x: 0,
        rotation: c.rot,
        opacity: 1,
        scale: 1,
        filter: 'blur(0px)',
        ease: 'power3.out',
        scrollTrigger: {
          trigger: sectionRef.current,
          start: 'top 80%',
          end: 'center 60%',
          scrub: 0.4 + i * 0.08,
        },
      });
      if (tween.scrollTrigger) triggers.push(tween.scrollTrigger);
    });

    return () => {
      triggers.forEach((t) => t && t.kill && t.kill());
      corners.forEach((c) => c && gsap.set(c, { clearProps: 'all' }));
    };
  }, []);

  return (
    <section ref={sectionRef}>
      <FloatChip brand="fundednext" color="blue" line="FundedNext Payout" val="+$3,720"
        top="80px" left="150px" delay={1.8} duration={8.5} />
      <div className="container">
        <div className="elite-stage">
          {/* CORNER ACCENT CARDS — slightly rotated, overlap main card corners */}
          <div ref={(el) => { cornersRef.current[0] = el; }} className="elite-corner elite-corner-tl">
            <div className="elite-bicon amber"><Icon name="crown" size={22} /></div>
            <div className="elite-beyebrow">Elite Tier</div>
            <h3>1-on-1<br/>Mentorship</h3>
          </div>

          <div ref={(el) => { cornersRef.current[1] = el; }} className="elite-corner elite-corner-tr">
            <div className="elite-bicon acid"><Icon name="coin" size={22} /></div>
            <div className="elite-beyebrow">Plan dovedit</div>
            <h3>Fă payout<br/>de la ZERO</h3>
          </div>

          <div ref={(el) => { cornersRef.current[2] = el; }} className="elite-corner elite-corner-bl">
            <div className="elite-bicon violet"><Icon name="users" size={22} /></div>
            <div className="elite-beyebrow acid">Active</div>
            <h3><span className="elite-big">17</span><br/>Elite members</h3>
          </div>

          <div ref={(el) => { cornersRef.current[3] = el; }} className="elite-corner elite-corner-br">
            <div className="elite-bicon rose"><Icon name="star" size={22} /></div>
            <div className="elite-beyebrow acid">4+ Years</div>
            <h3>Profitable<br/>NQ Trader</h3>
          </div>

        {/* MAIN ELITE RECTANGLE — gradient card */}
        <EliteMainCard onApply={() => onNav('elite')} user={user} />
      </div>
    </div>
    <style>{`
      .elite-stage {
        position: relative;
        max-width: 880px;
        margin: 60px auto;
        padding: 80px 40px;
      }

      /* ============================================================
         MAIN ELITE RECTANGLE — Gradient card (acid + cyan palette)
         ============================================================ */
      .elite-main {
        position: relative;
        z-index: 2;
        padding: 56px 56px 48px;
        border-radius: 32px;
        background-color: #050608;
        overflow: hidden;
        box-shadow:
          0 -10px 100px 10px rgba(183, 255, 26, 0.18),
          0 0 10px 0 rgba(0, 0, 0, 0.5),
          0 40px 120px rgba(0,0,0,0.65);
        will-change: transform;
      }
      .elite-main.is-hovered {
        box-shadow:
          0 -10px 100px 10px rgba(183, 255, 26, 0.28),
          0 0 10px 0 rgba(0, 0, 0, 0.5),
          0 40px 120px rgba(0,0,0,0.7);
      }

      /* Base black gradient */
      .elite-base {
        position: absolute; inset: 0;
        background: linear-gradient(180deg, #000000 0%, #000000 70%);
        z-index: 0;
        pointer-events: none;
      }

      /* Noise texture */
      .elite-noise {
        position: absolute; inset: 0;
        opacity: 0.30;
        mix-blend-mode: overlay;
        z-index: 10;
        pointer-events: none;
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
      }

      /* Smudge softlight */
      .elite-smudge {
        position: absolute; inset: 0;
        opacity: 0.10;
        mix-blend-mode: soft-light;
        z-index: 11;
        pointer-events: none;
        background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='smudge'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.01' numOctaves='3' seed='5' stitchTiles='stitch'/%3E%3CfeGaussianBlur stdDeviation='10'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23smudge)'/%3E%3C/svg%3E");
      }

      /* Side glows (acid + cyan) coming from the TOP corners — fade downward,
         stop around the middle of the card. Bottom stays clean/dark. */
      .elite-glow-side {
        position: absolute;
        top: 0; left: 0; right: 0;
        height: 50%;
        z-index: 20;
        pointer-events: none;
        filter: blur(40px);
        opacity: 0.80;
        background:
          radial-gradient(ellipse at top right, rgba(183, 255, 26, 0.55) -10%, rgba(143, 224, 0, 0) 70%),
          radial-gradient(ellipse at top left,  rgba(79, 231, 213, 0.55) -10%, rgba(43, 201, 181, 0) 70%);
        transition: opacity 0.4s ease;
      }
      .elite-main.is-hovered .elite-glow-side { opacity: 0.95; }

      /* Center acid glow — emanating from the TOP, fading toward the middle */
      .elite-glow-center {
        position: absolute;
        top: 0; left: 0; right: 0;
        height: 50%;
        z-index: 21;
        pointer-events: none;
        filter: blur(45px);
        opacity: 0.75;
        transform: translateY(-10%);
        background: radial-gradient(ellipse at top center, rgba(183, 255, 26, 0.6) -20%, rgba(183, 255, 26, 0) 65%);
        transition: opacity 0.4s ease;
      }
      .elite-main.is-hovered .elite-glow-center { opacity: 0.95; }

      /* Glass reflection on top */
      .elite-reflect {
        position: absolute; inset: 0;
        z-index: 35;
        pointer-events: none;
        opacity: 0.5;
        background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 40%, rgba(255,255,255,0) 80%, rgba(255,255,255,0.05) 100%);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        transition: opacity 0.4s ease;
      }
      .elite-main.is-hovered .elite-reflect { opacity: 0.75; }

      /* TOP border light — moved from bottom to top */
      .elite-bborder {
        position: absolute;
        top: 0; left: 0; right: 0;
        height: 2px;
        z-index: 25;
        pointer-events: none;
        background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 255, 255, 0.05) 100%);
        box-shadow:
          0 0 15px 3px rgba(183, 255, 26, 0.80),
          0 0 25px 5px rgba(143, 224, 0, 0.55),
          0 0 35px 7px rgba(79, 231, 213, 0.40);
        opacity: 0.9;
        transition: box-shadow 0.4s ease, opacity 0.4s ease;
      }
      .elite-main.is-hovered .elite-bborder {
        opacity: 1;
        box-shadow:
          0 0 20px 4px rgba(183, 255, 26, 0.9),
          0 0 30px 6px rgba(143, 224, 0, 0.7),
          0 0 40px 8px rgba(79, 231, 213, 0.5);
      }

      /* TOP corner verticals — mirror of the original bottom verticals */
      .elite-vline {
        position: absolute;
        top: 0;
        width: 1px;
        height: 25%;
        z-index: 25;
        border-radius: 999px;
        pointer-events: none;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.5) 20%, rgba(255, 255, 255, 0.3) 40%, rgba(255, 255, 255, 0.1) 60%, rgba(255, 255, 255, 0) 80%);
        box-shadow:
          0 0 15px 3px rgba(183, 255, 26, 0.80),
          0 0 25px 5px rgba(143, 224, 0, 0.55),
          0 0 35px 7px rgba(79, 231, 213, 0.40);
        opacity: 0.9;
        transition: box-shadow 0.4s ease, opacity 0.4s ease;
      }
      .elite-vline-l { left: 0; }
      .elite-vline-r { right: 0; }
      .elite-main.is-hovered .elite-vline {
        opacity: 1;
        box-shadow:
          0 0 20px 4px rgba(183, 255, 26, 0.9),
          0 0 30px 6px rgba(143, 224, 0, 0.7),
          0 0 40px 8px rgba(79, 231, 213, 0.5);
      }

      /* TOP corner wide accents — keep bottom clean by mirroring to top */
      .elite-side {
        position: absolute;
        top: 0;
        width: 25%;
        z-index: 25;
        pointer-events: none;
      }
      .elite-side-l {
        left: 0;
        height: 25%;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.55) 15%, rgba(255, 255, 255, 0.4) 30%, rgba(255, 255, 255, 0.25) 45%, rgba(255, 255, 255, 0.1) 70%, rgba(255, 255, 255, 0) 85%);
        mask: linear-gradient(to right, #000 0%, transparent 90%);
        -webkit-mask: linear-gradient(to right, #000 0%, transparent 90%);
      }
      .elite-side-r {
        right: 0;
        height: 33%;
        background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.55) 15%, rgba(255, 255, 255, 0.4) 30%, rgba(255, 255, 255, 0.25) 45%, rgba(255, 255, 255, 0.1) 70%, rgba(255, 255, 255, 0) 85%);
        mask: linear-gradient(to left, #000 0%, transparent 90%);
        -webkit-mask: linear-gradient(to left, #000 0%, transparent 90%);
      }

      .elite-main-inner {
        position: relative; z-index: 40;
        display: flex; flex-direction: column;
        align-items: center; text-align: center;
      }

      @media (prefers-reduced-motion: reduce) {
        .elite-main { transition: none !important; transform: none !important; }
      }

      .elite-pill {
        display: inline-flex; align-items: center; gap: 8px;
        padding: 7px 14px;
        border-radius: 999px;
        background: rgba(183,255,26,0.12);
        border: 1px solid rgba(183,255,26,0.3);
        color: var(--acid);
        font-family: 'JetBrains Mono', monospace;
        font-size: 10.5px;
        letter-spacing: 0.14em;
        text-transform: uppercase;
      }
      .elite-pill .dot {
        width: 6px; height: 6px; border-radius: 50%;
        background: var(--acid); box-shadow: 0 0 8px var(--acid-glow);
      }
      .elite-feat-title {
        font-size: clamp(46px, 6vw, 78px);
        line-height: 1;
        letter-spacing: -0.04em;
        margin: 22px 0 0;
        font-weight: 900;
      }
      .elite-feat-title .acid {
        background: linear-gradient(180deg, #DCFF7A 0%, #B7FF1A 60%, #8FE000 100%);
        -webkit-background-clip: text; background-clip: text;
        color: transparent;
        filter: drop-shadow(0 0 18px rgba(183,255,26,0.3));
      }
      .elite-feat-desc {
        margin: 18px auto 0;
        max-width: 480px;
        font-size: 15px;
        color: var(--text-dim);
        line-height: 1.55;
      }

      /* BENEFITS LIST */
      .elite-benefits {
        list-style: none;
        padding: 0;
        margin: 36px auto 36px;
        max-width: 620px;
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px 28px;
        text-align: left;
      }
      .elite-benefits li {
        display: flex; align-items: center; gap: 10px;
        font-size: 14px;
        color: var(--text);
      }
      .elite-benefits li svg {
        color: var(--acid);
        flex-shrink: 0;
        filter: drop-shadow(0 0 6px var(--acid-glow));
      }

      .elite-fineprint {
        margin-top: 16px;
        font-size: 12px;
        color: var(--text-mute);
        letter-spacing: 0.05em;
      }

      /* CORNER ACCENT CARDS — rotated, overlapping the main rectangle */
      .elite-corner {
        position: absolute;
        z-index: 3;
        width: 215px;
        padding: 22px 22px 20px;
        background: linear-gradient(180deg, #1a1a1a 0%, #0d0d0d 100%);
        border: 1px solid var(--line-2);
        border-radius: 20px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
        box-shadow: 0 24px 60px rgba(0,0,0,0.75), 0 0 0 1px rgba(255,255,255,0.04);
        transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), z-index 0s 0.35s;
      }
      .elite-corner h3 {
        font-size: 22px;
        line-height: 1.1;
        letter-spacing: -0.02em;
        margin: 0;
      }
      .elite-corner:hover {
        transform: rotate(0deg) translateY(-4px) scale(1.04) !important;
        z-index: 5;
        transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), z-index 0s;
      }

      .elite-corner-tl { top:  10px;  left:  -40px; transform: rotate(-5deg); }
      .elite-corner-tr { top:  -8px;  right: -60px; transform: rotate(4deg); }
      .elite-corner-bl { bottom: 0px;  left:  -70px; transform: rotate(3deg); }
      .elite-corner-br { bottom: 20px; right: -40px; transform: rotate(-4deg); }

      .elite-bicon {
        width: 46px; height: 46px;
        display: grid; place-items: center;
        border-radius: 13px;
        position: relative;
      }
      .elite-bicon::after {
        content: '';
        position: absolute; inset: 0;
        border-radius: inherit;
        background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.35), transparent 60%);
        pointer-events: none;
      }
      .elite-bicon.acid {
        background: linear-gradient(180deg, #C6FF3A 0%, #9DE000 100%);
        color: #050505;
        border: 1px solid rgba(0,0,0,0.18);
        box-shadow: 0 8px 22px rgba(183,255,26,0.40), inset 0 1px 0 rgba(255,255,255,0.35);
      }
      .elite-bicon.amber {
        background: linear-gradient(180deg, #FBBF24 0%, #D97706 100%);
        color: #1a0d00;
        border: 1px solid rgba(0,0,0,0.18);
        box-shadow: 0 8px 22px rgba(245,158,11,0.42), inset 0 1px 0 rgba(255,255,255,0.35);
      }
      .elite-bicon.rose {
        background: linear-gradient(180deg, #FB7185 0%, #E11D48 100%);
        color: #ffffff;
        border: 1px solid rgba(255,255,255,0.14);
        box-shadow: 0 8px 22px rgba(244,63,94,0.42), inset 0 1px 0 rgba(255,255,255,0.30);
      }
      .elite-bicon.violet {
        background: linear-gradient(180deg, #A78BFA 0%, #7C3AED 100%);
        color: #ffffff;
        border: 1px solid rgba(255,255,255,0.14);
        box-shadow: 0 8px 22px rgba(139,92,246,0.42), inset 0 1px 0 rgba(255,255,255,0.30);
      }
      .elite-bicon.cyan {
        background: linear-gradient(180deg, #66EFDE 0%, #2BC9B5 100%);
        color: #04261F;
        border: 1px solid rgba(0,0,0,0.16);
        box-shadow: 0 8px 22px rgba(79,231,213,0.42), inset 0 1px 0 rgba(255,255,255,0.32);
      }
      .elite-bicon svg { position: relative; z-index: 1; }
      .elite-beyebrow {
        font-family: 'JetBrains Mono', monospace;
        font-size: 11px;
        letter-spacing: 0.14em;
        color: var(--text-mute);
        text-transform: uppercase;
      }
      .elite-beyebrow.acid { color: var(--acid); }
      .elite-big {
        font-size: 48px;
        font-weight: 800;
        line-height: 1;
        letter-spacing: -0.04em;
        color: var(--text);
      }

      @media (max-width: 1100px) {
        .elite-stage { padding: 60px 20px; max-width: 760px; }
        .elite-corner { width: 180px; padding: 18px; }
        .elite-corner h3 { font-size: 18px; }
        .elite-corner-tl { top: -10px;  left: -20px; }
        .elite-corner-tr { top: -20px;  right: -20px; }
        .elite-corner-bl { bottom: -20px; left: -20px; }
        .elite-corner-br { bottom: -10px; right: -20px; }
      }
      @media (max-width: 760px) {
        .elite-stage { padding: 30px 0; }
        .elite-main { padding: 36px 26px 32px; }
        .elite-benefits {
          grid-template-columns: 1fr;
          gap: 12px;
          max-width: 360px;
        }
        .elite-corner {
          position: relative;
          width: 100%;
          margin: 14px 0;
          top: auto; left: auto; right: auto; bottom: auto;
          transform: none !important;
        }
        .elite-corner:hover { transform: translateY(-3px) !important; }
      }
    `}</style>
      </section>
  );
};


const HomePage = ({ onNav, user, onLogin, onSignup }) =>
<>
    <HomeHero onNav={onNav} user={user} />
    <HomeProof />
    <HomeLearn onNav={onNav} user={user} onLogin={onLogin} onSignup={onSignup} />
    <HomeWhy onNav={onNav} />
    <HomeElitePreview onNav={onNav} user={user} />
  </>;


Object.assign(window, { HomePage });
