// Maple Pavers Explorer — PROCESS / HOW IT WORKS, 5 variants.
(function () {
  const { Icon, Overline, PHOTO } = window.MP;
  const STEPS = window.MP.data.process;
  const Heading = ({ onDark }) => (
    <div style={{ textAlign: 'center', marginBottom: 28 }}>
      <Overline onDark>How It Works</Overline>
      <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 28, lineHeight: 1.12, color: onDark ? 'var(--beige-150)' : 'var(--text-strong)', margin: '10px 0 0' }}>Four steps from idea to driveway.</h2>
    </div>
  );

  // V1 — Numbered icon circles (2×2)
  function ProcGrid() {
    return (
      <section style={{ background: 'var(--color-bg)', padding: '52px 22px' }}>
        <Heading />
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 26 }}>
          {STEPS.map((s, i) => (
            <div key={s.t} style={{ textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10 }}>
              <div style={{ position: 'relative', width: 58, height: 58, borderRadius: 'var(--radius-full)', background: 'var(--terracotta-100)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                <Icon name={s.icon} size={24} color="var(--terracotta)" />
                <span style={{ position: 'absolute', top: -5, right: -5, width: 22, height: 22, borderRadius: 'var(--radius-full)', background: 'var(--terracotta)', color: '#fff', fontFamily: 'var(--font-body)', fontSize: 11, fontWeight: 700, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{i + 1}</span>
              </div>
              <h3 style={{ fontFamily: 'var(--font-body)', fontSize: 12, fontWeight: 700, letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--text-strong)', margin: 0 }}>{s.t}</h3>
              <p style={{ fontFamily: 'var(--font-body)', fontSize: 12.5, lineHeight: '19px', color: 'var(--text-muted)', margin: 0 }}>{s.d}</p>
            </div>
          ))}
        </div>
      </section>
    );
  }

  // V2 — Vertical timeline
  function ProcTimeline() {
    return (
      <section style={{ background: 'var(--beige-300)', padding: '52px 22px' }}>
        <Heading />
        <div style={{ position: 'relative', paddingLeft: 8 }}>
          {STEPS.map((s, i) => (
            <div key={s.t} style={{ display: 'flex', gap: 16, paddingBottom: i < STEPS.length - 1 ? 24 : 0 }}>
              <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
                <div style={{ width: 40, height: 40, borderRadius: 'var(--radius-full)', background: 'var(--terracotta)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', flex: 'none', boxShadow: 'var(--shadow-sm)' }}>
                  <Icon name={s.icon} size={18} />
                </div>
                {i < STEPS.length - 1 && <div style={{ width: 2, flex: 1, background: 'var(--border-default)', marginTop: 4 }} />}
              </div>
              <div style={{ paddingTop: 2 }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                  <span style={{ fontFamily: 'var(--font-body)', fontSize: 11, fontWeight: 700, color: 'var(--terracotta)' }}>STEP {String(i + 1).padStart(2, '0')}</span>
                </div>
                <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 19, color: 'var(--text-strong)', margin: '3px 0 4px' }}>{s.t}</h3>
                <p style={{ fontFamily: 'var(--font-body)', fontSize: 13.5, lineHeight: '20px', color: 'var(--text-muted)', margin: 0 }}>{s.d}</p>
              </div>
            </div>
          ))}
        </div>
      </section>
    );
  }

  // V3 — Big serif numerals
  function ProcNumerals() {
    return (
      <section style={{ background: 'var(--color-bg)', padding: '52px 22px' }}>
        <Heading />
        <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
          {STEPS.map((s, i) => (
            <div key={s.t} style={{ display: 'flex', gap: 18, alignItems: 'baseline', padding: '16px 0', borderTop: '1px solid var(--border-subtle)' }}>
              <span style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 44, lineHeight: 0.9, color: 'var(--terracotta)', opacity: 0.85, flex: 'none', width: 52 }}>{String(i + 1).padStart(2, '0')}</span>
              <div>
                <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 21, color: 'var(--text-strong)', margin: '0 0 5px' }}>{s.t}</h3>
                <p style={{ fontFamily: 'var(--font-body)', fontSize: 13.5, lineHeight: '20px', color: 'var(--text-muted)', margin: 0 }}>{s.d}</p>
              </div>
            </div>
          ))}
        </div>
      </section>
    );
  }

  // V4 — Stacked cards
  function ProcCards() {
    return (
      <section style={{ background: 'var(--beige-300)', padding: '52px 22px' }}>
        <Heading />
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
          {STEPS.map((s, i) => (
            <div key={s.t} style={{ display: 'flex', gap: 14, alignItems: 'flex-start', background: 'var(--color-surface)', border: '1px solid var(--border-subtle)', borderRadius: 'var(--radius)', boxShadow: 'var(--shadow-sm)', padding: '16px 16px' }}>
              <div style={{ width: 44, height: 44, borderRadius: 'var(--radius)', background: 'var(--terracotta-100)', display: 'flex', alignItems: 'center', justifyContent: 'center', flex: 'none' }}>
                <Icon name={s.icon} size={20} color="var(--terracotta)" />
              </div>
              <div>
                <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 4 }}>
                  <span style={{ fontFamily: 'var(--font-body)', fontSize: 10.5, fontWeight: 700, letterSpacing: '0.08em', color: 'var(--terracotta)' }}>STEP {String(i + 1).padStart(2, '0')}</span>
                </div>
                <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 18, color: 'var(--text-strong)', margin: '0 0 4px' }}>{s.t}</h3>
                <p style={{ fontFamily: 'var(--font-body)', fontSize: 13, lineHeight: '20px', color: 'var(--text-muted)', margin: 0 }}>{s.d}</p>
              </div>
            </div>
          ))}
        </div>
      </section>
    );
  }

  // V5 — Photo-paired
  function ProcPhoto() {
    const imgs = ['svc-driveways.png', 'house-render.png', 'svc-steps.png', 'svc-patios.png'];
    return (
      <section style={{ background: 'var(--color-bg)', padding: '52px 22px' }}>
        <Heading />
        <div style={{ display: 'flex', flexDirection: 'column', gap: 18 }}>
          {STEPS.map((s, i) => (
            <div key={s.t} style={{ display: 'flex', gap: 14, alignItems: 'center', flexDirection: i % 2 ? 'row-reverse' : 'row' }}>
              <div style={{ width: 112, height: 80, borderRadius: 'var(--radius)', backgroundImage: `url(${PHOTO}${imgs[i]})`, backgroundSize: 'cover', backgroundPosition: 'center', flex: 'none', boxShadow: 'var(--shadow-sm)' }} />
              <div style={{ flex: 1, textAlign: i % 2 ? 'right' : 'left' }}>
                <span style={{ fontFamily: 'var(--font-body)', fontSize: 11, fontWeight: 700, color: 'var(--terracotta)' }}>STEP {String(i + 1).padStart(2, '0')}</span>
                <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 18, color: 'var(--text-strong)', margin: '3px 0 4px' }}>{s.t}</h3>
                <p style={{ fontFamily: 'var(--font-body)', fontSize: 12.5, lineHeight: '19px', color: 'var(--text-muted)', margin: 0 }}>{s.d}</p>
              </div>
            </div>
          ))}
        </div>
      </section>
    );
  }

  window.MP.register('process', {
    label: 'How it works',
    options: [
      { id: 'grid', name: '1 · Icon grid', Render: ProcGrid },
      { id: 'timeline', name: '2 · Vertical timeline', Render: ProcTimeline },
      { id: 'numerals', name: '3 · Big numerals', Render: ProcNumerals },
      { id: 'cards', name: '4 · Stacked cards', Render: ProcCards },
      { id: 'photo', name: '5 · Photo-paired', Render: ProcPhoto },
    ],
  });
})();
