(()=>{
const NX=window.NURVEXAIDesignSystem_4750bb;const {useRef,useEffect,useState}=React;const {reduced}=window.NXH;
function HeroField(){
  const ref=useRef();
  useEffect(()=>{const c=ref.current,ctx=c.getContext('2d');const dpr=Math.min(2,devicePixelRatio||1);let w,h,raf;
    const mob=()=>innerWidth<900;const N=mob()?50:110;
    const size=()=>{w=c.offsetWidth;h=c.offsetHeight;c.width=w*dpr;c.height=h*dpr;ctx.setTransform(dpr,0,0,dpr,0,0)};size();
    const cx=()=>w*.5,cy=()=>h*.42;
    const g=()=>(Math.random()+Math.random()+Math.random()-1.5);
    const mk=init=>{const z=Math.random();return{x:cx()+g()*w*.3,y:init?cy()+g()*h*.7:cy()+h*(.15+Math.random()*.35),z,vx:g()*.12,vy:-(.1+z*.45),r:.4+z*1.7,life:init?Math.random()*400:0,max:300+Math.random()*500}};
    const ps=Array.from({length:N},()=>mk(true));
    const draw=()=>{ctx.clearRect(0,0,w,h);
      for(const p of ps){p.x+=p.vx;p.y+=p.vy;p.life++;const t=p.life/p.max;const a=Math.sin(Math.PI*Math.min(1,t))*(.2+p.z*.7);
        if(p.z>.6){ctx.beginPath();ctx.arc(p.x,p.y,p.r*3.2,0,7);ctx.fillStyle='rgba(77,184,255,'+a*.18+')';ctx.fill()}ctx.beginPath();ctx.arc(p.x,p.y,p.r,0,7);ctx.fillStyle=p.z>.85?'rgba(220,236,255,'+a+')':'rgba(77,184,255,'+a+')';ctx.fill();
        if(t>=1)Object.assign(p,mk(false))}
      if(!reduced)raf=requestAnimationFrame(draw)};
    const io=new IntersectionObserver(([e])=>{cancelAnimationFrame(raf);if(e.isIntersecting)draw()});io.observe(c);
    addEventListener('resize',size);return()=>{io.disconnect();cancelAnimationFrame(raf);removeEventListener('resize',size)}},[]);
  return <canvas ref={ref} className="hx-field" aria-hidden="true"></canvas>;
}
const DUR=5600;
const Pause=({on})=>on?<span className="hf-ico"><i></i><i></i></span>:<span className="hf-ico play"></span>;
function Hero({onCta,onWork}){
  const S=window.NX_DATA.services,C=window.NX_DATA.capabilities,V=window.NXViz||{};
  const scenes=[{id:'intro',ch:'NURVEX AI',line:'Build smarter. Automate faster.'},...S.map((s,k)=>({id:s.id,ch:C[k].name,line:C[k].line,s})),{id:'outro',ch:'Your system',line:'One technology partner.'}];
  const [i,setI]=useState(0);const [play,setPlay]=useState(!reduced);const [hold,setHold]=useState(false);
  const root=useRef(),bars=useRef([]),p=useRef(0),vis=useRef(true),holdR=useRef(false);holdR.current=hold;
  const go=n=>{p.current=0;setI(n)};
  useEffect(()=>{const io=new IntersectionObserver(([e])=>vis.current=e.isIntersecting,{threshold:.2});io.observe(root.current);return()=>io.disconnect()},[]);
  useEffect(()=>{bars.current.forEach((b,k)=>b&&(b.style.transform='scaleX('+(k<i?1:k===i?p.current:0)+')'));if(!play)return;
    let raf,last=performance.now();const dur=i===0?7200:DUR;
    const tick=t=>{const dt=Math.min(100,t-last);last=t;if(vis.current&&!document.hidden&&!holdR.current){p.current+=dt/dur;if(p.current>=1){go((i+1)%scenes.length);return}
      const b=bars.current[i];if(b)b.style.transform='scaleX('+p.current+')'}raf=requestAnimationFrame(tick)};
    raf=requestAnimationFrame(tick);return()=>cancelAnimationFrame(raf)},[play,i]);
  const mv=e=>{const r=root.current.getBoundingClientRect();root.current.style.setProperty('--mx',(e.clientX-r.left)+'px');root.current.style.setProperty('--my',(e.clientY-r.top)+'px');
    root.current.style.setProperty('--px',((e.clientX/r.width)-.5).toFixed(3));root.current.style.setProperty('--py',((e.clientY-r.top)/r.height-.5).toFixed(3))};
  const sc=scenes[i];const Viz=sc.s&&V[sc.id];
  return <section className="hx hf" id="top" ref={root} onMouseMove={mv} data-screen-label="01 Hero film">
    <div className={'hf-bg'+(i===0?'':i===scenes.length-1?' dim soft':' dim')}><div className="hx-drift"><img src={(window.__resources&&window.__resources.logoScene)||"assets/logo-scene.jpg"} alt="NURVEX AI logo in a dark, blue-lit chamber"/></div><div className="hx-sweep"></div></div>
    <div className="hx-floor hf-floor"></div><HeroField/><div className="hf-vign"></div><div className="hf-spot"></div>
    <div className="hf-stage" key={i}>
      {sc.id==='intro'?<div className="hf-intro"><div className="hf-w" style={{'--d':'2.1s'}}><NX.StatusLine>NURVEX AI SYSTEMS — ONLINE</NX.StatusLine></div>
        <h1 className="hf-tag hf-w" style={{'--d':'2.3s'}}><span className="nx-metal-text">Build smarter. </span><span className="hx-accent">Automate faster.</span></h1></div>
      :sc.id==='outro'?<div className="hf-outro"><span className="mono hf-w" style={{color:'var(--text-accent)'}}>Websites / Apps / AI Agents / Voice AI / Automation</span>
        <h2 className="hf-big hf-w" style={{'--d':'.15s'}}><span className="nx-metal-text">One technology partner.</span><span style={{color:'var(--nx-blue-400)'}}>Multiple possibilities.</span></h2>
        <div className="hx-ctas hf-w" style={{'--d':'.4s',justifyContent:'center'}}><NX.Button size="lg" iconRight="→" onClick={onCta}>Build my AI system</NX.Button><NX.Button size="lg" variant="secondary" iconRight="→" onClick={onWork}>Explore our work</NX.Button></div></div>
      :<div className="hf-svc"><div className="hf-cap">
          <span className="nx-label hf-w">{sc.s.n} / 05 — {sc.s.name}</span>
          <h2 className="hf-h hf-w" style={{'--d':'.12s'}}>{sc.s.headline.map((l,k)=><span key={k}>{l}</span>)}</h2>
          <p className="hf-d hf-w" style={{'--d':'.26s'}}>{sc.s.desc}</p></div>
        <div className="hf-viz" onMouseEnter={()=>setHold(true)} onMouseLeave={()=>setHold(false)}>{Viz?<Viz/>:null}<span className={'hf-hold mono'+(hold?' on':'')}>{hold?'● Paused — exploring':'Hover to explore'}</span></div></div>}
    </div>
    <div className="hf-bar">
      <button className="hf-play" aria-label={play?'Pause film':'Play film'} onClick={()=>setPlay(x=>!x)}><Pause on={play}/></button>
      <div className="hf-chs">{scenes.map((s,k)=><button key={s.id} className={'hf-ch'+(k===i?' on':'')} onClick={()=>go(k)} aria-label={'Play chapter: '+s.ch}>
        <span className="mono">{String(k).padStart(2,'0')} {s.ch}</span><i><b ref={el=>bars.current[k]=el}></b></i>
        <span className="hf-tip"><span className="mono" style={{color:'var(--text-accent)'}}>Chapter {String(k).padStart(2,'0')}</span><strong>{s.ch}</strong><span>{s.line}</span></span></button>)}</div>
      <div className="hf-cta"><NX.Button size="sm" iconRight="→" onClick={onCta}>Build my AI system</NX.Button></div>
    </div>
    <div className="hx-boot" aria-hidden="true"><div><span className="mono">Initialising NURVEX AI systems</span><b></b></div></div>
  </section>;
}
window.NXHero=Hero;
})();
