const { Eyebrow, Button, StatBlock, Card, Tag, Divider } = window.IndigoAdvisoryDesignSystem_fba97f;

const gutter = { paddingLeft: 'var(--gutter)', paddingRight: 'var(--gutter)' };
const wrap = { maxWidth: 'var(--container)', margin: '0 auto' };

const CAPABILITIES = [
  ['Negotiation', 'We only partake in the value that we create in the transaction.', ['rgba(180,120,60,0.9)', 'rgba(120,78,42,0.7)'], 'assets/scene-negotiation.png'],
  ['Structuring', 'We design structures that create additional alpha².', ['rgba(140,95,50,0.9)', 'rgba(90,58,32,0.72)'], 'assets/scene-structuring.png'],
  ['Investing', 'We commit capital alongside conviction, across private and public markets.', ['rgba(215,165,60,0.88)', 'rgba(150,105,40,0.7)'], 'assets/scene-investing.png'],
];

function CapabilitySlider() {
  const [i, setI] = React.useState(0);
  const [paused, setPaused] = React.useState(false);
  const n = CAPABILITIES.length;
  const DUR = 5200;
  React.useEffect(() => {
    if (paused) return;
    const t = setTimeout(() => setI((p) => (p + 1) % n), DUR);
    return () => clearTimeout(t);
  }, [i, paused, n]);

  const [title, desc, grad, photo] = CAPABILITIES[i];
  return (
    <div
      style={{
        position: 'relative', overflow: 'hidden', borderRadius: 'var(--radius-lg)',
        background: '#2a1c10', minHeight: 600, border: '1px solid rgba(215,165,60,0.22)',
        boxShadow: 'var(--shadow-lg, 0 30px 80px rgba(0,0,0,0.35))',
      }}
    >
      {/* Cinematic backdrop — recolors per scene, slow zoom */}
      <div key={`bg-${i}`} className="movie-scene" style={{
        position: 'absolute', inset: 0,
        background: `radial-gradient(70% 90% at 20% 15%, ${grad[0]}, transparent 60%), radial-gradient(80% 90% at 90% 100%, ${grad[1]}, transparent 65%), #2a1c10`,
        animation: 'sceneKen 6s var(--ease-out) forwards',
      }} />
      {photo && <React.Fragment>
        <div key={`ph-${i}`} className="movie-scene" style={{ position: 'absolute', inset: 0, backgroundImage: `url(${photo})`, backgroundSize: 'cover', backgroundPosition: 'center 45%', animation: 'sceneKen 6s var(--ease-out) forwards' }} />
        <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(90deg, rgba(20,14,8,0.9) 0%, rgba(24,17,9,0.55) 46%, rgba(30,20,10,0.2) 100%)' }} />
      </React.Fragment>}
      {/* Film grain / vignette */}
      <div style={{ position: 'absolute', inset: 0, background: 'radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(0,0,0,0.6))', pointerEvents: 'none' }} />
      {/* Letterbox bars */}
      <div style={{ position: 'absolute', top: 0, left: 0, right: 0, height: 28, background: '#000', zIndex: 3 }} />
      <div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, height: 28, background: '#000', zIndex: 3 }} />

      {/* Scene content */}
      <div key={`sc-${i}`} className="movie-scene" style={{ position: 'relative', zIndex: 2, padding: 'var(--space-10) var(--space-9)', minHeight: 600, display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
        {/* Giant ghost index */}
        <span style={{
          position: 'absolute', right: 'var(--space-7)', top: '50%', transform: 'translateY(-50%)',
          fontFamily: 'var(--font-display)', fontWeight: 'var(--fw-med)', fontSize: 'clamp(9rem, 22vw, 20rem)',
          lineHeight: 1, color: '#fff', opacity: 0.14, animation: 'sceneNum 1.2s var(--ease-out) forwards', pointerEvents: 'none',
        }}>0{i + 1}</span>

        <span style={{ fontFamily: 'var(--font-mono)', fontSize: 'var(--fs-xs)', letterSpacing: '0.18em', color: 'var(--yamabuki-400)', opacity: 0, animation: 'sceneLine 0.7s var(--ease-out) 0.1s forwards' }}>SCENE 0{i + 1} / 0{n}</span>

        <h3 style={{
          fontFamily: 'var(--font-display)', fontSize: 'clamp(2.5rem, 6vw, 4.5rem)', fontWeight: 'var(--fw-med)',
          letterSpacing: 'var(--ls-tight)', lineHeight: 'var(--lh-tight)', color: 'var(--paper)',
          margin: 'var(--space-4) 0 0', maxWidth: 720, opacity: 0, animation: 'sceneLine 0.9s var(--ease-out) 0.35s forwards',
        }}>{title}<span style={{ color: grad[0] }}>.</span></h3>

        <div style={{ height: 2, width: 120, background: 'var(--yamabuki-400)', transformOrigin: 'left', margin: 'var(--space-6) 0', animation: 'sceneBar 0.8s var(--ease-out) 0.7s both' }} />

        <p style={{
          fontFamily: 'var(--font-body)', fontSize: 'var(--fs-lead)', fontWeight: 'var(--fw-light)',
          lineHeight: 'var(--lh-normal)', color: 'rgba(255,255,255,0.86)', margin: 0, maxWidth: 560,
          opacity: 0, animation: 'sceneLine 1s var(--ease-out) 0.9s forwards',
        }}>{desc}</p>
      </div>

      {/* Scene progress bars */}
      <div style={{ position: 'absolute', left: 'var(--space-8)', bottom: 'var(--space-7)', zIndex: 4, display: 'flex', gap: 'var(--space-3)' }}>
        {CAPABILITIES.map(([t], idx) => (
          <button key={t} onClick={() => setI(idx)} aria-label={`Scene ${idx + 1}`} title={t} style={{
            position: 'relative', height: 3, width: idx === i ? 52 : 26, border: 'none', padding: 0, cursor: 'pointer',
            background: 'rgba(255,255,255,0.25)', borderRadius: 'var(--radius-pill)', overflow: 'visible',
            transition: 'width var(--dur-med) var(--ease-out)',
          }}>
            <span aria-hidden="true" style={{ position: 'absolute', left: 0, right: 0, top: -22, bottom: -22, cursor: 'pointer' }} />
            {idx === i && (
              <span key={`${i}-${paused}`} style={{
                position: 'absolute', inset: 0, background: 'var(--yamabuki-400)', transformOrigin: 'left', borderRadius: 'var(--radius-pill)',
                animation: paused ? 'none' : `capFill ${DUR}ms linear forwards`,
              }} />
            )}
          </button>
        ))}
      </div>
    </div>
  );
}

// A couple of cubelets per side lift and slide out of the plane, so the cube
// reads as an assembly of blocks rather than a printed grid.
const TileMoves = ({ seed = 0 }) => (
  <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none', zIndex: 7, transformStyle: 'preserve-3d' }}>
    {[[0, 2, 'tilePop', 7], [1, 1, 'tileSlide', 11], [2, 0, 'tilePop', 9]].map(([r, c, anim, dur], k) => (
      <div key={k} className="cube-tile" style={{
        position: 'absolute', left: `${c * (100 / 3)}%`, top: `${r * (100 / 3)}%`,
        width: `${100 / 3}%`, height: `${100 / 3}%`,
        background: 'linear-gradient(135deg, rgba(255,240,205,0.30), rgba(120,80,26,0.34))',
        boxShadow: 'inset 1px 1px 0 rgba(255,255,255,0.5), inset -2px -2px 0 rgba(0,0,0,0.4), 0 0 22px rgba(0,0,0,0.35)',
        border: '1px solid rgba(255,255,255,0.28)',
        animation: `${anim} ${dur}s ease-in-out ${(seed + k) * 1.3}s infinite`,
        transformStyle: 'preserve-3d',
      }} />
    ))}
  </div>
);

function HomeScreen({ onNav }) {
  // A real 3D cube that turns around in space. It auto-rotates continuously and
  // you can grab it to spin faster/slower — the front face carries the film, the
  // other faces carry the firm's statements, so all four sides come around.
  const [angle, setAngle] = React.useState(-18); // rotateY of the cube
  const [pitch, setPitch] = React.useState(-14); // rotateX of the cube
  const [dragging, setDragging] = React.useState(false);
  const dragRef = React.useRef(null);
  const velRef = React.useRef(-0.55); // idle spin speed (deg/frame)
  const rafRef = React.useRef(null);
  const tRef = React.useRef(0); // idle clock, drives the slow tumble on X

  React.useEffect(() => {
    let last = performance.now();
    const tick = (now) => {
      const dt = Math.min(2, (now - last) / 16.67); last = now;
      if (!dragRef.current) {
        setAngle((a) => a + velRef.current * dt);
        // ease idle speed back to a gentle constant drift
        velRef.current += (-0.55 - velRef.current) * 0.03;
        // Slow tumble on the other axis so it turns on a diagonal, not a turntable.
        tRef.current += dt;
        const target = -14 + Math.sin(tRef.current * 0.0055) * 16;
        setPitch((p) => p + (target - p) * 0.04);
      }
      rafRef.current = requestAnimationFrame(tick);
    };
    rafRef.current = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(rafRef.current);
  }, []);

  const onDown = (e) => { dragRef.current = { startX: e.clientX, startY: e.clientY, base: angle, baseP: pitch, lastX: e.clientX }; setDragging(true); e.preventDefault(); };
  const onMove = (e) => {
    const d = dragRef.current;
    if (!d) return;
    velRef.current = (e.clientX - d.lastX) * 0.4; // carry momentum on release
    d.lastX = e.clientX;
    setAngle(d.base + (e.clientX - d.startX) * 0.4);
    // drag up/down tilts the cube, clamped so it never flips over
    setPitch(Math.max(-70, Math.min(30, d.baseP + (e.clientY - d.startY) * 0.4)));
  };
  const endDrag = () => { dragRef.current = null; setDragging(false); };

  React.useEffect(() => {
    if (!dragging) return;
    const mv = (e) => onMove(e);
    window.addEventListener('mousemove', mv);
    window.addEventListener('mouseup', endDrag);
    return () => { window.removeEventListener('mousemove', mv); window.removeEventListener('mouseup', endDrag); };
  }, [dragging]);

  // Cube geometry — half-depth so faces sit flush at the edges.
  const CUBE = 320, HALF = CUBE / 2;
  // Face element stays a CLEAN 3d leaf (only transform/size/bg/backface) so
  // backface-visibility culls reliably. Border + shadow live on an inner child.
  const faceBase = {
    position: 'absolute', width: CUBE, height: CUBE, left: '50%', top: '50%',
    marginLeft: -HALF, marginTop: -HALF,
    backfaceVisibility: 'hidden', WebkitBackfaceVisibility: 'hidden',
    transformStyle: 'preserve-3d',
  };
  const faceDecor = {
    position: 'absolute', inset: 0, pointerEvents: 'none', zIndex: 5,
    border: '1px solid rgba(255,255,255,0.35)',
    boxShadow: 'inset 2px 2px 0 rgba(255,255,255,0.45), inset -3px -3px 0 rgba(0,0,0,0.35), inset -28px -28px 60px rgba(0,0,0,0.5), inset 22px 22px 70px rgba(255,255,255,0.14)',
  };
  // Nine cubelets per side: grooves on the thirds, with a lit edge either side
  // of each groove so every tile reads as its own bevelled block.
  const T = 100 / 3;
  const groove = (dir) => `repeating-linear-gradient(${dir},
    transparent 0 calc(${T}% - 5px),
    rgba(255,255,255,0.22) calc(${T}% - 5px) calc(${T}% - 3px),
    rgba(0,0,0,0.55) calc(${T}% - 3px) calc(${T}% + 1px),
    rgba(255,255,255,0.16) calc(${T}% + 1px) calc(${T}% + 3px),
    transparent calc(${T}% + 3px) ${T}%)`;
  const tileGrid = {
    position: 'absolute', inset: 0, pointerEvents: 'none', zIndex: 6,
    background: `${groove('90deg')}, ${groove('180deg')}`,
    backgroundSize: '100% 100%, 100% 100%',
    mixBlendMode: 'overlay',
  };
  const faceClip = { position: 'absolute', inset: 0, overflow: 'hidden' };
  const faceVideo = { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', background: 'linear-gradient(135deg,#2b2e33,#1d1f23)' };
  const filmScrim = { position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(20,14,6,0.35), rgba(20,14,6,0.62))' };
  // Manual backface culling — CSS backface-visibility won't cull inside this
  // preserve-3d group, so hide any face whose outward normal points away.
  const rx = pitch * Math.PI / 180, rz = 6 * Math.PI / 180, ry = angle * Math.PI / 180;
  const m3 = (a, b) => { const r = [[0,0,0],[0,0,0],[0,0,0]]; for (let i=0;i<3;i++) for (let j=0;j<3;j++) for (let k=0;k<3;k++) r[i][j]+=a[i][k]*b[k][j]; return r; };
  const Rx = [[1,0,0],[0,Math.cos(rx),-Math.sin(rx)],[0,Math.sin(rx),Math.cos(rx)]];
  const Rz = [[Math.cos(rz),-Math.sin(rz),0],[Math.sin(rz),Math.cos(rz),0],[0,0,1]];
  const Ry = [[Math.cos(ry),0,Math.sin(ry)],[0,1,0],[-Math.sin(ry),0,Math.cos(ry)]];
  const M = m3(m3(Rx, Rz), Ry);
  const vis = (n) => (M[2][0]*n[0] + M[2][1]*n[1] + M[2][2]*n[2]) > 0.02 ? 'visible' : 'hidden';
  const faceVis = { front: vis([0,0,1]), right: vis([1,0,0]), back: vis([0,0,-1]), left: vis([-1,0,0]), top: vis([0,1,0]), bottom: vis([0,-1,0]) };
  // Refined sheen — a single quiet light fall across polished stone.
  const cosmicSheen = { position: 'absolute', inset: 0, pointerEvents: 'none', background: 'linear-gradient(135deg, rgba(255,255,255,0.45) 0%, rgba(255,255,255,0.12) 22%, transparent 50%), radial-gradient(90% 80% at 78% 96%, rgba(0,0,0,0.55), transparent 68%)' };
  // Deep, muted mineral washes — bordeaux, graphite, bronze — not cosmic.
  const nebula = (a, b) => `radial-gradient(95% 95% at 28% 18%, ${a}, transparent 78%), radial-gradient(95% 95% at 82% 92%, ${b}, transparent 80%), #6a4a1e`;
  const panelText = {
    position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', justifyContent: 'center',
    padding: 'var(--space-7)', color: 'var(--paper)',
  };
  const scrim = { position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(12,11,16,0.35), rgba(12,11,16,0.7))' };
  return (
    <div>
      {/* Hero — a 3D cube that turns to state the mandate; drag to spin it */}
      <section
        onMouseDown={onDown}
        style={{ position: 'relative', minHeight: '86vh', overflow: 'hidden', background: 'linear-gradient(180deg, #f2ddab 0%, #e6c884 46%, #d3ab5c 100%)', cursor: dragging ? 'grabbing' : 'grab', userSelect: 'none' }}
      >
        {/* Facade texture — the tower read as light on glass, blended into the gold */}
        <div style={{ position: 'absolute', inset: 0, zIndex: 0, pointerEvents: 'none', backgroundImage: 'url(assets/tower.png)', backgroundSize: 'cover', backgroundPosition: 'center 30%', opacity: 0.62, mixBlendMode: 'soft-light' }} />
        <div style={{ position: 'absolute', inset: 0, zIndex: 0, pointerEvents: 'none', background: 'linear-gradient(90deg, rgba(242,221,171,0.88) 0%, rgba(242,221,171,0.45) 40%, rgba(230,200,132,0.06) 100%)' }} />
        {/* Moving gold light sweep */}
        <div className="gold-sweep" style={{ position: 'absolute', top: '-20%', left: 0, width: '38%', height: '140%', zIndex: 1, pointerEvents: 'none', background: 'linear-gradient(90deg, transparent, rgba(255,240,200,0.55), transparent)', filter: 'blur(6px)', animation: 'goldSweep 9s ease-in-out infinite' }} />
        {/* Quiet vignette */}
        <div style={{ position: 'absolute', inset: 0, zIndex: 1, pointerEvents: 'none', background: 'radial-gradient(70% 60% at 50% 38%, rgba(255,248,235,0.4), transparent 70%), radial-gradient(60% 55% at 50% 92%, rgba(150,110,60,0.28), transparent 70%)' }} />

        {/* Hero content — statement + cube */}
        <div style={{ ...gutter, position: 'relative', zIndex: 2 }}>
          <div style={{ ...wrap, display: 'grid', gridTemplateColumns: '1.05fr 1fr', gap: 'var(--space-8)', alignItems: 'center', minHeight: '86vh', paddingTop: 56, paddingBottom: 'var(--space-7)' }}>
            <div style={{ position: 'relative', zIndex: 4 }}>
              <Eyebrow style={{ color: 'var(--shu-600)' }}>Investment house creating value</Eyebrow>
              <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(2.6rem, 4.6vw, 4rem)', fontWeight: 'var(--fw-med)', letterSpacing: 'var(--ls-tight)', lineHeight: 'var(--lh-tight)', color: 'var(--shu-600)', margin: 'var(--space-5) 0 0', maxWidth: 560 }}>
                Investing with conviction<span style={{ color: 'var(--shu-600)' }}>.</span>
              </h1>
              <p style={{ fontFamily: 'var(--font-body)', fontSize: 'var(--fs-lead)', fontWeight: 'var(--fw-light)', lineHeight: 'var(--lh-normal)', color: 'var(--ink-600)', maxWidth: 520, margin: 'var(--space-5) 0 var(--space-7)' }}>
                We negotiate, structure, and invest to create value for companies and technology leaders — across Dubai. London. Hong-Kong. Mumbai.
              </p>
              <div style={{ display: 'flex', gap: 'var(--space-3)', flexWrap: 'wrap', alignItems: 'center' }}>
                <Button variant="solid" size="lg" onClick={() => onNav('contact')}>Start a conversation</Button>
                <Button variant="outline" size="lg" onClick={() => onNav('capabilities')} style={{ borderColor: 'rgba(74,50,26,0.4)', color: 'var(--sumi-900)' }}>See our capabilities</Button>
              </div>
            </div>
            <div style={{ position: 'relative', height: 540, display: 'grid', placeItems: 'center', perspective: '3400px' }}>
          {/* Ground shadow — grounds the cube in 3D space */}
          <div style={{ position: 'absolute', bottom: 56, left: '50%', transform: 'translateX(-50%)', width: CUBE * 0.95, height: 54, background: 'radial-gradient(ellipse at center, rgba(30,18,8,0.5), transparent 70%)', filter: 'blur(14px)', borderRadius: '50%', zIndex: 0 }} />
          <div className="cube-float" style={{ transformStyle: 'preserve-3d', animation: 'cubeFloat 6s ease-in-out infinite', position: 'relative', zIndex: 1 }}>
          <div style={{ width: CUBE, height: CUBE, position: 'relative', transformStyle: 'preserve-3d', transform: `rotateX(${pitch}deg) rotateZ(6deg) rotateY(${angle}deg)`, transition: dragging ? 'none' : 'none' }}>
            {/* FRONT — the film */}
            <div style={{ ...faceBase, visibility: faceVis.front, transform: `translateZ(${HALF}px)` }}>
              <div style={faceDecor} /><div style={tileGrid} /><TileMoves seed={0} />
              <video autoPlay muted loop playsInline preload="auto" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', background: 'linear-gradient(135deg,#2b2e33,#1d1f23)' }}>
                <source src="assets/hero.mp4" type="video/mp4" />
              </video>
              <div style={scrim} />
              <div style={{ ...panelText, justifyContent: 'center' }}>
                <span style={{ fontFamily: 'var(--font-mono)', fontSize: 'var(--fs-xs)', letterSpacing: '0.16em', color: 'var(--yamabuki-400)' }}>WE</span>
                <p style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(2.4rem,5vw,3.4rem)', fontWeight: 'var(--fw-med)', lineHeight: 'var(--lh-tight)', letterSpacing: 'var(--ls-tight)', margin: 'var(--space-3) 0 0', color: 'var(--paper)' }}>We<span style={{ color: 'var(--shu-400)' }}>.</span></p>
                <span style={{ fontFamily: 'var(--font-body)', fontSize: 'var(--fs-sm)', color: 'rgba(255,255,255,0.55)', marginTop: 'var(--space-4)' }}>drag to read the mandate →</span>
              </div>
            </div>
            {/* RIGHT — statement */}
            <div style={{ ...faceBase, visibility: faceVis.right, transform: `rotateY(90deg) translateZ(${HALF}px)`, background: nebula('rgba(232,182,84,1)', 'rgba(176,124,48,0.98)') }}>
              <video autoPlay muted loop playsInline preload="auto" style={faceVideo}><source src="assets/hero.mp4" type="video/mp4" /></video>
              <div style={filmScrim} />
              <div style={faceDecor} /><div style={tileGrid} /><TileMoves seed={1} />
              <div style={cosmicSheen} />
              <div style={panelText}>
                <p style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(2.4rem,5vw,3.4rem)', fontWeight: 'var(--fw-med)', lineHeight: 'var(--lh-tight)', letterSpacing: 'var(--ls-tight)', margin: 'var(--space-3) 0 0' }}>negotiate<span style={{ color: 'var(--yamabuki-400)' }}>,</span></p>
              </div>
            </div>
            {/* BACK — statement */}
            <div style={{ ...faceBase, visibility: faceVis.back, transform: `rotateY(180deg) translateZ(${HALF}px)`, background: nebula('rgba(210,160,72,1)', 'rgba(150,104,44,0.98)') }}>
              <video autoPlay muted loop playsInline preload="auto" style={faceVideo}><source src="assets/hero.mp4" type="video/mp4" /></video>
              <div style={filmScrim} />
              <div style={faceDecor} /><div style={tileGrid} /><TileMoves seed={2} />
              <div style={cosmicSheen} />
              <div style={panelText}>
                <p style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(2.4rem,5vw,3.4rem)', fontWeight: 'var(--fw-med)', lineHeight: 'var(--lh-tight)', letterSpacing: 'var(--ls-tight)', margin: 'var(--space-3) 0 0' }}>structure<span style={{ color: 'var(--shu-400)' }}>,</span></p>
              </div>
            </div>
            {/* LEFT — statement */}
            <div style={{ ...faceBase, visibility: faceVis.left, transform: `rotateY(-90deg) translateZ(${HALF}px)`, background: nebula('rgba(246,196,90,1)', 'rgba(206,150,54,0.98)') }}>
              <video autoPlay muted loop playsInline preload="auto" style={faceVideo}><source src="assets/hero.mp4" type="video/mp4" /></video>
              <div style={filmScrim} />
              <div style={faceDecor} /><div style={tileGrid} /><TileMoves seed={3} />
              <div style={cosmicSheen} />
              <div style={panelText}>
                <p style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(2.4rem,5vw,3.4rem)', fontWeight: 'var(--fw-med)', lineHeight: 'var(--lh-tight)', letterSpacing: 'var(--ls-tight)', margin: 'var(--space-3) 0 0' }}>&amp; invest<span style={{ color: 'var(--shu-400)' }}>.</span></p>
              </div>
            </div>
            {/* TOP */}
            <div style={{ ...faceBase, transform: `rotateX(90deg) translateZ(${HALF}px)`, background: nebula('rgba(240,192,110,1)', 'rgba(196,144,66,0.95)') }}>
              <video autoPlay muted loop playsInline preload="auto" style={faceVideo}><source src="assets/hero.mp4" type="video/mp4" /></video>
              <div style={filmScrim} />
              <div style={faceDecor} /><div style={tileGrid} /><TileMoves seed={4} />
              <div style={cosmicSheen} />
            </div>
            {/* BOTTOM */}
            <div style={{ ...faceBase, transform: `rotateX(-90deg) translateZ(${HALF}px)`, background: nebula('rgba(246,196,90,1)', 'rgba(196,144,66,0.95)') }}>
              <video autoPlay muted loop playsInline preload="auto" style={faceVideo}><source src="assets/hero.mp4" type="video/mp4" /></video>
              <div style={filmScrim} />
              <div style={faceDecor} /><div style={tileGrid} /><TileMoves seed={5} />
              <div style={cosmicSheen} />
            </div>
          </div>
          </div>
            </div>
          </div>
        </div>
      </section>

      {/* Cinematic skyline band */}
      <section data-reveal="1" style={{ position: 'relative', height: '62vh', minHeight: 440, overflow: 'hidden', background: '#0d1220' }}>
        <div style={{ position: 'absolute', inset: 0, backgroundImage: 'url(assets/capital-band.png)', backgroundSize: 'cover', backgroundPosition: 'center 55%', backgroundAttachment: 'fixed' }} />
        <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(8,12,22,0.35) 0%, rgba(8,12,22,0.1) 40%, rgba(8,10,16,0.8) 100%)' }} />
        <div style={{ position: 'absolute', inset: 0, background: 'radial-gradient(80% 70% at 18% 78%, rgba(196,124,44,0.28), transparent 65%)', mixBlendMode: 'screen' }} />
        <div style={{ position: 'absolute', left: 0, right: 0, bottom: 0, ...gutter, paddingBottom: 'var(--space-9)' }}>
          <div style={wrap}>
            <div style={{ width: 64, height: 2, background: 'var(--shu-500)', marginBottom: 'var(--space-5)' }} />
            <p style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(1.8rem, 4vw, 3.2rem)', fontWeight: 'var(--fw-med)', lineHeight: 1.1, letterSpacing: 'var(--ls-tight)', color: 'var(--paper)', margin: 0, maxWidth: 720 }}>
              Where capital meets conviction<span style={{ color: 'var(--yamabuki-400)' }}>.</span>
            </p>
          </div>
        </div>
      </section>

      {/* Capabilities preview */}
      <section data-reveal="1" style={{ background: 'var(--washi-50)', ...gutter, paddingTop: 'var(--space-10)', paddingBottom: 'var(--space-9)' }}>
        <div style={wrap}>
          <div data-slide-left="1">
            <Eyebrow style={{ color: 'var(--shu-600)' }}>What we do</Eyebrow>
            <h2 style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--fs-h2)', fontWeight: 'var(--fw-med)', margin: 'var(--space-4) 0 var(--space-7)', color: 'var(--shu-600)' }}>Three disciplines, one table.</h2>
          </div>
          <div data-slide-left="1" style={{ transitionDelay: '0.25s' }} className="depth-card">
            <CapabilitySlider />
          </div>
        </div>
      </section>

      {/* Sectors — dynamic marquee */}
      <section style={{ position: 'relative', background: '#0b1120', paddingTop: 'var(--space-9)', paddingBottom: 'var(--space-9)', overflow: 'hidden' }}>
        <div style={{ position: 'absolute', inset: 0, backgroundImage: 'url(assets/sectors-network.png)', backgroundSize: 'cover', backgroundPosition: 'center', opacity: 0.9 }} />
        <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(90deg, rgba(9,14,26,0.9) 0%, rgba(9,14,26,0.55) 45%, rgba(9,14,26,0.25) 100%)' }} />
        <div style={{ ...gutter, position: 'relative' }}>
          <div style={{ ...wrap, marginBottom: 'var(--space-7)', maxWidth: 620 }}>
            <Eyebrow style={{ color: 'var(--yamabuki-400)' }}>Sector-agnostic, tech-native</Eyebrow>
            <p style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--fs-h2)', fontWeight: 'var(--fw-med)', lineHeight: 'var(--lh-tight)', letterSpacing: 'var(--ls-tight)', color: 'var(--paper)', margin: 'var(--space-4) 0 0' }}>
              We work across markets — with particular interest in technology-driven businesses.
            </p>
          </div>
        </div>
        <div style={{ position: 'relative' }}><SectorMarquee /></div>
      </section>

      {/* Insights — institutional research row */}
      <section data-reveal="1" style={{ background: 'var(--paper)', ...gutter, paddingTop: 'var(--space-10)', paddingBottom: 'var(--space-10)' }}>
        <div style={wrap}>
          <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', gap: 'var(--space-6)', flexWrap: 'wrap', marginBottom: 'var(--space-8)' }}>
            <div>
              <Eyebrow>Insights</Eyebrow>
              <h2 style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--fs-h2)', fontWeight: 'var(--fw-med)', letterSpacing: 'var(--ls-tight)', color: 'var(--shu-600)', margin: 'var(--space-4) 0 0' }}>Perspectives from the table.</h2>
            </div>
            <button onClick={() => onNav('capabilities')} style={{ background: 'none', border: 'none', cursor: 'pointer', fontFamily: 'var(--font-mono)', fontSize: 'var(--fs-xs)', letterSpacing: '0.14em', color: 'var(--text-accent)' }}>ALL INSIGHTS →</button>
          </div>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--space-5)' }}>
            {INSIGHTS.map((a, i) => (
              <article key={a.title} className="depth-card" onClick={() => onNav('article', i)} style={{
                padding: 'var(--space-7) var(--space-6)', cursor: 'pointer',
                display: 'flex', flexDirection: 'column',
                background: 'var(--paper)', borderRadius: 'var(--radius-md)', borderTop: '3px solid var(--shu-500)', overflow: 'hidden', padding: 0,
              }}>
                <div style={{ position: 'relative', width: '100%', height: 180, background: '#0e131c', overflow: 'hidden' }}>
                  {a.img
                    ? <img src={a.img} alt={`${a.cat} insight`} style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} />
                    : <image-slot id={`insight-${i}`} shape="rect" placeholder={`Image for “${a.cat}” insight`}></image-slot>}
                </div>
                <div style={{ padding: 'var(--space-6)' }}>
                <div style={{ display: 'flex', gap: 'var(--space-4)', alignItems: 'center', marginBottom: 'var(--space-6)' }}>
                  <span style={{ fontFamily: 'var(--font-mono)', fontSize: 'var(--fs-xs)', letterSpacing: '0.12em', color: 'var(--text-accent)' }}>{a.cat}</span>
                </div>
                <h3 style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--fs-h4)', fontWeight: 'var(--fw-med)', lineHeight: 'var(--lh-snug)', color: 'var(--text-primary)', margin: '0 0 var(--space-6)', minHeight: '3.2em' }}>{a.title}</h3>
                <span style={{ fontFamily: 'var(--font-body)', fontSize: 'var(--fs-sm)', color: 'var(--text-accent)', fontWeight: 'var(--fw-med)' }}>Read →</span>
                </div>
              </article>
            ))}
          </div>
        </div>
      </section>

      {/* Global offices strip */}
      <section data-reveal="1" style={{ background: 'var(--washi-100)', borderTop: '1px solid var(--border-default)', ...gutter, paddingTop: 'var(--space-9)', paddingBottom: 'var(--space-9)' }}>
        <div style={wrap}>
          <Eyebrow>Global presence</Eyebrow>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 'var(--space-6)', marginTop: 'var(--space-7)' }}>
            {OFFICES.map((o) => (
              <div key={o.city} className="depth-card" style={{ borderTop: '3px solid var(--shu-500)', background: 'var(--paper)', borderRadius: 'var(--radius-md)', overflow: 'hidden' }}>
                <div style={{ position: 'relative', width: '100%', height: 190, background: '#0e131c', overflow: 'hidden' }}>
                  <img src={o.img} alt={`${o.city} skyline`} style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} />
                  <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(10,13,20,0) 40%, rgba(10,13,20,0.78) 100%)' }} />
                  <span style={{ position: 'absolute', left: 'var(--space-5)', bottom: 'var(--space-4)', fontFamily: 'var(--font-mono)', fontSize: 'var(--fs-xs)', letterSpacing: '0.18em', textTransform: 'uppercase', color: 'rgba(255,255,255,0.82)' }}>{o.city}</span>
                </div>
                <div style={{ padding: 'var(--space-5) var(--space-5) var(--space-6)' }}>
                <p style={{ fontFamily: 'var(--font-display)', fontSize: 'var(--fs-h4)', fontWeight: 'var(--fw-med)', color: 'var(--text-primary)', margin: 0 }}>{o.city}</p>
                <p style={{ fontFamily: 'var(--font-body)', fontSize: 'var(--fs-sm)', color: 'var(--text-secondary)', margin: 'var(--space-2) 0 0' }}>{o.role}</p>
                </div>
              </div>
            ))}
          </div>
        </div>
      </section>

      {/* Closing CTA */}
      <section style={{ position: 'relative', overflow: 'hidden', background: 'linear-gradient(120deg, #2a1c10 0%, #241811 60%, #1c130c 100%)', ...gutter, paddingTop: 'var(--space-10)', paddingBottom: 'var(--space-10)' }}>
        <div style={{ ...wrap, textAlign: 'center', position: 'relative', zIndex: 2 }}>
          <Eyebrow style={{ color: 'var(--yamabuki-400)' }}>On your side of the table</Eyebrow>
          <p style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(1.6rem, 3.2vw, 2.6rem)', fontWeight: 700, letterSpacing: '-0.02em', lineHeight: 1.05, color: 'var(--shu-400)', margin: 'var(--space-5) 0 0' }}>We don't do ordinary.</p>
          <h2 style={{ fontFamily: 'var(--font-display)', fontSize: 'clamp(2.5rem, 6vw, 4.5rem)', fontWeight: 'var(--fw-med)', letterSpacing: 'var(--ls-tight)', lineHeight: 'var(--lh-tight)', color: 'var(--paper)', margin: 'var(--space-4) auto var(--space-7)', maxWidth: 820 }}>
            Let's structure your next move<span style={{ color: 'var(--shu-400)' }}>.</span>
          </h2>
          <div style={{ display: 'flex', gap: 'var(--space-3)', flexWrap: 'wrap', justifyContent: 'center' }}>
            <Button variant="solid" size="lg" onClick={() => onNav('contact')}>Start a conversation</Button>
            <Button variant="outline" size="lg" onClick={() => onNav('capabilities')} style={{ background: 'transparent', borderColor: 'rgba(255,255,255,0.6)', color: 'var(--paper)' }}>See our capabilities</Button>
          </div>
        </div>
      </section>
    </div>
  );
}

const INSIGHTS = [
  {
    cat: 'M&A', dateline: 'Perspective', read: '6 min read', img: 'assets/insight-ma.png',
    title: 'Create PE arbitrage: the sum is more than individual parts, and vice versa.',
    standfirst: 'Value is not only found in the assets acquired. It is created in the re-rating — when combined earnings are priced on a higher multiple than the parts ever commanded alone.',
    body: [
      'Every acquisition carries two sources of return. The first is arithmetic: the earnings you buy. The second, larger and less understood, is the arbitrage between the multiple you pay privately and the multiple the combined entity commands once consolidated.',
      'That gap is where the real work sits. Buying earnings at a private multiple and holding them inside a platform valued on a higher one converts each transaction into an immediate re-rating — before a single operational synergy is realised.',
      'The effect is geometric rather than additive. Each acquisition raises the earnings base, and the re-rating applies to the whole. Repeated with discipline, the platform compounds on both terms at once: growing earnings, and a multiple that expands as scale, diversification, and quality of earnings improve.',
      React.createElement('span', null, React.createElement('strong', { style: { fontWeight: 700, fontSize: '1.35em', lineHeight: 1.35, color: 'var(--text-primary)' } }, 'The discipline is in what you decline.')),
    ],
    takeaways: [
      'Returns come from the multiple gap, not only the earnings acquired.',
      'Re-rating makes growth geometric — each deal lifts the value of the whole.',
    ],
  },
  {
    cat: 'CAPITAL', dateline: 'Analysis', read: '7 min read', img: 'assets/insight-capital.png',
    title: 'Acquiring significant minority stakes and underwriting the whole journey to IPO.',
    standfirst: 'A significant minority stake that underwrites the full capital requirement — two years of funding through to listing — removes the one risk founders cannot hedge: the next round.',
    body: [
      'Most growth capital is delivered in instalments. Each tranche buys eighteen months of runway and returns the company to the market for the next negotiation, usually at the least convenient moment. The financing risk never leaves the cap table.',
      'The alternative is to underwrite the whole path at once. We take a significant minority position and commit to the full capital requirement through to the listing — including the IPO itself — so the company raises once and then executes.',
      'The effect on negotiating posture is immediate. A business that is fully funded to its listing is never a forced seller of equity. It can time the market rather than be timed by it, and it approaches the IPO from a position of choice.',
      'Minority is the deliberate part. We take enough to align our capital with the outcome and to bear the underwriting risk, and not so much that control leaves the founders who built the business. The structure carries the risk; the operators keep the company.',
    ],
    takeaways: [
      'Tranche-by-tranche funding leaves financing risk permanently on the cap table.',
      'Underwriting the full requirement to IPO lets the company raise once and execute.',
      'A significant minority aligns capital with the outcome without taking control.',
    ],
  },
  {
    cat: 'MARKETS', dateline: 'Playbook', read: '5 min read', img: 'assets/insight-markets.png',
    title: 'Finding true value across private and listed markets.',
    standfirst: 'A company is rarely worth what either market says in isolation. True value sits between the two — and the work is knowing which market is mispricing the business, and when.',
    body: [
      'Private and listed markets price the same earnings differently. One rewards control, certainty, and negotiated terms; the other rewards liquidity, comparability, and narrative. Neither is right on its own, and the spread between them is where value is found.',
      'We start by establishing what a business is actually worth on its fundamentals — quality of earnings, durability of the customer base, capital intensity — independent of whichever market is currently setting the price.',
      'From there the question becomes practical: does this business realise more value negotiated privately, or re-rated publicly? The answer changes with scale, sector sentiment, and timing, and it determines the structure we build around it.',
      'Operating across both markets is what makes the judgement credible. We are pricing against live comparables on either side, so the recommendation is grounded in what capital is genuinely paying today — not in a valuation exercise on paper.',
    ],
    takeaways: [
      'Private and listed markets price identical earnings on different logic.',
      'Establish fundamental worth first — then choose the market that pays for it.',
      'Credible judgement requires live comparables on both sides.',
    ],
  },
];

const OFFICES = [
  { city: 'Dubai', role: 'MENA advisory & capital', img: 'assets/city-dubai.png' },
  { city: 'London', role: 'European structuring', img: 'assets/city-london.png' },
  { city: 'Hong Kong', role: 'APAC markets', img: 'assets/city-hongkong.png' },
  { city: 'Mumbai', role: 'India coverage & group headquarters', img: 'assets/city-mumbai.png' },
];

const SECTORS_A = ['Technology', 'Artificial Intelligence', 'Robotics', 'Real Estate', 'Financial Services'];
const SECTORS_B = ['Defence', 'Logistics', 'Energy', 'Public Markets', 'Infrastructure', 'Consumer & Retail'];

function MarqueeRow({ items, dir, dur }) {
  const line = [...items, ...items];
  return (
    <div className="marquee-mask">
      <div className="marquee-row" style={{ animation: `${dir === 'r' ? 'marqueeR' : 'marqueeL'} ${dur}s linear infinite` }}>
        {line.map((s, idx) => (
          <span key={idx} className="sector-word" style={{
            display: 'inline-flex', alignItems: 'center', gap: 'var(--space-6)',
            fontFamily: 'var(--font-display)', fontWeight: 'var(--fw-med)',
            fontSize: 'clamp(2.5rem, 6vw, 5rem)', lineHeight: 1.1, letterSpacing: 'var(--ls-tight)',
            color: 'var(--paper)', WebkitTextStroke: '0',
            padding: '0 var(--space-6)', whiteSpace: 'nowrap', transition: 'color 0.35s, -webkit-text-stroke-color 0.35s',
            cursor: 'default',
          }}
          onMouseEnter={(e) => { e.currentTarget.style.color = '#ffffff'; }}
          onMouseLeave={(e) => { e.currentTarget.style.color = 'var(--paper)'; }}
          >
            {s}<span style={{ color: 'rgba(255,255,255,0.4)', WebkitTextStroke: '0' }}>·</span>
          </span>
        ))}
      </div>
    </div>
  );
}

function SectorMarquee() {
  return (
    <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--space-4)' }}>
      <MarqueeRow items={SECTORS_A} dir="l" dur={28} />
      <MarqueeRow items={SECTORS_B} dir="r" dur={34} />
    </div>
  );
}

Object.assign(window, { HomeScreen, INSIGHTS });
