// cache-bust: 1779468723-8d9735
// =========================================================
// landing-2.jsx — remaining landing sections
// Lesson preview / projects / comparison / build log /
// pricing / FAQ / email capture / footer
// =========================================================

const D2 = window.BL_DATA;
const { useState: useState2 } = React;

// ────────────────────────────────────────────────────────────────
// Lesson preview — "what a session looks like"
// Mock of the interactive guided session (no video). Beat-by-beat
// narration, pinned prompt, inline Claude Q&A.
// ────────────────────────────────────────────────────────────────

function LessonPreview() {
  return (
    <section style={{ padding: '96px 56px' }}>
      <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', marginBottom: 48 }}>
        <div>
          <BLEyebrow>How a lesson plays</BLEyebrow>
          <h2 className="bl-display" style={{ fontSize: 60, marginTop: 14, lineHeight: 1 }}>
            Step through the build.<br/>
            <span className="bl-italic" style={{ color: 'var(--accent)' }}>Ask Claude</span> anything.
          </h2>
          <p style={{ marginTop: 14, fontSize: 17, color: 'var(--ink-dim)', maxWidth: 560 }}>
            Each episode is a guided session — not a video. Read the beat, copy the pinned prompt,
            run the patch. Stuck? Ask Claude inline. It already has the lesson's context loaded.
          </p>
        </div>
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: '1.6fr 1fr', gap: 28 }}>
        <SessionMock />
        <SessionSidecar />
      </div>
    </section>
  );
}

function SessionMock() {
  return (
    <div style={{ position: 'relative' }}>
      <BLCorners />
      <div onClick={() => { window.location.hash = '#ep/1.0'; }} className="bl-card" style={{
        overflow: 'hidden',
        boxShadow: '0 30px 80px -30px rgba(26,22,18,.2)',
        cursor: 'pointer',
        transition: 'transform .2s, box-shadow .2s',
      }}>
        {/* Header — episode + current beat title + nav */}
        <div style={{
          padding: '14px 20px', borderBottom: '1px solid var(--line-paper)',
          display: 'flex', alignItems: 'center', gap: 14, background: 'var(--paper)',
        }}>
          <span className="bl-mono" style={{ fontSize: 11, color: 'var(--ink-mute)', letterSpacing: '.06em' }}>
            EPISODE 1.0 · BEAT 03 / 08
          </span>
          <span className="bl-serif" style={{ fontSize: 15, color: 'var(--ink)', marginLeft: 4 }}>
            Scaffold the design canvas
          </span>
          <span style={{ flex: 1 }}></span>
          <button style={{ padding: '5px 11px', border: '1px solid var(--line-paper)', borderRadius: 5, fontFamily: 'var(--mono)', fontSize: 10.5, color: 'var(--ink-mute)', background: 'transparent' }}>← prev</button>
          <button style={{ padding: '5px 11px', border: '1px solid var(--accent)', borderRadius: 5, fontFamily: 'var(--mono)', fontSize: 10.5, color: '#fff', background: 'var(--accent)' }}>next →</button>
        </div>

        {/* Beat progress bar */}
        <div style={{ padding: '10px 20px', borderBottom: '1px solid var(--line-paper)', background: 'var(--paper-2)', display: 'flex', alignItems: 'center', gap: 7 }}>
          {[0,1,2,3,4,5,6,7].map((i) => (
            <span key={i} style={{
              height: 6, borderRadius: 3,
              flex: i === 2 ? '0 0 36px' : '1 1 0',
              background: i < 2 ? 'var(--sage)' : i === 2 ? 'var(--accent)' : 'var(--paper-3)',
              transition: 'all .15s',
            }}></span>
          ))}
        </div>

        {/* Two-column body — narration + pinned prompt */}
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr' }}>
          {/* narration */}
          <div style={{ padding: '22px 24px', borderRight: '1px solid var(--line-paper)', minHeight: 240 }}>
            <div className="bl-mono" style={{ fontSize: 10, color: 'var(--ink-mute)', letterSpacing: '.08em', marginBottom: 12 }}>
              NARRATION
            </div>
            <p style={{ fontSize: 14.5, lineHeight: 1.6, color: 'var(--ink-2)', margin: 0 }}>
              Open Claude Desktop and start a fresh project. Attach two references —
              the live <span className="bl-mono" style={{ fontSize: 13, color: 'var(--accent-deep)' }}>reloadin5.com</span> home page
              and a Stripe pricing page you like.
            </p>
            <p style={{ fontSize: 14.5, lineHeight: 1.6, color: 'var(--ink-2)', marginTop: 12, marginBottom: 0 }}>
              Now paste the prompt on the right. The designer scaffolds the whole landing page in HTML —
              hero, modules, pricing — on one canvas. You're not coding yet. You're locking the shape.
            </p>
            <div style={{ marginTop: 16, display: 'inline-flex', alignItems: 'center', gap: 6, padding: '4px 9px', background: 'var(--accent-tint)', borderRadius: 4 }}>
              <span style={{ width: 5, height: 5, borderRadius: '50%', background: 'var(--accent)' }}></span>
              <span className="bl-mono" style={{ fontSize: 10, color: 'var(--accent-deep)', letterSpacing: '.04em' }}>2 min · read at your pace</span>
            </div>
          </div>

          {/* pinned prompt */}
          <div style={{ padding: '22px 24px', background: 'var(--paper-2)', minHeight: 240 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }}>
              <div className="bl-mono" style={{ fontSize: 10, color: 'var(--ink-mute)', letterSpacing: '.08em' }}>
                PINNED PROMPT
              </div>
              <span style={{ flex: 1 }}></span>
              <button onClick={(e) => { e.stopPropagation(); const txt = "You are a premium product designer\nworking on the Build Lab landing page.\nTone: engineer-built, not marketing.\nWarm coral on cream paper.\n\nUse design_canvas. Lay out:\n  - desktop landing (1440)\n  - mobile landing (390)\n\nExpose tweaks for:\n  accent color, density, lock-state."; if (navigator.clipboard) navigator.clipboard.writeText(txt).then(() => { e.target.textContent = 'copied!'; setTimeout(() => { e.target.textContent = 'copy'; }, 1200); }); }} style={{ padding: '3px 9px', border: '1px solid var(--line-paper)', borderRadius: 4, fontFamily: 'var(--mono)', fontSize: 10, color: 'var(--ink-mute)', background: 'var(--paper)', cursor: 'pointer' }}>copy</button>
            </div>
            <pre className="bl-mono" style={{
              fontSize: 11.5, lineHeight: 1.55, color: 'var(--ink)',
              whiteSpace: 'pre-wrap', margin: 0,
            }}>{`You are a premium product designer
working on the Build Lab landing page.
Tone: engineer-built, not marketing.
Warm coral on cream paper.

Use design_canvas. Lay out:
  - desktop landing (1440)
  - mobile landing (390)

Expose tweaks for:
  accent color, density, lock-state.`}</pre>
          </div>
        </div>

        {/* Inline Claude Q&A */}
        <div style={{ borderTop: '1px solid var(--line-paper)', padding: '18px 24px', background: 'var(--paper)' }}>
          <div className="bl-mono" style={{ fontSize: 10, color: 'var(--ink-mute)', letterSpacing: '.08em', marginBottom: 12 }}>
            ASK CLAUDE · INLINE
          </div>
          <div style={{ fontSize: 13.5, lineHeight: 1.6 }}>
            <div>
              <span className="bl-mono" style={{ fontSize: 11, color: 'var(--accent-deep)' }}>{'> '}you</span>{' '}
              <span style={{ color: 'var(--ink-2)' }}>where do I find the Tweaks panel after the canvas loads?</span>
            </div>
            <div style={{ marginTop: 6 }}>
              <span className="bl-mono" style={{ fontSize: 11, color: 'var(--sage)' }}>{'> '}claude</span>{' '}
              <span style={{ color: 'var(--ink-2)' }}>Top-right of the canvas — slider icon. Tweaks are scoped to whichever artboard is selected, so click the desktop frame first.</span>
            </div>
          </div>
          <div style={{
            marginTop: 14, display: 'flex', alignItems: 'center', gap: 8,
            padding: '9px 13px', border: '1px solid var(--line-paper)', borderRadius: 6, background: 'var(--paper-2)',
          }}>
            <span className="bl-mono" style={{ fontSize: 11, color: 'var(--ink-mute)' }}>{'>'}</span>
            <span className="bl-mono" style={{ fontSize: 11.5, color: 'var(--ink-mute)', flex: 1 }}>ask a follow-up about this beat…</span>
            <span className="bl-mono" style={{ fontSize: 9.5, color: 'var(--ink-mute)', padding: '2px 6px', border: '1px solid var(--line-paper)', borderRadius: 3 }}>⏎</span>
          </div>
        </div>
      </div>
      <div className="bl-marker" style={{ bottom: -22, left: 4 }}>
        fig 03 · a beat in motion. read it. copy the prompt. ask anything that snags.
      </div>
    </div>
  );
}

function SessionSidecar() {
  const beats = [
    { n: '01', name: 'Set up a fresh Claude project',         done: true,  active: false },
    { n: '02', name: 'Attach reference screenshots',          done: true,  active: false },
    { n: '03', name: 'Scaffold the design canvas',            done: false, active: true  },
    { n: '04', name: 'Iterate live with Tweaks',              done: false, active: false },
    { n: '05', name: 'Add mobile + TikTok artboards',         done: false, active: false },
    { n: '06', name: 'Comment-driven single-element fix',     done: false, active: false },
    { n: '07', name: 'Export HTML as your blueprint',         done: false, active: false },
    { n: '08', name: 'Translate to Vite for the real build',  done: false, active: false },
  ];
  return (
    <div className="bl-card" style={{ overflow: 'hidden' }}>
      <div style={{ padding: '18px 20px 16px', borderBottom: '1px solid var(--line-paper)' }}>
        <div className="bl-mono" style={{ fontSize: 10, color: 'var(--ink-mute)', letterSpacing: '.08em' }}>
          EPISODE 1.0 · BEATS
        </div>
        <div className="bl-serif" style={{ fontSize: 21, marginTop: 6, lineHeight: 1.2 }}>
          Design the whole site in Claude — before you write code
        </div>
        <div className="bl-mono" style={{ fontSize: 10.5, color: 'var(--ink-mute)', marginTop: 10, letterSpacing: '.04em' }}>
          8 BEATS · ~12 MIN · INTERACTIVE
        </div>
      </div>

      <div>
        {beats.map((b, i) => (
          <div key={i} style={{
            display: 'grid', gridTemplateColumns: '26px 1fr',
            alignItems: 'center', gap: 10,
            padding: '10px 18px',
            borderLeft: b.active ? '3px solid var(--accent)' : '3px solid transparent',
            background: b.active ? 'var(--accent-tint)' : 'transparent',
          }}>
            <span style={{
              width: 18, height: 18, borderRadius: '50%',
              background: b.done ? 'var(--sage)' : b.active ? 'var(--accent)' : 'var(--paper-3)',
              color: '#fff', fontSize: 9, display: 'flex', alignItems: 'center', justifyContent: 'center',
              fontFamily: 'var(--mono)',
            }}>{b.done ? '✓' : b.n}</span>
            <span style={{ fontSize: 13, color: b.active ? 'var(--ink)' : 'var(--ink-2)', fontWeight: b.active ? 500 : 400 }}>{b.name}</span>
          </div>
        ))}
      </div>

      <div style={{ padding: '14px 18px', background: 'var(--paper-2)', borderTop: '1px solid var(--line-paper)' }}>
        <div className="bl-mono" style={{ fontSize: 10, color: 'var(--ink-mute)', letterSpacing: '.08em', marginBottom: 8 }}>PINNED IN THIS SESSION</div>
        {[
          ['design-prompt.txt',           '684 B'],
          ['canvas-export.html',          '14.2 KB'],
          ['vite-blueprint-checklist.md', '1.1 KB'],
        ].map((f, i) => (
          <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '4px 0' }}>
            <span style={{ fontSize: 11 }}>📎</span>
            <span className="bl-mono" style={{ fontSize: 11.5, color: 'var(--ink)' }}>{f[0]}</span>
            <span style={{ flex: 1 }}></span>
            <span className="bl-mono" style={{ fontSize: 10, color: 'var(--ink-mute)' }}>{f[1]}</span>
          </div>
        ))}
      </div>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────
// What you'll build
// ────────────────────────────────────────────────────────────────

function WhatYouBuild() {
  return (
    <section style={{ padding: '96px 56px', background: 'var(--paper-2)' }}>
      <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', marginBottom: 40 }}>
        <div>
          <BLEyebrow>What you'll build</BLEyebrow>
          <h2 className="bl-display" style={{ fontSize: 60, marginTop: 14, lineHeight: 1 }}>
            Eight working things.<br/>
            <span className="bl-italic" style={{ color: 'var(--accent)' }}>Yours to keep.</span>
          </h2>
        </div>
        <p style={{ maxWidth: 360, color: 'var(--ink-dim)', fontSize: 15 }}>
          Each project is a working tool, not a tutorial. You finish the lab with code that runs and a deploy URL.
        </p>
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14 }}>
        {D2.projects.map((p, i) => (
          <div key={i} className="bl-card" style={{ padding: 0, overflow: 'hidden' }}>
            <div style={{
              aspectRatio: '4/3',
              background: `linear-gradient(135deg, ${i % 2 ? 'var(--accent-tint)' : 'var(--paper-3)'}, ${i % 2 ? 'var(--paper-3)' : 'var(--accent-tint)'})`,
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              borderBottom: '1px solid var(--line-paper)',
              position: 'relative',
            }}>
              <div className="bl-serif" style={{ fontSize: 88, color: 'var(--accent-deep)', opacity: .8, lineHeight: 1 }}>{p.emoji}</div>
              <span className="bl-mono" style={{
                position: 'absolute', top: 10, left: 10,
                fontSize: 10, color: 'var(--ink-mute)', letterSpacing: '.06em',
              }}>PROJECT 0{i + 1}</span>
            </div>
            <div style={{ padding: '14px 16px 16px' }}>
              <div className="bl-serif" style={{ fontSize: 22, lineHeight: 1.1 }}>{p.title}</div>
              <div className="bl-mono" style={{ fontSize: 11, color: 'var(--ink-mute)', marginTop: 6, letterSpacing: '.04em' }}>
                {p.tag}
              </div>
            </div>
          </div>
        ))}
      </div>
    </section>
  );
}

// ────────────────────────────────────────────────────────────────
// Comparison table
// ────────────────────────────────────────────────────────────────

function Comparison() {
  const { cols, rows } = D2.comparison;
  const cell = (v) => {
    if (v === true) return <span style={{ color: 'var(--sage)', fontWeight: 600, fontSize: 16 }}>●</span>;
    if (v === false) return <span style={{ color: 'var(--ink-mute)', fontSize: 14 }}>—</span>;
    if (v === 'partial' || v === 'sometimes' || v === 'maybe') {
      return <span className="bl-mono" style={{ fontSize: 10.5, color: 'var(--amber)', letterSpacing: '.04em' }}>{v}</span>;
    }
    return <span className="bl-mono" style={{ fontSize: 11.5, color: 'var(--ink-dim)' }}>{v}</span>;
  };

  return (
    <section style={{ padding: '96px 56px' }}>
      <div style={{ textAlign: 'center', marginBottom: 48 }}>
        <BLEyebrow>How it compares</BLEyebrow>
        <h2 className="bl-display" style={{ fontSize: 60, marginTop: 14, lineHeight: 1 }}>
          Why this and <span className="bl-italic" style={{ color: 'var(--accent)' }}>not the rest.</span>
        </h2>
      </div>

      <div className="bl-card" style={{ overflow: 'hidden' }}>
        {/* header row */}
        <div style={{
          display: 'grid', gridTemplateColumns: '2fr repeat(4, 1fr)',
          background: 'var(--paper-2)', borderBottom: '1px solid var(--line-paper)',
        }}>
          <div style={{ padding: '18px 22px' }}>
            <span className="bl-mono" style={{ fontSize: 10, color: 'var(--ink-mute)', letterSpacing: '.08em' }}>FEATURE</span>
          </div>
          {cols.map((c, i) => (
            <div key={i} style={{
              padding: '18px 16px',
              textAlign: 'center',
              background: i === 0 ? 'var(--ink)' : 'transparent',
              color: i === 0 ? 'var(--paper)' : 'var(--ink)',
              borderLeft: '1px solid var(--line-paper)',
            }}>
              <div className="bl-serif" style={{ fontSize: 18, lineHeight: 1.1 }}>{c}</div>
              {i === 0 && (
                <div className="bl-mono" style={{ fontSize: 9, color: 'var(--accent-soft)', marginTop: 4, letterSpacing: '.08em' }}>
                  ← THIS PAGE
                </div>
              )}
            </div>
          ))}
        </div>

        {/* rows */}
        {rows.map((r, i) => (
          <div key={i} style={{
            display: 'grid', gridTemplateColumns: '2fr repeat(4, 1fr)',
            borderBottom: i === rows.length - 1 ? 'none' : '1px solid var(--line-paper)',
            background: i % 2 ? 'var(--surface-1)' : 'var(--paper)',
          }}>
            <div style={{ padding: '14px 22px', fontSize: 14.5, color: 'var(--ink-2)' }}>{r[0]}</div>
            {[1, 2, 3, 4].map((j) => (
              <div key={j} style={{
                padding: '14px 16px',
                textAlign: 'center',
                borderLeft: '1px solid var(--line-paper)',
                background: j === 1 ? 'rgba(217,104,70,.06)' : 'transparent',
              }}>
                {cell(r[j])}
              </div>
            ))}
          </div>
        ))}
      </div>
    </section>
  );
}

// ────────────────────────────────────────────────────────────────
// Build log — commit-style feed
// ────────────────────────────────────────────────────────────────

function BuildLog() {
  const tagColor = {
    episode: 'var(--accent)',
    short:   'var(--lavender)',
    commit:  'var(--sage)',
    feature: 'var(--amber)',
    docs:    'var(--blue)',
  };
  return (
    <section id="log" style={{ padding: '96px 56px', background: 'var(--dark)', color: 'var(--bone)' }}>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.4fr', gap: 72, alignItems: 'start' }}>
        <div>
          <BLEyebrow>Recently shipped</BLEyebrow>
          <h2 className="bl-display" style={{ fontSize: 60, marginTop: 14, lineHeight: 1 }}>
            What I built<br/>
            <span className="bl-italic" style={{ color: 'var(--accent)' }}>this week.</span>
          </h2>
          <p style={{ marginTop: 22, fontSize: 16, color: 'var(--bone-dim)', maxWidth: 420, lineHeight: 1.55 }}>
            The lab is alive. New episodes ship constantly. This is the actual commit log — pulled from the repo that powers
            reloadin5.com, filtered to what affects the curriculum.
          </p>
          <button onClick={() => { const t=document.getElementById('subscribe'); if(t) t.scrollIntoView({behavior:'smooth'}); }} className="bl-btn bl-btn-dark-ghost" style={{ marginTop: 28, cursor: 'pointer' }}>
            Subscribe to the build log →
          </button>
        </div>

        <div style={{
          background: 'var(--dark-2)', border: '1px solid var(--line-dark)',
          borderRadius: 'var(--r-md)', overflow: 'hidden',
        }}>
          <div style={{ padding: '12px 18px', background: 'var(--dark-3)', borderBottom: '1px solid var(--line-dark)',
            display: 'flex', alignItems: 'center', gap: 10 }}>
            <span className="bl-mono" style={{ fontSize: 11, color: 'var(--bone)' }}>git log --pretty=oneline --since=1.week</span>
            <span style={{ flex: 1 }}></span>
            <span className="bl-mono" style={{ fontSize: 10, color: 'var(--sage)' }}>● syncing</span>
          </div>
          {D2.build_log.map((e, i) => (
            <div key={i} style={{
              display: 'grid', gridTemplateColumns: '90px 80px 1fr',
              alignItems: 'center', gap: 14,
              padding: '12px 18px',
              borderBottom: i === D2.build_log.length - 1 ? 'none' : '1px solid var(--line-dark)',
            }}>
              <span className="bl-mono" style={{ fontSize: 10.5, color: 'var(--bone-mute)' }}>{e.when}</span>
              <span style={{
                background: 'transparent',
                border: `1px solid ${tagColor[e.tag]}`,
                color: tagColor[e.tag],
                padding: '2px 8px', borderRadius: 4,
                fontFamily: 'var(--mono)', fontSize: 9.5, letterSpacing: '.06em',
                textAlign: 'center', textTransform: 'uppercase',
              }}>{e.tag}</span>
              <span className="bl-mono" style={{ fontSize: 12, color: 'var(--bone)' }}>{e.msg}</span>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ────────────────────────────────────────────────────────────────
// Pricing
// ────────────────────────────────────────────────────────────────

function Pricing() {
  return (
    <section id="pricing" style={{ padding: '108px 56px 96px' }}>
      <div style={{ textAlign: 'center', marginBottom: 56 }}>
        <BLEyebrow>Pricing</BLEyebrow>
        <h2 className="bl-display" style={{ fontSize: 72, marginTop: 14, lineHeight: 1 }}>
          Four ways in.<br/>
          <span className="bl-italic" style={{ color: 'var(--accent)' }}>One that pays for itself.</span>
        </h2>
        <p style={{ marginTop: 16, fontSize: 17, color: 'var(--ink-dim)', maxWidth: 580, margin: '16px auto 0' }}>
          The lifetime price goes up with every new module. Today there are five. The roadmap has nine.
        </p>
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16 }}>
        {D2.pricing.map((p) => (
          <PriceCard key={p.id} p={p} />
        ))}
      </div>

      <p className="bl-mono" style={{ marginTop: 28, textAlign: 'center', fontSize: 11, color: 'var(--ink-mute)', letterSpacing: '.04em' }}>
        all prices in USD · stripe checkout · invoice / vat / vendor TIN available
      </p>
    </section>
  );
}

function PriceCard({ p }) {
  const isFeatured = p.featured;
  const isDark = p.id === 'lifetime';
  const bg = isFeatured ? 'var(--accent-tint)' : isDark ? 'var(--dark)' : 'var(--surface-1)';
  const text = isFeatured ? 'var(--dark)' : isDark ? 'var(--bone)' : 'var(--ink)';
  const muted = isFeatured ? 'var(--ink-dim)' : isDark ? 'var(--bone-mute)' : 'var(--ink-dim)';
  const border = isFeatured ? 'var(--accent)' : isDark ? 'var(--dark)' : 'var(--line-paper)';

  let btnClass = 'bl-btn-ghost';
  if (p.ctaKind === 'accent') btnClass = 'bl-btn-accent';
  if (p.ctaKind === 'ghost-dark') btnClass = 'bl-btn-dark';

  const _pc_auth = window.useBLAuth ? window.useBLAuth() : null;
  const [_pc_loading, _pc_setLoading] = React.useState(false);
  const [_pc_error, _pc_setError] = React.useState('');

  async function _pc_onClick() {
    _pc_setError('');
    // Free preview tier → scroll to curriculum
    if (p.id === 'preview') {
      const target = document.getElementById('curriculum');
      if (target) target.scrollIntoView({ behavior: 'smooth' });
      return;
    }
    // Paid tiers — login required first
    if (!_pc_auth || !_pc_auth.isLoggedIn) {
      if (_pc_auth) _pc_auth.openLogin();
      return;
    }
    _pc_setLoading(true);
    try {
      const res = await fetch('/api/build/checkout', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + _pc_auth.token },
        body: JSON.stringify({ tier: p.id }),
      });
      if (!res.ok) {
        const data = await res.json().catch(() => ({}));
        throw new Error((data && data.error) || 'Checkout failed (HTTP ' + res.status + ')');
      }
      const data = await res.json();
      if (data && data.url) {
        window.location.href = data.url;
      } else {
        throw new Error('No checkout URL returned');
      }
    } catch (err) {
      _pc_setError((err && err.message) || 'Something went wrong');
      _pc_setLoading(false);
    }
  }

  return (
    <div className="bl-card" style={{
      padding: '28px 24px 24px',
      background: bg, color: text, borderColor: border,
      position: 'relative',
      boxShadow: isFeatured ? '0 24px 60px -30px rgba(217,104,70,.45)' : 'var(--shadow-soft)',
      transform: isFeatured ? 'translateY(-8px)' : 'none',
    }}>
      {isFeatured && (
        <div style={{
          position: 'absolute', top: -12, left: 24,
          background: 'var(--accent)', color: '#fff',
          fontFamily: 'var(--mono)', fontSize: 10, letterSpacing: '.1em',
          padding: '4px 10px', borderRadius: 4,
        }}>MOST POPULAR · SAVE $79</div>
      )}

      <div className="bl-mono" style={{ fontSize: 11, color: muted, letterSpacing: '.08em' }}>
        {p.name.toUpperCase()}
      </div>

      <div style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginTop: 14 }}>
        <span className="bl-serif" style={{ fontSize: 56, lineHeight: 1, color: text }}>{p.price}</span>
        <span style={{ fontSize: 13, color: muted }}>{p.cadence}</span>
      </div>

      <div style={{ marginTop: 6, fontSize: 12.5, color: isFeatured ? 'var(--accent-deep)' : muted, fontWeight: isFeatured ? 600 : 400 }}>
        {p.tag}
      </div>

      <button
        onClick={_pc_onClick}
        disabled={_pc_loading}
        className={`bl-btn ${btnClass}`}
        style={{
          width: '100%', justifyContent: 'center', marginTop: 22, padding: '12px 16px',
          opacity: _pc_loading ? 0.7 : 1,
          cursor: _pc_loading ? 'wait' : 'pointer',
        }}
      >
        {_pc_loading ? 'Loading…' : p.cta}
      </button>
      {_pc_error ? (
        <div style={{ marginTop: 10, fontSize: 12, color: isDark ? 'var(--accent-glow)' : 'var(--accent-deep)' }}>
          {_pc_error}
        </div>
      ) : null}

      <ul style={{ listStyle: 'none', padding: 0, margin: '24px 0 0', display: 'grid', gap: 10 }}>
        {p.features.map((f, i) => (
          <li key={i} style={{ display: 'flex', gap: 8, alignItems: 'flex-start', fontSize: 13.5, color: text }}>
            <span style={{ color: isFeatured ? 'var(--accent-deep)' : isDark ? 'var(--accent-glow)' : 'var(--accent)', flex: '0 0 auto', marginTop: 4 }}>
              <svg width="10" height="10" viewBox="0 0 12 12" fill="none"><path d="M2 6l3 3 5-7" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/></svg>
            </span>
            <span>{f}</span>
          </li>
        ))}
      </ul>
    </div>
  );
}

// ────────────────────────────────────────────────────────────────
// FAQ
// ────────────────────────────────────────────────────────────────

function FAQ() {
  const [open, setOpen] = useState2(0);
  return (
    <section style={{ padding: '96px 56px', background: 'var(--paper-2)' }}>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.6fr', gap: 72 }}>
        <div>
          <BLEyebrow>FAQ</BLEyebrow>
          <h2 className="bl-display" style={{ fontSize: 60, marginTop: 14, lineHeight: 1 }}>
            Real <span className="bl-italic" style={{ color: 'var(--accent)' }}>questions</span>.<br/>Real answers.
          </h2>
          <p style={{ marginTop: 18, color: 'var(--ink-dim)', fontSize: 15, lineHeight: 1.5, maxWidth: 320 }}>
            Got one I haven't covered? Send it to the email at the bottom. Real human reply, usually same day.
          </p>
        </div>
        <div>
          {D2.faq.map((q, i) => (
            <div key={i}
              onClick={() => setOpen(open === i ? -1 : i)}
              style={{
                borderTop: '1px solid var(--line-paper-2)',
                borderBottom: i === D2.faq.length - 1 ? '1px solid var(--line-paper-2)' : 'none',
                padding: '20px 0',
                cursor: 'pointer',
              }}>
              <div style={{ display: 'flex', alignItems: 'flex-start', gap: 18 }}>
                <span className="bl-mono" style={{ fontSize: 11, color: 'var(--ink-mute)', marginTop: 6, letterSpacing: '.04em' }}>
                  {String(i + 1).padStart(2, '0')}
                </span>
                <span className="bl-serif" style={{ fontSize: 24, lineHeight: 1.25, flex: 1 }}>{q.q}</span>
                <span style={{
                  fontFamily: 'var(--mono)', fontSize: 18, color: 'var(--accent)',
                  transform: open === i ? 'rotate(45deg)' : 'rotate(0)',
                  transition: 'transform .2s',
                }}>+</span>
              </div>
              {open === i && (
                <p style={{ marginTop: 14, marginLeft: 32, color: 'var(--ink-dim)', fontSize: 15.5, lineHeight: 1.55, maxWidth: 600 }}>
                  {q.a}
                </p>
              )}
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ────────────────────────────────────────────────────────────────
// Email capture + footer
// ────────────────────────────────────────────────────────────────

function EmailCapture() {
  const [emailVal, setEmailVal] = React.useState('');
  const [status, setStatus] = React.useState(null); // null | 'sending' | 'sent' | 'error'
  const [errorMsg, setErrorMsg] = React.useState('');

  async function submitEmail() {
    const e = emailVal.trim();
    if (!e || !e.includes('@')) { setErrorMsg('Enter a valid email'); setStatus('error'); return; }
    setStatus('sending'); setErrorMsg('');
    try {
      const res = await fetch('/api/build/subscribe', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ email: e, source: 'landing' }),
      });
      const data = await res.json().catch(() => ({}));
      if (res.ok && data.ok) { setStatus('sent'); }
      else { setErrorMsg(data.error || 'Something went wrong'); setStatus('error'); }
    } catch (err) { setErrorMsg('Connection error — try again'); setStatus('error'); }
  }

  return (
    <section id="subscribe" style={{ padding: '108px 56px', background: 'var(--ink)', color: 'var(--paper)', position: 'relative', overflow: 'hidden' }}>
      <div style={{
        position: 'absolute', inset: 0,
        background: 'radial-gradient(at 80% 50%, rgba(255,139,98,.18), transparent 50%)',
        pointerEvents: 'none',
      }}></div>

      <div style={{ position: 'relative', display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: 72, alignItems: 'center' }}>
        <div>
          <BLEyebrow>Not ready yet?</BLEyebrow>
          <h2 className="bl-display" style={{ fontSize: 64, marginTop: 14, lineHeight: 0.98 }}>
            Get the free episode<br/>
            and <span className="bl-italic" style={{ color: 'var(--accent-glow)' }}>the patch script</span> in your inbox.
          </h2>
          <p style={{ marginTop: 20, fontSize: 17, color: 'var(--bone-dim)', maxWidth: 560, lineHeight: 1.5 }}>
            Episode 1.1 (7:42) plus the Python patch-script template I use for every change to reloadin5.com.
            No drip, no spam. Unsubscribe link on every send.
          </p>
        </div>

        <div>
          <div className="bl-card-dark" style={{
            padding: 24, background: 'var(--dark-2)',
            position: 'relative', overflow: 'hidden',
          }}>
            <BLCorners />
            <label className="bl-mono" style={{ fontSize: 11, color: 'var(--bone-mute)', letterSpacing: '.08em' }}>
              EMAIL
            </label>
            <div style={{
              display: 'flex', alignItems: 'center', gap: 8, marginTop: 8,
              background: 'var(--dark-3)', border: '1px solid var(--line-dark-2)',
              borderRadius: 8, padding: '4px 4px 4px 14px',
            }}>
              <input value={emailVal} onChange={(e) => setEmailVal(e.target.value)}
                onKeyDown={(e) => { if (e.key === 'Enter') submitEmail(); }}
                placeholder="you@company.com"
                disabled={status === 'sending' || status === 'sent'}
                style={{
                  flex: 1, background: 'transparent', border: 'none', outline: 'none',
                  color: 'var(--bone)', fontFamily: 'var(--mono)', fontSize: 13.5, padding: '10px 0',
                }}/>
              <button onClick={submitEmail}
                disabled={status === 'sending' || status === 'sent' || !emailVal.trim()}
                className="bl-btn bl-btn-accent"
                style={{ padding: '10px 16px', fontSize: 13, opacity: (status === 'sending' || status === 'sent' || !emailVal.trim()) ? 0.6 : 1 }}>
                {status === 'sending' ? 'sending…' : status === 'sent' ? 'sent ✓' : 'Send it →'}
              </button>
            </div>
            <div className="bl-mono" style={{ fontSize: 10.5, color: 'var(--bone-mute)', marginTop: 14, letterSpacing: '.04em' }}>
              Once a week. New lessons, real commits. No spam.
            </div>
            {status === 'sent' && (
              <div className="bl-mono" style={{ fontSize: 11.5, color: 'var(--accent-glow, #ff8b62)', marginTop: 12, letterSpacing: '.02em' }}>
                ✓ Got you. Check your inbox for the free episode.
              </div>
            )}
            {status === 'error' && errorMsg && (
              <div className="bl-mono" style={{ fontSize: 11.5, color: '#ff8b62', marginTop: 12, letterSpacing: '.02em' }}>
                {errorMsg}
              </div>
            )}
          </div>
        </div>
      </div>
    </section>
  );
}

function Footer() {
  return (
    <footer style={{ padding: '48px 56px 56px', background: 'var(--ink)', color: 'var(--bone-mute)', borderTop: '1px solid var(--line-dark)' }}>
      <div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', gap: 48 }}>
        <div>
          <LandingLogo dark />
          <p style={{ marginTop: 14, fontSize: 13.5, color: 'var(--bone-mute)', maxWidth: 320 }}>
            A members-only build log for IT engineers learning to ship with Claude.
            Lives at <span className="bl-mono" style={{ color: 'var(--bone)' }}>reloadin5.com/build</span>. Mirrors{' '}
            <span className="bl-mono" style={{ color: 'var(--bone)' }}>reloadin5.com</span> — go poke around.
          </p>
        </div>
        {[
          ['Lab', [
            ['Curriculum',   '#curriculum'],
            ['Architecture', '#arch'],
            ['Roadmap',      '#log'],
            ['Build log',    '#log'],
          ]],
          ['Live site', [
            ['reloadin5.com',       'https://reloadin5.com'],
            ['Cisco labs',          'https://reloadin5.com/lab'],
            ['Route Zero',          'https://reloadin5.com/rz'],
            ['Practice questions',  'https://reloadin5.com/practice'],
          ]],
          ['Company', [
            ['About',   '#top'],
            ['Email',   'mailto:hello@reloadin5.com'],
            ['TikTok',  'https://www.tiktok.com/@reloadin5'],
            ['YouTube', 'https://www.youtube.com/@reloadin5'],
          ]],
        ].map((col, i) => (
          <div key={i}>
            <div className="bl-mono" style={{ fontSize: 11, color: 'var(--bone-dim)', letterSpacing: '.08em', marginBottom: 14 }}>
              {col[0].toUpperCase()}
            </div>
            {col[1].map((item, j) => {
              const label = item[0]; const href = item[1];
              const isAnchor = href.charAt(0) === '#';
              const isExternal = href.indexOf('http') === 0;
              const handleClick = isAnchor ? (e) => {
                e.preventDefault();
                if (href === '#top') { window.scrollTo({ top: 0, behavior: 'smooth' }); return; }
                const t = document.getElementById(href.slice(1));
                if (t) t.scrollIntoView({ behavior: 'smooth' });
              } : undefined;
              return (
                <a key={j} href={href} onClick={handleClick}
                  target={isExternal ? '_blank' : undefined}
                  rel={isExternal ? 'noopener noreferrer' : undefined}
                  style={{ display: 'block', fontSize: 13.5, padding: '6px 0', color: 'var(--bone-mute)', textDecoration: 'none', cursor: 'pointer' }}>
                  {label}
                </a>
              );
            })}
          </div>
        ))}
      </div>
      <div style={{ marginTop: 56, paddingTop: 24, borderTop: '1px solid var(--line-dark)', display: 'flex', alignItems: 'center', gap: 18 }}>
        <span className="bl-mono" style={{ fontSize: 10.5, letterSpacing: '.04em' }}>
          © 2026 ReloadIn5 · Built with Claude on Cloudflare
        </span>
        <span className="bl-mono" style={{ fontSize: 10, color: 'var(--bone-mute)', opacity: 0.7, marginLeft: 18 }}>
          Not affiliated with or endorsed by Cisco Systems, Inc.
        </span>
        <span style={{ flex: 1 }}></span>
        <span className="bl-mono" style={{ fontSize: 10, color: 'var(--sage)' }}>● all systems normal · 38ms TTFB</span>
      </div>
    </footer>
  );
}

Object.assign(window, {
  LandingLessonPreview: LessonPreview,
  LandingProjects: WhatYouBuild,
  LandingComparison: Comparison,
  LandingBuildLog: BuildLog,
  LandingPricing: Pricing,
  LandingFAQ: FAQ,
  LandingEmailCapture: EmailCapture,
  LandingFooter: Footer,
});
