// ============================================================
// DEMIURGE — AGENT TEAM CARDS + WORKFLOW VIZ
// ============================================================

// Each agent gets a unique mechanical sigil (brass + cyan accent)
const AgentGlyph = ({ kind }) => {
  const common = { viewBox: '0 0 80 80', xmlns: 'http://www.w3.org/2000/svg' };
  const stroke = '#c9a674';
  const cy = '#4be8ff';
  switch (kind) {
    case 'atlas': // Globe with crosshair — sales/pipeline
      return (
        <svg {...common}>
          <defs><radialGradient id="g-atlas" cx="35%" cy="35%"><stop offset="0%" stopColor="#e8c98a"/><stop offset="60%" stopColor="#8a6a2e"/><stop offset="100%" stopColor="#2d2208"/></radialGradient></defs>
          <circle cx="40" cy="40" r="32" fill="none" stroke={stroke} strokeWidth="0.7" opacity="0.6"/>
          <circle cx="40" cy="40" r="26" fill="url(#g-atlas)" opacity="0.5"/>
          <circle cx="40" cy="40" r="26" fill="none" stroke={stroke} strokeWidth="1.2"/>
          <ellipse cx="40" cy="40" rx="26" ry="9" fill="none" stroke={stroke} strokeWidth="0.6"/>
          <ellipse cx="40" cy="40" rx="9" ry="26" fill="none" stroke={stroke} strokeWidth="0.6"/>
          <line x1="40" y1="6" x2="40" y2="14" stroke={cy} strokeWidth="0.8"/>
          <line x1="40" y1="66" x2="40" y2="74" stroke={cy} strokeWidth="0.8"/>
          <line x1="6" y1="40" x2="14" y2="40" stroke={cy} strokeWidth="0.8"/>
          <line x1="66" y1="40" x2="74" y2="40" stroke={cy} strokeWidth="0.8"/>
          <circle cx="40" cy="40" r="3" fill={cy} opacity="0.9"/>
          <circle cx="40" cy="40" r="6" fill="none" stroke={cy} strokeWidth="0.5" opacity="0.6"/>
        </svg>
      );
    case 'mercury': // Bolts + signal radiating — support
      return (
        <svg {...common}>
          <circle cx="40" cy="40" r="30" fill="none" stroke={stroke} strokeWidth="0.8" opacity="0.7"/>
          <circle cx="40" cy="40" r="24" fill="none" stroke={stroke} strokeWidth="0.4" opacity="0.4"/>
          <path d="M 40 16 a 24 24 0 0 1 24 24" fill="none" stroke={cy} strokeWidth="1.2"/>
          <path d="M 40 22 a 18 18 0 0 1 18 18" fill="none" stroke={cy} strokeWidth="0.8" opacity="0.6"/>
          <path d="M 40 28 a 12 12 0 0 1 12 12" fill="none" stroke={cy} strokeWidth="0.6" opacity="0.4"/>
          <path d="M 36 36 L 44 36 L 40 50 Z" fill={stroke}/>
          <circle cx="40" cy="50" r="2" fill={cy}/>
          <line x1="40" y1="62" x2="40" y2="70" stroke={stroke} strokeWidth="1"/>
        </svg>
      );
    case 'iris': // Concentric eye / iris — analytics
      return (
        <svg {...common}>
          <defs><radialGradient id="g-iris" cx="50%" cy="50%"><stop offset="0%" stopColor="#fff"/><stop offset="40%" stopColor="#c8a8ff"/><stop offset="100%" stopColor="#1e1455"/></radialGradient></defs>
          <path d="M 8 40 Q 40 12 72 40 Q 40 68 8 40 Z" fill="none" stroke={stroke} strokeWidth="1.2"/>
          <ellipse cx="40" cy="40" rx="32" ry="16" fill="none" stroke={stroke} strokeWidth="0.5" opacity="0.5"/>
          <circle cx="40" cy="40" r="14" fill="url(#g-iris)"/>
          <circle cx="40" cy="40" r="14" fill="none" stroke={cy} strokeWidth="0.6"/>
          <circle cx="40" cy="40" r="6" fill="#03040c"/>
          <circle cx="38" cy="38" r="2" fill="#fff" opacity="0.9"/>
          {Array.from({length: 12}).map((_, i) => {
            const a = (i * 30) * Math.PI / 180;
            const x1 = 40 + Math.cos(a) * 8;
            const y1 = 40 + Math.sin(a) * 8;
            const x2 = 40 + Math.cos(a) * 13;
            const y2 = 40 + Math.sin(a) * 13;
            return <line key={i} x1={x1} y1={y1} x2={x2} y2={y2} stroke="#8b6bff" strokeWidth="0.5" opacity="0.7"/>;
          })}
        </svg>
      );
    case 'vulcan': // Anvil / forge gear — operations
      return (
        <svg {...common}>
          <circle cx="40" cy="40" r="30" fill="none" stroke={stroke} strokeWidth="0.6" opacity="0.5"/>
          {Array.from({length: 8}).map((_, i) => {
            const a = (i * 45) * Math.PI / 180;
            const x1 = 40 + Math.cos(a) * 22;
            const y1 = 40 + Math.sin(a) * 22;
            const x2 = 40 + Math.cos(a) * 30;
            const y2 = 40 + Math.sin(a) * 30;
            return <line key={i} x1={x1} y1={y1} x2={x2} y2={y2} stroke={stroke} strokeWidth="3" strokeLinecap="butt"/>;
          })}
          <circle cx="40" cy="40" r="22" fill="#1a1305" stroke={stroke} strokeWidth="1.2"/>
          <circle cx="40" cy="40" r="14" fill="none" stroke={stroke} strokeWidth="0.6"/>
          <circle cx="40" cy="40" r="6" fill={cy} opacity="0.8"/>
          <circle cx="40" cy="40" r="6" fill="none" stroke={cy}/>
        </svg>
      );
    case 'orpheus': // Lyre / waveform — content/marketing
      return (
        <svg {...common}>
          <rect x="18" y="14" width="44" height="52" rx="2" fill="none" stroke={stroke} strokeWidth="0.8" opacity="0.6"/>
          <path d="M 22 20 Q 40 8 58 20" fill="none" stroke={stroke} strokeWidth="1.5"/>
          {[26, 32, 38, 44, 50, 56].map((x, i) => {
            const h = [12, 30, 22, 36, 18, 26][i];
            return <line key={i} x1={x} y1="60" x2={x} y2={60 - h} stroke={i % 2 === 0 ? cy : stroke} strokeWidth="1.5"/>;
          })}
          <line x1="18" y1="60" x2="62" y2="60" stroke={stroke} strokeWidth="0.6"/>
        </svg>
      );
    case 'artemis': // Crosshair / arrow — lead-gen
      return (
        <svg {...common}>
          <circle cx="40" cy="40" r="30" fill="none" stroke={stroke} strokeWidth="0.7"/>
          <circle cx="40" cy="40" r="22" fill="none" stroke={stroke} strokeWidth="0.5" opacity="0.5"/>
          <circle cx="40" cy="40" r="14" fill="none" stroke={stroke} strokeWidth="0.5" opacity="0.5"/>
          <line x1="40" y1="4" x2="40" y2="20" stroke={stroke} strokeWidth="0.7"/>
          <line x1="40" y1="60" x2="40" y2="76" stroke={stroke} strokeWidth="0.7"/>
          <line x1="4" y1="40" x2="20" y2="40" stroke={stroke} strokeWidth="0.7"/>
          <line x1="60" y1="40" x2="76" y2="40" stroke={stroke} strokeWidth="0.7"/>
          {/* Arrow pinned center */}
          <line x1="14" y1="66" x2="46" y2="34" stroke={cy} strokeWidth="1.4"/>
          <path d="M 14 66 L 19 64 L 16 69 Z" fill={cy}/>
          <circle cx="46" cy="34" r="2.5" fill={cy}/>
          <circle cx="46" cy="34" r="5" fill="none" stroke={cy} strokeWidth="0.5"/>
        </svg>
      );
    case 'hermes': // Envelope with wings — comms/inbox
      return (
        <svg {...common}>
          <path d="M 8 30 L 40 14 L 72 30 L 72 60 L 40 62 L 8 60 Z" fill="none" stroke={stroke} strokeWidth="1"/>
          <path d="M 8 30 L 40 50 L 72 30" fill="none" stroke={stroke} strokeWidth="1"/>
          <path d="M 14 38 Q 4 42 12 50 Q 6 54 16 56" fill="none" stroke={cy} strokeWidth="0.8" opacity="0.85"/>
          <path d="M 66 38 Q 76 42 68 50 Q 74 54 64 56" fill="none" stroke={cy} strokeWidth="0.8" opacity="0.85"/>
          <circle cx="40" cy="42" r="2" fill={cy}/>
        </svg>
      );
    case 'midas': // Coin / cog / value — pricing
      return (
        <svg {...common}>
          <defs><radialGradient id="g-midas" cx="35%" cy="35%"><stop offset="0%" stopColor="#fbe4a5"/><stop offset="60%" stopColor="#c9a674"/><stop offset="100%" stopColor="#3d2e12"/></radialGradient></defs>
          {Array.from({length: 12}).map((_, i) => {
            const a = (i * 30) * Math.PI / 180;
            const x = 40 + Math.cos(a) * 33;
            const y = 40 + Math.sin(a) * 33;
            return <rect key={i} x={x - 2} y={y - 3} width="4" height="6" fill={stroke} transform={`rotate(${i * 30} ${x} ${y})`}/>;
          })}
          <circle cx="40" cy="40" r="26" fill="url(#g-midas)"/>
          <circle cx="40" cy="40" r="26" fill="none" stroke="#8a6a2e" strokeWidth="0.8"/>
          <text x="40" y="46" textAnchor="middle" fill="#3d2e12" fontFamily="Instrument Serif" fontStyle="italic" fontSize="28" fontWeight="600">M</text>
          <ellipse cx="34" cy="32" rx="8" ry="3" fill="rgba(255,255,255,0.5)"/>
        </svg>
      );
    default:
      return null;
  }
};

const AGENTS = [
  { kind: 'atlas',    name: 'Atlas',    role: 'Lead Generation Operator', desc: 'Identifies your TAM from public records and intent signals. Runs the multi-touch outbound. Hands warm prospects to the closer.', stats: [['Leads sourced', '9,200/mo'], ['ICP fit', '92%'], ['Reply rate', '14.7%']], live: '41 meetings booked today' },
  { kind: 'hermes',   name: 'Hermes',   role: 'AI Phone Agent',           desc: 'Picks up in two rings, day or night. Handles intake, booking, qualification, and recall calls with the bedside manner of senior staff.', stats: [['Calls / week', '14,800'], ['Pickup time', '0.4s'], ['Booking rate', '64%']], live: 'On 84 live calls right now' },
  { kind: 'orpheus',  name: 'Calliope', role: 'Content Operator',         desc: 'Generates copy, image, video, and avatar/clone content in your brand voice. Broadcasts natively to TikTok, IG, YouTube, LinkedIn, X, Threads, Bluesky, Pinterest, Telegram, WhatsApp.', stats: [['Assets / mo', '2,400'], ['Channels live', '11'], ['CPM Δ', '-34%']], live: '184 assets shipped today' },
  { kind: 'iris',     name: 'Vesta',    role: 'Lead Qualification',       desc: 'Reads every inbound — form, call, DM, ad click. Scores against your ICP in real time. Routes only the qualified to your closers.', stats: [['Leads scored', '12,402/mo'], ['ICP precision', '92%'], ['False-positive', '1.4%']], live: 'Live-scoring 47 leads' },
  { kind: 'midas',    name: 'Orion',    role: 'Ad Optimisation',          desc: 'Re-allocates spend across Meta, Google, TikTok, LinkedIn hourly. Builds creative variants. Kills underperformers. Optimises to revenue, not clicks.', stats: [['Channels live', '5'], ['ROAS', '6.2x'], ['CPM Δ', '-34%']], live: 'Re-balancing £42k/day' },
  { kind: 'mercury',  name: 'Iris',     role: 'Customer Support',         desc: 'Handles tier-1 and tier-2 across email, chat, voice and DM in 31 languages. Escalates the 4% that need a human, with full context attached.', stats: [['CSAT', '4.91 / 5'], ['Deflection', '96%'], ['Resp. time', '22s']], live: '847 conversations open' }
];

const AgentSection = () => (
  <section className="lp-section" id="team">
    <div className="lp">
      <div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', gap: 48, flexWrap: 'wrap'}}>
        <div style={{maxWidth: 820}}>
          <div className="lp-eyebrow">/ 02 · The workforce</div>
          <h2 className="lp-h2" style={{marginTop: 18}}>
            Your competitors hire staff.<br/>
            You deploy <em className="lp-brass">operators</em>.
          </h2>
        </div>
        <p className="lp-lede" style={{maxWidth: 380, fontSize: 15.5}}>
          Each operator runs autonomously in its lane and coordinates with the rest through a shared model
          of your business. Not six chatbots glued together — one organism.
        </p>
      </div>

      <div className="lp-agent-grid lp-agent-grid-3">
        {AGENTS.map((a, i) => (
          <div className="lp-agent-card" key={a.kind}>
            <div className="ix">/ {String(i + 1).padStart(2, '0')}</div>
            <div className="lp-agent-live">
              <span className="dot"></span>
              <span>{a.live}</span>
            </div>
            <div className="lp-agent-glyph"><AgentGlyph kind={a.kind}/></div>
            <div className="lp-agent-name">{a.name}</div>
            <div className="lp-agent-role">{a.role}</div>
            <div className="lp-agent-desc">{a.desc}</div>
            <div className="lp-agent-spec">
              <div className="ln"><span>{a.stats[0][0]}</span><span className="v">{a.stats[0][1]}</span></div>
              <div className="ln"><span>{a.stats[1][0]}</span><span className="v">{a.stats[1][1]}</span></div>
              <div className="ln"><span>{a.stats[2][0]}</span><span className="v live">{a.stats[2][1]}</span></div>
            </div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

window.AgentSection = AgentSection;
window.AGENTS = AGENTS;
