function Hero() {
  const { Badge, Button, Icon } = DS;
  const heroRef = React.useRef(null);
  const out = useScrollProgress(heroRef, 0.12, -0.4);
  const wide = useMedia('(min-width: 1040px)');
  return (
    <section ref={heroRef} style={{ position: 'relative', overflow: 'hidden', borderBottom: '1px solid var(--yk-lavender)' }}>
      <div aria-hidden style={{ position: 'absolute', inset: 0, background: 'var(--mesh-bg)', opacity: .6 }} />
      <div aria-hidden style={{ position: 'absolute', inset: 0, opacity: .5, backgroundImage: 'radial-gradient(#CDD3EE 1px, transparent 1px)', backgroundSize: '22px 22px', backgroundPosition: `0 ${out * 60}px`, WebkitMaskImage: 'linear-gradient(180deg, #000 0%, transparent 85%)', maskImage: 'linear-gradient(180deg, #000 0%, transparent 85%)' }} />
      <Container style={{ position: 'relative', display: 'grid', gridTemplateColumns: wide ? 'minmax(0,1fr) minmax(0,1.08fr)' : 'minmax(0,1fr)', gap: wide ? 'clamp(40px, 4vw, 72px)' : 40, alignItems: 'center', paddingTop: wide ? 56 : 40, paddingBottom: wide ? 64 : 48 }}>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 22, alignItems: 'flex-start' }}>
          <Reveal><Badge>AI Automation. Simplified.</Badge></Reveal>
          <Reveal delay={0.07}><h1 style={{ font: `700 ${wide ? 'clamp(44px, 3.9vw, 58px)' : '38px'}/1.06 var(--font-display)`, letterSpacing: '-0.03em', color: 'var(--yk-indigo)', maxWidth: 640 }}>Custom software and AI workflows built for real operations.</h1></Reveal>
          <Reveal delay={0.14}><p style={{ font: '400 18px/1.6 var(--font-body)', color: 'var(--yk-charcoal)', maxWidth: 580 }}>We design, build, and integrate custom applications, voice &amp; chat agents, back-office automation, and human-reviewed content pipelines—engineered to fit how your team actually works.</p></Reveal>
          <Reveal delay={0.21} style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
            <Button size="lg" arrow onClick={() => kitScroll('scope')}>Scope Your Project</Button>
            <Button size="lg" variant="outline" onClick={() => kitScroll('services')}>Explore Services</Button>
          </Reveal>
          <Reveal delay={0.28} style={{ display: 'flex', gap: '12px 24px', flexWrap: 'wrap', marginTop: 4, padding: '14px 18px', borderRadius: 14, background: 'var(--glass-bg)', border: '1px solid var(--glass-border)', backdropFilter: 'var(--glass-blur)', WebkitBackdropFilter: 'var(--glass-blur)', boxShadow: 'var(--glass-shadow)' }}>
            {[['shield-check', 'Human-in-the-Loop Guardrails'], ['git-branch', 'Full Code Ownership'], ['webhook', 'API-First Architecture']].map(([ic, t]) => (
              <span key={t} style={{ display: 'inline-flex', alignItems: 'center', gap: 7, font: '500 13px var(--font-body)', color: 'var(--yk-charcoal)', whiteSpace: 'nowrap' }}><Icon name={ic} size={16} color="var(--yk-violet)" />{t}</span>
            ))}
          </Reveal>
        </div>
        <Reveal delay={0.12} style={{ minWidth: 0 }}>
          <div style={{ position: 'relative', transform: wide ? `translateY(${out * -40}px)` : 'none', willChange: 'transform', paddingBottom: wide ? 28 : 18 }}>
            {[2, 1].map((d) => <div key={d} aria-hidden style={{ position: 'absolute', left: d * 18, right: d * 18, top: d * 14, bottom: wide ? 28 - d * 14 : 18 - d * 9, borderRadius: 22, background: d === 2 ? 'rgba(255,255,255,.3)' : 'rgba(255,255,255,.45)', border: '1px solid var(--glass-border)', backdropFilter: 'var(--glass-blur)', WebkitBackdropFilter: 'var(--glass-blur)', boxShadow: 'var(--glass-shadow)', transform: `translateY(${d * (wide ? 14 : 9) + out * d * 12}px)` }} />)}
            <div style={{ position: 'relative', padding: wide ? 12 : 8, borderRadius: 22, background: 'var(--glass-bg)', border: '1px solid var(--glass-border)', backdropFilter: 'var(--glass-blur)', WebkitBackdropFilter: 'var(--glass-blur)', boxShadow: 'var(--glass-shadow)' }}><HeroConsole /></div>
            {wide && <HeroFloat style={{ left: -40, top: -30, animationDelay: '0s' }} icon="shield-check" title="Approval needed" sub="Refund ₹2,400 · conf. 71%" tone="#7C3AED" />}
            {wide && <HeroFloat style={{ right: -26, bottom: 64, animationDelay: '1.4s', transform: `translateY(${out * 30}px)` }} icon="webhook" title="POST /hooks/crm" sub="200 OK · 84 ms" tone="#0891B2" />}
          </div>
        </Reveal>
      </Container>
    </section>
  );
}

function HeroFloat({ icon, title, sub, tone, style }) {
  const { Icon } = DS;
  const reduce = useReducedMotion();
  return (
    <div style={{ position: 'absolute', zIndex: 3, ...style }}>
      <div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '10px 14px 10px 10px', borderRadius: 14, background: 'var(--glass-bg-strong)', border: '1px solid var(--glass-border)', backdropFilter: 'var(--glass-blur)', WebkitBackdropFilter: 'var(--glass-blur)', boxShadow: '0 1px 0 rgba(255,255,255,.8) inset, 0 18px 40px -14px rgba(30,27,75,.35)', animation: reduce ? 'none' : 'yk-float 5s ease-in-out infinite', animationDelay: style.animationDelay }}>
        <span style={{ width: 32, height: 32, borderRadius: 9, display: 'grid', placeItems: 'center', background: tone, color: '#fff', flex: 'none' }}><Icon name={icon} size={16} /></span>
        <div><div style={{ font: '600 12.5px var(--font-body)', color: 'var(--yk-indigo)', whiteSpace: 'nowrap' }}>{title}</div><div style={{ font: '500 10.5px var(--font-mono)', color: 'var(--yk-charcoal)', whiteSpace: 'nowrap' }}>{sub}</div></div>
      </div>
    </div>
  );
}

function Ticker() {
  const { Icon } = DS;
  const items = [['message-circle', 'WhatsApp Business'], ['braces', 'REST & GraphQL APIs'], ['kanban', 'CRM Pipelines'], ['phone', 'VoIP & Telephony'], ['database', 'PostgreSQL'], ['webhook', 'Webhooks'], ['mail', 'Email & SMS Gateways'], ['chart-column', 'Analytics Dashboards'], ['cloud', 'Cloud Infrastructure']];
  const [paused, setPaused] = React.useState(false);
  const Item = ({ ic, t }) => {
    const [h, setH] = React.useState(false);
    return <span onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)} style={{ display: 'inline-flex', alignItems: 'center', gap: 8, padding: '0 28px', font: '500 14px var(--font-body)', color: h ? 'var(--yk-indigo)' : 'var(--yk-slate-500)', whiteSpace: 'nowrap', transition: 'color .2s' }}><Icon name={ic} size={17} />{t}</span>;
  };
  return (
    <section style={{ background: 'var(--glass-bg)', backdropFilter: 'var(--glass-blur)', WebkitBackdropFilter: 'var(--glass-blur)', boxShadow: 'var(--glass-shadow)', borderTop: '1px solid var(--glass-border)', borderBottom: '1px solid var(--glass-border)', padding: '22px 0', overflow: 'hidden' }}>
      <Container style={{ marginBottom: 14 }}><MonoLabel style={{ textTransform: 'uppercase', letterSpacing: '.08em' }}>Engineered to integrate with your existing stack</MonoLabel></Container>
      <div onMouseEnter={() => setPaused(true)} onMouseLeave={() => setPaused(false)} style={{ WebkitMaskImage: 'linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent)', maskImage: 'linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent)' }}>
        <div style={{ display: 'flex', width: 'max-content', animation: 'yk-marquee 40s linear infinite', animationPlayState: paused ? 'paused' : 'running' }}>
          {[...items, ...items].map(([ic, t], i) => <Item key={i} ic={ic} t={t} />)}
        </div>
      </div>
    </section>
  );
}

Object.assign(window, { Hero, Ticker });
