// sections.jsx — Gasless Wallet landing sections
// Exports (to window): Nav, Hero, Stats, HowItWorks, Features, Security, Referral, FinalCTA, Footer, AppStoreBadge

const Ic = {
  apple: <svg viewBox="0 0 24 24" fill="currentColor"><path d="M17.05 12.04c-.03-2.6 2.12-3.85 2.22-3.91-1.21-1.77-3.1-2.01-3.77-2.04-1.6-.16-3.13.94-3.94.94-.81 0-2.07-.92-3.4-.9-1.75.03-3.36 1.02-4.26 2.58-1.82 3.16-.47 7.84 1.3 10.41.86 1.26 1.89 2.67 3.24 2.62 1.3-.05 1.79-.84 3.36-.84 1.57 0 2.01.84 3.39.81 1.4-.02 2.29-1.28 3.14-2.55.99-1.46 1.4-2.88 1.42-2.95-.03-.01-2.72-1.04-2.75-4.13zM14.6 4.42c.72-.87 1.2-2.08 1.07-3.29-1.03.04-2.28.69-3.02 1.56-.66.77-1.24 2-1.09 3.18 1.15.09 2.32-.58 3.04-1.45z" /></svg>,
  social: <svg viewBox="0 0 24 24" fill="none"><circle cx="12" cy="8" r="3.4" stroke="currentColor" strokeWidth="2" /><path d="M5 20c0-3.3 3.1-5.5 7-5.5s7 2.2 7 5.5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" /></svg>,
  fuel: <svg viewBox="0 0 24 24" fill="none"><path d="M5 21V5a2 2 0 012-2h6a2 2 0 012 2v16M3 21h14M15 8h2.5A1.5 1.5 0 0119 9.5V16a1.5 1.5 0 003 0V9l-3-3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /><path d="M7 8h6" stroke="currentColor" strokeWidth="2" strokeLinecap="round" /></svg>,
  bolt: <svg viewBox="0 0 24 24" fill="none"><path d="M13 2L4 14h6l-1 8 9-12h-6l1-8z" fill="currentColor" /></svg>,
  shield: <svg viewBox="0 0 24 24" fill="none"><path d="M12 3l7 3v5c0 4.4-3 8.4-7 9.5C8 19.4 5 15.4 5 11V6l7-3z" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" /><path d="M9 12l2 2 4-4" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /></svg>,
  layers: <svg viewBox="0 0 24 24" fill="none"><path d="M12 3l9 5-9 5-9-5 9-5z" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" /><path d="M3 13l9 5 9-5" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" /></svg>,
  key: <svg viewBox="0 0 24 24" fill="none"><circle cx="8" cy="8" r="4.5" stroke="currentColor" strokeWidth="2" /><path d="M11 11l8 8m-3 0l2-2m-4-2l2-2" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /></svg>,
  lock: <svg viewBox="0 0 24 24" fill="none"><rect x="5" y="11" width="14" height="9" rx="2.5" stroke="currentColor" strokeWidth="2" /><path d="M8 11V8a4 4 0 018 0v3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" /></svg>,
  eye: <svg viewBox="0 0 24 24" fill="none"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z" stroke="currentColor" strokeWidth="2" /><circle cx="12" cy="12" r="2.6" stroke="currentColor" strokeWidth="2" /></svg>,
  gift: <svg viewBox="0 0 24 24" fill="none"><rect x="3" y="9" width="18" height="11" rx="2" stroke="currentColor" strokeWidth="2" /><path d="M3 13h18M12 9v11M12 9S10.5 4 8 5.5 12 9 12 9zm0 0s1.5-5 4-3.5S12 9 12 9z" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" /></svg>,
  arrow: <svg viewBox="0 0 24 24" fill="none"><path d="M5 12h14m0 0l-6-6m6 6l-6 6" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" /></svg>,
  swap: <svg viewBox="0 0 24 24" fill="none"><path d="M4 8h12m0 0l-3.5-3.5M16 8l-3.5 3.5M20 16H8m0 0l3.5-3.5M8 16l3.5 3.5" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /></svg>,
  check: <svg viewBox="0 0 24 24" fill="none"><path d="M5 13l4 4L19 7" stroke="currentColor" strokeWidth="2.6" strokeLinecap="round" strokeLinejoin="round" /></svg>,
  x: <svg viewBox="0 0 24 24" fill="none"><path d="M7 7l10 10M17 7L7 17" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" /></svg>,
  alert: <svg viewBox="0 0 24 24" fill="none"><path d="M10.3 3.86 1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.7 3.86a2 2 0 00-3.42 0z" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" /><path d="M12 9v4.5M12 17.2h.01" stroke="currentColor" strokeWidth="2" strokeLinecap="round" /></svg>,
  google: <svg viewBox="0 0 24 24"><path fill="#4285F4" d="M21.6 12.2c0-.64-.06-1.25-.16-1.84H12v3.49h5.38a4.6 4.6 0 01-2 3.02v2.5h3.23c1.89-1.74 2.99-4.3 2.99-7.17z" /><path fill="#34A853" d="M12 22c2.7 0 4.96-.9 6.62-2.43l-3.23-2.5c-.9.6-2.05.96-3.39.96-2.6 0-4.8-1.76-5.59-4.12H3.07v2.58A10 10 0 0012 22z" /><path fill="#FBBC05" d="M6.41 13.91A6 6 0 016.09 12c0-.66.11-1.31.32-1.91V7.51H3.07A10 10 0 002 12c0 1.61.39 3.14 1.07 4.49l3.34-2.58z" /><path fill="#EA4335" d="M12 5.98c1.47 0 2.79.5 3.83 1.5l2.87-2.87C16.95 2.99 14.7 2 12 2A10 10 0 003.07 7.51l3.34 2.58C7.2 7.74 9.4 5.98 12 5.98z" /></svg>,
  telegram: <svg viewBox="0 0 24 24" fill="currentColor"><path d="M21.94 4.57 18.6 20.3c-.25 1.1-.9 1.38-1.83.86l-5.05-3.72-2.44 2.35c-.27.27-.5.5-1.02.5l.36-5.14L18.04 6.5c.4-.36-.09-.56-.63-.2L5.84 13.71l-4.97-1.56c-1.08-.34-1.1-1.08.23-1.6l19.43-7.49c.9-.34 1.69.2 1.41 1.51z" /></svg>,
  xLogo: <svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.24 2.25h3.31l-7.23 8.26 8.5 11.24h-6.66l-5.22-6.82-5.96 6.82H1.67l7.73-8.84L1.25 2.25h6.83l4.71 6.23 5.45-6.23zm-1.16 17.52h1.83L7.01 4.13H5.04l12.04 15.64z" /></svg>
};

const SOCIALS = [
  { name: 'Telegram', icon: 'telegram', url: 'https://t.me/gaslesswalletchannel' },
  { name: 'X', icon: 'xLogo', url: 'https://x.com/gasless_wallet' }];

function CountUp({ to = 1.38, duration = 1500, prefix = '$', suffix = 'M', decimals = 2 }) {
  const [val, setVal] = React.useState(0);
  const ref = React.useRef(null);
  React.useEffect(() => {
    let raf, start;
    let started = false;
    const run = () => {
      const step = (ts) => {
        if (!start) start = ts;
        const p = Math.min((ts - start) / duration, 1);
        const eased = 1 - Math.pow(1 - p, 3);
        setVal(to * eased);
        if (p < 1) raf = requestAnimationFrame(step);
      };
      raf = requestAnimationFrame(step);
    };
    const io = new IntersectionObserver((e) => {
      if (e[0].isIntersecting && !started) {started = true;run();io.disconnect();}
    }, { threshold: 0.4 });
    if (ref.current) io.observe(ref.current);
    const safety = setTimeout(() => {if (!started) {started = true;run();}}, 600);
    return () => {cancelAnimationFrame(raf);io.disconnect();clearTimeout(safety);};
  }, [to, duration]);
  return <span ref={ref}>{prefix}{val.toFixed(decimals)}{suffix}</span>;
}

const APP_STORE_URL = 'https://apps.apple.com/sk/app/gasless-wallet/id6759570166';
const NODE_URL = 'The Gasless Node.html';

function AppStoreBadge() {
  return (
    <span className="appstore-wrap">
      <a className="appstore" href={APP_STORE_URL} target="_blank" rel="noopener noreferrer">
        <span style={{ display: 'grid', placeItems: 'center' }}>{Ic.apple}</span>
        <span className="as-txt"><span className="as-1">Download on the</span><span className="as-2">App Store</span></span>
      </a>
      <span className="as-qr" role="tooltip">
        <span className="as-qr-card">
          <img
            src={'https://api.qrserver.com/v1/create-qr-code/?size=320x320&margin=0&qzone=1&color=0C1512&bgcolor=FFFFFF&data=' + encodeURIComponent(APP_STORE_URL)}
            alt="Scan to download Gasless Wallet on the App Store"
            width="148" height="148" />
          <span className="as-qr-label">Scan to download</span>
        </span>
      </span>
    </span>);

}

function Nav() {
  const [scrolled, setScrolled] = React.useState(false);
  React.useEffect(() => {
    const f = () => setScrolled(window.scrollY > 12);
    f();window.addEventListener('scroll', f);return () => window.removeEventListener('scroll', f);
  }, []);
  return (
    <nav className={`nav ${scrolled ? 'scrolled' : ''}`}>
      <div className="wrap nav-inner">
        <a className="brand" href="#top" aria-label="Gasless">
          <img src="assets/gasless-logo-dark.svg" alt="Gasless" style={{ height: 44, width: 'auto', display: 'block' }} />
        </a>
        <div className="nav-links">
          <a className="nav-active" href="index.html" aria-current="page">Gasless Wallet</a>
          <a className="nav-node" href={NODE_URL}>
            Gasless Node<span className="nav-new">new</span>
          </a>
        </div>
        <div className="nav-cta">
          <a className="btn btn-ghost" href="#download" style={{ padding: '10px 18px' }}>Get the app</a>
        </div>
      </div>
    </nav>);

}

function Hero({ headline, c }) {
  return (
    <header className="hero" id="top">
      <div className="wrap hero-grid">
        <div className="hero-copy">
          <span className="eyebrow"><span className="dot" />{c.hero.eyebrow}</span>
          <h1 style={{ marginTop: 22 }}>{headline}</h1>
          <p className="hero-sub">{c.hero.sub}</p>
          <div className="hero-actions">
            <AppStoreBadge />
            <a className="btn btn-ghost" href="#how">See how it works {Ic.arrow}</a>
          </div>
          <div className="hero-trust">
            <span className="avatars"><span /><span /><span /><span /></span>
            {c.hero.trust}
          </div>
          <a className="wallet-teaser" href="The Gasless Node.html">
            <span className="wt-icon">{Ic.swap}</span>
            <span className="wt-body">
              <span className="wt-q">Already on TronLink, TokenPocket or another wallet?<span className="wt-chev">{Ic.arrow}</span></span>
              <span className="wt-reveal">Keep your wallet — cut USDT fees up to 50% with the Gasless node {Ic.arrow}</span>
            </span>
            <span className="wt-pulse" aria-hidden="true" />
          </a>
        </div>
        <div className="phone-stage">
          <div className="phone-glow" />
          <div className="chip" style={{ top: '-3%', left: '-13%', animationDelay: '0s' }}>
            <span className="ci" style={{ background: 'var(--tint)', color: 'var(--accent)' }}>{Ic.social}</span>
            <span>No seed phrase<small>Sign in with Apple</small></span>
          </div>
          <div className="chip" style={{ bottom: '10%', right: '-10%', animationDelay: '1.4s' }}>
            <span className="ci" style={{ background: 'var(--tint)', color: 'var(--accent)' }}>{Ic.fuel}</span>
            <span>50% lower fees<small>On every USDT transfer</small></span>
          </div>
          <div className="phone-host" style={{ position: 'relative', zIndex: 2 }}><WalletDemo /></div>
        </div>
      </div>
    </header>);

}

function Stats() {
  const data = [
  ['3.5', ' TRX', 'Fee per transfer (~$1.1) — half the usual 7 TRX'],
  ['138K', '', 'Transactions sent through Gasless'],
  ['$159K', '', 'Saved for our customers'],
  ['2K', '+', 'People already use Gasless']];

  return (
    <section className="wrap" style={{ marginTop: 8 }}>
      <div className="stats reveal">
        {data.map(([n, u, l], i) =>
        <div className="stat" key={i}>
            <div className="num">{n}<span className="u">{u}</span></div>
            <div className="lbl">{l}</div>
          </div>
        )}
      </div>
    </section>);

}

function HowItWorks({ c }) {
  const seed = ['ribbon', 'meadow', 'anchor', 'velvet', 'copper', 'lagoon', 'tunnel', 'marble', 'quartz', 'dapple', 'sphinx', 'puzzle'];
  return (
    <section className="sec" id="how">
      <div className="wrap">
        <div className="sec-head center reveal">
          <span className="section-tag">{c.how.tag}</span>
          <h2>{c.how.title}</h2>
          <p data-comment-anchor="c97cfa51e0-p-144-11">{c.how.sub}</p>
        </div>

        {/* seed phrase vs Gasless — the contrast */}
        <div className="seedcmp reveal">
          <div className="sccard sccard--old">
            <div className="sccard-top">
              <span className="scbadge scbadge--x">{Ic.x}</span>
              <div className="sccard-h">
                <div className="sck">Other wallets</div>
                <div className="scsub">Back up 12 secret words</div>
              </div>
            </div>
            <div className="seedgrid">
              {seed.map((w, i) =>
              <span className="seedw" key={i}><i>{i + 1}</i>{w}</span>
              )}
            </div>
            <div className="scwarn">{Ic.alert}<span>Lose these words and your money is gone — <b>forever.</b></span></div>
          </div>

          <div className="scvs"><span>vs</span></div>

          <div className="sccard sccard--new">
            <div className="sccard-top">
              <span className="scbadge scbadge--ok">{Ic.check}</span>
              <div className="sccard-h">
                <div className="sck">Gasless</div>
                <div className="scsub">Just sign in — nothing to memorize</div>
              </div>
            </div>
            <div className="loginmock">
              <div className="lgn lgn--apple">{Ic.apple}<span>Continue with Apple</span></div>
              <div className="lgn lgn--google">{Ic.google}<span>Continue with Google</span></div>
              <div className="lgn-face">{Ic.lock}<span>Face ID confirms it&rsquo;s you</span></div>
            </div>
            <div className="scgood">{Ic.check}<span>No phrase to write down. <b>Nothing to lose.</b></span></div>
          </div>
        </div>

        {/* who holds the key — plain-language non-custodial */}
        <div className="keyflow reveal">
          <div className="kf-track">
            <div className="kf-node">
              <span className="kf-ic">{Ic.social}</span>
              <span className="kf-lbl">You</span>
              <span className="kf-meta">own your funds</span>
            </div>
            <span className="kf-arrow">{Ic.arrow}</span>
            <div className="kf-node kf-node--key">
              <span className="kf-ic">{Ic.lock}</span>
              <span className="kf-lbl">Secure key</span>
              <span className="kf-meta">locked in hardware — only you unlock it</span>
            </div>
            <span className="kf-arrow">{Ic.arrow}</span>
            <div className="kf-node">
              <span className="kf-ic">{Ic.bolt}</span>
              <span className="kf-lbl">Gasless</span>
              <span className="kf-meta">helps you send, never holds your money</span>
            </div>
          </div>
          <p className="kf-copy">Your key is created and locked inside secure hardware — only you can unlock it. Gasless makes Tron easy to use, but can never hold, freeze, or move your funds. That&rsquo;s what <b>non-custodial</b> means: all the convenience, none of the handover.</p>
        </div>
      </div>
    </section>);

}

function Comparison({ c }) {
  const cm = c.compare;
  return (
    <section className="sec" id="compare">
      <div className="wrap">
        {/* "What if I have no TRX?" interactive demo */}
        <div className="notrx reveal">
          <div className="notrx-copy">
            <span className="nt-eyebrow"><span className="dot" />New wallet, zero TRX?</span>
            <h3>&ldquo;But I don&rsquo;t have any&nbsp;TRX.&rdquo;</h3>
            <p className="nt-lead">On other wallets, a brand-new account can&rsquo;t move a single dollar until someone sends you TRX for fees. With Gasless you just tap <b style={{ color: 'var(--ink)' }}>Get TRX</b> and pay with the USDT you already hold.</p>
            <div className="notrx-steps">
              <div className="nt-step">
                <span className="nt-num">1</span>
                <div><div className="nt-b">Hit a wall</div><div className="nt-p">You go to send USDT, but your wallet holds 0 TRX for gas.</div></div>
              </div>
              <div className="nt-step">
                <span className="nt-num">2</span>
                <div><div className="nt-b">Tap Get TRX</div><div className="nt-p">Buy TRX with your USDT — no TRX required to do it, even on an empty wallet.</div></div>
              </div>
              <div className="nt-step">
                <span className="nt-num">3</span>
                <div><div className="nt-b">You&rsquo;re ready</div><div className="nt-p">TRX lands in seconds and your transfer goes through.</div></div>
              </div>
            </div>
            <span className="nt-hint"><span className="nt-tap" />Try it — tap <b style={{ color: 'var(--ink)' }}>Get TRX</b> in the wallet</span>
          </div>
          <div className="notrx-stage">
            <div className="nt-glow" />
            <div className="phone-host"><NoTrxDemo /></div>
          </div>
        </div>
      </div>
    </section>);

}

function Referral() {
  const [copied, setCopied] = React.useState(false);
  return (
    <section className="sec" id="referral">
      <div className="wrap">
        <div className="referral reveal">
          <div className="ref-grid">
            <div>
              <span className="section-tag">Referral program</span>
              <div className="ref-big">10%</div>
              <h2 style={{ fontSize: 'clamp(26px,3vw,38px)', fontWeight: 800, letterSpacing: '-0.03em', marginTop: 6 }}>Earn 10% of the fees from everyone you invite.</h2>
              <p style={{ color: 'var(--muted)', fontSize: 17, marginTop: 16, maxWidth: '34em' }}>
                Share your link. When friends send USDT with Gasless, you earn 10% of their network fees — automatically, for as long as they keep using the app.
              </p>
            </div>
            <div className="ref-card">
              <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
                <span style={{ width: 44, height: 44, borderRadius: 13, background: 'var(--tint)', color: 'var(--accent)', display: 'grid', placeItems: 'center' }}>{Ic.gift}</span>
                <div><div style={{ fontWeight: 700, fontFamily: 'var(--font-display)' }}>Your referral link</div><div style={{ fontSize: 13, color: 'var(--muted)' }}>Lifetime 10% rewards</div></div>
              </div>
              <div className="ref-link">
                <span className="lk">gasless.io/r/alex</span>
                <button className="ref-copy" onClick={() => {setCopied(true);setTimeout(() => setCopied(false), 1400);}}>{copied ? 'Copied!' : 'Copy'}</button>
              </div>
              <div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 18, paddingTop: 16, borderTop: '1px solid var(--line)' }}>
                <div><div style={{ fontFamily: 'var(--font-display)', fontSize: 24, fontWeight: 800 }}>38</div><div style={{ fontSize: 12.5, color: 'var(--muted)' }}>Friends joined</div></div>
                <div style={{ textAlign: 'right' }}><div style={{ fontFamily: 'var(--font-display)', fontSize: 24, fontWeight: 800, color: 'var(--accent)' }}>146 USDT</div><div style={{ fontSize: 12.5, color: 'var(--muted)' }}>Earned so far</div></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

function FinalCTA() {
  return (
    <section className="final" id="download">
      <div className="wrap">
        <div className="reveal">
          <span className="section-tag">Get started</span>
          <h2 style={{ marginTop: 18 }}>Move USDT the easy way.</h2>
          <p>Download Gasless Wallet, sign in, and send your first USDT in under a minute — no seed phrase, no TRX, no stress.</p>
          <div className="cta-row">
            <AppStoreBadge />
          </div>
          <div style={{ marginTop: 20, fontSize: 13.5, color: 'var(--faint)' }}>iOS · Tron network · Non-custodial</div>
        </div>
      </div>
    </section>);

}

function Footer() {
  const cols = [
  ['Product', [['How it works', '#how'], ['Referral', '#referral']]],
  ['Company', [['About', '#'], ['Blog', '#'], ['Careers', '#'], ['Contact', 'mailto:info@gaslesswallet.io']]],
  ['Legal', [['Terms of Use', 'Terms of Use.html'], ['Privacy', 'Privacy Policy.html'], ['Disclosures', '#']]]];

  return (
    <footer className="footer">
      <div className="wrap">
        <div className="foot-grid">
          <div className="foot-col">
            <a className="brand" href="#top" aria-label="Gasless" style={{ marginBottom: 16 }}><img src="assets/gasless-logo-dark.svg" alt="Gasless" style={{ height: 40, width: 'auto', display: 'block' }} /></a>
            <p style={{ color: 'var(--muted)', fontSize: 15, maxWidth: '34ch' }}>The non-custodial Tron wallet that handles gas for you — so USDT just works.</p>
            <div className="foot-social">
              {SOCIALS.map((s) =>
              <a key={s.name} className="foot-social-link" href={s.url} target="_blank" rel="noopener noreferrer" aria-label={s.name} title={s.name}>
                  {Ic[s.icon]}
                </a>
              )}
            </div>
          </div>
          {cols.map(([h, links], i) =>
          <div className="foot-col" key={i}>
              <h5>{h}</h5>
              {links.map(([label, href], j) => <a key={j} href={href}>{label}</a>)}
            </div>
          )}
        </div>
        <div className="foot-bottom">
          <span>© 2026 Gasless Wallet. All rights reserved.</span>
          <span className="foot-note">Gasless Wallet is a self-custodial application. You are solely responsible for your funds. Crypto assets are volatile and not covered by deposit insurance.</span>
        </div>
      </div>
    </footer>);

}

Object.assign(window, { Nav, Hero, Stats, HowItWorks, Comparison, Referral, FinalCTA, Footer, AppStoreBadge });