// Shared lo-fi sketch components for the Pulse LANDING PAGE wireframes.
// Same hand-drawn vocabulary as wireframe-components.jsx.
// Exports to window: LPNav, EmailCapture, SectionHead, LogoRow, StatBand,
// StepsRow, FeatureCard, FeatureGrid, FaqList, CTABand, LPFooter,
// ImgPlaceholder, BrowserFrame, Tag, CoordinatorMock, OrbitMock, StackMock.

const INK = '#2b2a28';
const MUT = '#6f6a60';
const DIM = '#98917f';
const PAPER = '#faf8f3';
const PAPER2 = '#ffffff';

// ---------- waitlist email capture ----------
function EmailCapture({ accent, size = 'lg', note = 'No credit card. Spots are limited.' }) {
  const h = size === 'lg' ? 52 : 44;
  const fs = size === 'lg' ? 17 : 15;
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 9 }}>
      <div style={{ display: 'flex', gap: 10, alignItems: 'stretch' }}>
        <div className="wf-box r2" style={{
          flex: 1, minWidth: 0, height: h, display: 'flex', alignItems: 'center',
          padding: '0 16px', background: PAPER2,
        }}>
          <span className="wf-mono" style={{ fontSize: fs, color: DIM }}>you@team.dev</span>
          <span className="wf-mono" style={{ marginLeft: 2, color: accent, fontWeight: 700 }}>|</span>
        </div>
        <button className="wf-box r1" style={{
          flex: 'none', height: h, padding: '0 24px', cursor: 'pointer',
          background: accent, color: '#fff', border: `2px solid ${accent}`,
          fontFamily: "'Patrick Hand', cursive", fontWeight: 700, fontSize: fs, whiteSpace: 'nowrap',
        }}>Join the waitlist →</button>
      </div>
      {note && <div className="wf-annot" style={{ fontSize: 17, color: DIM }}>{note}</div>}
    </div>
  );
}

// ---------- nav ----------
function LPNav({ accent, links = ['How it works', 'The views', 'Pricing', 'FAQ'] }) {
  return (
    <div style={{
      display: 'flex', alignItems: 'center', gap: 28, padding: '22px 64px',
      borderBottom: `2px solid ${INK}`, background: PAPER2,
    }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 11, fontWeight: 700, fontSize: 24, letterSpacing: '0.06em' }}>
        <span style={{
          width: 20, height: 20, borderRadius: '50%', border: `2.5px dashed ${accent}`,
          position: 'relative', flex: 'none', display: 'inline-block',
        }}>
          <span style={{ position: 'absolute', inset: 5, borderRadius: '50%', background: accent }}></span>
        </span>
        PULSE
      </div>
      <div style={{ display: 'flex', gap: 22, marginLeft: 26 }}>
        {links.map((l) => (
          <span key={l} style={{ fontSize: 17, color: MUT }}>{l}</span>
        ))}
      </div>
      <div style={{ marginLeft: 'auto', display: 'flex', gap: 12, alignItems: 'center' }}>
        <span style={{ fontSize: 17, color: MUT }}>Sign in</span>
        <button className="wf-box r1 wf-btn" style={{ width: 'auto', borderColor: accent, color: '#fff', background: accent }}>Join waitlist</button>
      </div>
    </div>
  );
}

// ---------- section eyebrow + heading ----------
function SectionHead({ eyebrow, title, sub, accent, align = 'left', maxW = 760 }) {
  return (
    <div style={{ textAlign: align, maxWidth: maxW, margin: align === 'center' ? '0 auto' : 0 }}>
      {eyebrow && (
        <div className="wf-mono" style={{ fontSize: 14, letterSpacing: '0.14em', textTransform: 'uppercase', color: accent, marginBottom: 12 }}>
          {eyebrow}
        </div>
      )}
      <div style={{ fontSize: 40, fontWeight: 700, lineHeight: 1.06, color: INK }}>{title}</div>
      {sub && <div style={{ fontSize: 19, color: MUT, marginTop: 14, lineHeight: 1.35 }}>{sub}</div>}
    </div>
  );
}

// ---------- striped image placeholder ----------
function ImgPlaceholder({ label, h = 200, w = '100%', accent, radius = 'r1' }) {
  return (
    <div className={`wf-box ${radius}`} style={{
      width: w, height: h, position: 'relative', overflow: 'hidden',
      background: `repeating-linear-gradient(45deg, #f1ece1, #f1ece1 9px, ${PAPER2} 9px, ${PAPER2} 18px)`,
      display: 'flex', alignItems: 'center', justifyContent: 'center',
    }}>
      <span className="wf-mono" style={{
        fontSize: 13, color: MUT, background: PAPER2, padding: '4px 12px',
        border: `1.5px solid ${INK}`, borderRadius: 6,
      }}>{label}</span>
    </div>
  );
}

// ---------- sketch browser chrome ----------
function BrowserFrame({ accent, url = 'pulse.dev/app', children, h }) {
  return (
    <div className="wf-box r1" style={{ overflow: 'hidden', background: PAPER2, height: h }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '9px 14px', borderBottom: `2px solid ${INK}`, background: '#efe9dd' }}>
        <span style={{ display: 'flex', gap: 6 }}>
          {[0, 1, 2].map((i) => <span key={i} style={{ width: 11, height: 11, borderRadius: '50%', border: `1.5px solid ${INK}`, display: 'block' }}></span>)}
        </span>
        <span className="wf-mono" style={{ flex: 1, textAlign: 'center', fontSize: 13, color: MUT }}>{url}</span>
        <span style={{ width: 40 }}></span>
      </div>
      <div>{children}</div>
    </div>
  );
}

// ---------- logo row (social proof) ----------
function LogoRow({ count = 6, label }) {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 18 }}>
      {label && <div className="wf-annot" style={{ fontSize: 20, color: DIM }}>{label}</div>}
      <div style={{ display: 'flex', gap: 18, flexWrap: 'wrap', justifyContent: 'center' }}>
        {Array.from({ length: count }).map((_, i) => (
          <div key={i} className="wf-box r3" style={{
            width: 132, height: 46, display: 'flex', alignItems: 'center', justifyContent: 'center',
            background: PAPER2, opacity: 0.92,
          }}>
            <span className="wf-mono" style={{ fontSize: 12, color: DIM }}>logo</span>
          </div>
        ))}
      </div>
    </div>
  );
}

// ---------- big stats band ----------
function StatBand({ accent, stats }) {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: `repeat(${stats.length}, 1fr)`, gap: 28 }}>
      {stats.map((s, i) => (
        <div key={i} style={{ display: 'flex', flexDirection: 'column', gap: 6, textAlign: 'center' }}>
          <div style={{ fontSize: 56, fontWeight: 700, color: accent, lineHeight: 1 }}>{s.n}</div>
          <div style={{ fontSize: 17, color: MUT }}>{s.l}</div>
        </div>
      ))}
    </div>
  );
}

// ---------- how it works steps ----------
function StepsRow({ accent, steps }) {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: `repeat(${steps.length}, 1fr)`, gap: 24 }}>
      {steps.map((s, i) => (
        <div key={i} className={`wf-box ${i % 2 ? 'r2' : 'r1'}`} style={{ padding: '26px 24px', background: PAPER2, display: 'flex', flexDirection: 'column', gap: 12 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
            <span style={{
              width: 38, height: 38, borderRadius: '50%', border: `2.5px solid ${accent}`, color: accent,
              display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 20, flex: 'none',
            }}>{i + 1}</span>
            <div style={{ fontSize: 22, fontWeight: 700, color: INK }}>{s.title}</div>
          </div>
          <div style={{ fontSize: 16.5, color: MUT, lineHeight: 1.4 }}>{s.body}</div>
          <ImgPlaceholder label={s.shot} h={120} accent={accent} radius={i % 2 ? 'r1' : 'r3'} />
        </div>
      ))}
    </div>
  );
}

// ---------- feature grid ----------
function FeatureCard({ f, accent, idx }) {
  return (
    <div className={`wf-box ${idx % 3 === 1 ? 'r2' : idx % 3 === 2 ? 'r3' : 'r1'}`} style={{ padding: '22px 22px', background: PAPER2, display: 'flex', flexDirection: 'column', gap: 10 }}>
      <div className="wf-box r3" style={{ width: 44, height: 44, display: 'flex', alignItems: 'center', justifyContent: 'center', borderColor: accent }}>
        <span style={{ width: 16, height: 16, borderRadius: 4, background: accent, display: 'block' }}></span>
      </div>
      <div style={{ fontSize: 20, fontWeight: 700, color: INK }}>{f.title}</div>
      <div style={{ fontSize: 16, color: MUT, lineHeight: 1.4 }}>{f.body}</div>
    </div>
  );
}
function FeatureGrid({ accent, features, cols = 3 }) {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: `repeat(${cols}, 1fr)`, gap: 20 }}>
      {features.map((f, i) => <FeatureCard key={i} f={f} accent={accent} idx={i} />)}
    </div>
  );
}

// ---------- FAQ ----------
function FaqList({ accent, items }) {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
      {items.map((it, i) => (
        <div key={i} className={`wf-box ${i % 2 ? 'r2' : 'r1'}`} style={{ padding: '18px 22px', background: PAPER2, display: 'flex', flexDirection: 'column', gap: i === 0 ? 10 : 0 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
            <div style={{ fontSize: 20, fontWeight: 700, color: INK, flex: 1 }}>{it.q}</div>
            <span style={{ fontSize: 26, color: accent, lineHeight: 1 }}>{i === 0 ? '–' : '+'}</span>
          </div>
          {i === 0 && <div style={{ fontSize: 16.5, color: MUT, lineHeight: 1.45 }}>{it.a}</div>}
        </div>
      ))}
    </div>
  );
}

// ---------- final CTA band ----------
function CTABand({ accent, title, sub }) {
  return (
    <div className="wf-box r1" style={{
      padding: '52px 56px', background: INK, color: PAPER,
      display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 22, textAlign: 'center',
      borderColor: INK,
    }}>
      <div style={{ fontSize: 44, fontWeight: 700, lineHeight: 1.05, maxWidth: 720 }}>{title}</div>
      {sub && <div style={{ fontSize: 19, opacity: 0.78, maxWidth: 560 }}>{sub}</div>}
      <div style={{ width: 'min(560px, 100%)', marginTop: 6 }}>
        <div style={{ display: 'flex', gap: 10 }}>
          <div className="wf-box r2" style={{ flex: 1, height: 52, display: 'flex', alignItems: 'center', padding: '0 16px', background: PAPER2 }}>
            <span className="wf-mono" style={{ fontSize: 16, color: DIM }}>you@team.dev</span>
          </div>
          <button className="wf-box r1" style={{
            flex: 'none', height: 52, padding: '0 26px', cursor: 'pointer', background: accent, color: '#fff',
            border: `2px solid ${accent}`, fontFamily: "'Patrick Hand', cursive", fontWeight: 700, fontSize: 17, whiteSpace: 'nowrap',
          }}>Join the waitlist →</button>
        </div>
      </div>
    </div>
  );
}

// ---------- footer ----------
function LPFooter({ accent }) {
  const cols = [
    { h: 'Product', items: ['How it works', 'Demo', 'Pricing', 'Changelog'] },
    { h: 'Company', items: ['About', 'Careers', 'Blog'] },
    { h: 'Resources', items: ['Docs', 'Status', 'Contact'] },
  ];
  return (
    <div style={{ padding: '48px 64px 40px', borderTop: `2px solid ${INK}`, background: PAPER2 }}>
      <div style={{ display: 'flex', gap: 48 }}>
        <div style={{ flex: 1, maxWidth: 320 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 11, fontWeight: 700, fontSize: 22, letterSpacing: '0.06em' }}>
            <span style={{ width: 18, height: 18, borderRadius: '50%', border: `2.5px dashed ${accent}`, position: 'relative', display: 'inline-block' }}>
              <span style={{ position: 'absolute', inset: 4, borderRadius: '50%', background: accent }}></span>
            </span>
            PULSE
          </div>
          <div style={{ fontSize: 16, color: MUT, marginTop: 12, lineHeight: 1.4 }}>One engineer. Many tasks. You stay in the loop by voice.</div>
        </div>
        {cols.map((c) => (
          <div key={c.h} style={{ display: 'flex', flexDirection: 'column', gap: 9 }}>
            <div className="wf-mono" style={{ fontSize: 13, letterSpacing: '0.1em', textTransform: 'uppercase', color: DIM }}>{c.h}</div>
            {c.items.map((it) => <span key={it} style={{ fontSize: 16, color: MUT }}>{it}</span>)}
          </div>
        ))}
      </div>
      <div style={{ display: 'flex', alignItems: 'center', marginTop: 36, paddingTop: 20, borderTop: `1.5px dashed ${DIM}` }}>
        <span className="wf-mono" style={{ fontSize: 13, color: DIM }}>© 2026 Pulse Labs · backed by Spring VC</span>
        <span className="wf-mono" style={{ marginLeft: 'auto', fontSize: 13, color: DIM }}>Privacy · Terms</span>
      </div>
    </div>
  );
}

Object.assign(window, {
  LPNav, EmailCapture, SectionHead, LogoRow, StatBand, StepsRow,
  FeatureCard, FeatureGrid, FaqList, CTABand, LPFooter, ImgPlaceholder, BrowserFrame,
  LP_INK: INK, LP_MUT: MUT, LP_DIM: DIM, LP_PAPER: PAPER, LP_PAPER2: PAPER2,
});
