// directionDv3.jsx — the honest cut. Real pill UI, real voice, no invented
// diff viewer. Reads like a personal note, because that's what vx is.
function DirectionDv3() {
  const P = VXP;
  const kicker = { fontFamily: P.mono, fontSize: 13, color: P.coral, letterSpacing: 0.3, marginBottom: 18 };
  const h2 = { fontFamily: P.display, fontWeight: 700, fontSize: 30, letterSpacing: -0.8, margin: '0 0 18px' };
  const body = { fontSize: 18, lineHeight: 1.72, color: P.mute, margin: '0 0 16px', maxWidth: 660 };
  return (
    <div style={{ width: '100%', background: P.ink, color: P.text, fontFamily: P.body }}>
      {/* minimal nav */}
      <nav style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '24px 72px', borderBottom: `1px solid ${P.line}` }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
          <img src="assets/vx-icon.png" alt="vx" width="34" height="34" style={{ display: 'block', borderRadius: 9, border: `1px solid rgba(255,255,255,0.08)` }} />
          <span style={{ fontFamily: P.display, fontWeight: 700, fontSize: 21, letterSpacing: -0.5 }}>vx</span>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 26, fontSize: 15, color: P.mute }}>
          <a className="vx-link" style={{ color: P.mute }} href="docs.html">{COPY.site.nav.docs}</a>
          <a className="vx-link" style={{ color: P.mute }} href="https://github.com/tonydelanuez/vx">{COPY.site.nav.github}</a>
          <a href="https://github.com/tonydelanuez/vx/releases" style={{ color: P.text, textDecoration: 'none', borderBottom: `2px solid ${P.coral}`, paddingBottom: 2 }}>{COPY.site.nav.download}</a>
        </div>
      </nav>

      {/* hero — lead with what it is, then the personal why */}
      <header style={{ padding: '84px 72px 0', maxWidth: 940 }}>
        <h1 style={{ fontFamily: P.display, fontWeight: 700, fontSize: 66, lineHeight: 1.0, letterSpacing: -2.6, margin: '0 0 22px' }}>
          {COPY.landing.h1}
        </h1>
        <div style={{ fontFamily: P.display, fontWeight: 600, fontSize: 26, color: P.text, letterSpacing: -0.6, marginBottom: 24 }}>
          {COPY.landing.tagline}
        </div>
        <p style={{ fontSize: 20, lineHeight: 1.65, color: P.mute, maxWidth: 680, margin: 0 }}>
          {COPY.landing.intro}
        </p>
        <div style={{ display: 'flex', gap: 14, alignItems: 'center', marginTop: 38 }}>
          <DownloadBtn big>{COPY.site.downloadBtn}</DownloadBtn>
          <GhostBtn big>{COPY.site.githubBtn}</GhostBtn>
        </div>
      </header>

      {/* the actual interface — the real pill */}
      <section style={{ padding: '86px 72px 0' }}>
        <div style={{ border: `1px solid ${P.line}`, borderRadius: 18, padding: '64px 40px 56px', background: P.ink900, display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
          <RealPillDemo P={P} />
          <p style={{ fontSize: 16.5, lineHeight: 1.7, color: P.mute, maxWidth: 560, textAlign: 'center', margin: '52px 0 0' }}>
            {COPY.landing.demoCaption}
          </p>
        </div>
      </section>

      {/* fast */}
      <section style={{ padding: '84px 72px 0', maxWidth: 820 }}>
        <h2 style={{ fontFamily: P.display, fontWeight: 700, fontSize: 46, letterSpacing: -1.6, lineHeight: 1.04, margin: '0 0 18px' }}>
          {COPY.landing.fastTitle}
        </h2>
        <p style={{ fontSize: 20, lineHeight: 1.6, color: P.mute, maxWidth: 640, margin: 0 }}>
          {COPY.landing.fastBody}
        </p>
      </section>

      {/* how it works — plain, no implementation jargon */}
      <section style={{ padding: '88px 72px 0', maxWidth: 760 }}>
        <div style={kicker}>{COPY.landing.howKicker}</div>
        <h2 style={h2}>{COPY.landing.howTitle}</h2>
        <p style={body}>
          {COPY.landing.howBody}
        </p>
      </section>

      {/* rules — accurate: trigger/replace pairs, per mode, synced via git */}
      <section style={{ padding: '64px 72px 0', maxWidth: 760 }}>
        <div style={kicker}>{COPY.landing.rulesKicker}</div>
        <h2 style={h2}>{COPY.landing.rulesTitle}</h2>
        <p style={body}>
          {COPY.landing.rulesBody1}
        </p>
        <p style={body}>
          {COPY.landing.rulesBody2}
        </p>
        {/* a small, real artifact in the actual format */}
        <div style={{ marginTop: 24, border: `1px solid ${P.line}`, borderRadius: 12, overflow: 'hidden', maxWidth: 560 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '10px 16px', borderBottom: `1px solid ${P.line}`, background: P.ink850 }}>
            <span style={{ width: 9, height: 9, borderRadius: 99, background: P.faint }} />
            <span style={{ fontFamily: P.mono, fontSize: 12.5, color: P.faint }}>{COPY.landing.rulesSampleFilename}</span>
          </div>
          <pre style={{ margin: 0, padding: '18px 18px', fontFamily: P.mono, fontSize: 13.5, lineHeight: 1.85, color: P.text, background: P.ink900 }}>{`rules:
  - trigger: `}<span style={{ color: P.coral }}>{'"open brace"'}</span>{`
    replace: `}<span style={{ color: P.green }}>{'"{"'}</span>{`
  - trigger: `}<span style={{ color: P.coral }}>{'"new line"'}</span>{`
    replace: `}<span style={{ color: P.green }}>{'"\\n"'}</span>{`
  - trigger: `}<span style={{ color: P.coral }}>{'"brb"'}</span>{`
    replace: `}<span style={{ color: P.green }}>{'"be right back"'}</span>{``}</pre>
        </div>
        <p style={{ ...body, fontSize: 15, color: P.faint, marginTop: 16 }}>
          {COPY.landing.rulesNote}
        </p>
      </section>

      {/* contexts — modes + auto app detection */}
      <section style={{ padding: '64px 72px 0', maxWidth: 760 }}>
        <div style={kicker}>{COPY.landing.contextsKicker}</div>
        <h2 style={h2}>{COPY.landing.contextsTitle}</h2>
        <p style={body}>
          {COPY.landing.contextsBody}
        </p>
      </section>

      {/* AI — optional, bring your own key, honest about the boundary */}
      <section style={{ padding: '64px 72px 0', maxWidth: 760 }}>
        <div style={kicker}>{COPY.landing.aiKicker}</div>
        <h2 style={h2}>{COPY.landing.aiTitle}</h2>
        <p style={body}>
          {COPY.landing.aiBody1}
        </p>
        <p style={body}>
          {COPY.landing.aiBody2}
        </p>
      </section>

      {/* close, in his words */}
      <section style={{ padding: '72px 72px 0', maxWidth: 760 }}>
        <div style={{ borderTop: `1px solid ${P.line}`, marginBottom: 40 }} />
        <p style={{ fontSize: 19, lineHeight: 1.7, color: P.mute, maxWidth: 640, margin: '0 0 30px' }}>
          {COPY.landing.close}
        </p>
        <div style={{ display: 'flex', gap: 14, alignItems: 'center' }}>
          <DownloadBtn big>{COPY.site.downloadBtn}</DownloadBtn>
          <GhostBtn big>{COPY.site.githubBtn}</GhostBtn>
        </div>
        <div style={{ marginTop: 36, fontFamily: P.mono, fontSize: 13.5, color: P.faint, maxWidth: 620, lineHeight: 1.65 }}>
          {COPY.landing.vibeCoded}
        </div>
      </section>

      <footer style={{ marginTop: 80, borderTop: `1px solid ${P.line}`, padding: '26px 72px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
          <img src="assets/vx-icon.png" alt="vx" width="26" height="26" style={{ display: 'block', borderRadius: 7, border: `1px solid rgba(255,255,255,0.08)` }} />
          <span style={{ fontSize: 14, color: P.faint }}>{COPY.site.footerBuilt}</span>
        </div>
        <div style={{ display: 'flex', gap: 22, fontSize: 14 }}>
          <a className="vx-link" style={{ color: P.mute }} href="https://github.com/tonydelanuez/vx">{COPY.site.footerGithub}</a>
          <a className="vx-link" style={{ color: P.mute }} href="https://ko-fi.com/tdoot">{COPY.site.footerDonate}</a>
          <a className="vx-link" style={{ color: P.mute }} href="https://x.com/tdoot_">{COPY.site.footerTwitter}</a>
        </div>
      </footer>
    </div>
  );
}

// Faithful recreation of the real vx HUD: gray capsule, X, green level
// meter, red stop, and the "Recording" → "Transcribed" label underneath.
function RealPillDemo({ P }) {
  const [phase, setPhase] = React.useState('rec'); // rec | done
  const [lvl, setLvl] = React.useState(5);
  React.useEffect(() => {
    let t;
    if (phase === 'rec') t = setTimeout(() => setPhase('done'), 2600);
    else t = setTimeout(() => setPhase('rec'), 1900);
    return () => clearTimeout(t);
  }, [phase]);
  React.useEffect(() => {
    if (phase !== 'rec') return;
    const id = setInterval(() => setLvl(3 + Math.floor(Math.random() * 6)), 130);
    return () => clearInterval(id);
  }, [phase]);

  const SEGS = 10;
  const lit = phase === 'done' ? SEGS : lvl;
  const seg = (i) => {
    if (i >= lit) return 'rgba(255,255,255,0.15)';      // empty = dark slot
    if (phase === 'done') return '#54dd5a';
    if (i === lit - 1) return '#c2e64d';                // leading edge = lime/amber
    return '#54dd5a';
  };

  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 16 }}>
      {/* capsule — dark */}
      <div style={{
        display: 'inline-flex', alignItems: 'center', gap: 14,
        padding: '11px 13px', borderRadius: 999,
        background: 'linear-gradient(180deg, #313137 0%, #27272b 100%)',
        border: '1px solid rgba(255,255,255,0.08)',
        boxShadow: '0 16px 38px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.05)',
      }}>
        {/* X cancel */}
        <div style={{ width: 34, height: 34, borderRadius: 999, background: 'rgba(255,255,255,0.12)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
          <svg width="13" height="13" viewBox="0 0 13 13" stroke="#eaeaec" strokeWidth="1.8" strokeLinecap="round"><path d="M2 2l9 9M11 2l-9 9" /></svg>
        </div>
        {/* level meter */}
        <div style={{ display: 'flex', alignItems: 'center', gap: 4, padding: '0 4px' }}>
          {Array.from({ length: SEGS }).map((_, i) => (
            <div key={i} style={{ width: 15, height: 19, borderRadius: 4, background: seg(i), transition: 'background .09s linear' }} />
          ))}
        </div>
        {/* stop */}
        <div style={{ width: 34, height: 34, borderRadius: 999, background: '#ff5b52', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
          <div style={{ width: 12, height: 12, borderRadius: 3, background: '#fff' }} />
        </div>
      </div>
      {/* status label */}
      <div style={{ background: '#26262a', color: '#dcdcdf', border: `1px solid rgba(255,255,255,0.08)`, fontFamily: P.body, fontSize: 13, padding: '4px 14px', borderRadius: 999, letterSpacing: 0.2, transition: 'all .2s' }}>
        {phase === 'done' ? 'Transcribed' : 'Recording'}
      </div>
    </div>
  );
}

window.DirectionDv3 = DirectionDv3;
