const TRACKS = [
  { icon: 'zap', name: 'Focused Automation Sprint', scope: 'Single high-impact workflow or AI agent deployment', fit: 'One process is costing the team hours every week and the systems involved are known.', incl: ['Audit of one workflow', 'One agent or automation in production', 'Monitoring and handover docs'] },
  { icon: 'boxes', name: 'Custom Product Build', scope: 'End-to-end web/SaaS app, internal tool, or modernization', fit: 'You need a new application or need to replace a legacy system without halting operations.', incl: ['Architecture and prototype', 'Weekly milestone releases', 'Full repository and IP transfer'], featured: true },
  { icon: 'infinity', name: 'Ongoing Automation Partner', scope: 'Continuous workflow expansion, monitoring, and digital marketing', fit: 'Automation is working and you want a team extending it month over month.', incl: ['Monthly roadmap and review', 'Monitoring and incident response', 'Digital marketing and content support'] },
];

const FAQS = [
  ['Who owns the code and infrastructure?', 'You do. Repositories, cloud accounts, API keys and documentation are created in or transferred to your organisation. There is no proprietary runtime you have to keep paying for.'],
  ['How do you keep AI agents and generated content under human control?', 'Agents act on their own only above confidence thresholds you approve; anything below escalates to a named person. Generated blog drafts, captions and Reel scripts sit in a review queue and cannot publish until an editor signs off.'],
  ['Can you work with our existing CRM and legacy software?', 'Yes. We integrate through official APIs where they exist and build a sync or API layer over legacy databases where they do not. Modernization happens module by module, with old and new systems running in parallel until the numbers match.'],
  ['How is our data secured?', 'We follow least-privilege access, keep data in your cloud region, encrypt in transit and at rest, and log every automated action. Third-party AI providers are configured with data-retention disabled where the provider supports it.'],
  ['What does a typical timeline look like?', 'A focused automation sprint usually runs a few weeks from audit to production. Product builds are planned in weekly milestones after the architecture stage, and we give you a dated plan before build starts.'],
  ['What happens after launch?', 'You get runbooks, dashboards and a handover session. You can run the system yourselves, or keep us on an ongoing partner track for monitoring, fixes and new workflows.'],
];

function TrackCard({ t }) {
  const { Icon, Badge } = DS;
  const [h, setH] = React.useState(false);
  return (
    <div onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)} style={{ display: 'flex', flexDirection: 'column', gap: 16, padding: 28, borderRadius: 20, background: 'var(--glass-bg)', backdropFilter: 'var(--glass-blur)', WebkitBackdropFilter: 'var(--glass-blur)', boxShadow: 'var(--glass-shadow)', background: t.featured ? 'var(--glass-bg-strong)' : 'var(--glass-bg)', border: `1px solid ${h ? 'var(--border-accent)' : 'var(--glass-border)'}`, transform: h ? 'translateY(-6px)' : t.featured ? 'translateY(-10px)' : 'none', transition: 'all .22s cubic-bezier(.22,1,.36,1)', position: 'relative', overflow: 'hidden', height: '100%' }}>
      {t.featured && <span aria-hidden style={{ position: 'absolute', left: 0, right: 0, top: 0, height: 2, background: 'var(--yk-gradient-h)' }} />}
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
        <span style={{ width: 40, height: 40, borderRadius: 10, display: 'grid', placeItems: 'center', background: '#fff', border: '1px solid var(--yk-lavender)', color: 'var(--yk-violet)' }}><Icon name={t.icon} size={19} /></span>
      </div>
      <div><h3 style={{ font: '600 20px/1.3 var(--font-display)', color: 'var(--yk-indigo)' }}>{t.name}</h3><p style={{ font: '500 14px/1.5 var(--font-body)', color: 'var(--yk-violet)', marginTop: 6 }}>{t.scope}</p></div>
      <p style={{ font: '400 15px/1.6 var(--font-body)', color: 'var(--yk-charcoal)' }}><strong style={{ fontWeight: 600, color: 'var(--yk-indigo)' }}>Good fit when: </strong>{t.fit}</p>
      <ul style={{ listStyle: 'none', margin: 0, padding: '16px 0 0', borderTop: '1px solid var(--yk-lavender)', display: 'grid', gap: 8 }}>
        {t.incl.map((x) => <li key={x} style={{ display: 'flex', gap: 8, font: '400 14px/1.5 var(--font-body)', color: 'var(--yk-charcoal)' }}><Icon name="check" size={16} color="var(--yk-sky-700)" style={{ marginTop: 2 }} />{x}</li>)}
      </ul>
    </div>
  );
}

function Engagement() {
  const { SectionHeader, Accordion } = DS;
  const wide = useMedia('(min-width: 1040px)');
  return (
    <section style={{ padding: `${wide ? 112 : 72}px 0`, background: 'transparent' }}>
      <Container>
        <Reveal><SectionHeader eyebrow="Engagement models" title="Three ways to work together." lead="Every track is scoped after a discovery call. Pricing depends on systems, volume and timeline, so we quote after the audit." /></Reveal>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(min(100%, 300px), 1fr))', gap: 20, marginTop: 48 }}>
          {TRACKS.map((t, i) => <Reveal key={t.name} delay={i * 0.07}><TrackCard t={t} /></Reveal>)}
        </div>
        <div id="faq" style={{ display: 'grid', gridTemplateColumns: wide ? 'minmax(0,.7fr) minmax(0,1.3fr)' : 'minmax(0,1fr)', gap: wide ? 64 : 32, marginTop: wide ? 112 : 72, scrollMarginTop: 90 }}>
          <Reveal><SectionHeader eyebrow="FAQ" title="Questions engineering and ops leads ask first." /></Reveal>
          <Reveal delay={0.07} style={{ ...glassPanel, borderRadius: 20, padding: wide ? '8px 28px' : '4px 16px' }}><Accordion defaultOpen={0} items={FAQS.map(([title, content]) => ({ title, content }))} /></Reveal>
        </div>
      </Container>
    </section>
  );
}

Object.assign(window, { Engagement });
