// Maple Pavers Explorer — FINAL CTA. Render-first: most options are a single
// "See your render" call to action (the render IS the lead capture). Phone is
// (647) 242-8442 throughout.
(function () {
  const { Button, Input, Badge } = window.MaplePaversDesignSystem_8de4d8;
  const { Icon, Overline, Stars, PHOTO, PHONE, startQuote } = window.MP;
  const CONSENT = 'We\u2019ll only use this to send your render and follow up once. No spam, ever.';

  function RenderCta({ children, glow }) {
    return (
      <button onClick={startQuote} className={'mp-press' + (glow ? ' mp-cta-cue' : '')} style={{ width: '100%', border: 0, cursor: 'pointer', background: 'var(--terracotta)', color: '#fff', borderRadius: 'var(--radius)', padding: '17px', fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 14, letterSpacing: '0.08em', textTransform: 'uppercase', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 10 }}>
        <Icon name="sparkles" size={17} /> {children} <Icon name="arrow" size={17} />
      </button>
    );
  }

  function AddressField({ onDark }) {
    const [val, setVal] = React.useState('');
    return (
      <div style={{ display: 'flex', alignItems: 'center', gap: 8, border: '1px solid', borderColor: onDark ? 'rgba(248,240,229,0.3)' : 'var(--border-default)', borderRadius: 'var(--radius)', padding: '12px 13px', background: onDark ? 'rgba(248,240,229,0.06)' : 'var(--white)' }}>
        <Icon name="map-pin" size={17} color="var(--terracotta)" />
        <input value={val} onChange={(e) => setVal(e.target.value)} placeholder="Your address in the GTA"
          style={{ flex: 1, border: 0, outline: 'none', fontFamily: 'var(--font-body)', fontSize: 16, background: 'transparent', color: onDark ? 'var(--beige-150)' : 'var(--text-body)', minWidth: 0 }} />
      </div>
    );
  }

  // ── 1 — Dark, render-only (their pick) ──
  function CtaDark() {
    return (
      <section style={{ background: '#141414', padding: '60px 22px', textAlign: 'center' }}>
        <Overline onDark color="var(--clay)">Free · No Obligation</Overline>
        <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 34, lineHeight: 1.08, color: 'var(--beige-150)', margin: '12px 0 0' }}>
          Ready to lose the cracked asphalt?
        </h2>
        <p style={{ fontFamily: 'var(--font-body)', fontSize: 15, lineHeight: '23px', color: 'var(--text-on-dark-muted)', margin: '14px auto 26px', maxWidth: 320 }}>
          See your home redone in a premium paver finish — free, in 90 seconds. The hardest part is uploading a photo.
        </p>
        <RenderCta glow>Design My Driveway</RenderCta>
        <a href="tel:+16472428442" style={{ display: 'inline-flex', alignItems: 'center', gap: 8, marginTop: 18, whiteSpace: 'nowrap', fontFamily: 'var(--font-body)', fontSize: 13, color: 'var(--text-on-dark-muted)' }}>
          <Icon name="phone" size={15} color="var(--clay)" /> Or call {PHONE}
        </a>
      </section>
    );
  }

  // ── 2 — Terracotta banner, render-only ──
  function CtaBanner() {
    return (
      <section style={{ background: 'var(--terracotta)', padding: '56px 22px', textAlign: 'center' }}>
        <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 38, lineHeight: 1.04, color: '#fff', margin: 0 }}>
          See your render.<br />Free.
        </h2>
        <p style={{ fontFamily: 'var(--font-body)', fontSize: 14.5, lineHeight: '22px', color: 'rgba(255,255,255,0.9)', margin: '14px auto 24px', maxWidth: 300 }}>
          Your driveway, redesigned and priced in about 90 seconds. No salesperson, no obligation.
        </p>
        <button onClick={startQuote} className="mp-press" style={{ width: '100%', border: 0, cursor: 'pointer', background: 'var(--graphite)', color: 'var(--beige-150)', borderRadius: 'var(--radius)', padding: '17px', fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 14, letterSpacing: '0.08em', textTransform: 'uppercase', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 10 }}>
          <Icon name="sparkles" size={17} color="var(--clay)" /> Design My Driveway <Icon name="arrow" size={17} />
        </button>
        <div style={{ display: 'flex', justifyContent: 'center', gap: 7, marginTop: 16 }}>
          <Stars count={5} size={14} color="#fff" />
          <span style={{ fontFamily: 'var(--font-body)', fontSize: 12, color: 'rgba(255,255,255,0.9)' }}>4.9 · 512 reviews</span>
        </div>
      </section>
    );
  }

  // ── 3 — Photo background, address + render (render-only) ──
  function CtaPhoto() {
    return (
      <section style={{ position: 'relative', overflow: 'hidden', padding: '56px 22px' }}>
        <div style={{ position: 'absolute', inset: 0, backgroundImage: `url(${PHOTO}hero-wide.png)`, backgroundSize: 'cover', backgroundPosition: 'center' }} />
        <div style={{ position: 'absolute', inset: 0, background: 'rgba(20,18,16,0.82)' }} />
        <div style={{ position: 'relative' }}>
          <div style={{ textAlign: 'center', marginBottom: 20 }}>
            <Overline onDark color="var(--clay)">See It Before We Build It</Overline>
            <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 30, lineHeight: 1.08, color: 'var(--beige-150)', margin: '10px 0 0' }}>Your free render, one tap away.</h2>
          </div>
          <div style={{ background: 'rgba(255,255,255,0.06)', backdropFilter: 'blur(8px)', WebkitBackdropFilter: 'blur(8px)', border: '1px solid rgba(248,240,229,0.18)', borderRadius: 'var(--radius-lg)', padding: 18 }}>
            <div style={{ marginBottom: 12 }}><AddressField onDark /></div>
            <RenderCta glow>Design My Driveway</RenderCta>
            <p style={{ fontFamily: 'var(--font-body)', fontSize: 11.5, color: 'rgba(248,240,229,0.7)', margin: '12px 0 0', textAlign: 'center' }}>{CONSENT}</p>
          </div>
        </div>
      </section>
    );
  }

  // ── 4 — One field → render ──
  function CtaAddress() {
    return (
      <section style={{ background: 'var(--beige-300)', padding: '56px 22px', textAlign: 'center' }}>
        <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 32, lineHeight: 1.06, color: 'var(--text-strong)', margin: 0 }}>One field. 90 seconds.</h2>
        <p style={{ fontFamily: 'var(--font-body)', fontSize: 14.5, color: 'var(--text-muted)', margin: '12px auto 22px', maxWidth: 300 }}>Drop your address and watch your home transform — free.</p>
        <div style={{ marginBottom: 12 }}><AddressField /></div>
        <RenderCta glow>Design My Driveway</RenderCta>
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 16, marginTop: 16, fontFamily: 'var(--font-body)', fontSize: 12, color: 'var(--text-muted)' }}>
          <span style={{ display: 'flex', alignItems: 'center', gap: 6 }}><Icon name="check" size={14} color="var(--success)" /> No obligation</span>
          <span style={{ display: 'flex', alignItems: 'center', gap: 6 }}><Icon name="check" size={14} color="var(--success)" /> No salesperson</span>
        </div>
      </section>
    );
  }

  // ── 5 — Short form (kept for the form-first crowd), render-titled ──
  function CtaForm() {
    return (
      <section style={{ background: 'var(--beige-300)', padding: '54px 22px' }}>
        <div style={{ textAlign: 'center', marginBottom: 22 }}>
          <Overline>Free Render · 48-Hour Response</Overline>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 28, lineHeight: 1.1, color: 'var(--text-strong)', margin: '10px 0 0' }}>See your render.</h2>
        </div>
        <div style={{ background: 'var(--color-surface)', border: '1px solid var(--border-subtle)', borderRadius: 'var(--radius-lg)', boxShadow: 'var(--shadow)', padding: '22px 20px', display: 'flex', flexDirection: 'column', gap: 14 }}>
          <Input label="Full Name" placeholder="Jane Smith" />
          <Input label="Phone" type="tel" placeholder="(647) 242-8442" />
          <Input label="Property Address" placeholder="123 Maple Ave, Toronto" />
          <div style={{ marginTop: 2 }}><RenderCta>Design My Driveway</RenderCta></div>
          <p style={{ fontFamily: 'var(--font-body)', fontSize: 11.5, lineHeight: '17px', color: 'var(--text-muted)', margin: 0, textAlign: 'center' }}>{CONSENT}</p>
        </div>
      </section>
    );
  }

  window.MP.register('cta', {
    label: 'Final CTA',
    options: [
      { id: 'dark', name: '1 · See your render (dark)', Render: CtaDark },
      { id: 'banner', name: '2 · See your render (banner)', Render: CtaBanner },
      { id: 'photo', name: '3 · Render over photo', Render: CtaPhoto },
      { id: 'address', name: '4 · One field → render', Render: CtaAddress },
      { id: 'form', name: '5 · Short form', Render: CtaForm },
    ],
  });
})();
