/* /pricing/ — what is free, what the full report costs, what the engine
   benchmark adds, and why. Prices come from the server (/api/pay), so the
   figures set in Vercel are the figures shown; the defaults here are what
   the page shows for the instant before it answers.

   Opened as /pricing/?c=<slug> (the link from a report page) the buy buttons
   start Checkout for that report. Opened cold, they lead to the free
   analysis: a report has to exist before it can be bought.  */

const ENGINES = ['ChatGPT', 'Perplexity', 'Gemini', 'Google AI Overviews', 'Claude'];

function Tick({ on = true }) {
  return <span style={{ flex: '0 0 auto', marginTop: 2, color: on ? 'var(--accent)' : 'var(--fg-subtle)' }}><Icon name={on ? 'check' : 'minus'} size={16} stroke={2.4} /></span>;
}

/* The three tiers. `ctx` says which report (if any) is being bought for. */
function PriceCards({ pay, ctx }) {
  const price = (p) => payPrice(pay, p) || ({ full_report: '$499', benchmark_byok: '$399', benchmark_managed: '$599' }[p]);
  const owned = (ctx && ctx.owned) || {};
  const slug = ctx && ctx.slug;
  const canBuy = pay && pay.enabled && slug;
  const cardStyle = (hero) => ({ padding: 'clamp(24px,3vw,34px)', display: 'flex', flexDirection: 'column', position: 'relative',
    ...(hero ? { border: '1px solid var(--accent)', background: 'var(--navy-2)', boxShadow: 'var(--sh-accent)' } : {}) });
  const list = (items) =>
    <ul style={{ listStyle: 'none', margin: '0 0 26px', padding: 0, display: 'flex', flexDirection: 'column', gap: 12, flex: 1 }}>
      {items.map((t) => <li key={t} style={{ display: 'flex', gap: 10, fontSize: 15, color: 'var(--fg)', lineHeight: 1.45 }}><Tick />{t}</li>)}
    </ul>;
  const cta = (product, label) => {
    if (product === 'free') return <a href="/#audit" className="btn btn-ghost" style={{ width: '100%', justifyContent: 'center' }}>Get my free report</a>;
    const ent = product.startsWith('benchmark') ? 'benchmark' : product;
    if (canBuy && owned[ent]) return <div className="btn btn-ghost" style={{ width: '100%', justifyContent: 'center', cursor: 'default', opacity: 0.8 }}><Icon name="check" size={16} /> You have this</div>;
    if (canBuy && ent === 'benchmark' && !(pay.has_full || owned.full_report)) {
      return <div style={{ textAlign: 'center', fontSize: 13.5, color: 'var(--fg-muted)' }}>Add it after the full report.</div>;
    }
    if (canBuy) return <BuyButton slug={slug} product={product} pay={pay} label={label} ghost={product === 'benchmark_byok'} />;
    // No report to buy for yet: one button per card, to the free report.
    if (product === 'benchmark_managed') return null;
    return <a href="/#audit" className={'btn ' + (product === 'full_report' ? 'btn-primary' : 'btn-ghost')} style={{ width: '100%', justifyContent: 'center' }}>
      {product === 'full_report' ? 'Start with the free report' : 'Add it from your report page'} <Icon name="arrow-right" size={16} /></a>;
  };
  return (
    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(270px, 1fr))', gap: 'clamp(14px,2vw,22px)', maxWidth: 1120, margin: '0 auto', alignItems: 'stretch' }}>
      <div className="card tier-card" style={cardStyle(false)}>
        <div className="overline" style={{ marginBottom: 12 }}>Free report</div>
        <div className="display" style={{ fontSize: 'clamp(30px,3.4vw,40px)', marginBottom: 4 }}>$0</div>
        <div style={{ fontSize: 13.5, color: 'var(--fg-muted)', marginBottom: 20 }}>As often as you like</div>
        {list([
          'How AI reads your site right now, in four layers: access, identity, answers, authority',
          'Your top findings, each with why it matters and the fix',
          'A report page you can share with your team',
          'Results in a couple of minutes',
        ])}
        {cta('free')}
      </div>
      <div className="card tier-card" style={cardStyle(true)}>
        <div style={{ position: 'absolute', top: -12, left: 24, background: 'var(--accent)', color: 'var(--on-accent)', fontSize: 11, fontWeight: 700,
          letterSpacing: '0.08em', textTransform: 'uppercase', padding: '4px 10px', borderRadius: 999 }}>Most chosen</div>
        <div className="overline" style={{ marginBottom: 12 }}>Full report</div>
        <div className="display" style={{ fontSize: 'clamp(30px,3.4vw,40px)', marginBottom: 4 }}>{price('full_report')}</div>
        <div style={{ fontSize: 13.5, color: 'var(--fg-muted)', marginBottom: 20 }}>One-time, per website. Ready within 24 hours.</div>
        {list([
          'Every finding on the site, by layer, written for your business',
          'The prioritised action plan: owner, effort and order for each fix',
          'Fix-ready files to paste in: robots rules, schema, page copy',
          'The 90-day roadmap',
          'Re-scans that verify each fix against your live site',
          'Where to take it beyond the website',
          'AI-referred visits and orders from your own GA4 or Shopify',
          'An access code at checkout; your report page unlocks itself',
        ])}
        {cta('full_report', 'Get the full report')}
        <div style={{ marginTop: 10 }}><SecurePayNote pay={pay} /></div>
      </div>
      <div className="card tier-card" style={cardStyle(false)}>
        <div className="overline" style={{ marginBottom: 12 }}>Engine benchmark · add-on</div>
        <div className="display" style={{ fontSize: 'clamp(30px,3.4vw,40px)', marginBottom: 4 }}>+{price('benchmark_byok')} <span style={{ fontSize: 15, fontFamily: 'var(--font-sans)', fontWeight: 400, color: 'var(--fg-muted)' }}>or +{price('benchmark_managed')}</span></div>
        <div style={{ fontSize: 13.5, color: 'var(--fg-muted)', marginBottom: 20 }}>Per website, on top of the full report. Results within 24 hours.</div>
        {list([
          `Buyer questions for your category put to ${ENGINES.length} engines: ${ENGINES.join(', ')}`,
          'How often you are named, where you rank, whether you are cited, with ranges',
          'Where competitors win: the prompts they are named on and you are not',
          'Live answers on demand, your name highlighted',
          'Run it again after the fixes and see the movement',
          `${price('benchmark_byok')} on your own API keys for the paid engines (Claude included on ours)`,
          `${price('benchmark_managed')} if we run every engine on Lojo's keys: nothing to set up`,
        ])}
        <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
          {cta('benchmark_byok', `Your keys · ${price('benchmark_byok')}`)}
          {cta('benchmark_managed', `Lojo's keys · ${price('benchmark_managed')}`)}
          {!canBuy && <div style={{ textAlign: 'center', fontSize: 12.5, color: 'var(--fg-subtle)' }}>Both options appear on your report page once the full report is yours.</div>}
        </div>
      </div>
    </div>);
}

function Compare() {
  const rows = [
    ['Four-layer read of your site', true, true, true],
    ['Top findings with fixes', 'the top ones', 'all of them', 'all of them'],
    ['Delivered', 'in minutes', 'within 24 hours', 'within 24 hours'],
    ['Written for your business, not a template', false, true, true],
    ['Prioritised action plan with owners', false, true, true],
    ['Fix-ready files to paste in', false, true, true],
    ['90-day roadmap', false, true, true],
    ['Re-scans that verify each fix', false, true, true],
    ['AI-referred traffic from your own analytics', false, true, true],
    ['What engines say when buyers ask', false, false, true],
    ['Mention, rank and citation rates with ranges', false, false, true],
    ['Where competitors win', false, false, true],
    ['Live answers on demand', false, false, true],
  ];
  const cell = (v) => v === true ? <Tick /> : v === false ? <Tick on={false} /> : <span style={{ fontSize: 13.5, color: 'var(--fg-muted)' }}>{v}</span>;
  return (
    <div className="card" style={{ padding: 0, overflow: 'hidden', maxWidth: 960, margin: '0 auto' }}>
      <table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 14.5 }}>
        <thead>
          <tr style={{ background: 'var(--navy-2)' }}>
            {['', 'Free', 'Full report', 'Full + benchmark'].map((h, i) =>
            <th key={i} style={{ textAlign: i === 0 ? 'left' : 'center', padding: '14px 16px', fontSize: 12, letterSpacing: '0.08em', textTransform: 'uppercase',
              color: i === 2 ? 'var(--accent)' : 'var(--fg-muted)', fontFamily: 'var(--font-mono)', fontWeight: 600 }}>{h}</th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map(([label, ...cols]) =>
          <tr key={label} style={{ borderTop: '1px solid var(--line)' }}>
            <td style={{ padding: '12px 16px', color: 'var(--fg)' }}>{label}</td>
            {cols.map((v, i) => <td key={i} style={{ padding: '12px 16px', textAlign: 'center' }}><span style={{ display: 'inline-flex' }}>{cell(v)}</span></td>)}
          </tr>)}
        </tbody>
      </table>
    </div>);
}

/* What a benchmark result looks like. Illustrative figures, labelled so. */
function BenchmarkSample() {
  const rows = [
    ['ChatGPT', '31%', '2.4', '18%'],
    ['Perplexity', '46%', '1.9', '52%'],
    ['Gemini', '22%', '3.1', '9%'],
    ['Google AI Overviews', '15%', '—', '15%'],
    ['Claude', '38%', '2.2', '27%'],
  ];
  return (
    <div className="card" style={{ padding: 'clamp(18px,2.5vw,26px)' }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', gap: 12, alignItems: 'baseline', flexWrap: 'wrap', marginBottom: 12 }}>
        <div className="mono" style={{ fontSize: 10.5, letterSpacing: '0.09em', textTransform: 'uppercase', color: 'var(--fg-subtle)' }}>Sample benchmark · 24 buyer questions × 3 runs</div>
        <span className="chip" style={{ borderColor: 'var(--warn)', color: 'var(--warn)' }}>Illustrative</span>
      </div>
      <table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 14 }}>
        <thead><tr>{['Engine', 'Named', 'Avg. position', 'Cited'].map((h, i) => <th key={h} style={{ textAlign: i ? 'right' : 'left', padding: '8px 6px', fontSize: 11.5, color: 'var(--fg-muted)', fontWeight: 500, borderBottom: '1px solid var(--line)' }}>{h}</th>)}</tr></thead>
        <tbody>{rows.map(([e, a, b, c]) =>
          <tr key={e}><td style={{ padding: '9px 6px' }}>{e}</td>
            <td className="mono" style={{ textAlign: 'right', padding: '9px 6px', color: 'var(--accent)' }}>{a}</td>
            <td className="mono" style={{ textAlign: 'right', padding: '9px 6px' }}>{b}</td>
            <td className="mono" style={{ textAlign: 'right', padding: '9px 6px' }}>{c}</td></tr>)}</tbody>
      </table>
      <div style={{ marginTop: 12, fontSize: 12.5, color: 'var(--fg-subtle)', lineHeight: 1.6 }}>
        Named: answers that mention the business. Position: its rank among businesses named. Cited: answers linking to its site. Every figure is reported with the range across runs.
      </div>
    </div>);
}

const PRICING_FAQ = [
  { q: 'Why buy the full report?', a: 'The free report tells you something is wrong. The full report tells you exactly what to change, in what order, who should do it, and hands you the files to paste in. Then it checks your live site after each fix so you know it landed.' },
  { q: 'Why is the benchmark separate, and why two prices?', a: 'The report is about what engines can read. The benchmark is about what they actually say, and it costs real engine calls each time it runs. Bring your own API keys for OpenAI, Perplexity, Gemini and SerpApi and it is $399; the engines bill you for the usage and Claude is included on our keys. Have us run everything on our keys and it is $599, nothing to set up. Either way the results land on your report page within 24 hours.' },
  { q: 'Which engines does the benchmark cover?', a: `${ENGINES.join(', ')}. Each buyer question is asked several times per engine, because answers vary, and every figure is shown with its range. The report page shows which engines actually ran.` },
  { q: 'How do the other modules work?', a: 'Start the module from one short screen: who you are, what you want it to change, headcount and timing. The Lojo engine reads what you provide, fetches your own website, researches the public record where it helps, and writes a first analysis with an evidence grade on every fact (A: you provided it; B: your own public sources; C: third-party sources; D: a labelled estimate). What it cannot know, such as vendor contracts, it lists as a gap instead of guessing. The first insights per module are free; the findings and recommendations unlock at the fixed price above, each with a 45-minute walkthrough.' },
  { q: 'What exactly do I get when I unlock a module?', a: 'Every finding the engine reached for that module with its impact and evidence grade, every recommendation with its effort and what it is worth, and the honest list of what cannot be modelled until you provide more, with what would change once you do. You can add answers and files from the page and re-run as often as you like. Then a 45-minute strategy walkthrough with the founders, and 30 days in the workspace to start running it.' },
  { q: 'Does Lojo do the implementation?', a: 'No. Lojo analyses, plans and runs the execution in the workspace; the work itself is done by your own people, a partner you bring, or a Lojo preferred partner you choose from inside the workspace. Every external implementer is approved by Lojo and signs a strict confidentiality agreement (no copying or passing off Lojo\'s software or recommendations) before they see a record. Preferred partners pay Lojo a share of their fees; you are never marked up.' },
  { q: 'What does the workspace cost, and can I cancel?', a: 'A monthly base that includes Execute and three seats, plus a monthly price for each module you keep live and for extra seats; approved implementation partners never use a seat. The first 30 days are included with any analysis. Change modules and seats any month and cancel any time from the billing panel; your data stays readable and exportable, and your analyses stay yours.' },
  { q: 'Can I see it before I pay for a module?', a: 'Yes. The free insights appear first, on the same page, with the same evidence grades; the locked part shows how many findings and recommendations are waiting and names the first of them. Unlock when it has earned it, or book a call and we will walk you through what we see.' },
  { q: 'Is my data safe, and when is an NDA needed?', a: 'Nothing sensitive (structure, compensation bands, financials, deal material, files) is asked for before a mutual NDA is in place; you sign ours on the page or upload your own. Your inputs are read only by the founders and the engine, train no shared model, and are used only for your analysis. Card details never touch Lojo: Stripe handles payment.' },
  { q: 'Is it a subscription?', a: 'The AI visibility report and every module analysis are one-time. Only the workspace, where you run the execution, is monthly, and it is optional: you can buy an analysis, take the walkthrough and never subscribe.' },
  { q: 'How do I pay, and when do I get the report?', a: 'By card or wallet through Stripe, from your report page after the free report. Your access code is shown the moment the payment lands and emailed to you. The report is ready within 24 hours, usually much sooner, and the page unlocks itself when it is.' },
  { q: 'Can my agency buy it for me?', a: 'Yes. Agencies run the free report from their workspace, buy the full report per client or draw on an allowance agreed with the Lojo team, and hand you the access code. They also get a proposal draft in their own voice.' },
  { q: 'What if I have a question about a charge?', a: 'Reply to the Stripe receipt, or email the team from your report page. A real person answers.' },
];

function PricingFAQ() {
  const [open, setOpen] = React.useState(0);
  return (
    <div style={{ maxWidth: 820, margin: '0 auto', borderBottom: '1px solid var(--line)' }}>
      {PRICING_FAQ.map((f, i) =>
      <div key={i} style={{ borderTop: '1px solid var(--line)' }}>
        <button onClick={() => setOpen(open === i ? -1 : i)} aria-expanded={open === i} style={{ width: '100%', background: 'transparent', border: 'none', cursor: 'pointer', textAlign: 'left',
          display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16, padding: '20px 0', color: 'var(--fg)' }}>
          <span style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(17px,2vw,21px)', fontWeight: 600, letterSpacing: '-0.01em' }}>{f.q}</span>
          <span style={{ flex: '0 0 auto', color: 'var(--accent-deep)', transition: 'transform .25s var(--ease)', transform: open === i ? 'rotate(45deg)' : 'none' }}>
            <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round"><path d="M12 5v14M5 12h14"/></svg>
          </span>
        </button>
        <div style={{ maxHeight: open === i ? 400 : 0, overflow: 'hidden', transition: 'max-height .35s var(--ease)' }}>
          <p style={{ margin: 0, paddingBottom: 22, maxWidth: 680, fontSize: 16, color: 'var(--fg-muted)', lineHeight: 1.6 }}>{f.a}</p>
        </div>
      </div>)}
    </div>);
}

function ModulePriceCard({ m, pay }) {
  const mp = pay && pay.module_prices && m.product && pay.module_prices[m.product];
  const price = mp ? '$' + Number(mp.usd).toLocaleString('en-US') : moduleMoney(m.fallback);
  const live = m.status === 'live';
  return <div id={'module-' + m.id} className="card" style={{ padding: 18, display: 'flex', flexDirection: 'column', borderColor: live ? 'var(--accent)' : 'var(--line-strong)' }}>
    <div className="mono" style={{ fontSize: 10, letterSpacing: '0.1em', textTransform: 'uppercase', color: live ? 'var(--accent)' : 'var(--warn)', marginBottom: 6 }}>{live ? 'Live' : 'Beta · available now'}</div>
    <div style={{ fontWeight: 600, fontSize: 17, marginBottom: 2 }}>{m.title}</div>
    <div className="display" style={{ fontSize: 26, margin: '4px 0 2px' }}>{price}<span style={{ fontSize: 12.5, fontFamily: 'var(--font-sans)', fontWeight: 400, color: 'var(--fg-muted)' }}> {m.unit}</span></div>
    <div style={{ fontSize: 13, color: 'var(--fg-muted)', lineHeight: 1.5, flex: 1, marginBottom: 12 }}>{m.problem}</div>
    <a href={moduleStartUrl(m)} className={'btn ' + (live ? 'btn-ghost' : 'btn-primary')} style={{ justifyContent: 'center', padding: '9px 14px', fontSize: 13.5 }}>{live ? 'Free report' : `Start · ${price}`}</a>
    <div style={{ marginTop: 10, fontSize: 12.5, display: 'flex', gap: 12, justifyContent: 'center' }}>
      <a href={moduleSampleUrl(m)} style={{ color: 'var(--accent)' }}>{live ? 'Sample report' : 'Sample analysis'}</a>
      {!live && <a href={moduleDemoUrl(m)} style={{ color: 'var(--fg-muted)' }}>Demo</a>}
      <a href={'/modules/#' + m.id} style={{ color: 'var(--fg-muted)' }}>Details</a>
    </div>
  </div>;
}

function PricingPage() {
  const slug = new URLSearchParams(window.location.search).get('c') || '';
  React.useEffect(() => { countOpen('pricing_page'); }, []);
  const [pay, setPay] = React.useState(null);
  const [ctx, setCtx] = React.useState(null);
  React.useEffect(() => {
    const body = slug ? { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'config', slug }) } : undefined;
    apiCall('/api/pay', body).then((d) => {
      if (!d.ok) return;
      setPay(d);
      if (slug && d.owned) setCtx({ slug, owned: d.owned });
    }).catch(() => {});
  }, [slug]);
  const stats = [
    { n: '94%', d: 'of B2B buyers use AI to research vendors before they talk to sales.', src: 'Chief Outsiders AI Search Report, 2026' },
    { n: '60%', d: 'of Google searches now end without a click to any website.', src: 'Bain & Company, 2025' },
    { n: '1', d: 'report. The handful of businesses an engine names is decided by what it can read and corroborate. That is what the report fixes.', src: 'How the full report is built' },
  ];
  return (
    <React.Fragment>
      <PageNav active="/pricing/" />
      <header className="section" style={{ paddingTop: 136, paddingBottom: 'clamp(28px,4vw,48px)', position: 'relative', overflow: 'hidden' }}>
        <div style={{ position: 'absolute', top: -120, left: '50%', transform: 'translateX(-50%)', width: 900, height: 520,
          background: 'radial-gradient(closest-side, var(--accent-glow), transparent)', opacity: 0.45, pointerEvents: 'none', filter: 'blur(20px)', maxWidth: '150vw' }}></div>
        <div className="wrap" style={{ position: 'relative', textAlign: 'center' }}>
          <div className="overline" style={{ marginBottom: 16 }}>Pricing</div>
          <h1 className="display" style={{ fontSize: 'clamp(34px,7vw,68px)', margin: '0 auto', maxWidth: 900 }}>
            See where you stand for free.<br />Pay once to <span style={{ color: 'var(--accent)' }}>fix it.</span>
          </h1>
          <p className="lede" style={{ maxWidth: 620, margin: '20px auto 0', color: 'var(--fg-muted)' }}>
            The free report costs nothing. The full report is a one-time purchase per website, with every fix in order and the files to paste in.
            The engine benchmark is an add-on for when you want to know what AI actually says about you.
          </p>
          <div style={{ display: 'flex', gap: 8, justifyContent: 'center', flexWrap: 'wrap', marginTop: 24 }}>
            <a href="#report-tiers" className="tour-tab on" style={{ padding: '9px 14px', fontSize: 13.5, textDecoration: 'none' }}>AI visibility report</a>
            <a href="#modules" className="tour-tab" style={{ padding: '9px 14px', fontSize: 13.5, textDecoration: 'none' }}>Platform modules · from $990</a>
          </div>
          {ctx &&
          <div className="chip" style={{ marginTop: 22, borderColor: 'var(--accent)', color: 'var(--accent)' }}>
            <span className="dot"></span> Buying for <span className="mono">{ctx.slug}</span> · <a href={'/r/?c=' + encodeURIComponent(ctx.slug)} style={{ color: 'var(--accent)' }}>back to the report</a>
          </div>}
          {!ctx && pay && pay.enabled &&
          <div style={{ marginTop: 18, fontSize: 13.5, color: 'var(--fg-subtle)' }}>Start with the free report; you buy from your report page in one click.</div>}
        </div>
      </header>

      <section id="report-tiers" className="section" style={{ paddingTop: 0, scrollMarginTop: 90 }}>
        <div className="wrap"><PriceCards pay={pay || {}} ctx={ctx} /></div>
      </section>

      <section className="section" style={{ background: 'var(--navy)', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)' }}>
        <div className="wrap">
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))', gap: 'clamp(20px,3vw,44px)' }}>
            {stats.map((s, i) => (
              <div key={i} style={{ textAlign: 'center' }}>
                <div className="display" style={{ fontSize: 'clamp(46px,6vw,80px)', color: 'var(--accent-deep)', lineHeight: 1, marginBottom: 14 }}>{s.n}</div>
                <p style={{ margin: '0 auto 12px', maxWidth: 300, fontSize: 'clamp(15px,1.5vw,17px)', color: 'var(--fg-muted)', lineHeight: 1.5 }}>{s.d}</p>
                <p className="mono" style={{ margin: 0, fontSize: 11, color: 'var(--fg-subtle)', letterSpacing: '0.03em' }}>{s.src}</p>
              </div>))}
          </div>
        </div>
      </section>

      <section className="section">
        <div className="wrap">
          <SectionHead over="What you are paying for" center title="A report that gets things fixed,<br>not a PDF that gets filed."
            sub="Claude reads your scan and what you told us about your business, then writes the plan a specialist would: specific to your pages, in the order that moves the needle." />
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(260px, 1fr))', gap: 'clamp(14px,2vw,22px)' }}>
            {[
              ['doc', 'Every finding, explained', 'Not a checklist. Each issue says what the engine sees, why it matters for a buyer’s question, and what to change on which page.'],
              ['zap', 'Fix-ready files', 'The robots rules, the schema, the rewritten copy: produced for your site, ready to paste. Hours of work handed over, not described.'],
              ['shield', 'Verified on your live site', 'Tick a fix off and the next re-scan checks it. Fixed stays fixed; regressions are flagged.'],
              ['clock', 'The 90-day roadmap', 'What to do this week, this month, this quarter, with an owner for each item: developer, marketing, founder, agency.'],
              ['globe', 'Beyond the website', 'The profiles, listings and sources engines use to corroborate you, and which ones to fix first.'],
              ['cart', 'AI traffic you can see', 'Connect GA4 or Shopify and watch visits and orders that arrived from an AI assistant, week by week, against your fixes.'],
            ].map(([icon, title, body]) =>
            <div key={title} className="card feature-card" style={{ padding: 'clamp(20px,2.6vw,28px)' }}>
              <div style={{ color: 'var(--accent)', marginBottom: 14 }}><Icon name={icon} size={24} stroke={1.7} /></div>
              <div style={{ fontFamily: 'var(--font-display)', fontSize: 19, fontWeight: 600, marginBottom: 8 }}>{title}</div>
              <p style={{ margin: 0, fontSize: 14.5, color: 'var(--fg-muted)', lineHeight: 1.6 }}>{body}</p>
            </div>)}
          </div>
        </div>
      </section>

      <section className="section" style={{ background: 'var(--navy)', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)' }}>
        <div className="wrap">
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: 'clamp(24px,4vw,56px)', alignItems: 'center' }}>
            <div>
              <div className="overline" style={{ marginBottom: 14 }}>The engine benchmark</div>
              <h2 className="display" style={{ fontSize: 'clamp(28px,3.6vw,44px)', margin: '0 0 16px' }}>Stop guessing what AI says about you.</h2>
              <p style={{ fontSize: 16.5, color: 'var(--fg-muted)', lineHeight: 1.65, margin: '0 0 14px' }}>
                Asking ChatGPT once tells you one answer on one day. The benchmark asks the questions buyers in your category actually ask,
                across {ENGINES.length} engines, several times each, and measures how often you are named, where you rank, and whether your site is cited.
              </p>
              <p style={{ fontSize: 16.5, color: 'var(--fg-muted)', lineHeight: 1.65, margin: '0 0 22px' }}>
                It shows where competitors win instead of you, lets you ask any engine live with your name highlighted, and runs again after the fixes so the movement is measured, not felt.
              </p>
              <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
                {ENGINES.map((e) => <span key={e} className="chip">{e}</span>)}
              </div>
            </div>
            <BenchmarkSample />
          </div>
        </div>
      </section>

      <section className="section">
        <div className="wrap">
          <SectionHead over="Side by side" center title="What each tier includes." />
          <Compare />
        </div>
      </section>

      <section className="section" style={{ background: 'var(--navy)', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)' }}>
        <div className="wrap">
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: 'clamp(24px,4vw,56px)', alignItems: 'center' }}>
            <div>
              <div className="overline" style={{ marginBottom: 14 }}>For agencies · beta</div>
              <h2 className="display" style={{ fontSize: 'clamp(28px,3.6vw,44px)', margin: '0 0 16px' }}>Same prices, your workspace.</h2>
              <p style={{ fontSize: 16.5, color: 'var(--fg-muted)', lineHeight: 1.65, margin: '0 0 22px' }}>
                Run the free report for any client, buy their full report per website or draw on an allowance agreed with the Lojo team, and hand them the access code.
                Each full report for an agency client comes with a proposal draft in your voice, priced from your rate. Bring your own API keys to run the paid engines on your accounts.
              </p>
              <div style={{ display: 'flex', gap: 10, flexWrap: 'wrap' }}>
                <a href="/agency/" className="btn btn-primary">Run a client's free report</a>
                <a href="/agency/admin/?signup=1" className="btn btn-ghost">Create an agency account</a>
              </div>
            </div>
            <div className="card" style={{ padding: 'clamp(20px,2.6vw,28px)' }}>
              {[
                ['One workspace', 'Every client you have run, their reports, codes, benchmarks and re-scans.'],
                ['Allowance or card', 'An agreed number of free full reports, then the same one-time prices.'],
                ['Your keys, your engines', 'Add OpenAI, Perplexity, Gemini or SerpApi keys once; they apply to all your clients.'],
                ['Pitch mode', 'Ask the engines live from a client’s report, with the client’s name highlighted, in the room.'],
              ].map(([t, b]) =>
              <div key={t} style={{ display: 'flex', gap: 12, padding: '12px 0', borderTop: '1px solid var(--line)' }}>
                <Tick /><div><div style={{ fontWeight: 600, fontSize: 15 }}>{t}</div><div style={{ fontSize: 14, color: 'var(--fg-muted)', lineHeight: 1.55 }}>{b}</div></div>
              </div>)}
            </div>
          </div>
        </div>
      </section>

      <section className="section" id="modules" style={{ scrollMarginTop: 90 }}>
        <div className="wrap">
          <SectionHead over="The platform" center title="One analysis per module,<br>one fixed price per module."
            sub="AI visibility is the free entry point. Every other module starts from one short screen: the Lojo engine reads what you provide, researches what is public, grades every fact, and shows the first insights free. Pay by card to unlock the findings; a 45-minute walkthrough with the founders is included." />
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))', gap: 12, maxWidth: 1120, margin: '0 auto' }}>
            {MODULE_CATALOG.map((m) => <ModulePriceCard key={m.id} m={m} pay={pay} />)}
          </div>
          <p style={{ textAlign: 'center', margin: '18px auto 0', maxWidth: 680, fontSize: 13.5, color: 'var(--fg-muted)', lineHeight: 1.6 }}>
            <b style={{ color: 'var(--warn)' }}>Beta pricing</b> is fixed and one-time for the analysis and the strategy, per organization (per transaction for M&A, per fund for Portfolio), with a 45-minute strategy walkthrough and 30 days in the workspace.
            The first insights of every module are free on your analysis page; evidence grades are shown on every fact; the unknowable is listed, never guessed. Sensitive detail is asked for only under a mutual NDA you can sign on the page or replace with your own.
          </p>
          <div style={{ textAlign: 'center', marginTop: 16, display: 'flex', gap: 10, justifyContent: 'center', flexWrap: 'wrap' }}><a href="/modules/" className="btn btn-primary">Find your module</a><a href="/app/?demo=1" className="btn btn-ghost">Explore the workspace demo</a></div>
        </div>
      </section>

      <section className="section" id="workspace" style={{ scrollMarginTop: 90, background: 'var(--navy)', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)' }}>
        <div className="wrap">
          <SectionHead over="Running it" center title="The workspace, monthly,<br>by modules and seats."
            sub="The analysis is one-time. Execution runs in the Lojo workspace: the opportunity ledger, approvals, actuals, roadmap, and whoever does the work: your people, a partner you bring, or a Lojo preferred partner. The first 30 days are included with any analysis." />
          <div style={{ maxWidth: 1040, margin: '0 auto' }}><WorkspacePricing workspace={pay && pay.workspace} /></div>
          <div style={{ textAlign: 'center', marginTop: 16, fontSize: 13.5, color: 'var(--fg-muted)' }}>Implementation firms: <a href="/partners/" style={{ color: 'var(--accent)' }}>apply to the preferred partner programme</a>.</div>
        </div>
      </section>

      <section className="section" style={{ background: 'var(--navy)', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)' }}>
        <div className="wrap">
          <SectionHead over="Questions" center title="Before you buy." />
          <PricingFAQ />
        </div>
      </section>

      <section className="section" style={{ textAlign: 'center' }}>
        <div className="wrap">
          <h2 className="display" style={{ fontSize: 'clamp(30px,5vw,56px)', margin: '0 auto', maxWidth: 820 }}>Start with the free report.</h2>
          <p className="lede" style={{ maxWidth: 520, margin: '18px auto 30px', color: 'var(--fg-muted)' }}>Two minutes. Then decide whether the full report is worth {payPrice(pay, 'full_report') || '$499'} to you. Most people decide quickly.</p>
          <a href="/#audit" className="btn btn-primary btn-lg">Get your free report <Icon name="arrow-right" size={20} /></a>
        </div>
      </section>
      <Footer />
    </React.Fragment>);
}

ReactDOM.createRoot(document.getElementById('root')).render(<PricingPage />);
