/* ARES Technology — Live work section
 *
 * Features real launched sites built by ARES Technology. Distinct from the
 * illustrative "Sample preview layouts" — every card links to the live URL.
 *
 * Currently featured:
 *   1. ARES Protocol — AI governance & compliance consulting
 *      https://www.aresprotocol.org/
 *   2. EdgeFinder AI — Gated AI product access page
 *      https://edgefinderai.org/gate
 */

/* LiveSiteEmbed — scaled iframe of a real production site.
 * Renders the iframe at desktop width inside a card-width container and
 * scales it down with CSS transform. Clicks pass through to the parent <a>.
 * If framing is blocked (X-Frame-Options / CSP) or the iframe never loads,
 * we swap in the styled mock fallback so the card never looks broken. */
function LiveSiteEmbed({ src, renderWidth = 1280, renderHeight = 820, fallback }) {
  const [loaded, setLoaded] = React.useState(false);
  const [errored, setErrored] = React.useState(false);
  // On phones the scaled-desktop iframe always crops awkwardly inside the card —
  // the styled mock fallback looks cleaner. Watch the viewport width so a
  // device-rotation or window resize swaps the right view in.
  const [isNarrow, setIsNarrow] = React.useState(() =>
    typeof window !== 'undefined' && window.matchMedia('(max-width: 720px)').matches
  );
  React.useEffect(() => {
    if (typeof window === 'undefined') return;
    const mql = window.matchMedia('(max-width: 720px)');
    const onChange = (e) => setIsNarrow(e.matches);
    if (mql.addEventListener) mql.addEventListener('change', onChange);
    else mql.addListener(onChange);
    return () => {
      if (mql.removeEventListener) mql.removeEventListener('change', onChange);
      else mql.removeListener(onChange);
    };
  }, []);

  // Measure the card's actual width so we can render the site at a true desktop
  // viewport (renderWidth × renderHeight) and scale it down to fit the card
  // exactly. This keeps one clean desktop fold visible — full width, correct
  // aspect ratio, no half-page crop and no side gaps.
  const wrapRef = React.useRef(null);
  const [boxW, setBoxW] = React.useState(0);
  React.useEffect(() => {
    const el = wrapRef.current;
    if (!el) return;
    const update = () => setBoxW(el.clientWidth);
    update();
    if (typeof ResizeObserver === 'undefined') {
      window.addEventListener('resize', update);
      return () => window.removeEventListener('resize', update);
    }
    const ro = new ResizeObserver(update);
    ro.observe(el);
    return () => ro.disconnect();
  }, []);

  // No auto-timeout — only fall back if the iframe itself errors.
  // Some sites (like edgefinderai.org/gate) take a long time to fully load
  // their interactive JS, but the visual is fine within a second or two.

  if ((errored || isNarrow) && fallback) {
    const Fallback = fallback;
    return <Fallback />;
  }

  const scale = boxW ? boxW / renderWidth : 0;
  const boxH = renderHeight * scale;

  return (
    <div
      ref={wrapRef}
      style={{
        position: 'relative',
        width: '100%',
        height: boxH || Math.round(renderHeight * 0.3),
        overflow: 'hidden',
        background: '#0A0A0A',
        pointerEvents: 'none',
      }}
    >
      {!loaded && (
        <div className="shimmer" style={{
          position: 'absolute', inset: 0,
          '--shimmer-base': '#1A1A1A',
        }} />
      )}
      {scale > 0 && (
        <iframe
          src={src}
          title="Live site preview"
          loading="lazy"
          sandbox="allow-same-origin allow-scripts"
          onLoad={() => setLoaded(true)}
          onError={() => setErrored(true)}
          scrolling="no"
          style={{
            border: 0,
            position: 'absolute', top: 0, left: 0,
            width: renderWidth,
            height: renderHeight,
            // The global `iframe { max-width: 100% }` reset would otherwise clamp
            // this to the card width and break the desktop-viewport scaling.
            maxWidth: 'none',
            transform: 'scale(' + scale + ')',
            transformOrigin: 'top left',
            opacity: loaded ? 1 : 0,
            transition: 'opacity 360ms ease',
            pointerEvents: 'none',
          }}
        />
      )}
    </div>
  );
}

function LiveWork({ onCta }) {
  const projects = [
    {
      id: 'ares-protocol',
      name: 'ARES Protocol',
      tagline: 'AI governance & compliance',
      description:
        'A B2B consulting site for institutional-grade AI governance — EU AI Act, GDPR, ISO 42001, healthcare and financial services compliance.',
      url: 'https://www.aresprotocol.org/',
      label: 'aresprotocol.org',
      tags: ['Custom build', 'B2B consulting', 'Marketing site'],
      mock: AresProtocolMock,
      // aresprotocol.org blocks framing via X-Frame-Options — skip iframe, use styled mock
      forceFallback: true,
    },
    {
      id: 'edgefinder-ai',
      name: 'EdgeFinder AI',
      tagline: 'Prediction-markets terminal',
      description:
        'A Bloomberg-terminal-style site for prediction-market signals — dense monospace UI, live ticker, verified win-rate tracking, and Pro access.',
      url: 'https://edgefinderai.org/gate',
      label: 'edgefinderai.org/gate',
      tags: ['Custom build', 'Product UI', 'Dense monospace'],
      mock: EdgeFinderMock,
      embedWidth: 1280,
      embedRenderHeight: 820,
    },
  ];

  return (
    <section id="live-work" style={{
      padding: '88px 28px',
      background: 'var(--paper-2)',
      borderTop: '1px solid var(--line)',
      borderBottom: '1px solid var(--line)',
    }}>
      <div style={{ maxWidth: 'var(--maxw)', margin: '0 auto' }}>
        <SectionHeader
          eyebrow="Live work · custom builds"
          title="A few sites we’ve put live."
          intro="These are custom builds for clients with bigger scopes — beyond our £249 / £349 local-business starter packages. They’re real launched sites by ARES Technology. Click any card to visit the live site."
        />

        <div
          className="reveal-stagger"
          style={{
            marginTop: 40,
            display: 'grid',
            gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 380px), 1fr))',
            gap: 18,
          }}
        >
          {projects.map((p) => (
            <LiveWorkCard key={p.id} project={p} />
          ))}
        </div>

        <div style={{
          marginTop: 28,
          display: 'flex',
          flexWrap: 'wrap',
          gap: 16,
          alignItems: 'center',
          justifyContent: 'space-between',
        }}>
          <p style={{ fontSize: 13.5, color: 'var(--muted)', maxWidth: 560 }}>
            Want something custom beyond the starter packages? We also
            build bespoke marketing sites, product landings, and gated portals.
          </p>
          <AccentBtn onClick={onCta}>Discuss a custom build</AccentBtn>
        </div>

        {/* Recently launched for local businesses */}
        <LocalSitesGrid />
      </div>
    </section>
  );
}

function TileFavicon({ url, name, fg }) {
  const [errored, setErrored] = React.useState(false);
  const initial = (name || '?').trim().charAt(0).toUpperCase();
  const clean = url.replace(/^https?:\/\/(www\.)?/, '').replace(/\/$/, '');

  if (errored) {
    return (
      <span style={{
        width: 32, height: 32,
        borderRadius: 6,
        background: 'white',
        color: '#0F172A',
        display: 'inline-flex',
        alignItems: 'center',
        justifyContent: 'center',
        fontSize: 16,
        fontWeight: 700,
        letterSpacing: '-0.01em',
        boxShadow: '0 4px 12px -4px rgba(0,0,0,0.35)',
      }}>
        {initial}
      </span>
    );
  }
  return (
    <img
      src={`https://www.google.com/s2/favicons?domain=${clean}&sz=64`}
      alt=""
      width="32"
      height="32"
      loading="lazy"
      style={{
        width: 32, height: 32,
        borderRadius: 6,
        background: 'white',
        padding: 4,
        boxShadow: '0 4px 12px -4px rgba(0,0,0,0.35)',
      }}
      onError={() => setErrored(true)}
    />
  );
}

function LocalSitesGrid() {
  const sites = [
    { url: 'https://www.surreyroofingltd.co.uk',    name: 'Surrey Roofing Ltd',      cat: 'Roofing',     bg: '#0F172A', fg: '#FACC15' },
    { url: 'https://www.surreyroofinggroup.co.uk',  name: 'Surrey Roofing Group',    cat: 'Roofing',     bg: '#1F2937', fg: '#F59E0B' },
    { url: 'https://guildfordtreesurgeons.co.uk',   name: 'Guildford Tree Surgeons', cat: 'Tree surgery',bg: '#2F5D2E', fg: '#A3C76B' },
    { url: 'https://southeasttreesurgeons.co.uk',   name: 'South East Tree Surgeons',cat: 'Tree surgery',bg: '#1F2C1B', fg: '#5BA15A' },
    { url: 'https://www.redwoodtreeservices.co.uk', name: 'Redwood Tree Services',   cat: 'Tree surgery',bg: '#5C1F0E', fg: '#FCD34D' },
    { url: 'http://www.nicholsandsons.co.uk',       name: 'Nichols & Sons',          cat: 'Builders',    bg: '#3F2E1C', fg: '#F4D58D' },
    { url: 'https://surrey-handyman.co.uk',         name: 'Surrey Handyman',         cat: 'Handyman',    bg: '#1F2937', fg: '#F59E0B' },
    { url: 'https://oakwoods.co.uk',                name: 'Oakwoods',                cat: 'Landscaping', bg: '#3E5D2D', fg: '#E6F0D0' },
    { url: 'https://penningtonselectrical.co.uk',   name: 'Penningtons Electrical',  cat: 'Electrical',  bg: '#0F172A', fg: '#FACC15' },
    { url: 'https://surreyplumbingservices.co.uk',  name: 'Surrey Plumbing Services',cat: 'Plumbing',    bg: '#0B1626', fg: '#3B82F6' },
    { url: 'https://we-are-fusion.co.uk',           name: 'We Are Fusion',           cat: 'Trades',      bg: '#1F2937', fg: '#22D3EE' },
    { url: 'https://www.davefordtreecare.co.uk',    name: 'Dave Ford Tree Care',     cat: 'Tree surgery',bg: '#2F5D2E', fg: '#A3C76B' },
    { url: 'https://www.heritageelectrical.co.uk',  name: 'Heritage Electrical',     cat: 'Electrical',  bg: '#1F2937', fg: '#FACC15' },
    { url: 'https://fuseboxelectricalservices.co.uk',name: 'Fusebox Electrical Services',cat: 'Electrical',bg: '#0F172A', fg: '#22D3EE' },
    { url: 'https://surrey-roofer.co.uk',           name: 'Surrey Roofer',           cat: 'Roofing',     bg: '#0F172A', fg: '#F59E0B' },
    { url: 'https://www.apexdesigngroup.co.uk/', name: 'Apex Design Group', cat: 'Surface design · Microcement', bg: '#3F3A33', fg: '#D9CFB4', status: 'construction' },
  ];
  // Strip protocol + leading www for display
  const cleanDomain = (u) => u.replace(/^https?:\/\/(www\.)?/, '').replace(/\/$/, '');

  return (
    <div style={{ marginTop: 56 }}>
      <div style={{ marginBottom: 22, display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12, flexWrap: 'wrap' }}>
        <div>
          <Eyebrow>Local trade sites · recently launched</Eyebrow>
          <h3 style={{ fontSize: 22, letterSpacing: '-0.02em', fontWeight: 600, marginTop: 8 }}>
            Real 1–5 page sites we’ve put live for local trades.
          </h3>
        </div>
        <span className="mono" style={{ fontSize: 11, color: 'var(--muted)' }}>
          {sites.length} sites · across Surrey &amp; UK
        </span>
      </div>

      <div
        className="reveal-stagger"
        style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(auto-fill, minmax(min(100%, 220px), 1fr))',
          gap: 10,
        }}
      >
        {sites.map((s) => (
          <a
            key={s.url}
            href={s.url}
            target="_blank"
            rel="noopener noreferrer"
            className="lift"
            style={{
              display: 'flex',
              flexDirection: 'column',
              background: 'white',
              border: '1px solid var(--line)',
              borderRadius: 12,
              overflow: 'hidden',
              textDecoration: 'none',
              color: 'inherit',
              boxShadow: 'var(--shadow-card)',
            }}
          >
            {/* Coloured banner with the favicon */}
            <div style={{
              position: 'relative',
              height: 64,
              background: s.bg,
              display: 'flex',
              alignItems: 'center',
              justifyContent: 'center',
              overflow: 'hidden',
            }}>
              <div className="sweep" style={{ '--sweep-delay': (Math.random() * 4) + 's' }} />
              <TileFavicon url={s.url} name={s.name} fg={s.fg} />
              {s.status === 'construction' ? (
                <span className="mono pulse-cta" style={{
                  position: 'absolute', top: 6, right: 6,
                  fontSize: 8.5, color: 'white',
                  background: 'rgba(234,88,12,0.92)',
                  padding: '2px 5px',
                  borderRadius: 3,
                  letterSpacing: '0.06em',
                  textTransform: 'uppercase',
                  display: 'inline-flex', alignItems: 'center', gap: 3,
                  whiteSpace: 'nowrap',
                }}>
                  <span style={{ width: 4, height: 4, borderRadius: 99, background: 'white' }} />
                  In progress
                </span>
              ) : (
                <span className="mono pulse-cta" style={{
                  position: 'absolute', top: 6, right: 6,
                  fontSize: 8.5, color: 'white',
                  background: 'rgba(21,163,92,0.85)',
                  padding: '2px 5px',
                  borderRadius: 3,
                  letterSpacing: '0.06em',
                  textTransform: 'uppercase',
                  display: 'inline-flex', alignItems: 'center', gap: 3,
                }}>
                  <span style={{ width: 4, height: 4, borderRadius: 99, background: 'white' }} />
                  Live
                </span>
              )}
            </div>
            <div style={{ padding: '10px 12px 12px', display: 'flex', flexDirection: 'column', gap: 4 }}>
              <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 6 }}>
                <span style={{ fontSize: 13, fontWeight: 600, color: 'var(--ink)', lineHeight: 1.2 }}>
                  {s.name}
                </span>
              </div>
              <span className="mono" style={{
                fontSize: 9.5, color: 'var(--accent-ink)',
                letterSpacing: '0.06em', textTransform: 'uppercase',
              }}>
                {s.cat}
              </span>
              <span className="mono" style={{
                fontSize: 10, color: 'var(--muted)',
                overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
                marginTop: 2,
              }}>
                {cleanDomain(s.url)}
              </span>
              <span style={{
                marginTop: 4,
                display: 'inline-flex',
                alignItems: 'center',
                gap: 4,
                fontSize: 11,
                color: 'var(--cta)',
                fontWeight: 500,
              }}>
                Visit
                <svg width="10" height="10" viewBox="0 0 12 12" fill="none">
                  <path d="M3 9 L9 3 M9 3 H4.5 M9 3 V7.5" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />
                </svg>
              </span>
            </div>
          </a>
        ))}
      </div>
    </div>
  );
}

function LiveWorkCard({ project }) {
  const Mock = project.mock;
  return (
    <a
      href={project.url}
      target="_blank"
      rel="noopener noreferrer"
      className="lift"
      style={{
        background: 'white',
        border: '1px solid var(--line)',
        borderRadius: 18,
        overflow: 'hidden',
        display: 'flex',
        flexDirection: 'column',
        boxShadow: 'var(--shadow-card)',
        textDecoration: 'none',
        color: 'inherit',
      }}
    >
      {/* Browser chrome */}
      <div style={{
        padding: '10px 12px',
        borderBottom: '1px solid var(--line)',
        background: 'white',
        display: 'flex',
        alignItems: 'center',
        gap: 8,
      }}>
        <span style={{ display: 'flex', gap: 5 }}>
          <i style={{ width: 8, height: 8, borderRadius: 99, background: '#FF6E5E' }} />
          <i style={{ width: 8, height: 8, borderRadius: 99, background: '#F0C24A' }} />
          <i style={{ width: 8, height: 8, borderRadius: 99, background: '#7BC68E' }} />
        </span>
        <span className="mono" style={{
          fontSize: 10.5,
          color: 'var(--muted)',
          marginLeft: 4,
          overflow: 'hidden',
          textOverflow: 'ellipsis',
          whiteSpace: 'nowrap',
        }}>
          {project.label}
        </span>
        <span className="mono pulse-cta" style={{
          marginLeft: 'auto',
          fontSize: 9.5,
          letterSpacing: '0.06em',
          textTransform: 'uppercase',
          color: 'white',
          background: 'var(--ok)',
          padding: '2px 6px',
          borderRadius: 4,
          whiteSpace: 'nowrap',
          display: 'inline-flex',
          alignItems: 'center',
          gap: 4,
        }}>
          <span style={{ width: 5, height: 5, borderRadius: 99, background: 'white', display: 'inline-block' }} />
          Live
        </span>
      </div>

      {/* Live embed (preferred) — falls back to the styled mock if blocked */}
      {project.forceFallback && Mock ? (
        <Mock />
      ) : (
        <LiveSiteEmbed
          src={project.url}
          renderWidth={project.embedWidth || 1280}
          renderHeight={project.embedRenderHeight || 820}
          fallback={Mock}
        />
      )}

      {/* Card meta */}
      <div style={{
        padding: '16px 18px 18px',
        borderTop: '1px solid var(--line)',
        display: 'flex',
        flexDirection: 'column',
        gap: 10,
        background: 'white',
      }}>
        <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }}>
          <h3 style={{ fontSize: 18, letterSpacing: '-0.015em', fontWeight: 600 }}>
            {project.name}
          </h3>
          <span className="mono" style={{
            fontSize: 10.5,
            color: 'var(--accent-ink)',
            background: 'var(--accent-soft)',
            padding: '3px 8px',
            borderRadius: 5,
            whiteSpace: 'nowrap',
            flexShrink: 0,
          }}>
            {project.tagline}
          </span>
        </div>
        <p style={{ fontSize: 13.5, color: 'var(--muted)', lineHeight: 1.5 }}>
          {project.description}
        </p>
        <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexWrap: 'wrap', gap: 4 }}>
          {project.tags.map((t) => (
            <li key={t} style={{
              fontSize: 11.5,
              padding: '3px 8px',
              border: '1px solid var(--line)',
              borderRadius: 99,
              color: 'var(--ink-2)',
              background: 'var(--paper)',
              whiteSpace: 'nowrap',
            }}>
              {t}
            </li>
          ))}
        </ul>
        <span style={{
          marginTop: 4,
          display: 'inline-flex',
          alignItems: 'center',
          gap: 5,
          fontSize: 13,
          color: 'var(--cta)',
          fontWeight: 500,
        }}>
          Visit live site
          <svg width="12" height="12" viewBox="0 0 12 12" fill="none">
            <path d="M3 9 L9 3 M9 3 H4.5 M9 3 V7.5" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />
          </svg>
        </span>
      </div>
    </a>
  );
}

/* ─── ARES Protocol mock — mirrors aresprotocol.org real palette ─── */
function AresProtocolMock() {
  return (
    <div style={{ background: '#FFFFFF', display: 'flex', flexDirection: 'column', position: 'relative' }}>
      {/* Top nav — white, blue ARES wordmark, blue CTA */}
      <div style={{
        padding: '10px 14px',
        display: 'flex',
        justifyContent: 'space-between',
        alignItems: 'center',
        borderBottom: '1px solid #F1F3F7',
        background: 'white',
      }}>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
          <span style={{
            width: 18, height: 18, borderRadius: 3,
            background: 'linear-gradient(135deg, #1F2937, #4B5563)',
            display: 'inline-block',
          }} />
          <span style={{ color: '#3D5BF6', fontSize: 13, fontWeight: 700, letterSpacing: '0.04em' }}>
            ARES
          </span>
        </span>
        <span style={{ display: 'flex', gap: 10, fontSize: 9.5, color: '#1F2937' }}>
          <span>Services ⌄</span>
          <span>Pricing</span>
          <span>Resources ⌄</span>
          <span>About</span>
        </span>
        <span className="mono pulse-cta" style={{
          fontSize: 9, color: 'white', fontWeight: 600,
          padding: '5px 10px', background: '#3D5BF6', borderRadius: 6,
          letterSpacing: '0.02em', whiteSpace: 'nowrap',
        }}>
          Book Consultation
        </span>
      </div>

      {/* Hero — centred, light bg */}
      <div style={{ position: 'relative', padding: '20px 14px 16px', textAlign: 'center', overflow: 'hidden' }}>
        <div className="sweep" style={{ '--sweep-delay': '2.5s' }} />
        <span style={{
          display: 'inline-flex',
          alignItems: 'center',
          gap: 5,
          padding: '4px 10px',
          background: '#EEF1FE',
          color: '#3D5BF6',
          fontSize: 9,
          fontWeight: 600,
          borderRadius: 99,
          letterSpacing: '0.02em',
        }}>
          <span style={{
            width: 9, height: 9, display: 'inline-flex',
            alignItems: 'center', justifyContent: 'center',
          }}>
            <svg width="9" height="9" viewBox="0 0 12 12" fill="none">
              <path d="M6 1 L10 3 V6.5 Q 10 9 6 11 Q 2 9 2 6.5 V3 Z"
                stroke="#3D5BF6" strokeWidth="1.2" fill="none" />
            </svg>
          </span>
          AI Governance &amp; Compliance Specialists
        </span>
        <div style={{ marginTop: 10 }}>
          <span style={{
            color: '#3D5BF6', fontSize: 17, lineHeight: 1.08,
            letterSpacing: '-0.025em', fontWeight: 700,
            display: 'block',
          }}>
            AI governance and evaluation
          </span>
          <span style={{
            color: '#0B1220', fontSize: 17, lineHeight: 1.08,
            letterSpacing: '-0.025em', fontWeight: 700,
            display: 'block',
            marginTop: 2,
          }}>
            for regulated environments
          </span>
        </div>
        <p style={{
          color: '#4B5563', fontSize: 10.5,
          lineHeight: 1.5, marginTop: 8,
          maxWidth: 260, marginLeft: 'auto', marginRight: 'auto',
        }}>
          Independent assessment of AI system behavior, oversight, and governance readiness in high-risk contexts.
        </p>

        <div style={{ display: 'flex', gap: 6, marginTop: 12, justifyContent: 'center', flexWrap: 'wrap' }}>
          <span className="pulse-cta mono" style={{
            background: '#3D5BF6', color: 'white',
            padding: '7px 12px', borderRadius: 6,
            fontSize: 10, fontWeight: 600, whiteSpace: 'nowrap',
          }}>
            Request a governance review
          </span>
          <span style={{
            border: '1px solid #1F2937', color: '#1F2937',
            padding: '6px 12px', borderRadius: 6,
            fontSize: 10, whiteSpace: 'nowrap', background: 'white',
          }}>
            View our governance approach
          </span>
        </div>

        {/* Green check trust marks */}
        <div style={{
          marginTop: 14,
          display: 'flex', justifyContent: 'center', gap: 18,
          fontSize: 10, color: '#1F2937',
        }}>
          {['Nephilim Framework™', 'Regulatory Expertise'].map((t, i) => (
            <span key={t} className="float-y" style={{
              display: 'inline-flex', alignItems: 'center', gap: 5,
              '--float-dur': '5s', '--float-delay': (i * 0.4) + 's',
            }}>
              <span style={{ color: '#10B981', display: 'inline-flex' }}>
                <Icon.check />
              </span>
              {t}
            </span>
          ))}
        </div>
      </div>

      {/* "What A.R.E.S Does" footer band */}
      <div style={{
        background: '#F8F9FB',
        padding: '14px 14px 16px',
        borderTop: '1px solid #F1F3F7',
        textAlign: 'center',
      }}>
        <span style={{
          color: '#0B1220', fontSize: 13,
          letterSpacing: '-0.015em', fontWeight: 700,
          display: 'block',
        }}>
          What A.R.E.S Does
        </span>
        <p style={{
          color: '#4B5563', fontSize: 10,
          lineHeight: 1.5, marginTop: 4,
          maxWidth: 320, marginLeft: 'auto', marginRight: 'auto',
        }}>
          Independent AI governance — evaluation, oversight, and regulatory readiness across real workflows.
        </p>
      </div>
    </div>
  );
}

/* ─── EdgeFinder AI mock — Bloomberg-terminal style for prediction markets ─── */
function EdgeFinderMock() {
  return (
    <div style={{
      background: '#0A0A0A',
      display: 'flex', flexDirection: 'column', position: 'relative',
      fontFamily: '"Geist Mono", ui-monospace, monospace',
    }}>
      {/* Top nav strip — orange logo + nav */}
      <div style={{
        padding: '8px 10px',
        display: 'flex',
        justifyContent: 'space-between',
        alignItems: 'center',
        borderBottom: '1px solid #1F1F1F',
      }}>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
          <span style={{
            width: 10, height: 10, background: '#F97316', display: 'inline-block',
          }} />
          <span style={{ color: '#FACC15', fontSize: 10, fontWeight: 700, letterSpacing: '0.04em', lineHeight: 1 }}>
            EDGEFINDER<br />AI
          </span>
        </span>
        <span style={{ display: 'flex', gap: 8, fontSize: 7.5, color: '#9CA3AF', letterSpacing: '0.06em' }}>
          <span>PLATFORMS</span>
          <span>MARKETS</span>
          <span>SIGNALS</span>
          <span>INTEL</span>
        </span>
        <span style={{
          background: '#F97316', color: 'black',
          fontSize: 7.5, padding: '3px 6px',
          fontWeight: 700, letterSpacing: '0.06em',
        }}>
          JOIN
        </span>
      </div>

      {/* Live ticker bar */}
      <div style={{
        padding: '5px 10px', background: '#0F0F0F',
        borderBottom: '1px solid #1F1F1F',
        display: 'flex', gap: 12, fontSize: 7,
        overflow: 'hidden', whiteSpace: 'nowrap',
      }}>
        <span style={{ color: '#22C55E' }}>● 325 SIGNALS</span>
        <span style={{ color: '#22C55E' }}>WIN ML</span>
        <span style={{ color: '#FACC15' }}>TATE POSTS</span>
        <span style={{ color: '#F97316' }}>IRAN PENDING</span>
        <span style={{ color: '#9CA3AF' }}>BTC $76K</span>
        <span style={{ color: '#22C55E' }}>67.4% OVERALL</span>
      </div>

      {/* Main hero */}
      <div style={{ padding: '14px 12px 12px', position: 'relative' }}>
        <div style={{ display: 'flex', gap: 6, alignItems: 'center', marginBottom: 8 }}>
          <span style={{
            background: '#F97316', color: 'black', fontSize: 7.5,
            padding: '2px 5px', fontWeight: 700, letterSpacing: '0.06em',
          }}>
            DAY 60
          </span>
          <span style={{ color: '#22C55E', fontSize: 7.5 }}>203 VERIFIED WINS</span>
          <span style={{ color: '#F97316', fontSize: 7.5 }}>67.4% WIN RATE</span>
          <span style={{
            color: '#22C55E', fontSize: 7,
            border: '1px solid #22C55E', padding: '1px 4px',
          }}>
            VALIDATED ✓
          </span>
        </div>

        <div style={{
          color: 'white', fontSize: 15, lineHeight: 1.1,
          fontWeight: 700, letterSpacing: '0.01em',
          textTransform: 'uppercase',
        }}>
          THE BLOOMBERG<br />TERMINAL FOR<br />PREDICTION MARKETS
        </div>

        <div style={{
          color: '#F97316', fontSize: 9,
          marginTop: 8, lineHeight: 1.4,
        }}>
          Cross-platform intelligence. ML-verified signals.<br />
          Professional-grade data.
        </div>

        <div style={{
          color: '#9CA3AF', fontSize: 8.5,
          marginTop: 6, lineHeight: 1.4,
        }}>
          Track <span style={{ color: '#FACC15' }}>$155B volume</span> across Polymarket, Kalshi, Manifold.{' '}
          <span style={{ color: '#22C55E' }}>67.4% win rate signals.</span>
        </div>

        <div style={{ display: 'flex', gap: 5, marginTop: 12 }}>
          <span className="pulse-cta" style={{
            background: '#F97316', color: 'black',
            padding: '6px 10px', fontSize: 9,
            fontWeight: 700, letterSpacing: '0.04em',
            whiteSpace: 'nowrap',
          }}>
            GET PRO ACCESS →
          </span>
          <span style={{
            border: '1px solid #4B5563', color: '#D1D5DB',
            padding: '5px 10px', fontSize: 9,
            letterSpacing: '0.04em',
            whiteSpace: 'nowrap',
          }}>
            VIEW TRACK RECORD
          </span>
        </div>
      </div>

      {/* Track record bars */}
      <div style={{
        padding: '10px 12px 12px', background: '#070707',
        borderTop: '1px solid #1F1F1F',
      }}>
        <div style={{
          fontSize: 7.5, color: '#6B7280', letterSpacing: '0.08em',
          marginBottom: 6, display: 'flex', justifyContent: 'space-between',
        }}>
          <span>TRACK RECORD — DAY 60 — VALIDATED</span>
          <span style={{ color: '#22C55E' }}>AUDITABLE</span>
        </div>
        {[
          { label: 'WINS',           value: 203, color: '#22C55E', pct: 67 },
          { label: 'CRASH DETECTION', value: '54W/37L', color: '#F97316', pct: 59 },
          { label: 'ML MODEL',        value: '147W/61L', color: '#FACC15', pct: 70 },
          { label: 'COMBINED',        value: '2W/0L',    color: '#22C55E', pct: 100 },
        ].map((row, i) => (
          <div key={row.label} style={{
            display: 'grid', gridTemplateColumns: '70px 60px 1fr',
            gap: 6, alignItems: 'center', marginBottom: 3,
          }}>
            <span style={{ fontSize: 7.5, color: '#9CA3AF' }}>{row.label}</span>
            <span style={{ fontSize: 7.5, color: row.color }}>{row.value}</span>
            <div style={{
              height: 4, background: '#1F1F1F', position: 'relative', overflow: 'hidden',
            }}>
              <div className="float-y" style={{
                position: 'absolute', top: 0, left: 0, bottom: 0,
                width: row.pct + '%', background: row.color,
                '--float-dur': '8s', '--float-delay': (i * 0.3) + 's',
              }} />
            </div>
          </div>
        ))}
      </div>
    </div>
  );
}

Object.assign(window, {
  LiveWork, LiveWorkCard, LiveSiteEmbed, LocalSitesGrid, TileFavicon,
  AresProtocolMock, EdgeFinderMock,
});
