// Body sections of the RangehandIQ homepage. The hero is 3D (paper +
// dark band). Sections that follow live on paper, in the same editorial
// register: plain language, italic serif used sparingly for the turn,
// mono labels for ledger rows, no decoration that doesn't earn its place.

// ─────────────────────────────────────────────────────────────────────────
// PROBLEM — Why this exists.
// "Your CPA tells you last year's story. The decisions that mattered were
//  made in May." Four observations, then a pilot quote (placeholder).

function ProblemSection() {
  const PROBLEMS = [
    {
      n: '01',
      head: 'The Cost Blind Spot',
      body: "Most operators know their total expenses but can\u2019t tell you what it actually costs to raise each calf. Without that number, every management decision is a guess.",
    },
    {
      n: '02',
      head: 'The Bank Meeting',
      body: "Every fall, ranchers walk in with a tax return and a handshake. A professionally documented financial package — balance sheet, cash flow, key ratios — changes the conversation.",
    },
    {
      n: '03',
      head: 'The Succession Gap',
      body: "The average Intermountain West rancher is in their sixties. Water rights, grazing schedules, vendor relationships, permit history — it lives in one person\u2019s head.",
    },
    {
      n: '04',
      head: 'The Federal Land Layer',
      body: "BLM and Forest Service grazing allotments require specific tracking, documentation, and reporting that no general business tool understands. This is not Iowa row crops.",
    },
  ];

  return (
    <section data-screen-label="Problem" id="problem" style={{
      width: '100%', background: RANCH_TOKENS.paperSoft,
      fontFamily: sansStack, padding: '120px 80px 110px',
      borderTop: `1px solid ${RANCH_TOKENS.hair}`,
    }}>
      {/* Header row — eyebrow + lead statement */}
      <div style={{
        display: 'grid', gridTemplateColumns: '180px 1fr',
        gap: 60, alignItems: 'flex-start', marginBottom: 72,
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 16,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: RANCH_TOKENS.inkMute, opacity: 0.6 }} />
          The problem
        </div>
        <h2 style={{
          margin: 0, maxWidth: 1080,
          fontFamily: sansStack, fontWeight: 400,
          fontSize: 56, lineHeight: 1.08, letterSpacing: '-0.022em',
          color: RANCH_TOKENS.ink, textWrap: 'balance',
        }}>
          Most ranches don&rsquo;t have a financial advisor. They have a CPA who shows up in March,
          a banker who calls in October, and{' '}
          <span style={{
            fontFamily: serifStack, fontStyle: 'italic',
            color: RANCH_TOKENS.brandRed, fontWeight: 400,
          }}>
            a spreadsheet that doesn&rsquo;t know a heifer from a steer.
          </span>
        </h2>
      </div>

      {/* Four observations */}
      <div style={{
        display: 'grid', gridTemplateColumns: '180px 1fr',
        gap: 60, marginBottom: 88,
      }}>
        <div /> {/* gutter for label alignment */}
        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)',
          columnGap: 60, rowGap: 44,
        }}>
          {PROBLEMS.map((p) => (
            <div key={p.n} style={{
              borderTop: `1px solid ${RANCH_TOKENS.hairStrong}`,
              paddingTop: 20, minWidth: 0,
            }}>
              <div style={{
                fontFamily: monoStack, fontSize: 11,
                color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
                marginBottom: 14,
              }}>{p.n}</div>
              <h3 style={{
                margin: '0 0 14px',
                fontFamily: sansStack, fontWeight: 500,
                fontSize: 22, lineHeight: 1.22, letterSpacing: '-0.012em',
                color: RANCH_TOKENS.ink, textWrap: 'balance',
              }}>{p.head}</h3>
              <p style={{
                margin: 0, maxWidth: 460,
                fontFamily: sansStack, fontSize: 16, lineHeight: 1.55,
                color: RANCH_TOKENS.inkSoft, fontWeight: 350,
                letterSpacing: '-0.003em',
              }}>{p.body}</p>
            </div>
          ))}
        </div>
      </div>

      {/* Pilot rancher pull-quote — placeholder until we have a real one */}
      <div style={{
        display: 'grid', gridTemplateColumns: '180px 1fr',
        gap: 60, alignItems: 'flex-start',
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 14,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: RANCH_TOKENS.inkMute, opacity: 0.6 }} />
          From a pilot
        </div>
        <figure style={{ margin: 0, maxWidth: 980 }}>
          <blockquote style={{
            margin: 0,
            fontFamily: serifStack, fontStyle: 'italic', fontWeight: 400,
            fontSize: 38, lineHeight: 1.2, letterSpacing: '-0.012em',
            color: RANCH_TOKENS.ink, textWrap: 'balance',
          }}>
            &ldquo;If it can&rsquo;t fit on the back of an envelope, it&rsquo;s too much.
            RangehandIQ gives you the envelope &mdash; with the math already done.&rdquo;
          </blockquote>
          <figcaption style={{
            marginTop: 22,
            fontFamily: monoStack, fontSize: 11,
            color: RANCH_TOKENS.inkMute, letterSpacing: '0.14em',
            textTransform: 'uppercase',
          }}>
            Box Elder County Rancher
          </figcaption>
        </figure>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────
// HOMEPAGE V1 — continuous page composition.
// Hero (3D) + Problem stacked, no canvas chrome between them, so we can
// see how the type, color and rhythm carry from one section to the next.

// ─────────────────────────────────────────────────────────────────────────
// FEATURES — "Six Problems. One Place."
// 3×2 grid on cream paper. Numbered to rhyme with Problem section.
// One item carries the section's editorial pull-quote.

function FeaturesSection() {
  const FEATURES = [
    {
      n: '01',
      head: 'Lender-Ready Export — One Button.',
      body: 'Balance sheet, cash-flow statement, key ratios. FFSC-aligned. The same package the big operations hand their banker — generated from the books you already keep.',
      meta: 'Green · Yellow · Red',
    },
    {
      n: '02',
      head: 'Spouse & Bookkeeper Access.',
      body: 'Role-based, multi-user. The person doing data entry doesn’t need to see the loan covenants. The person reading them doesn’t need to enter a single receipt.',
      meta: 'Roles · Permissions',
    },
    {
      n: '03',
      head: 'Cost-Per-Cow Benchmarking.',
      body: 'Anonymous comparison against your county and your state. Find out where your operation actually stands — without anyone knowing it’s yours.',
      meta: 'County · State',
    },
    {
      n: '04',
      head: 'Next-Gen Track Record.',
      body: 'FSA eligibility, loan history, three years of clean books — packaged for the day your son or daughter walks into a lender’s office for the first time.',
      meta: 'FSA · Inheritance',
    },
    {
      n: '05',
      head: 'Feed Inventory & Days-to-Grass.',
      body: 'Hay on hand, days of feed remaining, turnout date math. The numbers you already track in your head — and check three times a week — finally written down.',
      meta: 'Inventory · Forecasting',
      pull: '“I count the hay so many times I’ve worn the strings out.”',
      pullAttrib: 'Active ag lender and rancher',
    },
    {
      n: '06',
      head: 'Succession — On Your Terms.',
      body: 'Water rights, grazing schedules, vendor relationships, permit history. The records your kids will inherit, documented at your pace — not under duress.',
      meta: 'Documentation · Inheritance',
    },
  ];

  return (
    <section data-screen-label="Features" id="features" style={{
      width: '100%', background: RANCH_TOKENS.paper,
      fontFamily: sansStack, padding: '120px 64px 110px',
      borderTop: `1px solid ${RANCH_TOKENS.hair}`,
      boxSizing: 'border-box', overflow: 'hidden',
    }}>
      {/* Header */}
      <div style={{
        display: 'grid', gridTemplateColumns: '160px 1fr',
        gap: 48, alignItems: 'flex-start', marginBottom: 84,
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 16,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: RANCH_TOKENS.inkMute, opacity: 0.6 }} />
          What it does
        </div>
        <h2 style={{
          margin: 0, maxWidth: 1080,
          fontFamily: sansStack, fontWeight: 400,
          fontSize: 64, lineHeight: 1.0, letterSpacing: '-0.026em',
          color: RANCH_TOKENS.ink, textWrap: 'balance',
        }}>
          Six problems.{' '}
          <span style={{ fontFamily: serifStack, fontStyle: 'italic', color: RANCH_TOKENS.brandRed }}>
            One place.
          </span>
        </h2>
      </div>

      {/* 3 × 2 grid */}
      <div style={{
        display: 'grid', gridTemplateColumns: '160px 1fr',
        gap: 48,
      }}>
        <div /> {/* gutter */}
        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(3, minmax(0, 1fr))',
          columnGap: 36, rowGap: 56,
        }}>
          {FEATURES.map((f) => (
            <div key={f.n} style={{
              borderTop: `1px solid ${RANCH_TOKENS.hairStrong}`,
              paddingTop: 22, minWidth: 0,
              display: 'flex', flexDirection: 'column', gap: 14,
            }}>
              <div style={{
                fontFamily: monoStack, fontSize: 11,
                color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
              }}>{f.n}<span style={{
                marginLeft: 14, fontSize: 10, letterSpacing: '0.14em',
                textTransform: 'uppercase', opacity: 0.85,
              }}>{f.meta}</span></div>
              <h3 style={{
                margin: 0,
                fontFamily: sansStack, fontWeight: 500,
                fontSize: 22, lineHeight: 1.18, letterSpacing: '-0.012em',
                color: RANCH_TOKENS.ink, textWrap: 'balance',
              }}>{f.head}</h3>
              <p style={{
                margin: 0,
                fontFamily: sansStack, fontSize: 15.5, lineHeight: 1.55,
                color: RANCH_TOKENS.inkSoft, fontWeight: 350,
                letterSpacing: '-0.003em',
              }}>{f.body}</p>
              {f.pull && (
                <figure style={{ margin: '6px 0 0' }}>
                  <blockquote style={{
                    margin: 0,
                    fontFamily: serifStack, fontStyle: 'italic', fontWeight: 400,
                    fontSize: 19, lineHeight: 1.32, letterSpacing: '-0.008em',
                    color: RANCH_TOKENS.ink, textWrap: 'balance',
                  }}>
                    {f.pull}
                  </blockquote>
                  <figcaption style={{
                    marginTop: 10,
                    fontFamily: monoStack, fontSize: 10,
                    color: RANCH_TOKENS.inkMute, letterSpacing: '0.14em',
                    textTransform: 'uppercase',
                  }}>
                    {f.pullAttrib}
                  </figcaption>
                </figure>
              )}
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────
// PERSONAS — "Six Real People. One Tool."
// Stacked rows on paperSoft. Each row: [number + archetype | description].
// Note: "Senior Operator" replaces the live site's "Patriarch."

function PersonasSection() {
  const PERSONAS = [
    {
      n: '01',
      role: 'The Senior Operator',
      meta: '60s+ · Owner',
      body: 'Three generations in. The operation lives in his head and his red book — every gate, every grazing rotation, every handshake. He doesn’t need a new system. He needs his knowledge written down before he hands the reins over.',
    },
    {
      n: '02',
      role: 'The Next-Gen Operator',
      meta: '30s–40s · Heir apparent',
      body: 'Son or daughter coming home. Wants the records to back up the handshake — three years of clean books before the first solo meeting with the lender. Tech-fluent, but not interested in tools that talk down to his father.',
    },
    {
      n: '03a',
      role: 'The Spouse & Bookkeeper',
      meta: 'Senior household · Does the data entry',
      body: 'Often the only person who knows where every receipt actually went. Runs the books at the kitchen table after dinner. Needs the math — and a clean role boundary that means she doesn’t have to read the loan covenants she didn’t sign.',
    },
    {
      n: '03b',
      role: 'The Next-Gen Spouse',
      meta: 'Mid-30s · Initiates the decision',
      body: 'Watching her siblings-in-law build documented equity while her family’s operation lives in a pocket notebook. Has the laptop, the bandwidth, and the patience her husband doesn’t. She finds the tool, sets it up, runs the first lender export — and presents it to him as already working. The first person to read the package when it lands.',
    },
    {
      n: '04',
      role: 'The Ag Lender',
      meta: 'Banker · Annual review',
      body: 'Reads the package in October. Doesn’t have time to translate handwritten receipts into a balance sheet. A FFSC-aligned export from the operation he\u2019s lending to changes the conversation from "trust me" to "here are the numbers."',
    },
    {
      n: '05',
      role: 'The Red Book Operator',
      meta: 'Pocket notebook · 30+ yr',
      body: 'Keeps everything in a pocket notebook because that\u2019s what works. Isn\u2019t going to start over and isn\u2019t going to learn QuickBooks. Will accept a tool that respects the way he already works — and produces what the bank, the CPA, and his daughter all need.',
    },
  ];

  return (
    <section data-screen-label="Personas" id="personas" style={{
      width: '100%', background: RANCH_TOKENS.paperSoft,
      fontFamily: sansStack, padding: '120px 64px 110px',
      borderTop: `1px solid ${RANCH_TOKENS.hair}`,
      boxSizing: 'border-box', overflow: 'hidden',
    }}>
      <div style={{
        display: 'grid', gridTemplateColumns: '160px 1fr',
        gap: 48, alignItems: 'flex-start', marginBottom: 72,
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 16,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: RANCH_TOKENS.inkMute, opacity: 0.6 }} />
          Who it&rsquo;s for
        </div>
        <h2 style={{
          margin: 0, maxWidth: 1080,
          fontFamily: sansStack, fontWeight: 400,
          fontSize: 64, lineHeight: 1.0, letterSpacing: '-0.026em',
          color: RANCH_TOKENS.ink, textWrap: 'balance',
        }}>
          Six real people.{' '}
          <span style={{ fontFamily: serifStack, fontStyle: 'italic', color: RANCH_TOKENS.brandRed }}>
            One tool.
          </span>
        </h2>
      </div>

      <div style={{
        display: 'grid', gridTemplateColumns: '160px 1fr', gap: 48,
      }}>
        <div /> {/* gutter */}
        <div>
          {PERSONAS.map((p) => (
            <div key={p.n} style={{
              display: 'grid', gridTemplateColumns: '60px 1fr 1fr',
              columnGap: 36, alignItems: 'baseline',
              borderTop: `1px solid ${RANCH_TOKENS.hairStrong}`,
              padding: '28px 0 32px', minWidth: 0,
            }}>
              <div style={{
                fontFamily: monoStack, fontSize: 11,
                color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
              }}>{p.n}</div>
              <div style={{ minWidth: 0 }}>
                <h3 style={{
                  margin: 0,
                  fontFamily: sansStack, fontWeight: 500,
                  fontSize: 28, lineHeight: 1.12, letterSpacing: '-0.016em',
                  color: RANCH_TOKENS.ink,
                }}>{p.role}</h3>
                <div style={{
                  marginTop: 10,
                  fontFamily: monoStack, fontSize: 10,
                  color: RANCH_TOKENS.inkMute, letterSpacing: '0.14em',
                  textTransform: 'uppercase',
                }}>{p.meta}</div>
              </div>
              <p style={{
                margin: 0, minWidth: 0,
                fontFamily: sansStack, fontSize: 16, lineHeight: 1.55,
                color: RANCH_TOKENS.inkSoft, fontWeight: 350,
                letterSpacing: '-0.003em',
              }}>{p.body}</p>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────
// COUNTRY BAND — Geographic positioning interstitial.
// Wide horizon photo with editorial pull-line + state list.

function CountryBand() {
  const STATES = [
    ['UT', 'Utah'], ['ID', 'Idaho'], ['WY', 'Wyoming'],
    ['MT', 'Montana'], ['NV', 'Nevada'], ['CO', 'Colorado'],
  ];
  return (
    <section data-screen-label="Country band" id="country" style={{
      width: '100%', background: RANCH_TOKENS.ink,
      fontFamily: sansStack, position: 'relative',
      overflow: 'hidden', boxSizing: 'border-box',
    }}>
      <img src="img/cattle-drive.jpg" alt="" style={{
        position: 'absolute', inset: 0, width: '100%', height: '100%',
        objectFit: 'cover', objectPosition: 'center 40%',
        opacity: 0.55,
      }} />
      <div style={{
        position: 'absolute', inset: 0,
        background: 'linear-gradient(180deg, rgba(28,22,16,.72) 0%, rgba(28,22,16,.55) 50%, rgba(28,22,16,.78) 100%)',
      }} />
      <div style={{
        position: 'relative', zIndex: 1,
        padding: '110px 64px 96px',
        display: 'grid', gridTemplateColumns: '160px 1fr', gap: 48,
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: 'oklch(0.78 0.020 70)', letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 16,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: 'oklch(0.78 0.020 70)', opacity: 0.6 }} />
          Our country
        </div>
        <div>
          <h2 style={{
            margin: 0, maxWidth: 1080,
            fontFamily: sansStack, fontWeight: 400,
            fontSize: 60, lineHeight: 1.04, letterSpacing: '-0.024em',
            color: 'oklch(0.94 0.018 75)', textWrap: 'balance',
          }}>
            This is Intermountain West ranching &mdash;{' '}
            <span style={{ fontFamily: serifStack, fontStyle: 'italic', color: 'oklch(0.78 0.115 28)' }}>
              not Iowa row crops.
            </span>{' '}
            The tools should know the difference.
          </h2>
          <div style={{
            marginTop: 56,
            display: 'grid', gridTemplateColumns: 'repeat(6, minmax(0, 1fr))',
            columnGap: 24,
          }}>
            {STATES.map(([abbr, name]) => (
              <div key={abbr} style={{
                borderTop: '1px solid oklch(0.50 0.020 70 / 0.55)',
                paddingTop: 14, minWidth: 0,
              }}>
                <div style={{
                  fontFamily: sansStack, fontWeight: 500,
                  fontSize: 22, letterSpacing: '-0.012em',
                  color: 'oklch(0.94 0.018 75)',
                }}>{abbr}</div>
                <div style={{
                  marginTop: 4,
                  fontFamily: monoStack, fontSize: 10,
                  color: 'oklch(0.78 0.020 70)', letterSpacing: '0.14em',
                  textTransform: 'uppercase',
                }}>{name}</div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────
// EARLY ACCESS — Form section. Two-column: editorial left, form right.

// Form name is the key Netlify uses to bucket submissions in the dashboard.
// Notification recipient (sales_support@rangehandiq.com) is configured in the
// Netlify UI under Forms → early-access → Form notifications. There is also
// a hidden static <form name="early-access"> in index.html so Netlify's
// build-time crawler can register the form before React renders the real one.
const EARLY_ACCESS_FORM_NAME = 'early-access';

function EarlyAccessForm({ inputBase, labelBase }) {
  const [status, setStatus] = React.useState('idle'); // idle | submitting | success | error
  const [errorMsg, setErrorMsg] = React.useState('');

  const encode = (data) => Object.keys(data)
    .map((k) => encodeURIComponent(k) + '=' + encodeURIComponent(data[k] ?? ''))
    .join('&');

  const onSubmit = (e) => {
    e.preventDefault();
    if (status === 'submitting') return;
    const form = e.currentTarget;
    const fd = new FormData(form);
    // Honeypot — silent no-op if filled (a bot did it).
    if (fd.get('bot-field')) { setStatus('success'); return; }
    const payload = { 'form-name': EARLY_ACCESS_FORM_NAME };
    fd.forEach((v, k) => { payload[k] = v; });
    setStatus('submitting');
    fetch('/', {
      method: 'POST',
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
      body: encode(payload),
    })
      .then((r) => {
        if (!r.ok) throw new Error('Submission failed (' + r.status + ')');
        setStatus('success');
      })
      .catch((err) => {
        setErrorMsg(err.message || 'Something went wrong.');
        setStatus('error');
      });
  };

  if (status === 'success') {
    return (
      <div style={{ minWidth: 0, paddingTop: 16 }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.brandRed, letterSpacing: '0.16em',
          textTransform: 'uppercase', marginBottom: 18,
        }}>Received</div>
        <h3 style={{
          margin: 0, maxWidth: 520,
          fontFamily: sansStack, fontWeight: 400,
          fontSize: 36, lineHeight: 1.12, letterSpacing: '-0.018em',
          color: RANCH_TOKENS.ink, textWrap: 'balance',
        }}>
          Thank you. We&rsquo;ll be in touch{' '}
          <span style={{ fontFamily: serifStack, fontStyle: 'italic', color: RANCH_TOKENS.brandRed }}>
            within 24&ndash;48 hours.
          </span>
        </h3>
        <p style={{
          margin: '24px 0 0', maxWidth: 480,
          fontFamily: sansStack, fontSize: 16, lineHeight: 1.55,
          color: RANCH_TOKENS.inkSoft, fontWeight: 350, letterSpacing: '-0.003em',
        }}>
          A note from Matt will land in the inbox you provided. No automated drip,
          no sales sequence &mdash; just a real reply.
        </p>
      </div>
    );
  }

  return (
    <form
      name={EARLY_ACCESS_FORM_NAME}
      method="POST"
      data-netlify="true"
      data-netlify-honeypot="bot-field"
      onSubmit={onSubmit}
      style={{ display: 'flex', flexDirection: 'column', gap: 28, minWidth: 0 }}
    >
      {/* Required by Netlify when posted via fetch (matches the static form in index.html). */}
      <input type="hidden" name="form-name" value={EARLY_ACCESS_FORM_NAME} />
      {/* Honeypot — `hidden` attribute keeps the input in the DOM (so HTML-parsing
          bots see + fill it) but renders display:none for real users. */}
      <p hidden aria-hidden="true">
        <label>Don&rsquo;t fill this out if you&rsquo;re human:
          <input name="bot-field" tabIndex="-1" autoComplete="off" />
        </label>
      </p>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 32 }}>
        <div style={{ minWidth: 0 }}>
          <label style={labelBase} htmlFor="ea-name">Name</label>
          <input id="ea-name" name="name" type="text" required placeholder="Your name" style={inputBase} />
        </div>
        <div style={{ minWidth: 0 }}>
          <label style={labelBase} htmlFor="ea-phone">Phone</label>
          <input id="ea-phone" name="phone" type="tel" placeholder="Optional" style={inputBase} />
        </div>
      </div>
      <div>
        <label style={labelBase} htmlFor="ea-email">Email</label>
        <input id="ea-email" name="email" type="email" required placeholder="you@ranch.com" style={inputBase} />
      </div>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 32 }}>
        <div style={{ minWidth: 0 }}>
          <label style={labelBase} htmlFor="ea-state">State</label>
          <select id="ea-state" name="state" required defaultValue="" style={{ ...inputBase, appearance: 'none', cursor: 'pointer' }}>
            <option value="" disabled>Select…</option>
            <option>Utah</option>
            <option>Idaho</option>
            <option>Wyoming</option>
            <option>Montana</option>
            <option>Nevada</option>
            <option>Colorado</option>
            <option>Other</option>
          </select>
        </div>
        <div style={{ minWidth: 0 }}>
          <label style={labelBase} htmlFor="ea-herd">Herd size</label>
          <select id="ea-herd" name="herd_size" required defaultValue="" style={{ ...inputBase, appearance: 'none', cursor: 'pointer' }}>
            <option value="" disabled>Select…</option>
            <option>Under 250</option>
            <option>250 – 500</option>
            <option>500 – 750</option>
            <option>750 – 1,000</option>
            <option>Over 1,000</option>
          </select>
        </div>
      </div>
      <div>
        <label style={labelBase} htmlFor="ea-role">Role</label>
        <select id="ea-role" name="role" required defaultValue="" style={{ ...inputBase, appearance: 'none', cursor: 'pointer' }}>
          <option value="" disabled>Select…</option>
          <option>Owner / Senior operator</option>
          <option>Next-gen operator</option>
          <option>Spouse / Bookkeeper</option>
          <option>Ag lender</option>
          <option>Extension agent</option>
          <option>Manager</option>
          <option>Other</option>
        </select>
      </div>
      <div>
        <label style={labelBase} htmlFor="ea-question">Where do current tools fail you?</label>
        <textarea
          id="ea-question" name="question"
          rows={3}
          placeholder="Optional, but appreciated."
          style={{ ...inputBase, resize: 'vertical', minHeight: 64 }}
        />
      </div>
      <div style={{ display: 'flex', alignItems: 'center', gap: 16, marginTop: 8, flexWrap: 'wrap' }}>
        <button type="submit" disabled={status === 'submitting'} style={{
          display: 'inline-flex', alignItems: 'center', gap: 10,
          fontFamily: sansStack, fontSize: 14, fontWeight: 500,
          color: RANCH_TOKENS.paper, background: RANCH_TOKENS.brandRed,
          border: 'none', cursor: status === 'submitting' ? 'wait' : 'pointer',
          opacity: status === 'submitting' ? 0.7 : 1,
          padding: '14px 24px', borderRadius: 2, letterSpacing: '0.005em',
        }}>
          {status === 'submitting' ? 'Sending…' : 'Request access'}
          <span style={{ fontSize: 16, lineHeight: 1, marginTop: -1 }}>&rarr;</span>
        </button>
        <span style={{
          fontFamily: monoStack, fontSize: 10,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.14em',
          textTransform: 'uppercase',
        }}>Reviewed personally · 24–48 hr response</span>
      </div>
      {status === 'error' && (
        <div role="alert" style={{
          fontFamily: sansStack, fontSize: 14, lineHeight: 1.5,
          color: RANCH_TOKENS.brandRed,
          padding: '12px 14px',
          border: `1px solid ${RANCH_TOKENS.brandRed}`,
          borderRadius: 2, background: 'oklch(0.94 0.030 28 / 0.5)',
        }}>
          {errorMsg} Please email <a href="mailto:sales_support@rangehandiq.com" style={{ color: RANCH_TOKENS.brandRed }}>sales_support@rangehandiq.com</a> directly and we&rsquo;ll pick it up from there.
        </div>
      )}
    </form>
  );
}

function EarlyAccessSection() {
  const inputBase = {
    width: '100%', boxSizing: 'border-box',
    fontFamily: sansStack, fontSize: 15, fontWeight: 400,
    color: RANCH_TOKENS.ink,
    background: 'transparent',
    border: 'none',
    borderBottom: `1px solid ${RANCH_TOKENS.hairStrong}`,
    padding: '14px 2px 12px',
    outline: 'none',
  };
  const labelBase = {
    fontFamily: monoStack, fontSize: 10,
    color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
    textTransform: 'uppercase', display: 'block',
    marginBottom: 4,
  };
  return (
    <section data-screen-label="Early access" id="early-access" style={{
      width: '100%', background: RANCH_TOKENS.paper,
      fontFamily: sansStack, padding: '120px 64px 110px',
      borderTop: `1px solid ${RANCH_TOKENS.hair}`,
      boxSizing: 'border-box', overflow: 'hidden',
    }}>
      <div style={{
        display: 'grid', gridTemplateColumns: '160px 1fr', gap: 48,
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 16,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: RANCH_TOKENS.inkMute, opacity: 0.6 }} />
          Early access
        </div>

        <div style={{
          display: 'grid', gridTemplateColumns: '1fr 1.1fr',
          columnGap: 80, alignItems: 'flex-start',
        }}>
          {/* Editorial left */}
          <div style={{ minWidth: 0 }}>
            <h2 style={{
              margin: 0, maxWidth: 520,
              fontFamily: sansStack, fontWeight: 400,
              fontSize: 56, lineHeight: 1.02, letterSpacing: '-0.024em',
              color: RANCH_TOKENS.ink, textWrap: 'balance',
            }}>
              Tell us where the{' '}
              <span style={{ fontFamily: serifStack, fontStyle: 'italic', color: RANCH_TOKENS.brandRed }}>
                current tools
              </span>{' '}
              fail you.
            </h2>
            <p style={{
              margin: '32px 0 0', maxWidth: 480,
              fontFamily: sansStack, fontSize: 17, lineHeight: 1.5,
              color: RANCH_TOKENS.inkSoft, fontWeight: 350, letterSpacing: '-0.003em',
            }}>
              Private beta is by invitation. We&rsquo;re looking for operators in
              the Intermountain West &mdash; 250&ndash;1,000 head &mdash; willing
              to be honest about what doesn&rsquo;t work today.
            </p>
            <p style={{
              margin: '24px 0 0',
              fontFamily: serifStack, fontStyle: 'italic',
              fontSize: 18, lineHeight: 1.4,
              color: RANCH_TOKENS.ink,
            }}>
              No spam. No sales calls. We&rsquo;ll be in touch personally.
            </p>
            <div style={{
              marginTop: 40, display: 'flex', flexDirection: 'column', gap: 6,
            }}>
              <div style={{
                fontFamily: monoStack, fontSize: 10,
                color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
                textTransform: 'uppercase',
              }}>Or, if you&rsquo;d rather talk first</div>
              <a href="mailto:matt.rose@rangehandiq.com" style={{
                fontFamily: sansStack, fontSize: 17, fontWeight: 500,
                color: RANCH_TOKENS.ink, textDecoration: 'none',
                borderBottom: `1px solid ${RANCH_TOKENS.ink}`,
                paddingBottom: 2, alignSelf: 'flex-start',
              }}>matt.rose@rangehandiq.com &rarr;</a>
            </div>
          </div>

          {/* Form right */}
          <EarlyAccessForm inputBase={inputBase} labelBase={labelBase} />
        </div>
      </div>
    </section>
  );
}

function HomepageV1() {
  return (
    <div data-screen-label="Homepage v1" style={{
      width: '100%', background: RANCH_TOKENS.paperSoft,
      fontFamily: sansStack,
    }}>
      <div style={{ height: 900 }}>
        <Hero3D />
      </div>
      <ProblemSection />
      <FeaturesSection />
      <ProductProofSection />
      <PersonasSection />
      <CountryBand />
      <FounderNote mode="short" />
      <EarlyAccessSection />
      <FooterSection />
    </div>
  );
}

// ─────────────────────────────────────────────────────────────────────────
// FOUNDER NOTE — Matt Rose. Two versions: short (homepage inline) and full
// (linked or expanded). Editorial register, plain language, signature.

function FounderNote({ mode = 'short' }) {
  const isShort = mode === 'short';
  return (
    <section data-screen-label={`Founder note (${mode})`} id="founder" style={{
      width: '100%', background: RANCH_TOKENS.paper,
      fontFamily: sansStack, padding: '110px 80px 110px',
      borderTop: `1px solid ${RANCH_TOKENS.hair}`,
    }}>
      <div style={{
        display: 'grid', gridTemplateColumns: '180px 1fr',
        gap: 60, alignItems: 'flex-start',
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 16,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: RANCH_TOKENS.inkMute, opacity: 0.6 }} />
          {isShort ? 'Founder' : 'Founder note'}
        </div>

        <div style={{ maxWidth: 920 }}>
          {isShort ? (
            <p style={{
              margin: 0,
              fontFamily: sansStack, fontWeight: 400,
              fontSize: 32, lineHeight: 1.32, letterSpacing: '-0.014em',
              color: RANCH_TOKENS.ink, textWrap: 'pretty',
            }}>
              My dad spent 50+ years as a rancher and then an agricultural lender.
              My family has run cattle in Park Valley, Utah for three generations.
              I grew up watching both sides of that desk &mdash; and watching{' '}
              <span style={{ fontFamily: serifStack, fontStyle: 'italic', color: RANCH_TOKENS.brandRed }}>
                a structural gap that nobody had bothered to close.
              </span>{' '}
              RangehandIQ is my attempt to close it.
            </p>
          ) : (
            <div style={{
              fontFamily: sansStack, fontSize: 19, lineHeight: 1.55,
              color: RANCH_TOKENS.inkSoft, fontWeight: 350, letterSpacing: '-0.003em',
            }}>
              <p style={{ margin: '0 0 1em' }}>
                My dad spent 50+ years as a rancher and then an agricultural lender in southeast
                Idaho. My cousin and uncle have run cattle in Park Valley, Utah for three
                generations &mdash; the same Box Elder County country this tool is built for.
                I grew up watching both sides of that desk.
              </p>
              <p style={{ margin: '0 0 1em' }}>
                What I watched was a structural gap that nobody had bothered to close. The
                rancher&rsquo;s knowledge lives in his head and his red book. The lender works
                from annual snapshots. The CPA files the return in March. And the decisions that
                actually mattered &mdash; what to keep, what to cut, when to sell &mdash; happened
                in real time, months before any of those conversations.
              </p>
              <p style={{ margin: '0 0 1em' }}>
                It works. These families make it work. But they do it without the financial clarity
                that larger operations take for granted.
              </p>
              <p style={{
                margin: '0 0 1em',
                fontFamily: serifStack, fontStyle: 'italic', fontSize: 24,
                color: RANCH_TOKENS.ink, letterSpacing: '-0.008em',
              }}>
                The big ranches have people for this. The 400-head family operation doesn&rsquo;t.
              </p>
              <p style={{ margin: '0 0 1em' }}>
                RangehandIQ is my attempt to close that gap. Financial intelligence connected to
                the books you already keep, built on standards your lender already trusts, and
                designed to produce the records your kids will inherit.
              </p>
              <p style={{ margin: 0 }}>
                I&rsquo;m building this in private beta right now, and I&rsquo;d rather get it
                right than get it fast. If you run cattle in this country and you&rsquo;re willing
                to tell me where the current tools fail you, I want to hear from you.
              </p>
            </div>
          )}

          <div style={{
            marginTop: isShort ? 30 : 40,
            display: 'flex', alignItems: 'baseline', gap: 14,
            fontFamily: serifStack, fontStyle: 'italic',
            fontSize: 22, color: RANCH_TOKENS.ink,
          }}>
            <span>&mdash; Matt Rose</span>
            <span style={{
              fontFamily: monoStack, fontStyle: 'normal', fontSize: 11,
              color: RANCH_TOKENS.inkMute, letterSpacing: '0.14em',
              textTransform: 'uppercase',
            }}>
              {isShort ? 'Founder' : 'Park Valley, Utah'}
            </span>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────
// FOOTER — Dark colophon. Wordmark + closing line, then three columns
// (sitemap · contact · FFSC disclaimer), then a hairline copyright row.

function FooterSection() {
  const ink = 'oklch(0.18 0.012 60)';            // bark, matches Country band
  const cream = 'oklch(0.94 0.018 75)';          // paper on dark
  const muted = 'oklch(0.66 0.014 70)';          // soft sand
  const hair = 'oklch(0.32 0.014 65)';           // hairline on dark
  const oxblood = 'oklch(0.58 0.118 28)';

  const linkBase = {
    fontFamily: sansStack, fontSize: 15, fontWeight: 400,
    color: cream, textDecoration: 'none',
    letterSpacing: '-0.003em', display: 'block',
    padding: '4px 0',
  };
  const colLabel = {
    fontFamily: monoStack, fontSize: 10,
    color: muted, letterSpacing: '0.16em',
    textTransform: 'uppercase', marginBottom: 18,
  };

  const NAV = [
    { label: 'The problem', href: '#problem' },
    { label: 'What it does', href: '#features' },
    { label: 'The report', href: '#report' },
    { label: 'Who it\u2019s for', href: '#personas' },
    { label: 'Our country', href: '#country' },
    { label: 'Founder note', href: '#founder' },
    { label: 'Request access', href: '#early-access' },
  ];

  return (
    <footer data-screen-label="Footer" style={{
      width: '100%', background: ink,
      fontFamily: sansStack, padding: '110px 64px 36px',
      borderTop: `1px solid ${hair}`,
      boxSizing: 'border-box', position: 'relative', overflow: 'hidden',
    }}>
      {/* Top band — wordmark + closing line */}
      <div style={{
        display: 'grid', gridTemplateColumns: '1.3fr 1fr',
        columnGap: 80, alignItems: 'flex-end',
        paddingBottom: 60,
        borderBottom: `1px solid ${hair}`,
      }}>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
          <img src="img/logo-dark.png" alt="RangehandIQ"
            style={{ height: 84, width: 'auto', display: 'block', alignSelf: 'flex-start' }}
          />
          <div style={{
            fontFamily: monoStack, fontSize: 11,
            color: muted, letterSpacing: '0.18em',
            textTransform: 'uppercase',
          }}>
            Cow-calf operations &middot; 250&ndash;1,000 head &middot; Intermountain West
          </div>
        </div>

        <p style={{
          margin: 0, maxWidth: 520, justifySelf: 'flex-end',
          fontFamily: serifStack, fontStyle: 'italic', fontWeight: 400,
          fontSize: 30, lineHeight: 1.22, letterSpacing: '-0.012em',
          color: cream, textWrap: 'balance', textAlign: 'right',
        }}>
          Built for the ranches that built the{' '}
          <span style={{ color: oxblood }}>West.</span>
        </p>
      </div>

      {/* Three columns — sitemap · contact · disclaimer */}
      <div style={{
        display: 'grid', gridTemplateColumns: '1fr 1fr 1.4fr',
        columnGap: 80, padding: '60px 0 56px',
      }}>
        {/* Sitemap */}
        <nav>
          <div style={colLabel}>This page</div>
          <div>
            {NAV.map((n) => (
              <a key={n.href} href={n.href} style={linkBase}>{n.label}</a>
            ))}
          </div>
        </nav>

        {/* Contact */}
        <div>
          <div style={colLabel}>Contact</div>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
            <a href="mailto:matt.rose@rangehandiq.com" style={{
              ...linkBase, padding: 0,
              borderBottom: `1px solid ${muted}`, paddingBottom: 4,
              alignSelf: 'flex-start',
            }}>matt.rose@rangehandiq.com</a>
            <div style={{
              fontFamily: monoStack, fontSize: 10,
              color: muted, letterSpacing: '0.16em',
              textTransform: 'uppercase',
            }}>
              Phone by appointment &middot; After first email
            </div>
            <div style={{
              fontFamily: sansStack, fontSize: 15, fontWeight: 350,
              color: muted, lineHeight: 1.5, letterSpacing: '-0.003em',
            }}>
              Reviewed personally.<br />
              24&ndash;48 hour response.
            </div>
          </div>
        </div>

        {/* Disclaimer */}
        <div>
          <div style={colLabel}>Standards &amp; disclaimer</div>
          <p style={{
            margin: 0,
            fontFamily: sansStack, fontSize: 13.5, lineHeight: 1.55,
            color: muted, fontWeight: 350, letterSpacing: '-0.002em',
            maxWidth: 480,
          }}>
            Reports follow{' '}
            <span style={{ color: cream }}>Farm Financial Standards Council (FFSC)</span>{' '}
            guidelines and produce balance sheet, cash flow, and key-ratio outputs your
            lender already trusts. RangehandIQ is a financial management tool, not a
            substitute for professional accounting, tax, or legal advice. Talk to your
            CPA, your attorney, and your lender about decisions that matter.
          </p>
        </div>
      </div>

      {/* Bottom row — copyright + meta */}
      <div style={{
        display: 'flex', justifyContent: 'space-between',
        alignItems: 'baseline', flexWrap: 'wrap', gap: 16,
        paddingTop: 28, borderTop: `1px solid ${hair}`,
        fontFamily: monoStack, fontSize: 10,
        color: muted, letterSpacing: '0.16em',
        textTransform: 'uppercase',
      }}>
        <div>&copy; 2026 RangehandIQ, LLC &middot; All rights reserved</div>
        <div style={{ display: 'flex', gap: 24 }}>
          <a href="privacy.html" style={{ color: muted, textDecoration: 'none' }}>Privacy</a>
          <a href="terms.html" style={{ color: muted, textDecoration: 'none' }}>Terms</a>
          <span>Private beta &middot; v0.1</span>
        </div>
      </div>
    </footer>
  );
}

// ─────────────────────────────────────────────────────────────────────────
// PRODUCT PROOF — "The report your lender wants."
// Lender export image as primary; dashboard mobile inset as secondary.

function ProductProofSection() {
  return (
    <section data-screen-label="Product proof" id="report" style={{
      width: '100%', background: RANCH_TOKENS.paperSoft,
      fontFamily: sansStack, padding: '120px 64px 110px',
      borderTop: `1px solid ${RANCH_TOKENS.hair}`,
      boxSizing: 'border-box', overflow: 'hidden',
    }}>
      <div style={{
        display: 'grid', gridTemplateColumns: '160px 1fr',
        gap: 48, alignItems: 'flex-start', marginBottom: 64,
      }}>
        <div style={{
          fontFamily: monoStack, fontSize: 11,
          color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
          textTransform: 'uppercase', paddingTop: 16,
          display: 'flex', alignItems: 'center', gap: 12,
        }}>
          <span style={{ width: 28, height: 1, background: RANCH_TOKENS.inkMute, opacity: 0.6 }} />
          The report
        </div>
        <div>
          <h2 style={{
            margin: 0, maxWidth: 1080,
            fontFamily: sansStack, fontWeight: 400,
            fontSize: 64, lineHeight: 1.0, letterSpacing: '-0.026em',
            color: RANCH_TOKENS.ink, textWrap: 'balance',
          }}>
            The report your{' '}
            <span style={{ fontFamily: serifStack, fontStyle: 'italic', color: RANCH_TOKENS.brandRed }}>
              lender already trusts.
            </span>
          </h2>
          <p style={{
            margin: '28px 0 0', maxWidth: 720,
            fontFamily: sansStack, fontSize: 18, lineHeight: 1.5,
            color: RANCH_TOKENS.inkSoft, fontWeight: 350, letterSpacing: '-0.003em',
          }}>
            Balance sheet, cash-flow statement, key ratios &mdash; FFSC-aligned and
            generated from the books you already keep. The same package the big
            operations hand their banker, on one button.
          </p>
        </div>
      </div>

      {/* Image stage */}
      <div style={{
        display: 'grid', gridTemplateColumns: '160px 1fr', gap: 48,
      }}>
        <div /> {/* gutter */}
        <div style={{ position: 'relative', minWidth: 0 }}>
          {/* Primary: lender export */}
          <div style={{
            position: 'relative',
            background: RANCH_TOKENS.paper,
            border: `1px solid ${RANCH_TOKENS.hairStrong}`,
            boxShadow: '0 24px 60px -28px rgba(28,22,16,0.28), 0 2px 6px rgba(28,22,16,0.06)',
            overflow: 'hidden',
          }}>
            <img src="img/report-lender-export.png" alt="RangehandIQ lender package preview"
              style={{ display: 'block', width: '100%', height: 'auto' }} />
            <div style={{
              position: 'absolute', top: 16, right: 16,
              fontFamily: monoStack, fontSize: 10,
              color: RANCH_TOKENS.paper, background: 'rgba(28,22,16,0.78)',
              letterSpacing: '0.16em', textTransform: 'uppercase',
              padding: '6px 10px', borderRadius: 2,
            }}>Sample &middot; Fictional operation</div>
          </div>

          {/* Secondary: dashboard mobile inset, overlapping bottom-right */}
          <div style={{
            position: 'absolute',
            right: -24, bottom: -48,
            width: 360,
            background: RANCH_TOKENS.paperSoft,
            border: `1px solid ${RANCH_TOKENS.hairStrong}`,
            borderRadius: 18,
            boxShadow: '0 28px 60px -20px rgba(28,22,16,0.32)',
            overflow: 'hidden',
            transform: 'rotate(2.5deg)',
          }}>
            <img src="img/report-dashboard.png" alt="RangehandIQ in-app dashboard"
              style={{ display: 'block', width: '100%', height: 'auto' }} />
          </div>

          {/* Caption + actions */}
          <div style={{
            marginTop: 56,
            display: 'grid', gridTemplateColumns: '1fr auto',
            columnGap: 40, alignItems: 'flex-end',
            paddingTop: 24, borderTop: `1px solid ${RANCH_TOKENS.hairStrong}`,
          }}>
            <div>
              <div style={{
                fontFamily: monoStack, fontSize: 10,
                color: RANCH_TOKENS.inkMute, letterSpacing: '0.16em',
                textTransform: 'uppercase', marginBottom: 8,
              }}>What&rsquo;s inside</div>
              <p style={{
                margin: 0, maxWidth: 720,
                fontFamily: sansStack, fontSize: 16, lineHeight: 1.55,
                color: RANCH_TOKENS.inkSoft, fontWeight: 350, letterSpacing: '-0.003em',
              }}>
                Financial health snapshot &middot; balance sheet &middot; cash flow &middot;
                debt service and coverage ratios &middot; cost-per-cow benchmark
                against your county and your state. One PDF. Every number traceable.
              </p>
            </div>
            <a href="report/lender-export.html" target="_blank" rel="noopener" style={{
              display: 'inline-flex', alignItems: 'center', gap: 10,
              fontFamily: sansStack, fontSize: 14, fontWeight: 500,
              color: RANCH_TOKENS.ink,
              borderBottom: `1px solid ${RANCH_TOKENS.ink}`,
              paddingBottom: 4, textDecoration: 'none',
              whiteSpace: 'nowrap',
            }}>
              View sample report
              <span style={{ fontSize: 16, lineHeight: 1, marginTop: -1 }}>&rarr;</span>
            </a>
          </div>
        </div>
      </div>
    </section>
  );
}

Object.assign(window, {
  ProductProofSection, ProblemSection, FeaturesSection, PersonasSection,
  CountryBand, EarlyAccessSection, FounderNote, FooterSection, HomepageV1,
});
