// components.jsx — Sections 2 through 10 of the Arkwright homepage.

// ─────────────────────────────────────────────────────────────────────────────
// Section 2 — Category statement (vendor sprawl → Arkwright diagram)
// ─────────────────────────────────────────────────────────────────────────────

// 20 vendor chips, each with an initial position (% of container) and rotation.
// User can pick them up and drop them anywhere inside the sprawl.
const VENDORS = [
  { name: 'Trailer Co.',              code: 'v01', top: 4,   left: -2,  rot: -11 },
  { name: 'Canva',                    code: 'v02', top: 22,  left: 66,  rot: 9   },
  { name: 'Pelican Cases (eBay)',     code: 'v03', top: 12,  left: 38,  rot: -5  },
  { name: 'Microphones (Marketplace)',code: 'v04', top: -2,  left: 28,  rot: 6   },
  { name: 'Unreliable Giving App',    code: 'v05', top: 38,  left: 46,  rot: 14  },
  { name: 'Amateur DJ Lights',        code: 'v06', top: 56,  left: 24,  rot: -7  },
  { name: 'Kids Check-in Apps',       code: 'v07', top: 28,  left: 8,   rot: 10  },
  { name: 'Mailchimp?',               code: 'v08', top: 64,  left: 72,  rot: -13 },
  { name: 'Storage Unit (Off-site)',  code: 'v09', top: 80,  left: -4,  rot: 5   },
  { name: 'Logo From Fiverr',         code: 'v10', top: 48,  left: 58,  rot: -10 },
  { name: 'Big-box AV',               code: 'v11', top: 6,   left: 78,  rot: 13  },
  { name: "Projector's Too Dim",      code: 'v12', top: 72,  left: 32,  rot: -6  },
  { name: 'Print Shop',               code: 'v13', top: 18,  left: 80,  rot: 4   },
  { name: 'Slow Laptop',              code: 'v14', top: 42,  left: 0,   rot: -8  },
  { name: 'ProPresenter Licenses',    code: 'v15', top: 88,  left: 28,  rot: 11  },
  { name: "Grandpa's Soundboard",     code: 'v16', top: 60,  left: 4,   rot: -3  },
  { name: 'Web Designer (Nephew)',    code: 'v17', top: 30,  left: 36,  rot: 12  },
  { name: 'Wix',                      code: 'v18', top: 50,  left: 82,  rot: -9  },
  { name: 'Hand-me-down Drums',       code: 'v19', top: 94,  left: 56,  rot: 7   },
  { name: 'DIY Stage Backdrop',       code: 'v20', top: 78,  left: 48,  rot: -4  },
  { name: 'Sign Maker',               code: 'v21', top: 46,  left: 32,  rot: -2  },
];

function DraggableChip({ vendor, position, containerRef, onChange, index, hidden }) {
  const { useState, useEffect, useRef } = React;
  const [dragging, setDragging] = useState(false);
  const start = useRef({ pointerX: 0, pointerY: 0, leftPct: 0, topPct: 0 });

  const handleDown = (e) => {
    if (hidden) return;
    e.preventDefault();
    e.stopPropagation();
    const point = e.touches ? e.touches[0] : e;
    start.current = {
      pointerX: point.clientX,
      pointerY: point.clientY,
      leftPct: position.left,
      topPct: position.top,
    };
    setDragging(true);
  };

  useEffect(() => {
    if (!dragging) return;
    const handleMove = (e) => {
      if (e.cancelable && e.touches) e.preventDefault();
      const point = e.touches ? e.touches[0] : e;
      const rect = containerRef.current && containerRef.current.getBoundingClientRect();
      if (!rect) return;
      const dx = ((point.clientX - start.current.pointerX) / rect.width) * 100;
      const dy = ((point.clientY - start.current.pointerY) / rect.height) * 100;
      onChange({
        left: Math.max(0, Math.min(82, start.current.leftPct + dx)),
        top:  Math.max(0, Math.min(86, start.current.topPct + dy)),
      });
    };
    const handleUp = () => setDragging(false);
    window.addEventListener('mousemove', handleMove);
    window.addEventListener('touchmove', handleMove, { passive: false });
    window.addEventListener('mouseup', handleUp);
    window.addEventListener('touchend', handleUp);
    window.addEventListener('touchcancel', handleUp);
    return () => {
      window.removeEventListener('mousemove', handleMove);
      window.removeEventListener('touchmove', handleMove);
      window.removeEventListener('mouseup', handleUp);
      window.removeEventListener('touchend', handleUp);
      window.removeEventListener('touchcancel', handleUp);
    };
  }, [dragging, onChange, containerRef]);

  return (
    <div
      className={'vendor-chip' + (dragging ? ' dragging' : '') + (hidden ? ' hidden' : '')}
      style={{
        top: position.top + '%',
        left: position.left + '%',
        '--chip-rot': position.rot + 'deg',
        '--chip-scale': dragging ? 1.06 : (hidden ? 0.4 : 1),
        opacity: hidden ? 0 : 1,
        zIndex: dragging ? 30 : 'auto',
        pointerEvents: hidden ? 'none' : 'auto',
        transitionDelay: hidden ? `${index * 28}ms` : `${220 + (VENDORS.length - 1 - index) * 6}ms`,
      }}
      onMouseDown={handleDown}
      onTouchStart={handleDown}
    >
      {vendor.name}
    </div>
  );
}

function CategoryStatement() {
  const { useState, useRef, useCallback } = React;
  const [positions, setPositions] = useState(
    VENDORS.map((v) => ({ top: v.top, left: v.left, rot: v.rot }))
  );
  const [consolidated, setConsolidated] = useState(false);
  const containerRef = useRef(null);

  const updatePos = useCallback((i, partial) => {
    setPositions((prev) => {
      const next = prev.slice();
      next[i] = { ...next[i], ...partial };
      return next;
    });
  }, []);

  const toggle = () => {
    if (consolidated) {
      setPositions(VENDORS.map((v) => ({ top: v.top, left: v.left, rot: v.rot })));
    }
    setConsolidated(!consolidated);
  };

  return (
    <section className="section subtle" data-screen-label="02 Category statement">
      <div className="container">
        <div className="cat-stage" data-reveal>
          <div>
            <p className="section-label">What we are</p>
            <h2>
              The one place<br />
              <span className="muted">that handles all of it.</span>
            </h2>
          </div>
          <div className="cat-body">
            <p>Most portable ministries operate from a collection of vendors. A trailer from one place. Cases from another. Signage made in Canva. A website built by a friend. A check-in system pieced together from three different apps.</p>
            <p>Arkwright is the one place that handles all of it — designed together, delivered together, supported together.</p>
          </div>
        </div>

        <div className={'cat-diagram' + (consolidated ? ' consolidated' : '')} data-reveal>
          <div className="vendor-column">
            <div className="vendor-question" aria-hidden={consolidated}>
              <p>Don't focus <span className="muted">on the mess…</span></p>
            </div>
            <div className="vendor-sprawl" ref={containerRef}>
              {VENDORS.map((v, i) => (
                <DraggableChip
                  key={v.code}
                  vendor={v}
                  position={positions[i]}
                  containerRef={containerRef}
                  onChange={(p) => updatePos(i, p)}
                  index={i}
                  hidden={consolidated}
                />
              ))}
            </div>

            <div className="vendor-cta" aria-hidden={!consolidated}>
              <h3>Focus on the message.</h3>
              <p>Let us focus on the details we are best at so you can focus on pouring into people.</p>
              <a className="cta-pill" href="#build" tabIndex={consolidated ? 0 : -1}>
                <SplitText>Build a system →</SplitText>
              </a>
            </div>
          </div>

          <div className="cat-switch-wrap">
            <span className="cat-switch-eyebrow">
              {consolidated ? (
                <>Engage<br />Arkwright</>
              ) : (
                <>Engage<br />Arkwright</>
              )}
            </span>
            <button
              type="button"
              className={'cat-switch' + (consolidated ? ' on' : '')}
              role="switch"
              aria-checked={consolidated}
              onClick={toggle}
              aria-label="Toggle Arkwright state"
            >
              <span className="cat-switch-thumb" aria-hidden="true"></span>
            </button>
            <div className="cat-switch-label">
              <span className={!consolidated ? 'active' : ''}>Before Arkwright</span>
              <span className={consolidated ? 'active' : ''}>After Arkwright</span>
            </div>
          </div>

          <div className="cat-result">
            <div className="result-mark">
              <span className="glyph">A</span>
              Arkwright Systems<sup style={{ fontSize: 8, color: 'rgba(255,255,255,0.5)', marginLeft: 2 }}>®</sup>
            </div>
            <h3>One partner.<br />Zero distractions.</h3>
            <ul className="result-list">
              <li><strong>01</strong><span>Digital launch kit</span></li>
              <li><strong>02</strong><span>Custom cases</span></li>
              <li><strong>03</strong><span>Trailers</span></li>
              <li><strong>04</strong><span>Equipment</span></li>
              <li><strong>05</strong><span>Delivery</span></li>
              <li><strong>06</strong><span>Training</span></li>
            </ul>
            <span className="result-accent" aria-hidden="true"></span>
          </div>
        </div>

        <p className="cat-closing" data-reveal>
          Portability isn't a compromise.{' '}
          <a href="#how" className="link-wipe">It's a strategy.</a>
        </p>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 3 — Six components, each with a line-drawing illustration
// ─────────────────────────────────────────────────────────────────────────────

function IlloDigitalKit() {
  return (
    <svg viewBox="0 0 220 140" preserveAspectRatio="xMidYMid meet">
      {/* Laptop */}
      <rect x="40" y="30" width="100" height="64" rx="3" fill="none" stroke="#020108" strokeWidth="1.25" />
      <rect x="46" y="36" width="88" height="52" fill="#f5f5f4" />
      <rect x="34" y="94" width="112" height="6" rx="2" fill="none" stroke="#020108" strokeWidth="1.25" />
      <text x="90" y="56" textAnchor="middle" fontFamily="SF Pro Display, sans-serif" fontSize="11" fontWeight="700" fill="#020108">CALVARY</text>
      <text x="90" y="69" textAnchor="middle" fontFamily="SF Pro Display, sans-serif" fontSize="11" fontWeight="700" fill="#020108">FORGE</text>
      <line x1="62" y1="78" x2="118" y2="78" stroke="#fd7b03" strokeWidth="1.5" />
      {/* Phone */}
      <rect x="156" y="42" width="36" height="62" rx="6" fill="none" stroke="#020108" strokeWidth="1.25" />
      <rect x="160" y="48" width="28" height="50" fill="#f5f5f4" />
      <circle cx="174" cy="73" r="6" fill="none" stroke="#020108" strokeWidth="1" />
      <text x="174" y="76" textAnchor="middle" fontFamily="SF Pro Display, sans-serif" fontSize="7" fontWeight="700" fill="#020108">CF</text>
    </svg>
  );
}
function IlloCases() {
  return (
    <svg viewBox="0 0 220 140" preserveAspectRatio="xMidYMid meet">
      <rect x="20" y="28" width="180" height="80" rx="5" fill="none" stroke="#020108" strokeWidth="1.25" />
      <rect x="32" y="40" width="50" height="56" rx="2" fill="none" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <rect x="90" y="40" width="36" height="56" rx="2" fill="none" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <rect x="134" y="40" width="54" height="26" rx="2" fill="none" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <rect x="134" y="70" width="54" height="26" rx="2" fill="none" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <rect x="38" y="22" width="24" height="6" rx="1" fill="#020108" />
      <rect x="158" y="22" width="24" height="6" rx="1" fill="#020108" />
      <line x1="20" y1="120" x2="200" y2="120" stroke="#020108" strokeWidth="0.5" />
      <line x1="20" y1="116" x2="20" y2="124" stroke="#020108" strokeWidth="0.5" />
      <line x1="200" y1="116" x2="200" y2="124" stroke="#020108" strokeWidth="0.5" />
      <text x="110" y="132" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="8" fill="#8a8a8a">1240 mm</text>
    </svg>
  );
}
function IlloTrailer() {
  return (
    <svg viewBox="0 0 220 140" preserveAspectRatio="xMidYMid meet">
      <rect x="18" y="36" width="160" height="60" rx="4" fill="none" stroke="#020108" strokeWidth="1.25" />
      <rect x="178" y="54" width="22" height="22" rx="2" fill="none" stroke="#020108" strokeWidth="1.25" />
      <circle cx="50" cy="100" r="10" fill="none" stroke="#020108" strokeWidth="1.25" />
      <circle cx="146" cy="100" r="10" fill="none" stroke="#020108" strokeWidth="1.25" />
      <line x1="28" y1="48" x2="170" y2="48" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <line x1="28" y1="64" x2="170" y2="64" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <line x1="28" y1="80" x2="170" y2="80" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <circle cx="98" cy="56" r="4" fill="#fd7b03" />
      <text x="110" y="128" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="8" fill="#8a8a8a">16 ft enclosed</text>
    </svg>
  );
}
function IlloEquipment() {
  return (
    <svg viewBox="0 0 220 140" preserveAspectRatio="xMidYMid meet">
      {/* Speaker */}
      <rect x="32" y="24" width="46" height="88" rx="3" fill="none" stroke="#020108" strokeWidth="1.25" />
      <circle cx="55" cy="50" r="10" fill="none" stroke="#020108" strokeWidth="1" />
      <circle cx="55" cy="86" r="14" fill="none" stroke="#020108" strokeWidth="1" />
      {/* Mixer / rack */}
      <rect x="90" y="42" width="98" height="58" rx="3" fill="none" stroke="#020108" strokeWidth="1.25" />
      {[0,1,2,3,4,5,6,7].map(i => (
        <g key={i}>
          <line x1={100 + i*11} y1="50" x2={100 + i*11} y2="74" stroke="#8a8a8a" strokeWidth="0.8" />
          <circle cx={100 + i*11} cy={60 + (i%3)*4} r="2" fill="#020108" />
        </g>
      ))}
      <rect x="98" y="82" width="82" height="10" rx="2" fill="#020108" />
      {/* Light fixture */}
      <line x1="198" y1="24" x2="198" y2="48" stroke="#020108" strokeWidth="1.25" />
      <polygon points="186,48 210,48 198,72" fill="none" stroke="#020108" strokeWidth="1.25" />
      <circle cx="198" cy="56" r="3" fill="#fd7b03" />
    </svg>
  );
}
function IlloDelivery() {
  return (
    <svg viewBox="0 0 220 140" preserveAspectRatio="xMidYMid meet">
      {/* Building outline */}
      <polygon points="20,100 60,60 60,100" fill="none" stroke="#020108" strokeWidth="1.25" />
      <rect x="60" y="50" width="60" height="50" fill="none" stroke="#020108" strokeWidth="1.25" />
      <rect x="78" y="68" width="18" height="32" fill="none" stroke="#020108" strokeWidth="1" />
      {/* Trailer arriving */}
      <rect x="130" y="62" width="70" height="38" rx="3" fill="none" stroke="#020108" strokeWidth="1.25" />
      <circle cx="146" cy="106" r="6" fill="none" stroke="#020108" strokeWidth="1.25" />
      <circle cx="184" cy="106" r="6" fill="none" stroke="#020108" strokeWidth="1.25" />
      <line x1="120" y1="100" x2="200" y2="100" stroke="#020108" strokeWidth="1.25" />
      {/* Arrow */}
      <line x1="118" y1="120" x2="62" y2="120" stroke="#fd7b03" strokeWidth="1.5" />
      <polygon points="62,120 70,116 70,124" fill="#fd7b03" />
      <text x="90" y="134" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="8" fill="#8a8a8a">on-site set up</text>
    </svg>
  );
}
function IlloTraining() {
  return (
    <svg viewBox="0 0 220 140" preserveAspectRatio="xMidYMid meet">
      {/* Clipboard */}
      <rect x="74" y="22" width="72" height="100" rx="4" fill="none" stroke="#020108" strokeWidth="1.25" />
      <rect x="94" y="14" width="32" height="14" rx="3" fill="#020108" />
      {[
        [38, '01'], [54, '02'], [70, '03'], [86, '04'],
      ].map(([y, n]) => (
        <g key={y}>
          <rect x="82" y={y} width="12" height="10" rx="2" fill="none" stroke="#020108" strokeWidth="1" />
          <text x="100" y={y+8} fontFamily="SF Mono, monospace" fontSize="7" fill="#8a8a8a">{n}</text>
          <line x1="116" y1={y+6} x2="138" y2={y+6} stroke="#8a8a8a" strokeWidth="1" />
        </g>
      ))}
      <line x1="82" y1="102" x2="138" y2="102" stroke="#fd7b03" strokeWidth="1.5" />
      <text x="110" y="116" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="8" fill="#8a8a8a">runbook ready</text>
    </svg>
  );
}

const COMPONENTS = [
  {
    code: 'DK-01', label: 'Digital Launch Kit', illo: IlloDigitalKit,
    desc: 'Brand, website, email. The church online and the church on Sunday — unmistakably the same place.',
    href: '/system/digital-launch-kit',
  },
  {
    code: 'CS-04', label: 'Custom Cases', illo: IlloCases,
    desc: 'Engineered around your equipment and your team. Built to survive a thousand load-ins.',
    href: '/system/cases',
  },
  {
    code: 'TR-16', label: 'Trailers', illo: IlloTrailer,
    desc: 'A trailer built around your cases, your venue, and your weekend flow.',
    href: '/system/trailers',
  },
  {
    code: 'EQ-AV', label: 'Equipment', illo: IlloEquipment,
    desc: 'AV, signage, hospitality, kids check-in, stage build — specified for your context.',
    href: '/system/equipment',
  },
  {
    code: 'DL-WG', label: 'White-Glove Delivery', illo: IlloDelivery,
    desc: 'We set the system up alongside your team and run a complete dry run before your first Sunday.',
    href: '/system/delivery',
  },
  {
    code: 'TG-01', label: 'Training', illo: IlloTraining,
    desc: 'Setup choreography, breakdown sequencing, volunteer training, runbooks for every role.',
    href: '/system/training',
  },
];

function ComponentsSection() {
  return (
    <section className="section" data-screen-label="03 Six components">
      <div className="container">
        <div className="section-head" data-reveal>
          <div>
            <p className="section-label">What's inside</p>
            <h2 className="headline h-display-md">
              Six things every<br />
              <span className="muted">portable ministry needs.</span>
            </h2>
          </div>
          <div className="h-aside">
            Designed together. Delivered together. Supported together. You buy a system, not a stack of vendor invoices.
          </div>
        </div>

        <div className="components-grid" data-reveal-stagger="70">
          {COMPONENTS.map((c, i) => {
            return (
              <a key={c.code} href={c.href} className="component-tile" data-reveal-item>
                <div className="component-illo">
                  <span className="component-illo-placeholder" aria-hidden="true"></span>
                </div>
                <div>
                  <h3>{c.label}</h3>
                  <p>{c.desc}</p>
                </div>
                <div className="meta-row">
                  <span>0{i+1} / 06</span>
                  <span className="learn-more"><SplitText>Learn more →</SplitText></span>
                </div>
              </a>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 4 — Environments (floor-plan explorer)
// ─────────────────────────────────────────────────────────────────────────────

const ENVIRONMENTS = [
  { code: 'ENV-01', num: '01', label: 'First Impressions', short: 'Lobby',
    desc: 'Lobby, welcome, signage. The thirty seconds that decide whether a guest comes back.',
    placeholder: 'Lobby / welcome photo', href: '/environments/first-impressions',
    photo: 'first-impressions-bg.jpg',
    area: '74 m²', capacity: 'pass-through',
    zone: { x: 240, y: 360, w: 300, h: 100 } },
  { code: 'ENV-02', num: '02', label: 'Worship', short: 'Worship',
    desc: 'Auditorium, stage, sound, lighting. Where the room becomes a sanctuary.',
    placeholder: 'Worship / stage photo', href: '/environments/worship',
    photo: 'roles-bg.jpg',
    area: '218 m²', capacity: '380 seats',
    zone: { x: 240, y: 140, w: 300, h: 220 } },
  { code: 'ENV-03', num: '03', label: 'Kids & Nursery', short: 'Kids',
    desc: 'Check-in, classrooms, safety, fun. The environment parents trust most.',
    placeholder: 'Kids check-in photo', href: '/environments/kids',
    photo: 'kids-bg.jpg',
    area: '128 m²', capacity: '80 kids',
    zone: { x: 80, y: 60, w: 160, h: 220 } },
  { code: 'ENV-04', num: '04', label: 'Overflow', short: 'Overflow',
    desc: 'Secondary spaces that scale with your service — youth, classes, simulcast.',
    placeholder: 'Overflow room photo', href: '/environments/overflow',
    photo: 'overflow-bg.jpg',
    area: '146 m²', capacity: '120 seats',
    zone: { x: 540, y: 60, w: 180, h: 400 } },
  { code: 'ENV-05', num: '05', label: 'Hospitality', short: 'Coffee',
    desc: 'Coffee, snacks, info tables. The pause between arrival and worship.',
    placeholder: 'Hospitality / coffee photo', href: '/environments/hospitality',
    photo: 'hospitality-bg.jpg',
    area: '86 m²', capacity: 'rolling',
    zone: { x: 80, y: 280, w: 160, h: 180 } },
];

function EnvironmentsSection() {
  const [active, setActive] = React.useState('ENV-02');
  const env = ENVIRONMENTS.find((e) => e.code === active) || ENVIRONMENTS[0];

  return (
    <section className="section subtle" data-screen-label="04 Environments">
      <div className="container">
        <div className="section-head" data-reveal>
          <div>
            <p className="section-label">Where it works</p>
            <h2 className="headline h-display-md">
              Built for every space<br />
              <span className="muted">on Sunday morning.</span>
            </h2>
          </div>
          <div className="h-aside">
            A complete system isn't six product categories — it's six environments. Hover the plan to step through each, the way Sunday morning actually flows.
          </div>
        </div>

        <div className="env-explorer" data-reveal>
          <div className="env-list" role="list">
            {ENVIRONMENTS.map((e) => (
              <div
                key={e.code}
                role="listitem"
                className={'env-list-item' + (active === e.code ? ' active' : '')}
                onMouseEnter={() => setActive(e.code)}
                onFocus={() => setActive(e.code)}
                onClick={() => setActive(e.code)}
                tabIndex={0}
              >
                <span className="env-list-num">{e.num}</span>
                <span className="env-list-name">{e.label}</span>
                <span className="env-list-arrow" aria-hidden="true">→</span>
              </div>
            ))}
          </div>

          <div className="env-detail">
            <div className="env-detail-photo">
              <span className="env-detail-tag">{env.num} / {ENVIRONMENTS.length.toString().padStart(2, '0')}</span>
              {env.photo ? (
                <img src={env.photo} alt={env.label} className="env-detail-img" loading="lazy" />
              ) : (
                <image-slot
                  id={`env-${env.code.toLowerCase()}`}
                  shape="rect"
                  fit="cover"
                  placeholder={env.placeholder}
                ></image-slot>
              )}
            </div>
            <h3>{env.label}</h3>
            <p>{env.desc}</p>
            <a className="env-detail-link" href={env.href}>
              <SplitText>Explore {env.short.toLowerCase()} →</SplitText>
            </a>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 5 — Stages / Journey
// ─────────────────────────────────────────────────────────────────────────────

function IlloPlant() {
  return (
    <svg viewBox="0 0 320 200" preserveAspectRatio="xMidYMid meet">
      {/* Flag on a hill */}
      <line x1="60" y1="160" x2="280" y2="160" stroke="#020108" strokeWidth="1" />
      <line x1="160" y1="160" x2="160" y2="60" stroke="#020108" strokeWidth="1.5" />
      <polygon points="160,60 220,80 160,100" fill="#fd7b03" />
      <circle cx="160" cy="160" r="3" fill="#020108" />
      {/* Path */}
      <path d="M 30 180 Q 110 170 160 160 T 290 175" fill="none" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="4 4" />
      <text x="160" y="195" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="9" fill="#8a8a8a">DAY ONE</text>
    </svg>
  );
}
function IlloGrowing() {
  return (
    <svg viewBox="0 0 320 200" preserveAspectRatio="xMidYMid meet">
      {/* Growing bars / fan deployment */}
      {[50, 100, 150, 200, 250].map((x, i) => (
        <rect key={x} x={x} y={170 - (i+1)*22} width="22" height={(i+1)*22} fill="none" stroke="#020108" strokeWidth="1.25" />
      ))}
      <rect x="250" y="60" width="22" height="110" fill="#fd7b03" />
      {/* Floor line */}
      <line x1="30" y1="170" x2="290" y2="170" stroke="#020108" strokeWidth="1" />
      <text x="160" y="190" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="9" fill="#8a8a8a">YEAR 03 → 07</text>
    </svg>
  );
}
function IlloMultisite() {
  return (
    <svg viewBox="0 0 320 200" preserveAspectRatio="xMidYMid meet">
      {/* Three campus dots connected */}
      <line x1="70" y1="100" x2="160" y2="100" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <line x1="160" y1="100" x2="250" y2="100" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <line x1="160" y1="100" x2="160" y2="160" stroke="#8a8a8a" strokeWidth="1" strokeDasharray="3 3" />
      <circle cx="70" cy="100" r="22" fill="none" stroke="#020108" strokeWidth="1.5" />
      <circle cx="160" cy="100" r="28" fill="#020108" />
      <circle cx="250" cy="100" r="22" fill="none" stroke="#020108" strokeWidth="1.5" />
      <circle cx="160" cy="160" r="18" fill="#fd7b03" />
      <text x="70" y="138" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="9" fill="#8a8a8a">CAMPUS 02</text>
      <text x="160" y="100" textAnchor="middle" fontFamily="SF Pro Display, sans-serif" fontSize="11" fontWeight="700" fill="#fff">HQ</text>
      <text x="250" y="138" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="9" fill="#8a8a8a">CAMPUS 03</text>
      <text x="160" y="190" textAnchor="middle" fontFamily="SF Mono, monospace" fontSize="9" fill="#fd7b03">+ NEW</text>
    </svg>
  );
}

function StagesSection() {
  const stages = [
    { code: 'STG-01', name: 'Church Plants',
      body: 'A launch date, a launch team, and a hundred details you didn\'t sign up for. We help you start with a complete system instead of a collection of compromises.',
      href: '/solutions/church-plants', illo: IlloPlant },
    { code: 'STG-02', name: 'Growing Churches',
      body: 'You\'ve made portable work for years. You\'ve also outgrown the duct tape. Time for the system your team has earned.',
      href: '/solutions/established', illo: IlloGrowing },
    { code: 'STG-03', name: 'Multi-Campus',
      body: 'A new campus deserves the same care as the original. We build systems that scale your church without diluting it.',
      href: '/solutions/multi-site', illo: IlloMultisite },
  ];
  return (
    <section className="section" data-screen-label="05 Journey">
      <div className="container">
        <div className="section-head" data-reveal>
          <div>
            <p className="section-label">Where you are</p>
            <h2 className="headline h-display-md">
              We meet you<br />
              <span className="muted">on each step of the journey.</span>
            </h2>
          </div>
          <div className="h-aside">
            Most churches don't buy a system once. They grow into it. A church plant in year one needs something different than a multi-site campus in year ten.
          </div>
        </div>

        <div className="stages-grid" data-reveal-stagger="90">
          {stages.map((s, i) => {
            return (
              <a key={s.code} href={s.href} className="stage-card" data-reveal-item>
                <div className="stage-illo">
                  <span className="stage-illo-placeholder" aria-hidden="true"></span>
                </div>
                <div className="stage-num">
                  <span>{s.code}</span>
                  <span>0{i+1} / 03</span>
                </div>
                <h3>{s.name}</h3>
                <p>{s.body}</p>
                <div className="stage-link"><SplitText>Read more →</SplitText></div>
              </a>
            );
          })}
        </div>

        <div className="aside-trade" data-reveal>
          <strong className="aside-title">Already have a system that's tired?</strong>
          <p className="aside-body">Our buy-back and upgrade program helps churches at any stage trade up to current equipment without starting from scratch.</p>
          <a className="cta-pill secondary aside-cta" href="/solutions/upgrading"><SplitText>Trade up →</SplitText></a>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 6 — Roles
// ─────────────────────────────────────────────────────────────────────────────

const ROLES = [
  { code: 'R-01', glyph: 'LP', name: 'Lead Pastor',
    desc: 'Stay focused on shepherding people, not chasing logistics.',
    href: '/who-we-serve/lead-pastors' },
  { code: 'R-02', glyph: 'XP', name: 'Executive Pastor',
    desc: 'A repeatable system that scales with your campus plan.',
    href: '/who-we-serve/executive-pastors' },
  { code: 'R-03', glyph: 'CP', name: 'Campus Pastor',
    desc: 'Consistency with the rest of your church, identity for your campus.',
    href: '/who-we-serve/campus-pastors' },
  { code: 'R-04', glyph: 'WP', name: 'Worship Pastor',
    desc: 'Sunday morning that runs the way you\'ve always wanted it to.',
    href: '/who-we-serve/worship-pastors' },
  { code: 'R-05', glyph: 'TD', name: 'Tech / Production Director',
    desc: 'Systems that protect your team and never let you down.',
    href: '/who-we-serve/tech-directors' },
  { code: 'R-06', glyph: 'CD', name: 'Children\'s Director',
    desc: 'Spaces that feel safe, intentional, and joyful — every week.',
    href: '/who-we-serve/childrens-directors' },
];

function RolesSection() {
  return (
    <section className="section roles-section" data-screen-label="06 Roles">
      <div className="roles-bg" aria-hidden="true"></div>
      <div className="container">
        <div className="section-head" data-reveal>
          <div>
            <p className="section-label">Who we build for</p>
            <h2 className="headline h-display-md">
              Built around<br />
              <span className="muted">your role.</span>
            </h2>
          </div>
          <div className="h-aside">
            A portable ministry system gets bought by a team, not a person. Every seat at the table has a different concern — and a different reason this works.
          </div>
        </div>

        <div className="roles-grid" data-reveal-stagger="55">
          {ROLES.map((r, i) => (
            <a key={r.code} href={r.href} className="role-card" data-reveal-item>
              <div className="role-meta">
                <span>{r.code}</span>
                <span>0{i+1} / 06</span>
              </div>
              <div className="role-glyph">{r.glyph}</div>
              <h3>{r.name}</h3>
              <p>{r.desc}</p>
              <div className="role-link"><SplitText>For {r.name.toLowerCase()}s →</SplitText></div>
            </a>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 7 — Proof / Case studies
// ─────────────────────────────────────────────────────────────────────────────

function ProofSection() {
  return (
    <section className="section" data-screen-label="07 Proof">
      <div className="container">
        <div className="section-head" data-reveal>
          <div>
            <p className="section-label">Proof</p>
            <h2 className="headline h-display-md">
              Real churches.<br />
              <span className="muted">Real systems.<br />
              Real Sundays.</span>
            </h2>
          </div>
          <div className="h-aside">
            We don't promise polish — we show it. Each system below was built around a specific church, a specific venue, a specific volunteer team.
          </div>
        </div>

        <div className="proof-grid" data-reveal>
          <div className="case-feature">
            <div className="case-photo">
              <img src="bay-chapel.jpg" alt="Bay Chapel worship service" className="case-photo-img" />
            </div>
            <div className="case-body">
              <div className="case-meta">
                <strong>Bay Chapel</strong>
                <span>CASE-001 · CHICAGO IL</span>
              </div>
              <p className="case-quote">
                We went from a four-hour load-in held together by two veteran volunteers to a ninety-minute set-up any new team member can run. Sunday morning finally feels like Sunday morning again.
              </p>
              <div className="case-attr">— Pastor [PILOT QUOTE TBD], Lead Pastor</div>
              <a className="case-link" href="/case-studies/bay-chapel"><SplitText>See how we built their system →</SplitText></a>
            </div>
          </div>

          <div className="case-list">
            <a className="case-mini" href="/case-studies/riverside-collective">
              <div>
                <div className="mini-meta">CASE-002 · AUSTIN TX · CHURCH PLANT</div>
                <h4>Riverside Collective</h4>
              </div>
              <p>Launched into a high school theater in 14 weeks with full kit, brand, and volunteer training.</p>
            </a>
            <a className="case-mini" href="/case-studies/northbrook">
              <div>
                <div className="mini-meta">CASE-003 · NORTHBROOK IL · MULTI-SITE</div>
                <h4>Northbrook Community</h4>
              </div>
              <p>Second campus deployed in a converted school cafeteria — operationally identical to the original.</p>
            </a>
            <a className="case-mini" href="/case-studies/lighthouse">
              <div>
                <div className="mini-meta">CASE-004 · LIGHTHOUSE FL · GROWING</div>
                <h4>Lighthouse Church</h4>
              </div>
              <p>Replaced eight years of duct-tape AV with a single integrated rack and trained crew of nine.</p>
            </a>
          </div>
        </div>

        <div className="proof-footer" data-reveal>
          <a className="cta-pill secondary" href="/case-studies"><SplitText>See all case studies →</SplitText></a>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 8 — Promise / pillars
// ─────────────────────────────────────────────────────────────────────────────

function PromiseSection() {
  return (
    <section className="section" data-screen-label="08 Promise">
      <div className="container" style={{ maxWidth: 1320 }}>
        <div style={{ marginBottom: 56 }} data-reveal>
          <p className="section-label">The promise</p>
          <h2 className="headline h-display-md" style={{ marginTop: 24, maxWidth: 900 }}>
            Three things we build<br />
            <span className="muted">our entire company on.</span>
          </h2>
        </div>

        <div className="pillars-grid" data-reveal-stagger="110">
          <div className="pillar" data-reveal-item>
            <div className="pillar-icon">
              <span className="pillar-icon-placeholder" aria-hidden="true"></span>
            </div>
            <h3>One company.</h3>
            <p>Brand to building. Design to delivery. Cases to training. You buy a system, not a stack of vendor invoices.</p>
          </div>
          <div className="pillar" data-reveal-item>
            <div className="pillar-icon">
              <span className="pillar-icon-placeholder" aria-hidden="true"></span>
            </div>
            <h3>Built for the long Sunday.</h3>
            <p>Equipment that survives a thousand load-ins. Systems that work the same way every weekend. Support that's still there a year after launch.</p>
          </div>
          <div className="pillar" data-reveal-item>
            <div className="pillar-icon">
              <span className="pillar-icon-placeholder" aria-hidden="true"></span>
            </div>
            <h3>Built by people who get it.</h3>
            <p>Founded by leaders with backgrounds in ministry, manufacturing, and brand design. We've been the people setting up at 7 AM. We built the company we wished we'd had.</p>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Line icons for VisionClose path cards
// Simple front-elevation iconography in the project's technical-drawing
// vocabulary (1.5px strokes, currentColor, single orange accent).
// ─────────────────────────────────────────────────────────────────────────────

function IconSeedling() {
  return (
    <svg viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
      <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" fill="none">
        {/* Ground line */}
        <line x1="14" y1="76" x2="82" y2="76" />
        {/* Soil mound dashes */}
        <line x1="36" y1="80" x2="42" y2="80" opacity="0.5" />
        <line x1="54" y1="80" x2="60" y2="80" opacity="0.5" />
        {/* Stem */}
        <line x1="48" y1="76" x2="48" y2="36" />
        {/* Left leaf */}
        <path d="M 48 50 C 38 50 30 44 26 36 C 34 42 42 46 48 46 Z" />
        {/* Right leaf */}
        <path d="M 48 42 C 58 42 66 36 70 28 C 62 34 54 38 48 38 Z" />
      </g>
      {/* Accent bud */}
      <circle cx="48" cy="32" r="3.5" fill="#fd7b03" />
    </svg>
  );
}

function IconTree() {
  return (
    <svg viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
      <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" fill="none">
        {/* Ground line */}
        <line x1="10" y1="80" x2="86" y2="80" />
        {/* Trunk */}
        <line x1="44" y1="80" x2="44" y2="52" />
        <line x1="52" y1="80" x2="52" y2="52" />
        <line x1="44" y1="52" x2="52" y2="52" />
        {/* Canopy — three circles */}
        <circle cx="48" cy="34" r="22" />
        <circle cx="32" cy="42" r="14" />
        <circle cx="64" cy="42" r="14" />
      </g>
      {/* Accent fruit */}
      <circle cx="60" cy="28" r="3.5" fill="#fd7b03" />
    </svg>
  );
}

function IconTreeSeeds() {
  return (
    <svg viewBox="0 0 96 96" fill="none" xmlns="http://www.w3.org/2000/svg">
      <g stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" fill="none">
        {/* Ground line */}
        <line x1="4" y1="80" x2="92" y2="80" />
        {/* Center tree — smaller */}
        <line x1="46" y1="80" x2="46" y2="56" />
        <line x1="50" y1="80" x2="50" y2="56" />
        <line x1="46" y1="56" x2="50" y2="56" />
        <circle cx="48" cy="42" r="14" />
        <circle cx="36" cy="48" r="9" />
        <circle cx="60" cy="48" r="9" />
        {/* Left seedling */}
        <line x1="16" y1="80" x2="16" y2="70" />
        <path d="M 16 74 C 12 74 10 72 9 70" />
        <path d="M 16 72 C 20 72 22 70 23 68" />
        {/* Right seedling */}
        <line x1="80" y1="80" x2="80" y2="70" />
        <path d="M 80 74 C 76 74 74 72 73 70" />
        <path d="M 80 72 C 84 72 86 70 87 68" />
      </g>
      {/* Center fruit + seedling bud accents */}
      <circle cx="56" cy="36" r="3" fill="#fd7b03" />
      <circle cx="16" cy="68" r="2.5" fill="#fd7b03" />
      <circle cx="80" cy="68" r="2.5" fill="#fd7b03" />
    </svg>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 9 — Vision close
// ─────────────────────────────────────────────────────────────────────────────

function VisionClose() {
  return (
    <section className="section vision-section" data-screen-label="09 Vision close">
      <div className="vision-bg" aria-hidden="true"></div>
      <div className="container">
        <div className="vision-frame" data-reveal>
          <p className="section-label vision-eyebrow">Where to start</p>

          <h2 className="vision-headline">
            The churches reaching the most people in the next decade
            <span className="muted"> won't be the ones with the biggest buildings.</span>
          </h2>
          <p className="vision-body">
            They'll be the ones who learned to plant the flag wherever the mission led — and operate at the level of permanence wherever they landed. Arkwright exists to help you do that.
          </p>

          <div className="vision-routing">
            <div className="vision-origin">
              <span className="vision-origin-dot" aria-hidden="true"></span>
              <span>Solutions for scale</span>
            </div>
            <svg className="vision-tree" viewBox="0 0 1000 110" aria-hidden="true">
              <defs>
                <path id="vision-route-left"   d="M 500 0 L 500 49 L 167 49 L 167 104" />
                <path id="vision-route-center" d="M 500 49 L 500 104" />
                <path id="vision-route-right"  d="M 500 49 L 833 49 L 833 104" />
                <filter id="orb-blur" x="-200%" y="-200%" width="500%" height="500%">
                  <feGaussianBlur stdDeviation="2.4" />
                </filter>
              </defs>

              <use href="#vision-route-left"   fill="none" stroke="currentColor" strokeWidth="1" strokeDasharray="4 5" />
              <use href="#vision-route-center" fill="none" stroke="currentColor" strokeWidth="1" strokeDasharray="4 5" />
              <use href="#vision-route-right"  fill="none" stroke="currentColor" strokeWidth="1" strokeDasharray="4 5" />

              <circle cx="500" cy="49"  r="3" fill="currentColor" />
              <circle cx="167" cy="104" r="3" fill="currentColor" />
              <circle cx="500" cy="104" r="3" fill="currentColor" />
              <circle cx="833" cy="104" r="3" fill="currentColor" />

              {/* Orange pulses — sharp orb + blurred halo behind for motion-blur feel */}
              {[
                { id: 'vision-route-left',   delay: '0s'   },
                { id: 'vision-route-center', delay: '0.4s' },
                { id: 'vision-route-right',  delay: '0.8s' },
              ].map(({ id, delay }) => (
                <g key={id}>
                  {/* Halo */}
                  <circle r="4.2" fill="#fd7b03" opacity="0" filter="url(#orb-blur)">
                    <animateMotion
                      dur="10s"
                      begin={delay}
                      repeatCount="indefinite"
                      keyPoints="0;0;1;1"
                      keyTimes="0;0.06;0.2;1"
                      calcMode="linear"
                    >
                      <mpath href={`#${id}`} />
                    </animateMotion>
                    <animate
                      attributeName="opacity"
                      dur="10s"
                      begin={delay}
                      repeatCount="indefinite"
                      values="0;0.55;0.55;0;0"
                      keyTimes="0;0.07;0.18;0.2;1"
                    />
                  </circle>
                  {/* Sharp orb */}
                  <circle r="2.5" fill="#fd7b03" opacity="0">
                    <animateMotion
                      dur="10s"
                      begin={delay}
                      repeatCount="indefinite"
                      keyPoints="0;0;1;1"
                      keyTimes="0;0.06;0.2;1"
                      calcMode="linear"
                    >
                      <mpath href={`#${id}`} />
                    </animateMotion>
                    <animate
                      attributeName="opacity"
                      dur="10s"
                      begin={delay}
                      repeatCount="indefinite"
                      values="0;0.95;0.95;0;0"
                      keyTimes="0;0.07;0.18;0.2;1"
                    />
                  </circle>
                </g>
              ))}
            </svg>

            <div className="vision-paths">
              <a className="vision-path" href="/solutions/church-plants">
                <span className="vp-code">Under 250</span>
                <h3>Plant a church</h3>
                <p>Launch into your first venue with a complete system — brand to building, day one.</p>
                <span className="vp-arrow"><SplitText>For plants →</SplitText></span>
              </a>
              <a className="vision-path featured" href="/solutions/established">
                <span className="vp-code">250 – 1,200</span>
                <h3>Grow your church</h3>
                <p>Replace eight years of duct tape. Upgrade to the system your team has earned.</p>
                <span className="vp-arrow"><SplitText>For growing →</SplitText></span>
              </a>
              <a className="vision-path" href="/solutions/multi-site">
                <span className="vp-code">Over 1,200</span>
                <h3>Add a campus</h3>
                <p>Deploy a new location at the same operational level as the original.</p>
                <span className="vp-arrow"><SplitText>For multi-site →</SplitText></span>
              </a>
            </div>
          </div>

          <div className="vision-footer">
            <a className="cta-pill vision-cta" href="#build">
              <SplitText>Build a system →</SplitText>
            </a>
            <span className="vision-footer-or">
              Or just talk to us —{' '}
              <a href="mailto:hello@arkwright.systems" className="link-wipe">hello@arkwright.systems</a>
            </span>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─────────────────────────────────────────────────────────────────────────────
// Section 10 — Footer
// ─────────────────────────────────────────────────────────────────────────────

function SiteFooter() {
  return (
    <footer className="site-footer" data-screen-label="10 Footer">
      <div className="container">
        <div className="footer-top">
          <div className="footer-brand">
            <a className="wordmark" href="/">
              <span className="glyph">A</span>
              Arkwright Systems<sup>®</sup>
            </a>
            <p>Complete systems for portable ministries. Design, cases, trailers, equipment, delivery, training — one partner, one coordinated whole.</p>
          </div>

          <div className="footer-col">
            <h5>System</h5>
            <ul>
              <li><a href="/system/digital-launch-kit">Digital Launch Kit</a></li>
              <li><a href="/system/cases">Custom Cases</a></li>
              <li><a href="/system/trailers">Trailers</a></li>
              <li><a href="/system/equipment">Equipment</a></li>
              <li><a href="/system/delivery">Delivery</a></li>
              <li><a href="/system/training">Training</a></li>
            </ul>
          </div>

          <div className="footer-col">
            <h5>Who we serve</h5>
            <ul>
              <li><a href="/solutions/church-plants">Church Plants</a></li>
              <li><a href="/solutions/established">Growing Churches</a></li>
              <li><a href="/solutions/multi-site">Multi-Campus</a></li>
              <li><a href="/solutions/upgrading">Trade Up</a></li>
            </ul>
          </div>

          <div className="footer-col">
            <h5>Company</h5>
            <ul>
              <li><a href="/how-it-works">How it works</a></li>
              <li><a href="/launch-a-church">Launch a church</a></li>
              <li><a href="/about">About</a></li>
              <li><a href="/case-studies">Case studies</a></li>
              <li><a href="/contact">Contact</a></li>
            </ul>
          </div>

          <div className="footer-col">
            <h5>Resources</h5>
            <ul>
              <li><a href="/resources/setup-guide">Setup guide</a></li>
              <li><a href="/resources/readiness-quiz">Readiness quiz</a></li>
              <li><a href="/resources/cost-calculator">Cost calculator</a></li>
              <li><a href="/resources/checklists">Checklists</a></li>
            </ul>
          </div>
        </div>

        <div className="footer-bottom">
          <div>© 2026 ARKWRIGHT SYSTEMS · ALL RIGHTS RESERVED</div>
          <div>BUILT FOR THE LONG SUNDAY</div>
          <div>PRIVACY · TERMS · ACCESSIBILITY</div>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, {
  CategoryStatement,
  ComponentsSection,
  EnvironmentsSection,
  StagesSection,
  RolesSection,
  ProofSection,
  PromiseSection,
  VisionClose,
  SiteFooter,
});
