// Marketing site — content sections below the hero.

// ===================================================================
// PRODUCT FEATURE STRIP — three big cards explaining the loop
// ===================================================================
function FeatureStrip() {
  const features = [
    {
      icon: 'lobby',
      tone: '#a378ff',
      eyebrow: '01 · Lobby',
      title: 'Set the stakes with friends',
      body: 'Pick the apps you want to lock out. Set a duration. Invite up to 8 friends. Everyone stakes ELO — winner takes the pot.',
    },
    {
      icon: 'block',
      tone: '#ffbe64',
      eyebrow: '02 · Lock in',
      title: 'The vault opens when time runs out',
      body: 'Once locked, blocked apps just vanish. No bypass, no five-minute extension. If you crack — even for a single peek — you\'re out.',
    },
    {
      icon: 'climb',
      tone: '#5ae6c8',
      eyebrow: '03 · Climb',
      title: 'Real ELO, real consequences',
      body: 'Win and you take everyone\'s stake, climb the global ladder, and unlock new avatars. Lose and the whole group sees the screenshot.',
    },
  ];
  return (
    <section style={{ padding: '120px 32px 80px', position: 'relative' }}>
      <div style={{ maxWidth: 1280, margin: '0 auto' }}>
        <SectionHeader
          eyebrow="The loop"
          title={<>It's a <GradWord>multiplayer game</GradWord> with your screen-time as the chips.</>}
          sub="Vault doesn't try to nag you about your habits. It bets your friends that you can resist your phone — and lets the leaderboard do the talking."
          maxWidth={840}
        />
        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: 18,
        }}>
          {features.map((f, i) => (
            <FeatureCard key={i} {...f}/>
          ))}
        </div>
      </div>
    </section>
  );
}

function FeatureCard({ icon, tone, eyebrow, title, body }) {
  return (
    <div style={{
      position: 'relative',
      padding: 28,
      borderRadius: 24,
      background: 'linear-gradient(180deg, rgba(30,20,60,0.55), rgba(15,10,30,0.4))',
      border: '1px solid rgba(255,255,255,0.08)',
      overflow: 'hidden',
      minHeight: 320,
      display: 'flex', flexDirection: 'column',
    }}>
      <div style={{
        position: 'absolute', top: -60, right: -60, width: 200, height: 200, borderRadius: '50%',
        background: `radial-gradient(circle, ${tone}30 0%, transparent 70%)`,
        pointerEvents: 'none',
      }}/>
      <div style={{ position: 'relative', display: 'flex', alignItems: 'center', gap: 12 }}>
        <div style={{
          width: 44, height: 44, borderRadius: 12,
          background: `linear-gradient(135deg, ${tone}40, ${tone}10)`,
          border: `1px solid ${tone}50`,
          display: 'flex', alignItems: 'center', justifyContent: 'center',
        }}>
          <FeatureIcon kind={icon} color={tone}/>
        </div>
        <div style={{
          fontSize: 11, letterSpacing: '0.18em', textTransform: 'uppercase',
          fontWeight: 700, color: tone, whiteSpace: 'nowrap',
        }}>{eyebrow}</div>
      </div>
      <h3 style={{
        marginTop: 22, fontSize: 24, fontWeight: 600,
        letterSpacing: '-0.02em', lineHeight: 1.15, color: '#fff',
      }}>{title}</h3>
      <p style={{
        marginTop: 12, fontSize: 14.5, lineHeight: 1.55, color: '#9089b3', flex: 1,
      }}>{body}</p>
    </div>
  );
}

function FeatureIcon({ kind, color }) {
  if (kind === 'lobby') return (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none">
      <circle cx="9" cy="9" r="3.2" stroke={color} strokeWidth="1.6"/>
      <circle cx="16" cy="11" r="2.5" stroke={color} strokeWidth="1.6"/>
      <path d="M3 19c0-2.5 2.5-4.5 6-4.5s6 2 6 4.5" stroke={color} strokeWidth="1.6" strokeLinecap="round"/>
      <path d="M14 18c0-1.8 1.5-3 3.5-3s3.5 1.2 3.5 3" stroke={color} strokeWidth="1.6" strokeLinecap="round"/>
    </svg>
  );
  if (kind === 'block') return (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none">
      <rect x="6" y="10" width="12" height="9" rx="1.5" stroke={color} strokeWidth="1.6"/>
      <path d="M8 10V7a4 4 0 0 1 8 0v3" stroke={color} strokeWidth="1.6"/>
      <circle cx="12" cy="14.5" r="1.4" fill={color}/>
    </svg>
  );
  return (
    <svg width="22" height="22" viewBox="0 0 24 24" fill="none">
      <path d="M4 18h4v-5H4v5zm6 0h4V8h-4v10zm6 0h4V4h-4v14z" stroke={color} strokeWidth="1.6" strokeLinejoin="round"/>
    </svg>
  );
}

// ===================================================================
// RANK LADDER
// ===================================================================
function RankLadder() {
  const ranks = [
    { id: 'addicted',    glyph: 'phone',   range: '0–1199',  desc: 'Where everyone starts. The phone owns you.' },
    { id: 'scroller',    glyph: 'feed',    range: '1200–1399', desc: 'You\'ve survived a few rounds. Still fragile.' },
    { id: 'seeker',      glyph: 'compass', range: '1400–1699', desc: 'You can do four hours dark. Most can\'t.' },
    { id: 'lucid',       glyph: 'eye',     range: '1700–1999', desc: 'Top 8% globally. People notice when you don\'t reply.' },
    { id: 'clairvoyant', glyph: 'crystal', range: '2000+',     desc: 'Top 0.5%. The phone exists for them, not the other way.' },
  ];
  return (
    <section id="ranks" style={{ padding: '120px 32px 80px', position: 'relative' }}>
      <div style={{
        position: 'absolute', inset: 0, pointerEvents: 'none',
        background: 'radial-gradient(900px 500px at 50% 50%, rgba(122,68,238,0.1), transparent 60%)',
      }}/>
      <div style={{ position: 'relative', maxWidth: 1280, margin: '0 auto' }}>
        <SectionHeader
          eyebrow="The ladder"
          title={<>Five tiers. <GradWord from="#ff8a9c" via="#a378ff" to="#5ae6c8">One way up.</GradWord></>}
          sub="No participation badges. Climb by winning challenges, holding streaks, and beating people ranked higher than you. Each tier unlocks new avatars, lobby caps, and bragging rights."
          maxWidth={780}
        />

        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: 14,
          marginTop: 40,
        }} className="rank-grid">
          {ranks.map((r, i) => <RankCard key={r.id} {...r} index={i}/>)}
        </div>

        <div style={{
          marginTop: 56, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 12,
          padding: '14px 22px',
          borderRadius: 999,
          background: 'rgba(255,255,255,0.03)',
          border: '1px solid rgba(255,255,255,0.08)',
          maxWidth: 'fit-content', margin: '56px auto 0',
        }}>
          <span style={{ fontSize: 13, color: '#9089b3' }}>And 15 collectible avatars across the tiers.</span>
          <a href="#" style={{ fontSize: 13, color: '#c8a6ff', fontWeight: 600, textDecoration: 'none' }}>
            See the gallery →
          </a>
        </div>
      </div>
    </section>
  );
}

function RankCard({ id, glyph, range, desc, index }) {
  const p = RANK_PALETTES[id];
  return (
    <div style={{
      position: 'relative',
      padding: '28px 18px 22px',
      borderRadius: 20,
      background: `linear-gradient(180deg, ${p.mid}80 0%, rgba(15,10,30,0.6) 100%)`,
      border: `1px solid ${p.ring}`,
      display: 'flex', flexDirection: 'column', alignItems: 'center', textAlign: 'center',
      transition: 'transform 0.3s, box-shadow 0.3s',
      cursor: 'default',
    }}
    onMouseEnter={e=>{e.currentTarget.style.transform='translateY(-6px)';e.currentTarget.style.boxShadow=`0 30px 60px -20px ${p.glow}`;}}
    onMouseLeave={e=>{e.currentTarget.style.transform='translateY(0)';e.currentTarget.style.boxShadow='none';}}
    >
      <div style={{
        position: 'absolute', top: 12, left: 14,
        fontSize: 10, fontWeight: 700, letterSpacing: '0.16em',
        color: p.hi, opacity: 0.7,
      }}>0{index + 1}</div>

      <div style={{
        marginTop: 14, marginBottom: 18,
        filter: `drop-shadow(0 14px 28px ${p.glow})`,
      }}>
        <Avatar avatar={{ id, glyph }} tone={id} size={84}/>
      </div>

      <div style={{
        fontSize: 18, fontWeight: 700, letterSpacing: '-0.01em', color: '#fff',
      }}>{p.name}</div>
      <div style={{
        marginTop: 4, fontSize: 11, fontWeight: 600,
        color: p.hi, letterSpacing: '0.1em',
        fontVariantNumeric: 'tabular-nums', whiteSpace: 'nowrap',
      }}>{range} ELO</div>
      <div style={{
        marginTop: 14, fontSize: 12.5, lineHeight: 1.5, color: '#aaa3cc',
        textWrap: 'balance',
      }}>{desc}</div>
    </div>
  );
}

window.FeatureStrip = FeatureStrip;
window.RankLadder = RankLadder;
