// sections.jsx — All homepage sections
const { useState, useEffect, useRef } = React;

function useInView(threshold = 0.12) {
  const ref = useRef(null);
  const [visible, setVisible] = useState(false);
  useEffect(() => {
    const el = ref.current; if (!el) return;
    const obs = new IntersectionObserver(([e]) => {
      if (e.isIntersecting) { setVisible(true); obs.disconnect(); }
    }, { threshold });
    obs.observe(el);
    return () => obs.disconnect();
  }, []);
  return [ref, visible];
}

function useCountUp(target, duration = 1600, started = false) {
  const [val, setVal] = useState(0);
  useEffect(() => {
    if (!started) return;
    let start = null;
    const isNum = typeof target === 'number';
    if (!isNum) return;
    const step = (ts) => {
      if (!start) start = ts;
      const p = Math.min((ts - start) / duration, 1);
      const ease = 1 - Math.pow(1 - p, 3);
      setVal(Math.floor(ease * target));
      if (p < 1) requestAnimationFrame(step);
    };
    requestAnimationFrame(step);
  }, [started, target, duration]);
  return val;
}

function Eyebrow({ children, light }) {
  return (
    <div style={{
      fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.12em',
      textTransform: 'uppercase', color: light ? 'rgba(255,255,255,0.35)' : 'var(--muted)',
      marginBottom: 20,
    }}>{children}</div>
  );
}

// ── Logo SVG ──────────────────────────────────────────────────────
// Tight 32×28 viewBox. Solid dot at left, then three concentric arcs.
// Each arc is the right-opening half-circle of its radius. Radii grow in
// arithmetic 5 → 8 → 11 so the stroke spacing stays visually even.
// Anchor x for each arc = (16 - r/2) so they share a center column near
// x=16 and read as one tightening wave. Endpoints (cx, cy±r) lie exactly
// on each circle so the arc geometry is mathematically clean.
function EchoLogo({ size = 28 }) {
  // Brand mark — uses the canonical Echo logo image asset.
  return (
    <img
      src="img/echo-logo.jpeg"
      alt="Echo"
      width={size}
      height={size}
      style={{ display: 'block', borderRadius: 4, objectFit: 'contain' }}
    />
  );
}

// (DemoSection removed — demo is now embedded inside the Agents section.)

// ── Problem ───────────────────────────────────────────────────────
function StatCard({ prefix = '', value, suffix = '', label, source, started }) {
  const count = useCountUp(typeof value === 'number' ? value : 0, 1800, started);
  const isNum = typeof value === 'number';
  const display = isNum ? `${prefix}${count.toLocaleString()}${suffix}` : value;

  return (
    <div style={{ background: 'var(--bg)', border: '1px solid var(--hairline)', borderRadius: 12, padding: '24px 20px', display: 'flex', flexDirection: 'column', gap: 12, transition: 'border-color 0.25s, transform 0.25s', cursor: 'default', minHeight: 168 }}
      onMouseEnter={e => { e.currentTarget.style.borderColor = 'var(--accent)'; e.currentTarget.style.transform = 'translateY(-2px)'; }}
      onMouseLeave={e => { e.currentTarget.style.borderColor = 'var(--hairline)'; e.currentTarget.style.transform = 'none'; }}
    >
      <div className="stat-value" style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(22px, 2.4vw, 36px)', fontWeight: 400, color: 'var(--ink)', lineHeight: 1.05, letterSpacing: '-0.025em' }}>{display}</div>
      <div className="stat-label" style={{ fontSize: 12.5, color: 'var(--ink)', lineHeight: 1.45, fontWeight: 500 }}>{label}</div>
      <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.08em', color: 'var(--muted)', marginTop: 'auto', textTransform: 'uppercase' }}>{source}</div>
    </div>
  );
}

function Problem() {
  const [ref, visible] = useInView(0.12);
  const stats = [
    { value: '30+ hrs / wk', label: 'Lost to manual back-office work.', source: 'McKinsey · 2025' },
    { value: '$2M / yr',     label: 'Wasted on manual workflows.',      source: 'ATRI · 2024' },
    { value: '48%',          label: 'Still run on email and sheets.',   source: 'PwC · 2025' },
    { value: '2 days',       label: 'Average email response.',          source: 'Industry benchmark' },
  ];
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div ref={ref} className="glass-plate glass-plate--rounded plate-pad" style={{ maxWidth: 1240, margin: '0 auto', padding: '52px 56px' }}>
        <Eyebrow>The problem</Eyebrow>
        <div className="problem-header" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 48, marginBottom: 56, alignItems: 'end' }}>
          <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, lineHeight: 1.1, letterSpacing: '-0.02em' }}>
            Where time<br />
            <em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>and money leak.</em>
          </h2>
          <p style={{ fontSize: 15, color: 'var(--muted)', lineHeight: 1.6, maxWidth: 420 }}>
            Back-office still runs on inbound email, phone calls, and manual TMS entry.
          </p>
        </div>
        <div className="problem-stats stats-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14 }}>
          {stats.map((s, i) => <StatCard key={i} {...s} started={visible} />)}
        </div>
      </div>
    </section>
  );
}

// ── Agent glyphs ──────────────────────────────────────────────────
const glyphs = {
  Docs:   <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="18" height="13" rx="2"/><path d="M7 8h4M7 11h6"/><path d="M8 21h8M12 16v5"/></svg>,
  Triage: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"><rect x="2" y="4" width="20" height="16" rx="2"/><polyline points="22,6 12,13 2,6"/></svg>,
  Cal:    <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>,
  Ledger: <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>,
};

function AgentCard({ num, name, domain, tagline, outcome, href, delay = 0 }) {
  const [hovered, setHovered] = useState(false);
  return (
    <a href={href} onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)} style={{
      background: 'var(--bg)', border: `1px solid ${hovered ? 'var(--accent)' : 'var(--hairline)'}`,
      borderRadius: 12, padding: '28px 24px', display: 'flex', flexDirection: 'column', gap: 16,
      cursor: 'pointer', textDecoration: 'none', color: 'inherit',
      transform: hovered ? 'translateY(-3px)' : 'none',
      boxShadow: hovered ? '0 12px 40px var(--accent-glow)' : 'none',
      transition: 'all 0.28s cubic-bezier(0.4,0,0.2,1)',
    }}>
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
        <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'var(--muted)' }}>{num}</span>
        <span style={{ display: 'flex', alignItems: 'center', gap: 8, color: hovered ? 'var(--accent)' : 'var(--muted)', transition: 'color 0.28s' }}>
          {glyphs[name]}
          <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" style={{ transform: hovered ? 'translate(2px, -2px)' : 'none', transition: 'transform 0.28s' }}><path d="M7 17L17 7M7 7h10v10"/></svg>
        </span>
      </div>
      <div>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'var(--muted)', textTransform: 'uppercase', marginBottom: 6 }}>{domain}</div>
        <div style={{ fontFamily: 'var(--ff-display)', fontSize: 34, fontWeight: 400, letterSpacing: '-0.02em', lineHeight: 1 }}>{name}</div>
      </div>
      <p style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.6, margin: 0 }}>{tagline}</p>
      <div style={{ marginTop: 'auto', paddingTop: 14, borderTop: '1px solid var(--hairline)', display: 'flex', alignItems: 'flex-start', gap: 8 }}>
        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--accent)" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round" style={{ flexShrink: 0, marginTop: 2 }}><polyline points="9 18 15 12 9 6"/></svg>
        <span style={{ fontSize: 12, color: 'var(--ink)', fontWeight: 500, lineHeight: 1.5 }}>{outcome}</span>
      </div>
    </a>
  );
}

function Agents() {
  const agents = [
    { num: '01 · TEAMS + OUTLOOK', name: 'Triage', domain: 'Email Triage',            tagline: 'Reads every inbound email, classifies the intent (rate, T&T, pickup, claim), and routes to the right action.',         outcome: 'Every email triaged. Intent classified. Routed.',  href: 'agents/triage.html' },
    { num: '02 · TEAMS',           name: 'Docs',   domain: 'PODs & BOLs',              tagline: 'Reads inbound PODs and BOLs, extracts the data, posts to your TMS the same shift.',                                            outcome: 'Every POD posted the same shift.',             href: 'agents/docs.html' },
    { num: '03 · SMS + TEAMS',     name: 'Cal',    domain: 'Dock Scheduling',          tagline: 'Takes dock booking requests by SMS or Teams. Books into TMS and OpenDock the same minute.',                     outcome: 'Every booking in your TMS. Automatically.',    href: 'agents/cal.html' },
    { num: '04 · TEAMS',           name: 'Ledger', domain: 'Detention & Claims',       tagline: 'Pulls GPS and timestamps to substantiate detention. Files the package to AR.',                                                  outcome: 'Every detention charge documented and billed.',href: 'agents/ledger.html' },
  ];
  return (
    <section id="agents" style={{ padding: '60px 0' }}>
      <div style={{ maxWidth: 1160, margin: '0 auto', padding: '0 40px' }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', marginBottom: 32 }}>
          <div>
            <Eyebrow>Meet the agents</Eyebrow>
            <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.025em', lineHeight: 1.05 }}>
              Four agents.<br />One Teams channel.
            </h2>
          </div>
          <a href="agents/triage.html" style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: 'var(--muted)', display: 'flex', alignItems: 'center', gap: 7, borderBottom: '1px solid var(--hairline)', paddingBottom: 2, textTransform: 'uppercase', transition: 'all 0.2s' }}
            onMouseEnter={e => { e.currentTarget.style.color = 'var(--ink)'; e.currentTarget.style.borderColor = 'var(--ink)'; }}
            onMouseLeave={e => { e.currentTarget.style.color = 'var(--muted)'; e.currentTarget.style.borderColor = 'var(--hairline)'; }}
          >
            See Triage in action
            <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
          </a>
        </div>
        <div className="agents-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14 }}>
          {agents.map((a, i) => <AgentCard key={a.name} {...a} delay={i * 70} />)}
        </div>
      </div>
    </section>
  );
}

// ── How It Works ──────────────────────────────────────────────────
function HowItWorks() {
  const steps = [
    {
      tag: 'Step 01 · Connect',
      title: 'Point Echo at your stack',
      body: 'Azure AD SSO and read-write access, provisioned in your tenant. Nothing leaves your infrastructure.',
      items: ['Azure AD / Entra SSO', 'Your TMS / ERP API access', 'Azure OpenAI (your tenant)', 'No data egress'],
    },
    {
      tag: 'Step 02 · Configure',
      title: 'Assign agents to channels',
      body: 'Each agent connects to its channel: Teams, SMS, or email. Set escalation rules, thresholds, and overrides.',
      items: ['Teams / SMS / Email', 'Escalation thresholds', 'Human-in-the-loop controls', 'Role-based overrides'],
    },
    {
      tag: 'Step 03 · Operate',
      title: 'Decision log, in Teams',
      body: 'Every agent action posts to a Teams channel with the input, the confidence score, and the action taken. Your team scans the feed, your compliance team queries it.',
      items: ['Streaming decision log', 'Posts to Teams', 'SLA tracking', '24/7 operation'],
    },
  ];
  return (
    <section id="how-it-works" className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded plate-pad" style={{ maxWidth: 1240, margin: '0 auto', padding: '52px 56px' }}>
        <Eyebrow>Deployment</Eyebrow>
        <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.02em', lineHeight: 1.1, marginBottom: 60, maxWidth: 480 }}>
          Operational in weeks,<br /><em style={{ fontStyle: 'italic', fontWeight: 300 }}>not months.</em>
        </h2>
        <div className="how-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', borderTop: '1px solid var(--hairline)' }}>
          {steps.map((s, i) => (
            <div key={i} className={`how-step${i < 2 ? ' how-step--bordered' : ''}`} style={{ padding: '36px', borderRight: i < 2 ? '1px solid var(--hairline)' : 'none' }}>
              <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.1em', color: 'var(--accent)', textTransform: 'uppercase', marginBottom: 20 }}>{s.tag}</div>
              <h3 style={{ fontFamily: 'var(--ff-display)', fontSize: 22, fontWeight: 400, marginBottom: 12, letterSpacing: '-0.01em' }}>{s.title}</h3>
              <p style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.7, marginBottom: 24 }}>{s.body}</p>
              <div style={{ display: 'flex', flexDirection: 'column', gap: 7 }}>
                {s.items.map(d => (
                  <div key={d} style={{ display: 'flex', alignItems: 'center', gap: 9 }}>
                    <div style={{ width: 4, height: 4, borderRadius: '50%', background: 'var(--accent)', flexShrink: 0 }}></div>
                    <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.06em', color: 'var(--muted)', textTransform: 'uppercase' }}>{d}</span>
                  </div>
                ))}
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── Comparison ────────────────────────────────────────────────────
function Comparison() {
  const [ref, visible] = useInView(0.08);
  const rows = [
    { workflow: 'Customer email triage', today: 'CSR sorts inbox; replies stretch into days',           echo: 'Triage responds in minutes with full context' },
    { workflow: 'Document intake',       today: 'Team keys data from emailed PDFs or fax',              echo: 'Docs extracts and posts to TMS same shift' },
    { workflow: 'Booking + scheduling',  today: 'Phone calls and manual entry across two systems',     echo: 'Cal books from a Teams or SMS request' },
    { workflow: 'AR + claims',           today: 'Team reconstructs timelines after the fact',          echo: 'Ledger pulls GPS timestamps as the wait happens and files' },
    { workflow: 'Accessorial billing',   today: 'Inconsistent. Depends which CSR caught it',           echo: 'Every charge flagged, documented, billed' },
  ];
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded plate-pad" style={{ maxWidth: 1240, margin: '0 auto', padding: '52px 56px' }}>
        <Eyebrow>Today vs. Echo</Eyebrow>
        {/* (Pillar section is 04 · Why Echo) */}
        <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, letterSpacing: '-0.02em', lineHeight: 1.1, marginBottom: 52, maxWidth: 480 }}>
          What changes when<br /><em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>agents go to work.</em>
        </h2>
        <div ref={ref} className="compare-table" style={{ border: '1px solid var(--hairline)', borderRadius: 12, overflow: 'hidden', maxWidth: '100%' }}>
          <div className="compare-header" style={{ display: 'grid', gridTemplateColumns: '180px 1fr 1fr', background: 'var(--surface)' }}>
            {[['WORKFLOW', false], ['TODAY', false], ['WITH ECHO', true]].map(([h, accent]) => (
              <div key={h} style={{ padding: '12px 18px', fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.12em', color: accent ? 'var(--accent)' : 'var(--muted)', borderRight: h !== 'WITH ECHO' ? '1px solid var(--hairline)' : 'none', borderBottom: '1px solid var(--hairline)' }}>{h}</div>
            ))}
          </div>
          {rows.map((r, i) => (
            <div key={i} className="compare-row" style={{
              display: 'grid', gridTemplateColumns: '180px 1fr 1fr',
              borderBottom: i < rows.length - 1 ? '1px solid var(--hairline)' : 'none',
              opacity: visible ? 1 : 0,
              transform: visible ? 'none' : 'translateX(-10px)',
              transition: `opacity 0.5s cubic-bezier(0,0,0.2,1) ${i * 70}ms, transform 0.5s cubic-bezier(0,0,0.2,1) ${i * 70}ms`,
            }}>
              <div className="compare-cell compare-cell--label" style={{ padding: '16px 18px', borderRight: '1px solid var(--hairline)', fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.07em', color: 'var(--muted)', textTransform: 'uppercase', display: 'flex', alignItems: 'center' }}>{r.workflow}</div>
              <div className="compare-cell compare-cell--today" data-mobile-label="TODAY" style={{ padding: '16px 18px', borderRight: '1px solid var(--hairline)', fontSize: 13, color: 'var(--muted)', lineHeight: 1.55, display: 'flex', alignItems: 'center' }}>{r.today}</div>
              <div className="compare-cell compare-cell--echo" data-mobile-label="WITH ECHO" style={{ padding: '16px 18px', fontSize: 13, color: 'var(--ink)', lineHeight: 1.55, display: 'flex', alignItems: 'center', gap: 10 }}>
                <span style={{ width: 5, height: 5, borderRadius: '50%', background: 'var(--accent)', flexShrink: 0 }}></span>
                {r.echo}
              </div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ── Vertical Teasers ──────────────────────────────────────────────
// Cross-links to Echo's other industry verticals. Each card carries
// its own accent so the section reads as "same shape, different domain"
// at a glance — no need to read every word.
function VerticalCard({ tag, accent, name, sub, body, href }) {
  const [hovered, setHovered] = useState(false);
  return (
    <a
      href={href}
      onMouseEnter={() => setHovered(true)}
      onMouseLeave={() => setHovered(false)}
      style={{
        position: 'relative',
        background: 'var(--bg)',
        border: `1px solid ${hovered ? accent : 'var(--hairline)'}`,
        borderRadius: 12,
        padding: '26px 24px 22px',
        display: 'flex',
        flexDirection: 'column',
        gap: 14,
        cursor: 'pointer',
        textDecoration: 'none',
        color: 'inherit',
        transform: hovered ? 'translateY(-3px)' : 'none',
        boxShadow: hovered ? `0 14px 40px ${accent}33` : 'none',
        transition: 'border-color 0.28s, transform 0.28s, box-shadow 0.28s',
        overflow: 'hidden',
      }}
    >
      {/* Accent corner bar — sits flush against top-left, signature mark */}
      <span style={{
        position: 'absolute', top: 0, left: 0,
        width: 44, height: 3, background: accent,
        borderTopLeftRadius: 12,
      }} />
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
        <span style={{
          display: 'inline-flex', alignItems: 'center', gap: 8,
          fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.12em',
          color: 'var(--muted)', textTransform: 'uppercase',
        }}>
          <span style={{ width: 7, height: 7, borderRadius: '50%', background: accent, flexShrink: 0 }} />
          {tag}
        </span>
        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke={hovered ? accent : 'var(--muted)'} strokeWidth="2" strokeLinecap="round" style={{ transform: hovered ? 'translate(2px, -2px)' : 'none', transition: 'transform 0.28s, stroke 0.28s' }}>
          <path d="M7 17L17 7M7 7h10v10"/>
        </svg>
      </div>
      <div>
        <div style={{ fontFamily: 'var(--ff-display)', fontSize: 24, fontWeight: 400, letterSpacing: '-0.015em', lineHeight: 1.15, marginBottom: 6 }}>{name}</div>
        <div style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, letterSpacing: '0.08em', color: 'var(--muted)', textTransform: 'uppercase' }}>{sub}</div>
      </div>
      <p style={{ fontSize: 13, color: 'var(--muted)', lineHeight: 1.6, margin: 0 }}>{body}</p>
      <div style={{ marginTop: 'auto', paddingTop: 12, borderTop: '1px solid var(--hairline)', display: 'flex', alignItems: 'center', gap: 7 }}>
        <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', color: hovered ? accent : 'var(--ink)', textTransform: 'uppercase', fontWeight: 600, transition: 'color 0.28s' }}>
          View
        </span>
        <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke={hovered ? accent : 'var(--ink)'} strokeWidth="2.4" strokeLinecap="round" style={{ transform: hovered ? 'translateX(3px)' : 'none', transition: 'transform 0.28s, stroke 0.28s' }}>
          <path d="M5 12h14M12 5l7 7-7 7"/>
        </svg>
      </div>
    </a>
  );
}

function VerticalTeasers() {
  const verticals = [
    {
      tag: 'Oracle ERP',
      accent: '#C74634',
      name: 'Oracle ERP',
      sub: 'Fusion · NetSuite · JD Edwards',
      body: 'Agents that close the books faster inside Fusion and NetSuite.',
      href: '/erp',
    },
    {
      tag: 'Freight Brokers',
      accent: '#F59E0B',
      name: 'Freight & 3PLs',
      sub: 'Brokers · Tender-to-cash',
      body: 'Load posting, carrier check-calls, and settlement on autopilot.',
      href: '/freight',
    },
    {
      tag: 'Regen Health',
      accent: '#10B981',
      name: 'Health Clinics',
      sub: 'Patient intake · Claims · AR',
      body: 'Intake, eligibility, and claims for regenerative and aesthetic clinics.',
      href: '/health',
    },
  ];
  return (
    <section className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded plate-pad" style={{ maxWidth: 1240, margin: '0 auto', padding: '52px 56px' }}>
        <Eyebrow>More verticals</Eyebrow>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 48, marginBottom: 48, alignItems: 'end' }} className="problem-header">
          <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.6vw, 50px)', fontWeight: 400, lineHeight: 1.1, letterSpacing: '-0.02em' }}>
            Echo runs on<br />other stacks too.
          </h2>
          <p style={{ fontSize: 15, color: 'var(--muted)', lineHeight: 1.6, maxWidth: 420 }}>
            One playbook. Finance, brokerage, and clinics.
          </p>
        </div>
        <div className="verticals-grid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 14 }}>
          {verticals.map(v => <VerticalCard key={v.href} {...v} />)}
        </div>
      </div>
    </section>
  );
}

// ── FAQ ───────────────────────────────────────────────────────────
// Single-open accordion. Click a question to expand its answer; opening
// a new one closes the rest. Chevron rotates 180° on the open row.
function FaqItem({ q, a, open, onToggle, isLast }) {
  return (
    <div style={{
      borderBottom: isLast ? 'none' : '1px solid var(--hairline)',
    }}>
      <button
        onClick={onToggle}
        aria-expanded={open}
        style={{
          width: '100%',
          display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 24,
          padding: '22px 4px',
          background: 'none', border: 'none', cursor: 'pointer',
          textAlign: 'left',
          color: 'inherit',
          transition: 'color 0.2s',
        }}
        onMouseEnter={e => e.currentTarget.style.color = 'var(--accent)'}
        onMouseLeave={e => e.currentTarget.style.color = ''}
      >
        <span style={{
          fontFamily: 'var(--ff-display)', fontSize: 18, fontWeight: 400,
          letterSpacing: '-0.005em', lineHeight: 1.35,
          color: open ? 'var(--accent)' : 'var(--ink)',
          transition: 'color 0.2s',
        }}>{q}</span>
        <span style={{
          flexShrink: 0,
          width: 28, height: 28, borderRadius: '50%',
          border: `1px solid ${open ? 'var(--accent)' : 'var(--hairline)'}`,
          display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
          color: open ? 'var(--accent)' : 'var(--muted)',
          transition: 'border-color 0.25s, color 0.25s',
        }}>
          <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" style={{ transform: open ? 'rotate(180deg)' : 'none', transition: 'transform 0.28s cubic-bezier(0.4,0,0.2,1)' }}>
            <path d="M6 9l6 6 6-6"/>
          </svg>
        </span>
      </button>
      <div style={{
        maxHeight: open ? 280 : 0,
        opacity: open ? 1 : 0,
        overflow: 'hidden',
        transition: 'max-height 0.4s cubic-bezier(0.16,1,0.3,1), opacity 0.3s ease, padding 0.3s ease',
        paddingBottom: open ? 22 : 0,
      }}>
        <p style={{
          fontSize: 14.5, color: 'var(--muted)', lineHeight: 1.7,
          maxWidth: 720, paddingRight: 52,
        }}>{a}</p>
      </div>
    </div>
  );
}

function FAQ() {
  const [openIdx, setOpenIdx] = useState(-1);
  const items = [
    {
      q: 'How long does Echo take to deploy?',
      a: 'Your first agent goes live in 2 to 3 weeks. The full suite is running within 6.',
    },
    {
      q: 'Does Echo replace my staff?',
      a: 'No. Echo takes the repetitive work off your CSRs and AR team: email triage, POD posting, detention filings. Your team gets their afternoons back to handle real exceptions.',
    },
    {
      q: 'Does it integrate with my TMS?',
      a: 'Yes. Echo is TruckMate-native and works with any TMS via API. Read-write access stays in your tenant. Your data never leaves your systems.',
    },
    {
      q: 'What if an agent gets it wrong?',
      a: 'Every action needs human approval by default, and you set the confidence threshold. Every decision posts to the Teams audit channel with full context, so your compliance team gets the trail they have been asking for.',
    },
    {
      q: 'Who owns the data?',
      a: 'You do. Echo runs inside your Microsoft Azure tenant. Your emails, PODs, and customer records stay where they already live.',
    },
    {
      q: 'What does it cost?',
      a: 'Pricing is per agent. One flat rate per agent per month. Book a demo for the number on your volume.',
    },
  ];
  return (
    <section id="faq" className="plate-section" style={{ padding: '40px 0' }}>
      <div className="glass-plate glass-plate--rounded plate-pad" style={{ maxWidth: 1240, margin: '0 auto', padding: '52px 56px' }}>
        <div className="faq-grid" style={{ display: 'grid', gridTemplateColumns: '320px 1fr', gap: 64, alignItems: 'start' }}>
          <div>
            <Eyebrow>Frequently asked</Eyebrow>
            <h2 style={{ fontFamily: 'var(--ff-display)', fontSize: 'clamp(32px, 3.2vw, 44px)', fontWeight: 400, letterSpacing: '-0.02em', lineHeight: 1.1, marginBottom: 20 }}>
              What carriers<br /><em style={{ fontStyle: 'italic', fontWeight: 300, color: 'var(--muted)' }}>usually ask.</em>
            </h2>
            <p style={{ fontSize: 14, color: 'var(--muted)', lineHeight: 1.65 }}>
              Don't see your question? Book a call and we'll answer it directly.
            </p>
          </div>
          <div>
            {items.map((it, i) => (
              <FaqItem
                key={i}
                q={it.q}
                a={it.a}
                open={openIdx === i}
                onToggle={() => setOpenIdx(openIdx === i ? -1 : i)}
                isLast={i === items.length - 1}
              />
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

// ── Solutions row (footer vertical nav) ───────────────────────────
function SolutionsRow({ current }) {
  const items = [
    { href: '/', label: 'Carriers', key: 'carriers' },
    { href: '/erp', label: 'Oracle ERP', key: 'erp' },
    { href: '/freight', label: 'Freight & Logistics', key: 'freight' },
    { href: '/health', label: 'Regenerative Health', key: 'health' },
  ];
  return (
    <div style={{ borderTop: '1px solid var(--hairline)', padding: '16px 0 18px', display: 'flex', alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
      <style>{`.echo-solutions-link{color:var(--muted);text-decoration:none;border-bottom:1px solid transparent;transition:color 200ms ease,border-color 200ms ease}.echo-solutions-link:hover{color:var(--ink);border-bottom-color:var(--ink)}`}</style>
      <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.14em', textTransform: 'uppercase' }}>Verticals</span>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' }}>
        {items.map((v, i) => (
          <span key={v.key} style={{ display: 'inline-flex', alignItems: 'center', gap: 10 }}>
            {v.key === current ? (
              <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--muted-soft)', letterSpacing: '0.08em', textTransform: 'uppercase' }}>{v.label}</span>
            ) : (
              <a href={v.href} className="echo-solutions-link" style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, letterSpacing: '0.08em', textTransform: 'uppercase' }}>{v.label}</a>
            )}
            {i < items.length - 1 && <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 11, color: 'var(--hairline)' }}>·</span>}
          </span>
        ))}
      </div>
    </div>
  );
}

// ── Footer ────────────────────────────────────────────────────────
function Footer() {
  return (
    <footer className="plate-section" style={{ padding: '40px 0 60px' }}>
      <div className="glass-plate glass-plate--rounded plate-pad-footer" style={{ maxWidth: 1240, margin: '0 auto', padding: '48px 56px 32px' }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', gap: 32, flexWrap: 'wrap', marginBottom: 32 }}>
          <div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 14 }}>
              <EchoLogo size={26} />
              <span style={{ fontFamily: 'var(--ff-mono)', fontSize: 13, fontWeight: 500, letterSpacing: '0.05em' }}>Echo</span>
            </div>
            <p style={{ fontFamily: 'var(--ff-display)', fontSize: 16, color: 'var(--ink)', lineHeight: 1.5, maxWidth: 320, fontWeight: 400, letterSpacing: '-0.01em' }}>
              AI agents for carriers.<br/>
              <span style={{ color: 'var(--muted)', fontStyle: 'italic', fontWeight: 300 }}>Built on your stack. Owned by you.</span>
            </p>
          </div>
          <a href="#book" data-open-book-call className="echo-cta echo-cta--primary">
            Get a demo
          </a>
        </div>
        <SolutionsRow current="carriers" />
        <div style={{ borderTop: '1px solid var(--hairline)', paddingTop: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 12 }}>
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 14, flexWrap: 'wrap', fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.07em' }}>
            <span>© 2026 ELITE CAPITAL INC.</span>
            <span style={{ display: 'inline-flex', alignItems: 'center', gap: 8 }}>
              <a href="/privacy.html" className="echo-solutions-link">Privacy</a>
              <span style={{ color: 'var(--hairline)' }}>·</span>
              <a href="/terms.html" className="echo-solutions-link">Terms</a>
              <span style={{ color: 'var(--hairline)' }}>·</span>
              <a href="/security.html" className="echo-solutions-link">Security</a>
              <span style={{ color: 'var(--hairline)' }}>·</span>
              <a href="mailto:jay@echoagents.io" className="echo-solutions-link">Contact</a>
            </span>
          </span>
          <div style={{ display: 'flex', alignItems: 'center', gap: 14, flexWrap: 'wrap' }}>
            <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7, fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.07em' }}>
              <span style={{ width: 6, height: 6, borderRadius: '50%', background: '#7DC9A8', boxShadow: '0 0 6px rgba(125,201,168,0.6)', animation: 'pulse 2.4s ease-in-out infinite' }} />
              All systems operational
            </span>
            <span style={{ display: 'inline-flex', alignItems: 'baseline', gap: 6, fontFamily: 'var(--ff-mono)', fontSize: 10, color: 'var(--muted)', letterSpacing: '0.07em' }}>
              SOC 2
              <span style={{ fontSize: 9, opacity: 0.7 }}>(Type II in progress)</span>
            </span>
          </div>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { EchoLogo, Problem, Agents, HowItWorks, Comparison, VerticalTeasers, FAQ, Footer });
