// Landing page sections for WealthLens.

const LandingHero = () => {
  const [triggered, setTriggered] = React.useState(false);
  React.useEffect(() => { const t = setTimeout(() => setTriggered(true), 200); return () => clearTimeout(t); }, []);
  const missed = useCountUp(7600, 1400, triggered);
  const compounded = useCountUp(110098, 1800, triggered);
  const tenYr = useCountUp(110098, 1800, triggered);
  void tenYr;

  return (
    <section style={{
      maxWidth:1240, margin:'0 auto', padding:'88px 32px 48px',
      display:'grid', gridTemplateColumns:'1.05fr 1.1fr', gap:72, alignItems:'center',
    }}>
      <div>
        <div className="wl-eyebrow" style={{marginBottom:22, display:'flex', alignItems:'center', gap:10}}>
          <span style={{width:6, height:6, borderRadius:'50%', background:'var(--wl-accent)', boxShadow:'0 0 10px rgba(212,132,90,0.6)'}}/>
          Built for South African investors
        </div>
        <h1 style={{
          font:'var(--wl-h1)', fontSize:'clamp(44px, 5.4vw, 68px)', lineHeight:1.04,
          letterSpacing:'-0.028em', margin:0, color:'var(--wl-fg-0)',
          maxWidth:620,
        }}>
          You're leaving money{' '}
          <span style={{fontFamily:'var(--wl-font-display)', fontStyle:'italic', fontWeight:500}}>on the table.</span>
          <br/>
          <span style={{color:'var(--wl-fg-2)'}}>Here's how much.</span>
        </h1>
        <p style={{
          fontSize:18, color:'var(--wl-fg-1)', lineHeight:1.55,
          marginTop:24, maxWidth:520,
        }}>
          Finvue connects your accounts — bank, investments, property, crypto — and shows you exactly where you're losing money.
        </p>
        <div style={{display:'flex', gap:14, marginTop:36, alignItems:'center', flexWrap:'wrap'}}>
          <a href={DEMO_URL} target="_blank" rel="noopener" style={{
            background:'#D4845A', color:'#0C0B09',
            padding:'15px 24px', borderRadius:12,
            fontSize:15, fontWeight:500, textDecoration:'none',
            display:'inline-flex', alignItems:'center', gap:8,
          }}>Try the demo <span style={{fontSize:14}}>→</span></a>
          <a href="features.html" style={{
            color:'var(--wl-fg-1)', fontSize:15,
            padding:'15px 18px', textDecoration:'none',
            borderBottom:'1px solid var(--wl-line-2)',
          }}>See how it works</a>
        </div>
        <div style={{
          display:'flex', gap:28, marginTop:52, flexWrap:'wrap',
          fontSize:11, color:'var(--wl-fg-2)',
          letterSpacing:'0.12em', textTransform:'uppercase',
        }}>
          <span>● Read-only access</span>
          <span>● Bank-grade encryption</span>
          <span>● SA-built</span>
        </div>
      </div>

      {/* The hook card */}
      <div style={{
        background:'linear-gradient(180deg, rgba(204,82,82,0.04) 0%, rgba(24,21,16,0) 60%), var(--wl-bg-2)',
        border:'1px solid var(--wl-line-1)',
        borderRadius:20,
        padding:'40px 40px 32px',
        boxShadow:'0 0 0 1px rgba(204,82,82,0.12), 0 32px 96px rgba(204,82,82,0.08)',
        position:'relative', overflow:'hidden',
      }}>
        <div style={{position:'absolute', top:0, left:0, right:0, height:1, background:'linear-gradient(90deg, transparent, rgba(204,82,82,0.4), transparent)'}}/>
        <div style={{display:'flex', justifyContent:'space-between', alignItems:'center'}}>
          <div className="wl-eyebrow" style={{color:'var(--wl-loss)'}}>
            Money you're losing each year
          </div>
          <span style={{
            fontSize:10, color:'var(--wl-fg-3)', letterSpacing:'0.14em',
            textTransform:'uppercase', border:'1px solid var(--wl-line-2)',
            padding:'4px 8px', borderRadius:999,
          }}>Example · demo user</span>
        </div>
        <div style={{
          fontFamily:'var(--wl-font-display)', fontWeight:700,
          fontSize:'clamp(88px, 11vw, 148px)', letterSpacing:'-0.035em',
          color:'var(--wl-loss)', lineHeight:0.95,
          fontVariantNumeric:'tabular-nums', marginTop:20,
          fontFeatureSettings:"'lnum' 1, 'tnum' 1",
        }}>
          R&nbsp;{formatZAR(missed)}
        </div>

        <div style={{
          marginTop:24, paddingTop:22, paddingBottom:8,
          borderTop:'1px solid var(--wl-line-1)',
          display:'grid', gridTemplateColumns:'1fr 1fr', gap:24,
        }}>
          <div>
            <div className="wl-eyebrow" style={{marginBottom:8}}>10 yr compounded</div>
            <div style={{
              fontFamily:'var(--wl-font-display)', fontWeight:600, fontSize:28,
              letterSpacing:'-0.02em', color:'var(--wl-fg-0)', fontVariantNumeric:'tabular-nums',
              fontFeatureSettings:"'lnum' 1, 'tnum' 1",
            }}>R&nbsp;{formatZAR(compounded)}</div>
          </div>
          <div>
            <div className="wl-eyebrow" style={{marginBottom:8}}>Sources</div>
            <div style={{fontSize:13, color:'var(--wl-fg-1)', lineHeight:1.5}}>
              Low-yield cash · Duplicate ETF exposure · Forgotten RA fees
            </div>
          </div>
        </div>

        <div style={{
          marginTop:24, paddingTop:18,
          borderTop:'1px solid var(--wl-line-1)',
          display:'flex', justifyContent:'space-between', alignItems:'center',
        }}>
          <a href={LAUNCH_URL} target="_blank" rel="noopener" style={{color:'var(--wl-accent)', fontSize:14, fontWeight:500, textDecoration:'none'}}>
            See where it's coming from →
          </a>
          <span style={{fontSize:11, color:'var(--wl-fg-3)', fontFamily:'var(--wl-font-mono)'}}>
            Updated 22 Apr 2026
          </span>
        </div>
      </div>
    </section>
  );
};

const ProofStrip = () => {
  const items = ['JSE', 'NYSE', 'LSE', 'Binance', 'Luno', 'Standard Bank', 'FNB', 'Absa', 'Easy Equities', '10X', 'Allan Gray'];
  return (
    <section style={{padding:'40px 32px', borderTop:'1px solid var(--wl-line-1)', borderBottom:'1px solid var(--wl-line-1)'}}>
      <div style={{maxWidth:1240, margin:'0 auto', display:'flex', alignItems:'center', gap:48, flexWrap:'wrap', justifyContent:'center'}}>
        <div className="wl-eyebrow" style={{flexShrink:0}}>Track assets across 8 000+ platforms</div>
        <div style={{
          display:'flex', gap:36, flexWrap:'wrap', justifyContent:'center',
          color:'var(--wl-fg-2)', fontFamily:'var(--wl-font-display)',
          fontStyle:'italic', fontSize:17, fontWeight:500,
        }}>
          {items.map(i => <span key={i}>{i}</span>)}
        </div>
      </div>
    </section>
  );
};

// Allocation donut matching real platform segments
const AllocationDonut = ({size = 140}) => (
  <svg width={size} height={size} viewBox="0 0 42 42">
    {/* Property 46% */}
    <circle cx="21" cy="21" r="15.9" fill="none" stroke="#B8B3A8" strokeWidth="4.2" strokeDasharray="46 54" transform="rotate(-90 21 21)"/>
    {/* Retirement 22% */}
    <circle cx="21" cy="21" r="15.9" fill="none" stroke="#6AA6F3" strokeWidth="4.2" strokeDasharray="22 78" strokeDashoffset="-46" transform="rotate(-90 21 21)"/>
    {/* Banking 11% */}
    <circle cx="21" cy="21" r="15.9" fill="none" stroke="#F5B657" strokeWidth="4.2" strokeDasharray="11 89" strokeDashoffset="-68" transform="rotate(-90 21 21)"/>
    {/* Investments 8% */}
    <circle cx="21" cy="21" r="15.9" fill="none" stroke="#D4845A" strokeWidth="4.2" strokeDasharray="8 92" strokeDashoffset="-79" transform="rotate(-90 21 21)"/>
    {/* Vehicle 7% */}
    <circle cx="21" cy="21" r="15.9" fill="none" stroke="#7A8F7F" strokeWidth="4.2" strokeDasharray="7 93" strokeDashoffset="-87" transform="rotate(-90 21 21)"/>
    {/* Crypto 6% */}
    <circle cx="21" cy="21" r="15.9" fill="none" stroke="#C98B7A" strokeWidth="4.2" strokeDasharray="6 94" strokeDashoffset="-94" transform="rotate(-90 21 21)"/>
  </svg>
);

// Product preview — matches actual platform dashboard layout
const ProductPreview = () => (
  <section id="product" style={{maxWidth:1240, margin:'0 auto', padding:'128px 32px 64px'}}>
    <div style={{display:'grid', gridTemplateColumns:'1fr 1fr', gap:48, alignItems:'end', marginBottom:56}}>
      <div>
        <div className="wl-eyebrow" style={{marginBottom:16}}>The product</div>
        <h2 style={{font:'var(--wl-h2)', fontSize:'clamp(36px, 4.4vw, 56px)', letterSpacing:'-0.025em', margin:0, lineHeight:1.05}}>
          One view of everything{' '}
          <span style={{fontFamily:'var(--wl-font-display)', fontStyle:'italic', color:'var(--wl-fg-2)', fontWeight:500}}>you own.</span>
        </h2>
      </div>
      <p style={{color:'var(--wl-fg-2)', fontSize:16, lineHeight:1.6, margin:0, maxWidth:480, justifySelf:'end'}}>
        From JSE equities to that flat in Parkhurst, crypto, and every cash account between. Everything reconciled nightly. Nothing leaves finvue.
      </p>
    </div>

    <div style={{
      background:'var(--wl-bg-1)', border:'1px solid var(--wl-line-1)',
      borderRadius:20, padding:32, position:'relative',
      boxShadow:'0 40px 120px rgba(0,0,0,0.6)',
    }}>
      {/* Header bar */}
      <div style={{display:'flex', justifyContent:'space-between', alignItems:'center', marginBottom:32, paddingBottom:20, borderBottom:'1px solid var(--wl-line-1)'}}>
        <div>
          <div style={{fontSize:18, fontWeight:500, color:'var(--wl-fg-0)', letterSpacing:'-0.01em'}}>Good afternoon, Jeremy.</div>
          <div style={{color:'var(--wl-fg-2)', fontSize:13, marginTop:3}}>Friday, 24 April 2026</div>
        </div>
        <div style={{
          fontSize:12, color:'var(--wl-fg-2)', padding:'8px 16px',
          border:'1px solid var(--wl-line-2)', borderRadius:8,
          display:'flex', alignItems:'center', gap:8,
        }}>
          <span style={{color:'var(--wl-fg-3)'}}>NET WORTH</span>
          <span style={{color:'var(--wl-fg-0)', fontFamily:'var(--wl-font-mono)', fontSize:13}}>R 1 142 601</span>
        </div>
      </div>

      {/* Net worth hero — dominant, stacked */}
      <div style={{marginBottom:8}}>
        <div className="wl-eyebrow" style={{marginBottom:12}}>Net worth</div>
        <div style={{
          fontFamily:'var(--wl-font-display)', fontWeight:700,
          fontSize:'clamp(52px, 7vw, 96px)', letterSpacing:'-0.03em', lineHeight:1,
          fontVariantNumeric:'tabular-nums', fontFeatureSettings:"'lnum' 1, 'tnum' 1",
          whiteSpace:'nowrap',
        }}>R&nbsp;1&nbsp;142&nbsp;600,69</div>
        <div style={{marginTop:10, display:'flex', gap:20, alignItems:'center', flexWrap:'wrap'}}>
          <span style={{fontFamily:'var(--wl-font-mono)', fontSize:13, color:'var(--wl-loss)'}}>−R 102,93 · −0,01% today</span>
          <span style={{fontSize:13, color:'var(--wl-fg-3)'}}>Assets R 1 157 600,69 · Liabilities R 15 000,00</span>
        </div>
      </div>

      {/* Missed returns — consequence, below net worth */}
      <div style={{
        marginTop:24, marginBottom:28,
        padding:'18px 0', borderTop:'1px solid var(--wl-line-1)',
      }}>
        <div className="wl-eyebrow" style={{color:'var(--wl-fg-2)', marginBottom:8}}>Your current arrangement costs you annually</div>
        <div style={{
          fontFamily:'var(--wl-font-display)', fontWeight:700,
          fontSize:'clamp(36px, 5vw, 60px)', letterSpacing:'-0.025em', lineHeight:1,
          color:'var(--wl-loss)', fontVariantNumeric:'tabular-nums',
          fontFeatureSettings:"'lnum' 1, 'tnum' 1",
        }}>−R&nbsp;7&nbsp;600</div>
        <div style={{marginTop:6, fontSize:13, color:'var(--wl-fg-2)'}}>
          That's <span style={{color:'var(--wl-fg-1)'}}>R 110 098</span> over 10 years at 8%
        </div>
        <div style={{marginTop:10}}>
          <a href={LAUNCH_URL} target="_blank" rel="noopener" style={{color:'var(--wl-accent)', fontSize:13, fontWeight:500, textDecoration:'none'}}>See where it's coming from →</a>
        </div>
      </div>

      {/* Chart + allocation */}
      <div style={{display:'grid', gridTemplateColumns:'1.6fr 1fr', gap:20}}>
        <div style={{background:'var(--wl-bg-2)', border:'1px solid var(--wl-line-1)', borderRadius:14, padding:22}}>
          <div style={{display:'flex', justifyContent:'space-between', alignItems:'baseline', marginBottom:16}}>
            <div>
              <div style={{font:'var(--wl-h4)', fontSize:14}}>Net worth history</div>
              <div style={{fontSize:12, color:'var(--wl-fg-2)', marginTop:2}}>Daily snapshots</div>
            </div>
            <div style={{display:'flex', gap:4}}>
              {['1W','1M','3M','6M','1Y'].map((t,i)=>(
                <span key={t} style={{
                  padding:'4px 10px', borderRadius:999, fontSize:10,
                  background: i===1 ? '#D4845A' : 'transparent',
                  color: i===1 ? '#0C0B09' : 'var(--wl-fg-3)',
                  fontWeight: i===1 ? 500 : 400,
                }}>{t}</span>
              ))}
            </div>
          </div>
          <Sparkline height={140}/>
        </div>

        <div style={{background:'var(--wl-bg-2)', border:'1px solid var(--wl-line-1)', borderRadius:14, padding:22}}>
          <div style={{font:'var(--wl-h4)', fontSize:14, marginBottom:16}}>Allocation</div>
          <div style={{display:'flex', gap:16, alignItems:'center'}}>
            <AllocationDonut size={120}/>
            <div style={{fontSize:11, color:'var(--wl-fg-2)', lineHeight:2.1}}>
              <div><span style={{display:'inline-block', width:7, height:7, borderRadius:2, background:'#B8B3A8', marginRight:7}}/>Property <span style={{color:'var(--wl-fg-0)', marginLeft:4}}>46%</span></div>
              <div><span style={{display:'inline-block', width:7, height:7, borderRadius:2, background:'#6AA6F3', marginRight:7}}/>Retirement <span style={{color:'var(--wl-fg-0)', marginLeft:4}}>22%</span></div>
              <div><span style={{display:'inline-block', width:7, height:7, borderRadius:2, background:'#F5B657', marginRight:7}}/>Banking <span style={{color:'var(--wl-fg-0)', marginLeft:4}}>11%</span></div>
              <div><span style={{display:'inline-block', width:7, height:7, borderRadius:2, background:'#D4845A', marginRight:7}}/>Investments <span style={{color:'var(--wl-fg-0)', marginLeft:4}}>8%</span></div>
              <div><span style={{display:'inline-block', width:7, height:7, borderRadius:2, background:'#7A8F7F', marginRight:7}}/>Vehicle <span style={{color:'var(--wl-fg-0)', marginLeft:4}}>7%</span></div>
              <div><span style={{display:'inline-block', width:7, height:7, borderRadius:2, background:'#C98B7A', marginRight:7}}/>Crypto <span style={{color:'var(--wl-fg-0)', marginLeft:4}}>6%</span></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
);

// Insights section — four categories of insight
const Insights = () => {
  const leaks = [
    {
      cat:'Opportunity',
      eye:'01 · Low-yield cash',
      amount:'R 7 380',
      ten:'R 106 920',
      amountLabel:'Annual cost',
      desc:'R 128 000 sitting in a cheque account earning 2.1% — a notice deposit at 8.25% closes the gap.',
      bar:65,
      amountColor:'var(--wl-loss)',
    },
    {
      cat:'Tax',
      eye:'02 · Unused TFSA allowance',
      amount:'R 1 080',
      ten:'—',
      amountLabel:'Annual tax saving',
      desc:'R 36 000 TFSA allowance unused with 10 months left in the tax year.',
      bar:25,
      amountColor:'var(--wl-gain)',
    },
    {
      cat:'Allocation',
      eye:'03 · ZAR concentration',
      amount:'Monitor',
      ten:'—',
      amountLabel:'Flagged as',
      desc:'92% of assets are ZAR-denominated — rand has depreciated against major currencies.',
      bar:0,
      amountColor:'var(--wl-warn)',
    },
  ];

  return (
    <section id="insights" style={{maxWidth:1240, margin:'0 auto', padding:'128px 32px 96px'}}>
      <div style={{display:'grid', gridTemplateColumns:'1fr 1fr', gap:72, alignItems:'end', marginBottom:64}}>
        <div>
          <div className="wl-eyebrow" style={{marginBottom:16}}>Insights</div>
          <h2 style={{font:'var(--wl-h2)', fontSize:'clamp(36px, 4.4vw, 56px)', letterSpacing:'-0.025em', margin:0, lineHeight:1.05}}>
            A few places money{' '}
            <span style={{fontFamily:'var(--wl-font-display)', fontStyle:'italic', color:'var(--wl-loss)', fontWeight:500}}>quietly leaks.</span>
          </h2>
        </div>
        <p style={{color:'var(--wl-fg-2)', fontSize:16, lineHeight:1.6, margin:0, maxWidth:480, justifySelf:'end'}}>
          Insights span opportunities, tax savings, and allocation warnings — not just cash drag. We show you the long-term impact, so you can decide if it's worth fixing.
        </p>
      </div>

      {/* Insight rows */}
      <div style={{border:'1px solid var(--wl-line-1)', borderRadius:20, background:'var(--wl-bg-1)', overflow:'hidden'}}>
        {/* header */}
        <div style={{display:'grid', gridTemplateColumns:'0.85fr 1.6fr 0.9fr 0.9fr', gap:24, padding:'18px 32px', borderBottom:'1px solid var(--wl-line-1)', alignItems:'center'}}>
          <div className="wl-eyebrow">Type · Insight</div>
          <div className="wl-eyebrow">What's happening</div>
          <div className="wl-eyebrow" style={{textAlign:'right'}}>Impact</div>
          <div className="wl-eyebrow" style={{textAlign:'right'}}>10 yr compounded</div>
        </div>
        {leaks.map((l, i) => (
          <div key={l.eye} style={{
            display:'grid', gridTemplateColumns:'0.85fr 1.6fr 0.9fr 0.9fr',
            gap:24, padding:'28px 32px', alignItems:'center',
            borderBottom: i < leaks.length - 1 ? '1px solid var(--wl-line-1)' : 'none',
          }}>
            <div>
              <div style={{
                display:'inline-block', fontSize:10, letterSpacing:'0.12em',
                textTransform:'uppercase', padding:'3px 8px', borderRadius:999,
                marginBottom:8,
                color: l.cat==='Opportunity' ? 'var(--wl-accent)' : l.cat==='Tax' ? 'var(--wl-gain)' : 'var(--wl-warn)',
                border: `1px solid ${l.cat==='Opportunity' ? 'rgba(212,132,90,0.3)' : l.cat==='Tax' ? 'rgba(79,173,133,0.3)' : 'rgba(245,182,87,0.3)'}`,
              }}>{l.cat}</div>
              <div style={{font:'var(--wl-h4)', fontSize:14, color:'var(--wl-fg-0)', lineHeight:1.4}}>{l.eye.split(' · ')[1]}</div>
            </div>
            <div>
              <div style={{color:'var(--wl-fg-1)', fontSize:14, lineHeight:1.55, marginBottom:12, maxWidth:440}}>{l.desc}</div>
              {l.bar > 0 && (
                <div style={{height:4, borderRadius:2, background:'var(--wl-bg-3)', overflow:'hidden', maxWidth:380}}>
                  <div style={{width:`${l.bar}%`, height:'100%', background:'var(--wl-loss)', opacity:0.7}}/>
                </div>
              )}
            </div>
            <div>
              <div style={{fontSize:10, color:'var(--wl-fg-3)', letterSpacing:'0.12em', textTransform:'uppercase', marginBottom:6, textAlign:'right'}}>{l.amountLabel}</div>
              <div style={{textAlign:'right', fontFamily:'var(--wl-font-display)', fontWeight:600, fontSize:26, letterSpacing:'-0.015em', color:l.amountColor, fontVariantNumeric:'tabular-nums', fontFeatureSettings:"'lnum' 1, 'tnum' 1"}}>{l.amount}</div>
            </div>
            <div style={{textAlign:'right', fontFamily:'var(--wl-font-display)', fontWeight:500, fontSize:22, letterSpacing:'-0.015em', color: l.ten === '—' ? 'var(--wl-fg-3)' : 'var(--wl-fg-0)', fontVariantNumeric:'tabular-nums', fontFeatureSettings:"'lnum' 1, 'tnum' 1"}}>{l.ten}</div>
          </div>
        ))}
      </div>

      {/* Compounding visual */}
      <div style={{marginTop:48, display:'grid', gridTemplateColumns:'1fr 1.3fr', gap:48, alignItems:'center', padding:'40px 32px', border:'1px solid var(--wl-line-1)', borderRadius:20, background:'var(--wl-bg-1)'}}>
        <div>
          <div className="wl-eyebrow" style={{color:'var(--wl-accent)', marginBottom:12}}>How it compounds</div>
          <div style={{font:'var(--wl-h3)', fontSize:24, lineHeight:1.3, letterSpacing:'-0.01em'}}>
            An R 7 380 leak today grows to
            <span style={{fontFamily:'var(--wl-font-display)', color:'var(--wl-loss)', fontWeight:700, fontSize:32, letterSpacing:'-0.02em', fontFeatureSettings:"'lnum' 1, 'tnum' 1"}}> R 106 920</span> at 8% over ten years.
          </div>
          <p style={{color:'var(--wl-fg-2)', fontSize:14, lineHeight:1.6, marginTop:14}}>
            Every opportunity carries a compounded cost — see what it grows to over 1 to 10 years, so you can weigh whether it's worth fixing today.
          </p>
        </div>
        <CompoundChart/>
      </div>
    </section>
  );
};

const CompoundChart = () => {
  const [ref, seen] = useInView(0.3);
  // Bars 1..10 yrs; compounded R 7600 at 8%
  const years = Array.from({length:10}, (_, i) => {
    const v = 7600 * ((Math.pow(1.08, i+1) - 1) / 0.08);
    return Math.round(v);
  });
  const max = years[years.length - 1];
  return (
    <div ref={ref} style={{display:'flex', gap:8, alignItems:'flex-end', height:200, paddingBottom:28, position:'relative'}}>
      {years.map((v, i) => {
        const h = (v / max) * 100;
        const isLast = i === years.length - 1;
        return (
          <div key={i} style={{flex:1, display:'flex', flexDirection:'column', alignItems:'center', gap:8}}>
            <div style={{fontSize:10, fontFamily:'var(--wl-font-mono)', color: isLast ? 'var(--wl-loss)' : 'var(--wl-fg-3)'}}>
              {v >= 1000 ? `${Math.round(v/1000)}k` : v}
            </div>
            <div style={{
              width:'100%', height: seen ? `${h}%` : 0,
              background: isLast ? 'var(--wl-loss)' : 'var(--wl-bg-3)',
              borderTop: isLast ? 'none' : '1px solid var(--wl-line-2)',
              borderRadius:'4px 4px 0 0',
              transition: `height 900ms cubic-bezier(0.16, 1, 0.3, 1) ${i * 60}ms`,
              opacity: isLast ? 1 : 0.6 + (i/30),
            }}/>
            <div style={{fontSize:10, color:'var(--wl-fg-3)', fontFamily:'var(--wl-font-mono)'}}>Y{i+1}</div>
          </div>
        );
      })}
    </div>
  );
};

// Trust section
const Trust = () => {
  const pillars = [
    { title:'Read-only, always', body:'Finvue connects to your accounts through regulated aggregators. We can see balances and transactions. We cannot move money, and we never will.' },
    { title:'Bank-grade encryption', body:'AES-256 at rest, TLS 1.3 in transit. Credentials live at the aggregator, not with us. You can revoke any connection from inside the app in one click.' },
    { title:'Analyst, not advisor', body:'We don\'t recommend products, make predictions, or earn commissions from what you hold. We show the math. The decision is always yours.' },
  ];
  return (
    <section id="trust" style={{borderTop:'1px solid var(--wl-line-1)', borderBottom:'1px solid var(--wl-line-1)', background:'var(--wl-bg-1)'}}>
      <div style={{maxWidth:1240, margin:'0 auto', padding:'112px 32px'}}>
        <div style={{display:'grid', gridTemplateColumns:'1fr 1.2fr', gap:72}}>
          <div style={{position:'sticky', top:120, alignSelf:'start'}}>
            <div className="wl-eyebrow" style={{color:'var(--wl-accent)', marginBottom:16}}>Trust</div>
            <h2 style={{font:'var(--wl-h2)', fontSize:'clamp(32px, 4vw, 48px)', letterSpacing:'-0.025em', margin:0, lineHeight:1.1}}>
              We don't hold your money.
              <br/>
              <span style={{fontFamily:'var(--wl-font-display)', fontStyle:'italic', color:'var(--wl-fg-2)', fontWeight:500}}>We don't sell it either.</span>
            </h2>
            <div style={{marginTop:28, width:72, height:72, border:'1px solid var(--wl-accent)', borderRadius:16, display:'grid', placeItems:'center'}}>
              <svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="#D4845A" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
                <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
              </svg>
            </div>
          </div>
          <div style={{display:'flex', flexDirection:'column', gap:24}}>
            {pillars.map(p => (
              <div key={p.title} style={{padding:'28px 32px', border:'1px solid var(--wl-line-1)', borderRadius:16, background:'var(--wl-bg-2)'}}>
                <div style={{font:'var(--wl-h3)', fontSize:20, letterSpacing:'-0.01em', marginBottom:10}}>{p.title}</div>
                <p style={{color:'var(--wl-fg-1)', fontSize:15, lineHeight:1.6, margin:0}}>{p.body}</p>
              </div>
            ))}
            <div style={{padding:'20px 32px', border:'1px dashed var(--wl-line-2)', borderRadius:16, fontSize:13, color:'var(--wl-fg-2)', lineHeight:1.6}}>
              <span className="wl-eyebrow" style={{marginRight:12, color:'var(--wl-fg-3)'}}>Disclosure</span>
              Finvue is an information tool, not a financial services provider under FAIS. We do not offer advice, intermediate products, or earn revenue from recommendations.
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

const TESTIMONIALS = [
  {
    quote: "I actually had no idea how many better alternatives existed for my money — or how much I was leaving on the table. Can't wait for the full version.",
    city: "Cape Town",
  },
  {
    quote: "You never know you need something until you try it. Finvue genuinely opened my eyes to things I didn't know I was missing. Phase 2 can't come fast enough.",
    city: "Johannesburg",
  },
  {
    quote: "I'm not a finance person, but this was surprisingly easy to follow. My only frustration is that the full version isn't live yet.",
    city: "Cape Town",
  },
];

const Testimonial = () => {
  const [idx, setIdx] = React.useState(0);
  const [paused, setPaused] = React.useState(false);
  const touchRef = React.useRef({x: 0, active: false});

  React.useEffect(() => {
    if (paused) return;
    const t = setInterval(() => setIdx(i => (i + 1) % TESTIMONIALS.length), 4500);
    return () => clearInterval(t);
  }, [paused]);

  const go = (i) => setIdx((i + TESTIMONIALS.length) % TESTIMONIALS.length);

  const onTouchStart = (e) => { touchRef.current = {x: e.touches[0].clientX, active: true}; };
  const onTouchEnd = (e) => {
    if (!touchRef.current.active) return;
    const dx = e.changedTouches[0].clientX - touchRef.current.x;
    if (Math.abs(dx) > 40) go(idx + (dx < 0 ? 1 : -1));
    touchRef.current.active = false;
  };

  return (
    <section
      style={{maxWidth:1100, margin:'0 auto', padding:'128px 32px', textAlign:'center'}}
      onMouseEnter={() => setPaused(true)}
      onMouseLeave={() => setPaused(false)}
      onTouchStart={onTouchStart}
      onTouchEnd={onTouchEnd}
    >
      <div className="wl-eyebrow" style={{marginBottom:28}}>From beta users</div>

      {/* Conveyor */}
      <div style={{position:'relative', overflow:'hidden', minHeight:260}}>
        <div style={{
          display:'flex',
          width:`${TESTIMONIALS.length * 100}%`,
          transform:`translateX(-${idx * (100 / TESTIMONIALS.length)}%)`,
          transition:'transform 720ms cubic-bezier(0.16, 1, 0.3, 1)',
        }}>
          {TESTIMONIALS.map((t, i) => (
            <div key={i} style={{width:`${100 / TESTIMONIALS.length}%`, flexShrink:0, padding:'0 8px'}}>
              <blockquote style={{
                fontFamily:'var(--wl-font-display)', fontStyle:'italic', fontWeight:500,
                fontSize:'clamp(24px, 2.8vw, 36px)', lineHeight:1.32,
                letterSpacing:'-0.015em', color:'var(--wl-fg-0)',
                margin:'0 auto', maxWidth:860, textWrap:'pretty',
                opacity: i === idx ? 1 : 0.4,
                transition:'opacity 480ms',
              }}>
                "{t.quote}"
              </blockquote>
              <div style={{marginTop:32, color:'var(--wl-fg-2)', fontSize:13, opacity: i === idx ? 1 : 0.4, transition:'opacity 480ms'}}>
                — Early beta tester, <span style={{color:'var(--wl-fg-0)'}}>{t.city}</span>
              </div>
            </div>
          ))}
        </div>
      </div>

      {/* Dots */}
      <div style={{marginTop:36, display:'flex', gap:8, justifyContent:'center'}}>
        {TESTIMONIALS.map((_, i) => (
          <button
            key={i}
            onClick={() => go(i)}
            aria-label={`Testimonial ${i+1}`}
            style={{
              width: i === idx ? 28 : 8, height:8, borderRadius:999,
              background: i === idx ? 'var(--wl-accent)' : 'var(--wl-bg-3)',
              border:'none', padding:0, cursor:'pointer',
              transition:'width 360ms, background 240ms',
            }}
          />
        ))}
      </div>
    </section>
  );
};

const FinalCTA = () => (
  <section id="cta" style={{
    borderTop:'1px solid var(--wl-line-1)',
    padding:'128px 32px 128px',
    textAlign:'center',
    background:'radial-gradient(circle at 50% 0%, rgba(204,82,82,0.06), transparent 60%)',
  }}>
    <div style={{maxWidth:780, margin:'0 auto'}}>
      <div className="wl-eyebrow" style={{color:'var(--wl-loss)', marginBottom:20}}>Your turn</div>
      <h2 style={{font:'var(--wl-h2)', fontSize:'clamp(40px, 6vw, 72px)', letterSpacing:'-0.03em', margin:'0 0 20px', lineHeight:1.02}}>
        How much are{' '}
        <span style={{fontFamily:'var(--wl-font-display)', fontStyle:'italic', color:'var(--wl-loss)', fontWeight:500}}>you</span>
        <br/>
        losing each year?
      </h2>
      <p style={{color:'var(--wl-fg-2)', fontSize:17, margin:'0 auto 40px', maxWidth:480, lineHeight:1.55}}>
        Connect one account. See your number.
      </p>
      <a href={LAUNCH_URL} target="_blank" rel="noopener" style={{
        display:'inline-flex', alignItems:'center', gap:10,
        background:'#D4845A', color:'#0C0B09',
        padding:'18px 32px', borderRadius:14,
        fontSize:16, fontWeight:500, textDecoration:'none',
      }}>Launch the app <span style={{fontSize:15}}>↗</span></a>
      <div style={{marginTop:22, fontSize:11, color:'var(--wl-fg-3)', letterSpacing:'0.12em', textTransform:'uppercase'}}>
        No signup · No card · Sample data
      </div>
    </div>
  </section>
);

Object.assign(window, {
  LandingHero, ProofStrip, ProductPreview, Insights, Trust, Testimonial, FinalCTA,
});