// Four hero variants for Motion.html, each isolating one animation technique.
// Renders <DirBeforeAfter hero={...}/> with a different hero swapped in.

// ─── A · Flow Diagram Hero (ported from Dir 1) ─────────────────
function HeroFlowDiagram() {
  return (
    <section style={{ background: AX.navy, color: '#fff', padding: '100px 64px 80px', position: 'relative', overflow: 'hidden' }}>
      <div style={{
        position: 'absolute', top: -200, right: -200, width: 600, height: 600, borderRadius: '50%',
        background: `radial-gradient(circle, ${AX.teal}20 0%, transparent 70%)`, pointerEvents: 'none',
      }} />
      <div style={{ display: 'grid', gridTemplateColumns: '1.1fr 1fr', gap: 80, alignItems: 'center', position: 'relative' }}>
        <div>
          <div style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '6px 14px', borderRadius: 999, background: `rgba(31,168,168,0.12)`, border: `1px solid rgba(31,168,168,0.3)`, color: AX.teal, fontSize: 12, letterSpacing: 1.2, textTransform: 'uppercase', fontWeight: 600, marginBottom: 28 }}>
            <span style={{ width: 6, height: 6, background: AX.teal, borderRadius: 99, animation: 'mv-pulse 2s infinite' }} /> Live · Automation consulting
          </div>
          <h1 style={{
            fontFamily: 'Space Grotesk, sans-serif',
            fontSize: 76, fontWeight: 700, lineHeight: 0.98, letterSpacing: -2.5,
            margin: 0, textWrap: 'balance',
          }}>
            Your systems should<br/>
            <span style={{ color: AX.teal, fontStyle: 'italic', fontWeight: 500 }}>work together.</span><br/>
            <span style={{ color: 'rgba(255,255,255,0.45)' }}>Not against you.</span>
          </h1>
          <p style={{ fontSize: 19, lineHeight: 1.55, color: 'rgba(255,255,255,0.72)', marginTop: 32, maxWidth: 540, textWrap: 'pretty' }}>
            Automate the manual work flowing through your business — every input, every handoff, every output, running in the background.
          </p>
          <div style={{ display: 'flex', gap: 12, marginTop: 36 }}>
            <a href="#book" style={{
              padding: '16px 28px', background: AX.teal, color: '#fff', borderRadius: 999,
              fontSize: 15, fontWeight: 600, textDecoration: 'none', display: 'inline-flex', alignItems: 'center', gap: 10,
            }}>
              Book a 30-minute review {Icon.arrow('#fff')}
            </a>
            <a href="#calc" style={{
              padding: '16px 28px', background: 'transparent', color: '#fff',
              border: '1px solid rgba(255,255,255,0.2)', borderRadius: 999,
              fontSize: 15, fontWeight: 500, textDecoration: 'none',
            }}>
              Calculate your ROI
            </a>
          </div>
        </div>
        <MVFlowDiagram />
      </div>
      <style>{`
        @keyframes mv-pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.3 } }
        @keyframes mv-flow-dot { 0% { offset-distance: 0% } 100% { offset-distance: 100% } }
      `}</style>
    </section>
  );
}

function MVFlowDiagram() {
  const Node = ({ x, y, label, sub, size = 'm', color = '#fff' }) => {
    const w = size === 'lg' ? 160 : 140;
    return (
      <div style={{
        position: 'absolute', left: x, top: y,
        background: 'rgba(255,255,255,0.04)', border: `1px solid rgba(255,255,255,0.1)`,
        borderRadius: 10, padding: '12px 14px', width: w,
      }}>
        <div style={{ fontSize: 11, color: 'rgba(255,255,255,0.5)', fontFamily: 'JetBrains Mono, monospace', textTransform: 'uppercase', letterSpacing: 0.6 }}>{sub}</div>
        <div style={{ fontSize: 14, color, fontWeight: 500, fontFamily: 'Space Grotesk, sans-serif', marginTop: 2 }}>{label}</div>
      </div>
    );
  };
  const paths = [
    'M 110 90 C 180 90, 220 240, 290 270',
    'M 110 190 C 180 190, 220 250, 290 270',
    'M 110 290 C 180 290, 220 270, 290 270',
    'M 110 390 C 180 390, 220 290, 290 270',
    'M 310 270 C 380 270, 420 120, 490 120',
    'M 310 270 C 380 270, 420 220, 490 220',
    'M 310 270 C 380 270, 420 320, 490 320',
    'M 310 270 C 380 270, 420 420, 490 420',
  ];
  return (
    <div style={{
      position: 'relative', height: 540, width: '100%',
      background: 'linear-gradient(180deg, rgba(11,30,63,0.6) 0%, rgba(7,21,46,0.4) 100%)',
      border: '1px solid rgba(255,255,255,0.06)', borderRadius: 16, overflow: 'hidden',
    }}>
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%' }} viewBox="0 0 600 540" preserveAspectRatio="none">
        {paths.map((d, i) => (
          <g key={i}>
            <path d={d} stroke="rgba(255,255,255,0.1)" strokeWidth="1" fill="none" />
            <circle r="3.5" fill={AX.teal} style={{ offsetPath: `path('${d}')`, animation: `mv-flow-dot ${2 + (i % 3) * 0.4}s linear ${i * 0.25}s infinite`, filter: `drop-shadow(0 0 4px ${AX.teal})` }} />
          </g>
        ))}
      </svg>
      {/* Inputs */}
      <Node x={10}  y={70}  sub="Input" label="Email inbox" />
      <Node x={10}  y={170} sub="Input" label="Xero invoices" />
      <Node x={10}  y={270} sub="Input" label="SharePoint docs" />
      <Node x={10}  y={370} sub="Input" label="Teams alerts" />
      {/* Brain */}
      <div style={{
        position: 'absolute', left: 210, top: 230, width: 180, padding: '16px 18px',
        background: 'rgba(31,168,168,0.15)', border: `1px solid ${AX.teal}`, borderRadius: 12,
        boxShadow: `0 0 40px rgba(31,168,168,0.25)`,
      }}>
        <div style={{ fontSize: 11, color: AX.teal, fontFamily: 'JetBrains Mono, monospace', letterSpacing: 1.2, textTransform: 'uppercase' }}>Axiom Brain</div>
        <div style={{ fontSize: 15, fontWeight: 600, fontFamily: 'Space Grotesk, sans-serif', marginTop: 4 }}>Process · Validate · Route</div>
      </div>
      {/* Outputs */}
      <Node x={410} y={100} sub="Action" label="Create record" color={AX.teal} />
      <Node x={410} y={200} sub="Action" label="Send approval" color={AX.teal} />
      <Node x={410} y={300} sub="Action" label="Post to Teams" color={AX.teal} />
      <Node x={410} y={400} sub="Action" label="File & archive" color={AX.teal} />
    </div>
  );
}

// ─── B · Ticking Counter Hero ─────────────────────────────────
function HeroTickingCounter() {
  const [hoursSaved, setHoursSaved] = React.useState(24187);
  React.useEffect(() => {
    const id = setInterval(() => setHoursSaved((x) => x + 1), 1200);
    return () => clearInterval(id);
  }, []);
  // Motion-blurred figures moving through a corridor — editorial, not stock-face
  const HERO_IMG = 'https://images.unsplash.com/photo-1600880292203-757bb62b4baf?w=2000&q=80&auto=format&fit=crop';
  return (
    <section style={{ padding: '48px 64px 72px', position: 'relative', background: AX.bone, overflow: 'hidden' }}>
      {/* Duotone photo background */}
      <div aria-hidden="true" style={{
        position: 'absolute', inset: 0,
        backgroundImage: `url(${HERO_IMG})`,
        backgroundSize: 'cover', backgroundPosition: 'center',
        filter: 'grayscale(1) contrast(1.1)',
        opacity: 0.22,
        mixBlendMode: 'multiply',
        pointerEvents: 'none',
      }} />
      <div aria-hidden="true" style={{
        position: 'absolute', inset: 0,
        background: `linear-gradient(135deg, ${AX.bone}dd 0%, ${AX.bone}bb 45%, ${AX.teal}1a 100%)`,
        pointerEvents: 'none',
      }} />
      {/* soft radial glow behind headline */}
      <div style={{
        position: 'absolute', left: -180, top: 40, width: 820, height: 820, borderRadius: '50%',
        background: `radial-gradient(circle, ${AX.teal}22 0%, transparent 60%)`, pointerEvents: 'none', filter: 'blur(8px)',
      }} />
      <div style={{
        position: 'absolute', right: -220, bottom: -120, width: 640, height: 640, borderRadius: '50%',
        background: `radial-gradient(circle, ${AX.coral}18 0%, transparent 60%)`, pointerEvents: 'none', filter: 'blur(8px)',
      }} />
      {/* faint dot grid */}
      <svg style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', pointerEvents: 'none', opacity: 0.55 }}>
        <defs>
          <pattern id="mv-dots" width="28" height="28" patternUnits="userSpaceOnUse">
            <circle cx="1.2" cy="1.2" r="1.2" fill={AX.navy} opacity="0.08" />
          </pattern>
        </defs>
        <rect width="100%" height="100%" fill="url(#mv-dots)" />
      </svg>

      <div style={{ position: 'relative', display: 'grid', gridTemplateColumns: '1.3fr 1fr', gap: 64, alignItems: 'end', paddingTop: 20 }}>
        <div>
          <h1 style={{
            fontFamily: 'Space Grotesk, sans-serif',
            fontSize: 96, fontWeight: 700, lineHeight: 0.92, letterSpacing: -4,
            margin: 0, color: AX.navy, textWrap: 'balance',
          }}>
            Your systems should<br/>
            <span style={{ color: AX.teal, fontStyle: 'italic', fontWeight: 500 }}>work together.</span><br/>
            Not against you.
          </h1>
          <div style={{ marginTop: 36, maxWidth: 600, fontSize: 19, color: AX.slate, lineHeight: 1.55, textWrap: 'pretty' }}>
            We connect and automate your tools to eliminate double handling, delays, and inefficiencies — using the Microsoft 365 environment you already have.
          </div>
          <div style={{ display: 'flex', gap: 12, marginTop: 36 }}>
            <a href="#book" style={{
              padding: '16px 26px', background: AX.teal, color: '#fff', borderRadius: 999,
              fontSize: 15, fontWeight: 600, textDecoration: 'none', display: 'inline-flex', alignItems: 'center', gap: 10,
            }}>
              Book a 30-minute review {Icon.arrow('#fff')}
            </a>
            <a href="#calc" style={{
              padding: '16px 26px', background: 'transparent', color: AX.navy,
              border: `1px solid ${AX.navy}`, borderRadius: 999,
              fontSize: 15, fontWeight: 500, textDecoration: 'none',
            }}>
              Calculate your ROI
            </a>
          </div>
        </div>

        <div style={{
          background: AX.navy, color: '#fff', borderRadius: 20, padding: 32,
          position: 'relative', overflow: 'hidden',
        }}>
          <div style={{ position: 'absolute', top: 16, right: 20, display: 'flex', alignItems: 'center', gap: 8, fontSize: 11, letterSpacing: 1.5, textTransform: 'uppercase', color: AX.teal, fontFamily: 'JetBrains Mono, monospace', fontWeight: 600 }}>
            <span style={{ width: 6, height: 6, background: AX.teal, borderRadius: 99, animation: 'mv-pulse2 1.2s infinite' }} /> LIVE
          </div>
          <div style={{ fontSize: 12, letterSpacing: 1.5, textTransform: 'uppercase', color: 'rgba(255,255,255,0.6)', fontFamily: 'JetBrains Mono, monospace', fontWeight: 600 }}>
            Hours saved for clients this year
          </div>
          <div style={{
            fontFamily: 'Space Grotesk, sans-serif',
            fontSize: 84, fontWeight: 700, letterSpacing: -3,
            lineHeight: 1, marginTop: 12, fontVariantNumeric: 'tabular-nums',
          }}>
            {hoursSaved.toLocaleString('en-AU')}
          </div>
          <div style={{ height: 1, background: 'rgba(255,255,255,0.1)', margin: '24px 0' }} />
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
            <div>
              <div style={{ fontSize: 11, color: 'rgba(255,255,255,0.5)', fontFamily: 'JetBrains Mono, monospace', letterSpacing: 1 }}>ERRORS CUT</div>
              <div style={{ fontFamily: 'Space Grotesk, sans-serif', fontSize: 24, fontWeight: 600 }}>99.4%</div>
            </div>
            <div>
              <div style={{ fontSize: 11, color: 'rgba(255,255,255,0.5)', fontFamily: 'JetBrains Mono, monospace', letterSpacing: 1 }}>AVG. ROI MONTH</div>
              <div style={{ fontFamily: 'Space Grotesk, sans-serif', fontSize: 24, fontWeight: 600 }}>3.2</div>
            </div>
          </div>
        </div>
      </div>
      <style>{`@keyframes mv-pulse2 { 0%, 100% { opacity: 1 } 50% { opacity: 0.3 } }`}</style>
    </section>
  );
}

// ─── C · Auto-Toggle Split Screen ──────────────────────────────
function HeroAutoToggle() {
  // divider position as % — oscillates between 35 and 65 every few seconds
  const [pos, setPos] = React.useState(50);
  React.useEffect(() => {
    const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
    if (reduce) return;
    let dir = 1;
    const id = setInterval(() => {
      setPos((p) => {
        if (p >= 72) dir = -1;
        if (p <= 28) dir = 1;
        return p + dir * 0.6;
      });
    }, 40);
    return () => clearInterval(id);
  }, []);

  const HEIGHT = 620;
  return (
    <section style={{ position: 'relative' }}>
      <div style={{ position: 'relative', minHeight: HEIGHT, overflow: 'hidden' }}>
        {/* BEFORE (full width, underneath) */}
        <div style={{ position: 'absolute', inset: 0, background: AX.bone, padding: '80px 56px' }}>
          <div style={{ fontSize: 11, letterSpacing: 2.5, textTransform: 'uppercase', color: AX.mute, fontFamily: 'JetBrains Mono, monospace', fontWeight: 700, marginBottom: 20 }}>
            Before · Manual
          </div>
          <div style={{ fontFamily: 'Space Grotesk, sans-serif', fontSize: 54, fontWeight: 600, color: AX.ink, letterSpacing: -1.8, lineHeight: 1.02, textWrap: 'balance', maxWidth: '48%' }}>
            Your team spends<br/>hours on tasks<br/>
            <span style={{ textDecoration: 'line-through', textDecorationColor: AX.coral, textDecorationThickness: 3, color: AX.mute }}>software can do</span>
          </div>
          <div style={{ marginTop: 40, display: 'flex', flexDirection: 'column', gap: 10, maxWidth: '48%' }}>
            {['Re-enter invoice data into Xero','Chase approvals in email','Compile weekly report from 4 spreadsheets','Reconcile deliveries from yesterday',"Fix errors from yesterday's fixes"].map((t, i) => (
              <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 12, fontSize: 14, color: AX.slate }}>
                <div style={{ width: 16, height: 16, borderRadius: 4, border: `1.5px solid ${AX.mute}`, background: '#fff' }} />
                {t}
              </div>
            ))}
          </div>
          <div style={{ position: 'absolute', bottom: 40, left: 56, right: '52%', display: 'flex', alignItems: 'center', gap: 14, fontFamily: 'JetBrains Mono, monospace', fontSize: 13, color: AX.coral }}>
            <div style={{ flex: 1, height: 1, background: AX.coral, opacity: 0.3 }} />
            ~6 HOURS/DAY LOST
            <div style={{ flex: 1, height: 1, background: AX.coral, opacity: 0.3 }} />
          </div>
        </div>

        {/* AFTER (clipped to right of divider) */}
        <div style={{ position: 'absolute', inset: 0, clipPath: `polygon(${pos}% 0, 100% 0, 100% 100%, ${pos}% 100%)`, background: AX.navy, color: '#fff', padding: '80px 56px', transition: 'clip-path 40ms linear' }}>
          <div style={{ position: 'absolute', top: -100, right: -100, width: 400, height: 400, borderRadius: '50%', background: `radial-gradient(circle, ${AX.teal}40 0%, transparent 70%)`, pointerEvents: 'none' }} />
          {/* right-side content, mirrored to right half */}
          <div style={{ marginLeft: '50%', paddingLeft: 32 }}>
            <div style={{ fontSize: 11, letterSpacing: 2.5, textTransform: 'uppercase', color: AX.teal, fontFamily: 'JetBrains Mono, monospace', fontWeight: 700, marginBottom: 20 }}>
              After · Automated
            </div>
            <div style={{ fontFamily: 'Space Grotesk, sans-serif', fontSize: 54, fontWeight: 600, letterSpacing: -1.8, lineHeight: 1.02, textWrap: 'balance' }}>
              Your systems<br/>do the work.<br/>
              <span style={{ color: AX.teal, fontStyle: 'italic', fontWeight: 500 }}>Automatically.</span>
            </div>
            <div style={{ marginTop: 40, display: 'flex', flexDirection: 'column', gap: 10 }}>
              {['Invoices synced to Xero on receipt','Approvals routed & logged in Teams','Reports generated before you arrive','Deliveries reconciled overnight','Exceptions flagged — the rest just works'].map((t, i) => (
                <div key={i} style={{ display: 'flex', alignItems: 'center', gap: 12, fontSize: 14, color: 'rgba(255,255,255,0.9)' }}>
                  <div style={{ width: 16, height: 16, borderRadius: 4, background: AX.teal, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                    <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="#fff" strokeWidth="3.5" strokeLinecap="round" strokeLinejoin="round"><path d="M4 12l5 5L20 6" /></svg>
                  </div>
                  {t}
                </div>
              ))}
            </div>
            <div style={{ position: 'absolute', bottom: 40, left: '50%', right: 56, paddingLeft: 32, display: 'flex', alignItems: 'center', gap: 14, fontFamily: 'JetBrains Mono, monospace', fontSize: 13, color: AX.teal }}>
              <div style={{ flex: 1, height: 1, background: AX.teal, opacity: 0.3 }} />
              ~5 MIN OVERSIGHT
              <div style={{ flex: 1, height: 1, background: AX.teal, opacity: 0.3 }} />
            </div>
          </div>
        </div>

        {/* Divider line + chevron handle */}
        <div style={{
          position: 'absolute', top: 0, bottom: 0, left: `${pos}%`,
          width: 2, background: '#fff', boxShadow: '0 0 20px rgba(0,0,0,0.2)',
          transition: 'left 40ms linear', zIndex: 4, pointerEvents: 'none',
        }} />
        <div style={{
          position: 'absolute', top: '50%', left: `${pos}%`, transform: 'translate(-50%, -50%)',
          width: 84, height: 84, borderRadius: '50%', background: '#fff',
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          boxShadow: '0 10px 40px rgba(0,0,0,0.25), 0 0 0 8px rgba(255,255,255,0.4)',
          transition: 'left 40ms linear', zIndex: 5,
        }}>
          <svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke={AX.navy} strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round">
            <path d="M5 12h14M13 5l7 7-7 7" />
          </svg>
        </div>
      </div>

      {/* subhead band (shared with default hero) */}
      <div style={{ padding: '56px 64px', display: 'grid', gridTemplateColumns: '1fr auto', gap: 48, alignItems: 'center', background: '#fff' }}>
        <div>
          <h1 style={{ fontFamily: 'Space Grotesk, sans-serif', fontSize: 52, fontWeight: 600, color: AX.navy, letterSpacing: -1.8, lineHeight: 1, margin: 0, textWrap: 'balance' }}>
            Your systems should work together.<br/>
            <span style={{ color: AX.teal }}>Not against you.</span>
          </h1>
          <p style={{ fontSize: 18, color: AX.slate, lineHeight: 1.55, marginTop: 20, maxWidth: 720, textWrap: 'pretty' }}>
            We connect and automate your tools to eliminate double handling, delays, and inefficiencies — using the Microsoft 365 environment you already have.
          </p>
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
          <a href="#book" style={{
            padding: '16px 26px', background: AX.teal, color: '#fff', borderRadius: 999,
            fontSize: 15, fontWeight: 600, textDecoration: 'none', display: 'inline-flex', alignItems: 'center', gap: 10, justifyContent: 'center',
          }}>
            Book a 30-minute review {Icon.arrow('#fff')}
          </a>
          <a href="#calc" style={{
            padding: '16px 26px', background: 'transparent', color: AX.navy,
            border: `1px solid ${AX.navy}`, borderRadius: 999,
            fontSize: 15, fontWeight: 500, textDecoration: 'none', textAlign: 'center',
          }}>
            Calculate your ROI
          </a>
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { HeroFlowDiagram, HeroTickingCounter, HeroAutoToggle });
