const { Button: Btn } = window.IOptusDesignSystem_ff608d;
const IC = window.IOptusIcons;
const L = window.LOGO;

const PRODUCTS = [
{ n: '01', theme: 'optusecho', name: 'OptusEcho', logo: 'OptusEcho.png', dot: 'var(--blue-400)', tag: 'AI voice agents · any sector', icon: 'PhoneCall',
  line: 'Voice agents that answer and make your calls.', feats: ['Inbound and outbound, 24/7', 'Books into your systems', 'Warm human handover'], spec: [['Built', 'Per client & use case'], ['Sectors', 'Housing, care, councils & more'], ['Handover', 'To a real person']] },
{ n: '02', theme: 'empient', name: 'Empient', logo: 'Empient.png', dot: 'var(--yellow-400)', tag: 'For housing teams', icon: 'Home',
  line: 'Cases, assets and everything between.', feats: ['Cases & repairs', 'Asset register', 'Reporting & CRM'], spec: [['Modules', 'Cases · Assets · CRM'], ['Integrates', 'OptusApp & OptusEcho'], ['Migration', 'Handled by us']] },
{ n: '03', theme: 'optusapp', name: 'OptusApp', logo: 'OptusApp.png', dot: 'var(--coral-500)', tag: 'For tenants', icon: 'Smartphone',
  line: 'A tenant’s home, in their pocket.', feats: ['Report a repair', 'Pay & track rent', 'Message your officer'], spec: [['Platform', 'iOS · Android · Web'], ['Works with', 'Your housing system'], ['Access', 'WCAG 2.2 AA target']] }];


function ProductCard({ p, i }) {
  const Head = IC[p.icon];
  return (
    <div data-theme={p.theme} className="pcard reveal" style={{ transitionDelay: i * 90 + 'ms' }}>
      <span className="glow" />
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24 }}>
        <span style={{ position: 'relative', width: 50, height: 50, borderRadius: 14, background: 'rgba(255,255,255,0.08)', border: '1px solid rgba(255,255,255,0.12)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
          <Head size={22} color="#fff" />
          <span style={{ position: 'absolute', top: -3, right: -3, width: 12, height: 12, borderRadius: '50%', background: p.dot, border: '2px solid var(--p900)' }} />
        </span>
      </div>
      <span style={{ display: 'inline-flex', background: '#fff', borderRadius: 12, padding: '10px 14px', marginBottom: 18, boxShadow: '0 10px 24px -14px rgba(0,0,0,0.5)' }}><img src={L + p.logo} alt={p.name} style={{ height: 22, display: 'block' }} /></span>
      <h3 style={{ fontSize: 21, fontWeight: 600, color: '#fff', lineHeight: 1.2 }}>{p.line}</h3>
      <ul style={{ listStyle: 'none', padding: 0, margin: '18px 0 22px', display: 'flex', flexDirection: 'column', gap: 9 }}>
        {p.feats.map((f, j) => <li key={j} style={{ display: 'flex', alignItems: 'center', gap: 10, fontSize: 14.5, color: 'var(--p200)' }}><IC.Check size={15} color="var(--p300)" />{f}</li>)}
      </ul>
      <dl className="spec" style={{ margin: 0, paddingTop: 18, borderTop: '1px solid rgba(255,255,255,0.1)' }}>
        {p.spec.map(([k, v]) => <React.Fragment key={k}><dt>{k}</dt><dd>{v}</dd></React.Fragment>)}
      </dl>
    </div>);

}

function Diagram() {
  return (
    <svg className="diagram" viewBox="0 0 1140 96" width="100%" height="96" aria-hidden="true" style={{ display: 'block', marginBottom: 4, overflow: 'visible' }}>
      <g fill="none" stroke="var(--p700)" strokeWidth="1.5">
        <path className="dash" d="M190 76 V50 H950 V76" data-comment-anchor="ef3eedd522-path-41-9" /><path className="dash" d="M570 50 V76" />
      </g>
      <text x="570" y="36" textAnchor="middle" fill="var(--p400)" fontFamily="var(--font-mono)" fontSize="11" letterSpacing="1.5">NATIVELY INTEGRATED · USE ONE OR ALL</text>
      <circle cx="190" cy="81" r="4" fill="var(--blue-400)" /><circle cx="570" cy="81" r="4" fill="var(--yellow-400)" /><circle cx="950" cy="81" r="4" fill="var(--coral-500)" />
    </svg>);

}

function Products() {
  return (
    <section id="products" style={{ background: 'var(--p900)', padding: '88px 0 96px', position: 'relative' }}>
      <div className="wrap">
        <div className="reveal" style={{ textAlign: 'center', maxWidth: 640, margin: '0 auto 40px' }}>
          <h2 style={{ fontSize: 'clamp(30px,3.8vw,48px)', fontWeight: 700, color: '#fff' }}>Three products. Use one, or all together.</h2>
          <p style={{ fontSize: 17.5, color: 'var(--p300)', marginTop: 16, lineHeight: 1.6 }}>Each is a complete product in its own right. Use the one you need, and when you use more than one, they talk to each other out of the box.</p>
        </div>
        <Diagram />
        <div className="pgrid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 20 }}>
          {PRODUCTS.map((p, i) => <ProductCard key={p.theme} p={p} i={i} />)}
        </div>
      </div>
    </section>);

}

/* ============================ APPROACH ============================ */
function Approach() {
  const vals = [
  ['Users', 'We build with you', 'You talk to the people who make the product, no hierarchy here.'],
  ['Activity', 'Always improving', 'Regular updates shaped by what our clients ask for, rolled out without disruption.'],
  ['Lock', 'Secure, UK & EU-hosted', 'GDPR-ready and UK & EU-hosted, held to the standard your clients deserve.'],
  ['Grid', 'Fits what you already run', 'Integrates with your existing systems, so nothing has to be ripped out to get started.']];

  return (
    <section id="approach" style={{ padding: '96px 0' }}>
      <div className="wrap apgrid" style={{ display: 'grid', gridTemplateColumns: '0.85fr 1.15fr', gap: 56, alignItems: 'start' }}>
        <div className="reveal" style={{ position: 'sticky', top: 100 }}>
          <h2 style={{ fontSize: 'clamp(28px,3.4vw,44px)', fontWeight: 700 }}>A small team that treats your service like ours.</h2>
          <p style={{ fontSize: 17, color: 'var(--p600)', marginTop: 18, lineHeight: 1.6 }}>We're deliberately small — every client gets our full attention, and the roadmap is shaped by the sector, not shareholders.</p>
          <div style={{ marginTop: 28 }}><Btn size="lg" iconRight={<IC.ChevronRight size={19} />} onClick={() => {location.href = window.PAGES.contact;}}>Talk to the team</Btn></div>
        </div>
        <div className="vgrid" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
          {vals.map(([ic, t, d], i) => {
            const Vi = IC[ic] || IC.Check;
            return (
              <div key={i} className="reveal" style={{ transitionDelay: i * 70 + 'ms', background: '#fff', borderRadius: 18, border: '1px solid var(--p100)', padding: '26px 24px', boxShadow: 'var(--shadow-xs)' }}>
                <span style={{ width: 44, height: 44, borderRadius: 12, background: 'var(--p50)', border: '1px solid var(--p100)', display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: 18 }}><Vi size={20} color="var(--p600)" /></span>
                <h3 style={{ fontSize: 18, fontWeight: 600 }}>{t}</h3>
                <p style={{ fontSize: 14.5, color: 'var(--p500)', marginTop: 9, lineHeight: 1.55 }}>{d}</p>
              </div>);

          })}
        </div>
      </div>
    </section>);

}

/* ============================ TESTIMONIALS ============================ */
const QUOTES = [
  ['They picked up the phone on a Sunday. That’s not a software company, that’s a partner who cares whether our customers are looked after.', 'Housing operations lead', 'Regional housing association'],
  ['Half our households registered with the app in the first week. We’d budgeted for a six month push.', 'Digital lead', 'Northern housing association'],
  ['The voice agent raises the repair, books the slot and the tenant sees it in the app. Nothing is entered twice.', 'Head of customer service', 'Community housing provider']];
function Quote() {
  return (
    <section style={{ padding: '0 0 96px' }} data-comment-anchor="95a29c55cd-section-126-5">
      <div className="wrap">
        <div className="reveal" style={{ textAlign: 'center', maxWidth: 560, margin: '0 auto 40px' }}>
          <p className="kick" style={{ marginBottom: 16 }}></p>
          <h2 style={{ fontSize: 'clamp(28px,3.4vw,44px)', fontWeight: 700 }}>Judged by the people who use it.</h2>
        </div>
        <div className="tgrid" style={{ display: 'grid', gridTemplateColumns: 'repeat(3,1fr)', gap: 20 }}>
          {QUOTES.map(([q, role, org], i) => (
            <figure key={i} className="reveal" style={{ margin: 0, transitionDelay: i * 80 + 'ms', background: '#fff', borderRadius: 20, border: '1px solid var(--p100)', padding: '30px 28px', boxShadow: 'var(--shadow-xs)', display: 'flex', flexDirection: 'column', gap: 22 }}>
              <span aria-hidden="true" style={{ fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 44, lineHeight: 0.6, color: 'var(--p200)' }}>&ldquo;</span>
              <blockquote style={{ margin: 0, flex: 1, fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 18.5, lineHeight: 1.4, color: 'var(--p900)', letterSpacing: '-0.01em' }}>{q}</blockquote>
            </figure>))}
        </div>
      </div>
    </section>);
}

/* ============================ CTA ============================ */
function CTA() {
  return (
    <section id="contact" style={{ padding: '0 0 96px' }}>
      <div className="wrap reveal">
        <div style={{ position: 'relative', overflow: 'hidden', borderRadius: 26, background: 'linear-gradient(135deg, var(--purple-600), var(--purple-800))', padding: '68px 48px', textAlign: 'center', boxShadow: '0 30px 60px -30px var(--p700)' }}>
          <h2 style={{ color: '#fff', fontSize: 'clamp(30px,4vw,50px)', fontWeight: 700, maxWidth: 680, margin: '0 auto' }}>Let&rsquo;s build something that works for your clients.</h2>
          <p style={{ color: 'var(--p200)', fontSize: 17.5, marginTop: 18, maxWidth: 500, marginInline: 'auto', lineHeight: 1.6 }}>Book a 30-minute demo. We&rsquo;ll listen, show you the products, and tell you honestly if we&rsquo;re the right fit.</p>
          <div style={{ display: 'flex', gap: 12, justifyContent: 'center', marginTop: 32, flexWrap: 'wrap' }}>
            <Btn size="lg" variant="secondary" data-theme="ioptus" iconRight={<IC.ChevronRight size={19} />} onClick={() => window.openDemo()}>Book a demo</Btn>
          </div>
        </div>
      </div>
    </section>);

}

function App() {
  window.useReveal();
  const { Nav, Hero, Trust, Footer } = window;
  return <React.Fragment><Nav /><main><Hero /><Trust /><Products /><Approach /><Quote /><CTA /></main><Footer /></React.Fragment>;
}
ReactDOM.createRoot(document.getElementById('root')).render(<App />);