// ServiceHeroes — per-service animated hero visuals keyed by slug.
// Each returns a JSX element that sits in the hero card slot.
// Kept simple + on-brand. Every hero is SVG or CSS — no images needed.

const { useState: useStateSh, useEffect: useEffectSh, useRef: useRefSh } = React;

// --- Generic building blocks ---

// Tiny pass-through to window.__i18n.t with a safe fallback. Per-hero
// components don't subscribe to i18n themselves — they re-render whenever the
// parent ServicePage does (which already subscribes via window.__useI18n).
const _t = (key, fb) => {
  const fn = (typeof window !== 'undefined' && window.__i18n && window.__i18n.t);
  return fn ? fn(key) : (fb != null ? fb : key);
};

function SlugGrid() {
  return (
    <svg viewBox="0 0 100 60" preserveAspectRatio="none"
      style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', opacity: 0.5 }}>
      <defs>
        <pattern id="sh-grid" width="5" height="5" patternUnits="userSpaceOnUse">
          <path d="M 5 0 L 0 0 0 5" fill="none" stroke="rgba(30,87,214,0.1)" strokeWidth="0.15"/>
        </pattern>
      </defs>
      <rect width="100" height="60" fill="url(#sh-grid)"/>
    </svg>
  );
}

function SlugFrame({ children, palette, aspect }) {
  const p = palette || { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#D0E1F8' };
  return (
    <div style={{ position: 'relative', width: '100%', aspectRatio: aspect || '1.15',
      background: `linear-gradient(180deg, ${p.bg1} 0%, ${p.bg2} 100%)`,
      border: `1px solid ${p.border}`, borderRadius: 20, overflow: 'hidden',
      boxShadow: '0 30px 60px -20px rgba(16,24,40,0.15)' }}>
      <SlugGrid/>
      {children}
    </div>
  );
}

// ——— LCL: video-backed container loading + live telemetry
function LCLHero() {
  const [t, setT] = useStateSh(0);
  const lclVideoRef = useRefSh(null);
  const [lclVideoEnded, setLclVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayLclVideo = () => {
    const v = lclVideoRef.current;
    if (!v) return;
    setLclVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = lclVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayLclVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const etaBase = 312;
  const eta = Math.max(1, etaBase - Math.floor(t / 60));
  const h = String(Math.floor(eta / 60)).padStart(1, '0');
  const m = String(eta % 60).padStart(2, '0');
  const cbm = (24.6 + Math.sin(t * 0.035) * 0.4).toFixed(1);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const LCL_VIDEO_URL = '../uploads/optimized/lcl.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, click to replay) ——— */}
        <video
          ref={lclVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setLclVideoEnded(true)}
          onClick={replayLclVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/lcl.jpg">
          <source src={LCL_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live telemetry card (reveals when video finishes) ——— */}
        <div style={{ position: 'absolute', bottom: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 176, fontFamily: 'Inter, sans-serif',
          opacity: lclVideoEnded ? 1 : 0,
          transform: lclVideoEnded ? 'translateY(0)' : 'translateY(6px)',
          transition: 'opacity 480ms ease, transform 480ms ease',
          pointerEvents: lclVideoEnded ? 'auto' : 'none' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'lcl-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>LIVE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>ABGU-8472</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>SHA</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>LAX</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '74%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: '74%', top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>VOLUME</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {cbm} <span style={{ color: '#94A3B8', fontSize: 9 }}>cbm</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ETA</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {h}h {m}m
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes lcl-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {/* MetricStrip removed per design — telemetry card carries the message */}
    </SlugFrame>
  );
}

function MetricStrip({ items, compact, leftAligned }) {
  const pad = compact ? '8px 12px' : 14;
  const gap = compact ? 8 : 12;
  const valueSize = compact ? 14 : 18;
  const labelSize = compact ? 9 : 10;
  const dividerPad = compact ? 10 : 12;
  const labelMargin = compact ? 1 : 3;
  const positionStyle = leftAligned
    ? { left: 24, bottom: 20, display: 'inline-grid' }
    : { left: 24, right: 24, bottom: 20, display: 'grid' };
  return (
    <div style={{ position: 'absolute', ...positionStyle,
      gridTemplateColumns: `repeat(${items.length}, auto)`, gap,
      background: 'rgba(255,255,255,0.85)', backdropFilter: 'blur(8px)',
      padding: pad, borderRadius: 12, border: '1px solid rgba(255,255,255,0.9)',
      boxShadow: '0 10px 24px -8px rgba(16,24,40,0.15)' }}>
      {items.map(([v, l], i) => (
        <div key={i} style={{ borderLeft: i > 0 ? '1px solid #eaecf0' : 'none', paddingLeft: i > 0 ? dividerPad : 0 }}>
          <div style={{ fontSize: valueSize, fontWeight: 700, letterSpacing: '-0.02em',
            color: '#0B1220', fontFamily: 'JetBrains Mono, monospace', lineHeight: 1.1 }}>{v}</div>
          <div style={{ fontSize: labelSize, color: '#475467', letterSpacing: '0.04em',
            textTransform: 'uppercase', fontWeight: 600, marginTop: labelMargin }}>{l}</div>
        </div>
      ))}
    </div>
  );
}

// ——— Buyer's Consolidation: video-backed CFS cinematic + live consolidation telemetry
function BuyersConsHero() {
  const [t, setT] = useStateSh(0);
  const buyersVideoRef = useRefSh(null);
  const [buyersVideoEnded, setBuyersVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayBuyersVideo = () => {
    const v = buyersVideoRef.current;
    if (!v) return;
    setBuyersVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay whenever the hero scrolls back into view (after having ended).
  useEffectSh(() => {
    const v = buyersVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayBuyersVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Suppliers steadily mark "received" at the CFS as the animation plays.
  const TOTAL_SUPPLIERS = 12;
  const received = Math.min(TOTAL_SUPPLIERS, 4 + Math.floor(t / 70));
  const pct = Math.round((received / TOTAL_SUPPLIERS) * 100);

  // CBM filled into the 40' HQ as receipts post (target ~64 CBM).
  const cbmBase = 42.5;
  const cbm = (cbmBase + (received / TOTAL_SUPPLIERS) * 20 + Math.sin(t * 0.04) * 0.3).toFixed(1);

  // Cutoff countdown (h/m) to give the card a live pulse.
  const cutoffBase = 212; // minutes
  const cutoff = Math.max(1, cutoffBase - Math.floor(t / 60));
  const ch = String(Math.floor(cutoff / 60)).padStart(1, '0');
  const cm = String(cutoff % 60).padStart(2, '0');

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };

  const BUYERS_VIDEO_URL = '../uploads/optimized/buyers-consolidation.mp4';

  return (
    <SlugFrame palette={palette} aspect="2.36">
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, click to replay) ——— */}
        <video
          ref={buyersVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setBuyersVideoEnded(true)}
          onClick={replayBuyersVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', objectPosition: 'center', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/buyers-consolidation.jpg">
          <source src={BUYERS_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Soft brand tint for color consistency with sibling service heroes */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live consolidation telemetry card (top-right) ——— */}
        <div style={{ position: 'absolute', top: 22, right: 22,
          transform: 'scale(0.7)', transformOrigin: 'top right',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 198, fontFamily: 'Inter, sans-serif' }}>
          {/* header */}
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'buyers-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>CFS LIVE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>ABGU 558921-7</span>
          </div>

          {/* route */}
          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>SHA</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>LAX</span>
          </div>

          {/* suppliers-received progress bar */}
          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginBottom: 4 }}>
            <span style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
              letterSpacing: '1.2px', fontFamily: 'JetBrains Mono, monospace' }}>SUPPLIERS RECEIVED</span>
            <span style={{ fontSize: 10, color: '#0B1220', fontWeight: 800,
              fontFamily: 'JetBrains Mono, monospace', fontVariantNumeric: 'tabular-nums' }}>
              {received}/{TOTAL_SUPPLIERS}
            </span>
          </div>
          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${pct}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999,
              transition: 'width 0.4s ease' }}/>
            <div style={{ position: 'absolute', left: `${pct}%`, top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)',
              transform: 'translateX(-4px)', transition: 'left 0.4s ease' }}/>
          </div>

          {/* stats row — CBM filled + cutoff */}
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>CBM FILLED</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>
                {cbm} <span style={{ color: '#94A3B8', fontSize: 9 }}>/ 68</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>CUTOFF</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>
                {ch}h {cm}m
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes buyers-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>
    </SlugFrame>
  );
}

// ——— Trucking: side-view semi driving, dynamic road + live telemetry
function TruckingHero() {
  const [t, setT] = useStateSh(0);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  // ETA minutes, counting down so it feels alive
  const etaBase = 238;
  const eta = Math.max(1, etaBase - Math.floor(t / 60));
  const h = String(Math.floor(eta / 60)).padStart(1, '0');
  const m = String(eta % 60).padStart(2, '0');

  // Speed needle wobble (around 64 mph)
  const mph = Math.round(64 + Math.sin(t * 0.05) * 2);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };

  const TRUCK_VIDEO_URL = '../uploads/optimized/trucking.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (semi-truck driving) ——— */}
        <video
          autoPlay muted loop playsInline preload="metadata"
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', pointerEvents: 'none',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/trucking.jpg">
          <source src={TRUCK_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Soft warm tint for on-brand color consistency */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live telemetry card (top-left, over the "sky") ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 176, fontFamily: 'Inter, sans-serif' }}>
          {/* header */}
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'truck-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>LIVE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>ABG-4412</span>
          </div>

          {/* route */}
          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>LAX</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>CHI</span>
          </div>

          {/* progress bar */}
          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '64%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: '64%', top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          {/* stats row */}
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>SPEED</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {mph} <span style={{ color: '#94A3B8', fontSize: 9 }}>mph</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ETA</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {h}h {m}m
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes truck-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['14,000+', _t('hero.trucking.l1')],
        ['97.4%',   _t('hero.trucking.l2')],
        ['90s',     _t('hero.trucking.l3')],
      ]}/>
    </SlugFrame>
  );
}
function Wheel({ cx, cy, angle, size = 8 }) {
  return (
    <g>
      {/* tire */}
      <circle cx={cx} cy={cy} r={size} fill="#0F172A"/>
      {/* rim */}
      <circle cx={cx} cy={cy} r={size * 0.55} fill="#64748B"/>
      {/* spokes */}
      <g transform={`rotate(${angle} ${cx} ${cy})`}>
        <line x1={cx} y1={cy - size * 0.5} x2={cx} y2={cy + size * 0.5}
          stroke="#CBD5E1" strokeWidth={size * 0.18} strokeLinecap="round"/>
        <line x1={cx - size * 0.5} y1={cy} x2={cx + size * 0.5} y2={cy}
          stroke="#CBD5E1" strokeWidth={size * 0.18} strokeLinecap="round"/>
      </g>
      {/* hub */}
      <circle cx={cx} cy={cy} r={size * 0.18} fill="#0F172A"/>
    </g>
  );
}

// ——— Order Management: PO list with live status
function OrderMgmtHero() {
  const rows = [
    ['PO-4192', 'Vendor A', 'In transit', '#12b76a'],
    ['PO-4188', 'Vendor B', 'Cargo ready', '#1E57D6'],
    ['PO-4186', 'Vendor C', 'Delayed', '#F97316'],
    ['PO-4181', 'Vendor A', 'Cleared', '#12b76a'],
    ['PO-4175', 'Vendor D', 'Delivered', '#98a2b3'],
  ];
  return (
    <SlugFrame>
      <div style={{ position: 'absolute', top: 32, left: 32, right: 32,
        background: '#fff', borderRadius: 12, border: '1px solid #eaecf0',
        boxShadow: '0 20px 40px -16px rgba(16,24,40,0.15)', overflow: 'hidden' }}>
        <div style={{ padding: '12px 16px', borderBottom: '1px solid #eaecf0',
          display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          background: '#f9fafb' }}>
          <span style={{ fontSize: 11, fontWeight: 700, color: '#0B1220',
            fontFamily: 'JetBrains Mono, monospace', letterSpacing: '0.08em' }}>
            PO TRACKER — 4 open
          </span>
          <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#12b76a',
            boxShadow: '0 0 0 3px rgba(18,183,106,0.2)', animation: 'pulse-dot 2s infinite' }}/>
        </div>
        {rows.map((r, i) => (
          <div key={i} style={{ padding: '12px 16px', display: 'grid',
            gridTemplateColumns: '1fr 1.4fr 1.2fr', gap: 12,
            borderBottom: i < rows.length-1 ? '1px solid #f2f4f7' : 'none', fontSize: 11.5,
            alignItems: 'center' }}>
            <span style={{ fontWeight: 700, color: '#0B1220', fontFamily: 'JetBrains Mono, monospace' }}>{r[0]}</span>
            <span style={{ color: '#475467' }}>{r[1]}</span>
            <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: r[3] }}/>
              <span style={{ color: '#0B1220', fontWeight: 600 }}>{r[2]}</span>
            </span>
          </div>
        ))}
      </div>
      <MetricStrip items={[['4.2M', _t('hero.order.l1')], ['−12d', _t('hero.order.l2')], ['14', _t('hero.order.l3')]]}/>
    </SlugFrame>
  );
}

// ——— Generic hero (fallback): icon burst with the service icon
function GenericHero({ slug, icon, accent }) {
  const p = accent === 'indigo'
    ? { bg1: '#F5F3FF', bg2: '#EDE9FE', border: '#DDD6FE' }
    : accent === 'amber'
    ? { bg1: '#FFFBEB', bg2: '#FEF3C7', border: '#FDE68A' }
    : { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#D0E1F8' };
  return (
    <SlugFrame palette={p}>
      <div style={{ position: 'absolute', inset: 0, display: 'flex',
        alignItems: 'center', justifyContent: 'center' }}>
        <div style={{ position: 'relative', width: '55%', aspectRatio: '1' }}>
          {[1,2,3].map(ring => (
            <div key={ring} style={{ position: 'absolute', inset: `${(4-ring)*8}%`,
              border: '1px dashed rgba(30,87,214,0.25)', borderRadius: '50%',
              animation: `orbit ${12 + ring*6}s linear ${ring % 2 ? 'normal' : 'reverse'} infinite` }}>
              <div style={{ position: 'absolute', top: '50%', left: '-6px',
                width: 12, height: 12, borderRadius: 9999,
                background: 'var(--accent-dark, #1846B0)',
                boxShadow: '0 4px 10px -2px rgba(30,87,214,0.4)' }}/>
            </div>
          ))}
          <div style={{ position: 'absolute', inset: '36%', borderRadius: '50%',
            background: '#fff', border: '1px solid #eaecf0',
            boxShadow: '0 12px 28px -8px rgba(16,24,40,0.15)',
            display: 'grid', placeItems: 'center', color: 'var(--accent-dark, #1846B0)' }}>
            <Icon name={icon} size={48}/>
          </div>
        </div>
      </div>
    </SlugFrame>
  );
}

// ——— Mexico: video-backed border crossing w/ live clearance telemetry
function MexicoHero() {
  const [t, setT] = useStateSh(0);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const dwellBase = 192; // minutes
  const dwell = Math.max(1, dwellBase - Math.floor(t / 60));
  const dh = String(Math.floor(dwell / 60)).padStart(1, '0');
  const dm = String(dwell % 60).padStart(2, '0');
  const crossings = 8420 + Math.floor(t / 4);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const MX_VIDEO_URL = '../uploads/optimized/mexico-crossborder.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer ——— */}
        <video
          autoPlay muted loop playsInline preload="metadata"
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', pointerEvents: 'none',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/mexico-crossborder.jpg">
          <source src={MX_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 200, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'mx-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>CLEARED</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>IN-BOND 7-512</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>MTY</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>LRD</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>DFW</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '72%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: '72%', top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>DWELL</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {dh}h {dm}m
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>CROSSINGS</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {crossings.toLocaleString()}
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes mx-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['9',    _t('hero.mexico.l1')],
        ['3.2h', _t('hero.mexico.l2')],
        ['220+', _t('hero.mexico.l3')],
      ]}/>
    </SlugFrame>
  );
}

// ——— Prep: video-backed hero (marketplace prep & kitting) w/ live prep-line telemetry
function PrepHero() {
  const [t, setT] = useStateSh(0);
  const prepVideoRef = useRefSh(null);
  const [prepVideoEnded, setPrepVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayPrepVideo = () => {
    const v = prepVideoRef.current;
    if (!v) return;
    setPrepVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = prepVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayPrepVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Unit counter — steady tick upward (units prepped today)
  const unitsBase = 18240;
  const units = unitsBase + Math.floor(t / 2);
  const unitsStr = units.toLocaleString('en-US');

  // Marketplace cycle: FBA → WFS → Target+ → TikTok, rotates every 3s
  const marketplaces = ['FBA', 'WFS', 'T+', 'TikTok'];
  const mpIdx = Math.floor((t / 180) % marketplaces.length);
  const mpLabel = marketplaces[mpIdx];

  // Batch progress cycles 0..100 over ~6s
  const batchProgress = Math.round(((t % 360) / 360) * 100);

  // Reject rate — tiny ripple around 0.2%
  const rejectRate = (0.18 + Math.sin(t * 0.04) * 0.05).toFixed(2);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const PREP_VIDEO_URL = '../uploads/optimized/prep.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, no replay UI) ——— */}
        <video
          ref={prepVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setPrepVideoEnded(true)}
          onClick={replayPrepVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/prep.jpg">
          <source src={PREP_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint so the video blends with the rest of the palette */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live prep-line telemetry card (right edge, vertically centered, masks label-printer station) ——— */}
        <div style={{ position: 'absolute', top: '50%', right: 22,
          transform: 'translateY(-50%)',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '11px 12px',
          boxShadow: '0 14px 28px -10px rgba(16,24,40,0.28)',
          width: 132, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 7 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 5 }}>
              <span style={{ width: 5, height: 5, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 2.5px rgba(34,197,94,0.2)',
                animation: 'prep-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 8.5, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.3px' }}>PREP LINE</span>
            </div>
            <span style={{ fontSize: 8.5, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.1px' }}>L-04</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            gap: 6, marginBottom: 8 }}>
            <span style={{ fontSize: 12, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>RECV</span>
            <svg width="22" height="7" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 12, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>{mpLabel}</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 9, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${batchProgress}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999,
              transition: 'width 120ms linear' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 7,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 7.5, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.1px', marginBottom: 1 }}>UNITS</div>
              <div style={{ fontSize: 12, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>{unitsStr}</div>
            </div>
            <div>
              <div style={{ fontSize: 7.5, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.1px', marginBottom: 1 }}>REJECT</div>
              <div style={{ fontSize: 12, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>
                {rejectRate}<span style={{ color: '#94A3B8', fontSize: 8.5 }}>%</span>
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes prep-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>
    </SlugFrame>
  );
}

// ——— Wholesale Fulfillment: video-backed hero (retailer-ready cases & pallets)
function WholesaleHero() {
  const wholesaleVideoRef = useRefSh(null);
  const [wholesaleVideoEnded, setWholesaleVideoEnded] = useStateSh(false);

  const replayWholesaleVideo = () => {
    const v = wholesaleVideoRef.current;
    if (!v) return;
    setWholesaleVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = wholesaleVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayWholesaleVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const WHOLESALE_VIDEO_URL = '../uploads/optimized/wholesale-fulfillment.mp4';

  return (
    <SlugFrame palette={palette} aspect="2.45">
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, click to replay) ——— */}
        {/* Frame matches the video's native 1488×608 (~2.45) so the image fills */}
        {/* edge-to-edge with zero letterboxing and zero cropping. */}
        <video
          ref={wholesaleVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setWholesaleVideoEnded(true)}
          onClick={replayWholesaleVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer', display: 'block',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 88%, rgba(0,0,0,0.85) 96%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 88%, rgba(0,0,0,0.85) 96%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/wholesale-fulfillment.jpg">
          <source src={WHOLESALE_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint so the video blends with the rest of the palette */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Replay affordance (fades in when the video has ended) ——— */}
        <div
          onClick={replayWholesaleVideo}
          style={{ position: 'absolute', top: 16, right: 16,
            display: 'inline-flex', alignItems: 'center', gap: 6,
            padding: '7px 12px',
            background: 'rgba(255,255,255,0.92)',
            backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
            border: '1px solid rgba(204,220,245,0.9)',
            borderRadius: 9999, fontSize: 11, fontWeight: 600,
            color: 'var(--accent-dark, #1846B0)',
            letterSpacing: '0.02em',
            boxShadow: '0 8px 20px -8px rgba(30,87,214,0.25)',
            opacity: wholesaleVideoEnded ? 1 : 0,
            transform: wholesaleVideoEnded ? 'translateY(0)' : 'translateY(-4px)',
            transition: 'opacity 280ms ease, transform 280ms ease',
            pointerEvents: wholesaleVideoEnded ? 'auto' : 'none',
            cursor: 'pointer', userSelect: 'none' }}>
          <svg width="11" height="11" viewBox="0 0 16 16" fill="none" aria-hidden>
            <path d="M13.5 3v3.5H10" stroke="currentColor" strokeWidth="1.6"
              strokeLinecap="round" strokeLinejoin="round"/>
            <path d="M13.2 6.4A5.5 5.5 0 1 0 14 9" stroke="currentColor" strokeWidth="1.6"
              strokeLinecap="round" strokeLinejoin="round"/>
          </svg>
          Replay
        </div>
      </div>
    </SlugFrame>
  );
}

// ——— D2C Fulfillment: video-backed hero (pick-pack-ship) w/ live order telemetry
function D2CHero() {
  const [t, setT] = useStateSh(0);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  // Orders shipped today — steady tick upward
  const shippedBase = 4382;
  const shipped = shippedBase + Math.floor(t / 2);
  // Pick-pack-ship stage progress — cycles through three stages
  const cycle = (t % 360) / 360;           // 0..1 across a 6s cycle at 60fps
  const stage = cycle < 0.34 ? 0 : cycle < 0.67 ? 1 : 2;
  const stageLabel = ['PICKING', 'PACKING', 'SHIPPING'][stage];
  const progress = Math.min(100, Math.round(cycle * 100));

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const D2C_VIDEO_URL = '../uploads/optimized/d2c-fulfillment.mp4';

  return (
    <SlugFrame palette={palette} aspect="2.36">
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (continuous loop) ——— */}
        <video
          autoPlay muted loop playsInline preload="metadata"
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', pointerEvents: 'none',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/d2c-fulfillment.jpg">
          <source src={D2C_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint so the video blends with the rest of the palette */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        <style>{`
          @keyframes d2c-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>
    </SlugFrame>
  );
}

// ——— Duty Drawback: piggy bank counter
function DrawbackHero() {
  const [v, setV] = useStateSh(0);
  useEffectSh(() => {
    let r;
    const start = Date.now();
    const loop = () => {
      const t = Math.min(1, (Date.now() - start) / 3000);
      setV(t * 820);
      if (t < 1) r = requestAnimationFrame(loop);
      else setTimeout(() => { setV(0); loop(); }, 2000);
    };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);
  return (
    <SlugFrame palette={{ bg1: '#FFFBEB', bg2: '#FEF3C7', border: '#FDE68A' }}>
      <div style={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column',
        alignItems: 'center', justifyContent: 'center', gap: 20 }}>
        <div style={{ fontSize: 11, fontWeight: 700, letterSpacing: '0.14em',
          textTransform: 'uppercase', color: '#92400E' }}>
          Total recovered since 2015
        </div>
        <div style={{ fontSize: 96, fontWeight: 800, letterSpacing: '-0.05em',
          color: '#0B1220', fontVariantNumeric: 'tabular-nums',
          fontFamily: 'JetBrains Mono, monospace', lineHeight: 1 }}>
          ${Math.floor(v)}M+
        </div>
        <div style={{ display: 'flex', gap: 12, marginTop: 12 }}>
          {['Unused', 'Mfg drawback', 'Rejected mdse'].map(s => (
            <div key={s} style={{ padding: '6px 12px', background: '#fff',
              border: '1px solid #FDE68A', borderRadius: 9999, fontSize: 11,
              fontWeight: 600, color: '#92400E' }}>{s}</div>
          ))}
        </div>
      </div>
    </SlugFrame>
  );
}

// ——— Frozen Logistics: video-backed reefer + live temperature telemetry chart
function FrozenHero() {
  const [t, setT] = useStateSh(0);
  const frozenVideoRef = useRefSh(null);
  const [frozenVideoEnded, setFrozenVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    const i = setInterval(() => setT(v => v + 1), 80);
    return () => clearInterval(i);
  }, []);

  const replayFrozenVideo = () => {
    const v = frozenVideoRef.current;
    if (!v) return;
    setFrozenVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay whenever the hero scrolls back into view (after having ended).
  useEffectSh(() => {
    const v = frozenVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayFrozenVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Generate a stable temperature trace around -18°C setpoint with tiny noise.
  const points = Array.from({ length: 60 }, (_, i) => {
    const phase = (i + t * 0.3) * 0.18;
    const noise = Math.sin(phase) * 0.25 + Math.sin(phase * 2.3) * 0.1;
    return -18 + noise;
  });
  const current = points[points.length - 1].toFixed(1);

  // Plot coords inside the chart card (measured in %s of its own SVG viewBox 400x110)
  const cx0 = 22, cx1 = 378, cy0 = 92, cy1 = 26;
  const tempMin = -19.2, tempMax = -16.8;
  const sx = (i) => cx0 + (i / (points.length - 1)) * (cx1 - cx0);
  const sy = (v) => cy0 - ((v - tempMin) / (tempMax - tempMin)) * (cy0 - cy1);
  const path = points.map((v, i) => `${i === 0 ? 'M' : 'L'} ${sx(i).toFixed(1)} ${sy(v).toFixed(2)}`).join(' ');
  const area = `${path} L ${cx1} ${cy0} L ${cx0} ${cy0} Z`;

  const palette = { bg1: '#EFF6FF', bg2: '#DBEAFE', border: '#BFDBFE' };
  const FROZEN_VIDEO_URL = '../uploads/optimized/frozen-reefer.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, no loop) ——— */}
        <video
          ref={frozenVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setFrozenVideoEnded(true)}
          onClick={replayFrozenVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 55%, rgba(0,0,0,0.6) 72%, rgba(0,0,0,0.2) 86%, rgba(0,0,0,0) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 55%, rgba(0,0,0,0.6) 72%, rgba(0,0,0,0.2) 86%, rgba(0,0,0,0) 100%)' }} poster="../assets/posters/frozen-reefer.jpg">
          <source src={FROZEN_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Cool blue tint so the video blends with the brand palette */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(219,234,254,0.12) 0%, rgba(30,87,214,0.12) 100%)',
          pointerEvents: 'none' }}/>

        {frozenVideoEnded && (<>
        {/* ——— Live telemetry card (matches Trucking / Air / Break Bulk pattern) ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 208, fontFamily: 'Inter, sans-serif' }}>
          {/* header */}
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'frozen-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>LIVE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>ABGU-4729</span>
          </div>

          {/* route */}
          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>ROT</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>NYC</span>
          </div>

          {/* mini trace */}
          <svg viewBox="0 0 400 110" preserveAspectRatio="none"
            style={{ width: '100%', height: 44, display: 'block', marginBottom: 8, overflow: 'visible' }}>
            <defs>
              <linearGradient id="chart-area-v2" x1="0" y1="0" x2="0" y2="1">
                <stop offset="0%" stopColor="rgba(30,87,214,0.28)"/>
                <stop offset="100%" stopColor="rgba(30,87,214,0)"/>
              </linearGradient>
            </defs>
            <line x1={cx0} y1={sy(-18)} x2={cx1} y2={sy(-18)}
              stroke="#CBD5E1" strokeDasharray="2 3" strokeWidth="0.6"/>
            <path d={area} fill="url(#chart-area-v2)"/>
            <path d={path} fill="none" stroke="#1E57D6" strokeWidth="1.6"
              strokeLinecap="round" strokeLinejoin="round"/>
            <circle cx={sx(points.length - 1)} cy={sy(points[points.length - 1])} r="2.6"
              fill="#1E57D6" stroke="#fff" strokeWidth="1.2"/>
          </svg>

          {/* stats row */}
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>TEMP</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {current}<span style={{ color: '#94A3B8', fontSize: 9 }}>°C</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>SETPOINT</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                −18.0<span style={{ color: '#94A3B8', fontSize: 9 }}>°C</span>
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes reefer-fan { from { transform: rotate(0); } to { transform: rotate(360deg); } }
          @keyframes reefer-led { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
          @keyframes frozen-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
        </>)}
      </div>

      {frozenVideoEnded && (
        <MetricStrip items={[
          ['-18.0°C', _t('hero.frozen.l1')],
          ['±0.3°',   _t('hero.frozen.l2')],
          ['GDP',     _t('hero.frozen.l3')],
        ]}/>
      )}
    </SlugFrame>
  );
}

// ——— Break Bulk: video-backed hero (crane loading heavy cargo)
function BreakBulkHero() {
  const [t, setT] = useStateSh(0);
  const bbVideoRef = useRefSh(null);
  const [bbVideoEnded, setBbVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayBbVideo = () => {
    const v = bbVideoRef.current;
    if (!v) return;
    setBbVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = bbVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayBbVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Live counters for the telemetry card
  const etaBase = 186;
  const eta = Math.max(1, etaBase - Math.floor(t / 60));
  const h = String(Math.floor(eta / 60)).padStart(1, '0');
  const m = String(eta % 60).padStart(2, '0');
  const tons = Math.round(482 + Math.sin(t * 0.04) * 3);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const BB_VIDEO_URL = '../uploads/optimized/break-bulk.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, replays on re-entry) ——— */}
        <video
          ref={bbVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setBbVideoEnded(true)}
          onClick={replayBbVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/break-bulk.jpg">
          <source src={BB_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live telemetry card (revealed after video ends) ——— */}
        {bbVideoEnded && (
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 176, fontFamily: 'Inter, sans-serif',
          animation: 'bb-card-in 0.5s ease-out both' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'bb-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>LIVE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>LIFT-7218</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>HOU</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>ANT</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '42%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: '42%', top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>WEIGHT</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {tons} <span style={{ color: '#94A3B8', fontSize: 9 }}>t</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ETA</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {h}h {m}m
              </div>
            </div>
          </div>
        </div>
        )}

        <style>{`
          @keyframes bb-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
          @keyframes bb-card-in {
            from { opacity: 0; transform: translateY(6px); }
            to   { opacity: 1; transform: translateY(0); }
          }
        `}</style>
      </div>

      {bbVideoEnded && (
        <MetricStrip items={[
          ['500t+', _t('hero.bb.l1')],
          ['38',    _t('hero.bb.l2')],
          ['RO/RO', _t('hero.bb.l3')],
        ]}/>
      )}
    </SlugFrame>
  );
}

// ——— Air Freight: video-backed hero (cargo plane in flight)
function AirFreightHero() {
  const [t, setT] = useStateSh(0);
  const afVideoRef = useRefSh(null);
  const [, setAfVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayAfVideo = () => {
    const v = afVideoRef.current;
    if (!v) return;
    setAfVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = afVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayAfVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const etaBase = 214;
  const eta = Math.max(1, etaBase - Math.floor(t / 60));
  const h = String(Math.floor(eta / 60)).padStart(1, '0');
  const m = String(eta % 60).padStart(2, '0');
  const alt = Math.round(36800 + Math.sin(t * 0.05) * 80);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const AIR_VIDEO_URL = '../uploads/optimized/air-freight.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, click to replay) ——— */}
        <video
          ref={afVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setAfVideoEnded(true)}
          onClick={replayAfVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/air-freight.jpg">
          <source src={AIR_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 176, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'air-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>IN FLIGHT</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>AWB-218-4412</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>HKG</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>ORD</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '58%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: '58%', top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ALT</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {alt.toLocaleString()} <span style={{ color: '#94A3B8', fontSize: 9 }}>ft</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ETA</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {h}h {m}m
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes air-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['24h',  _t('hero.air.l1')],
        ['IATA', _t('hero.air.l2')],
        ['120+', _t('hero.air.l3')],
      ]}/>
    </SlugFrame>
  );
}

// ——— Purchasing Agent: video-backed hero (supplier factory floor) w/ live sourcing telemetry
function PurchasingAgentHero() {
  const [t, setT] = useStateSh(0);
  const paVideoRef = useRefSh(null);
  const [paVideoEnded, setPaVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayPaVideo = () => {
    const v = paVideoRef.current;
    if (!v) return;
    setPaVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = paVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayPaVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Suppliers contacted ticker (counts up gently so the card breathes)
  const suppliersBase = 7;
  const suppliers = suppliersBase + Math.floor(t / 140);
  // QC pass rate wobble around 96%
  const qc = Math.round(96 + Math.sin(t * 0.04) * 1.2);
  // RFQ countdown ETA (hours/minutes)
  const etaBase = 312; // minutes
  const eta = Math.max(1, etaBase - Math.floor(t / 60));
  const h = String(Math.floor(eta / 60)).padStart(1, '0');
  const m = String(eta % 60).padStart(2, '0');

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const PA_VIDEO_URL = '../uploads/optimized/purchasing-agent.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, click to replay) ——— */}
        <video
          ref={paVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setPaVideoEnded(true)}
          onClick={replayPaVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/purchasing-agent.jpg">
          <source src={PA_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live sourcing telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 196, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'pa-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>RFQ OPEN</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>PO-88-2014</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>SHENZHEN</span>
            <svg width="22" height="8" viewBox="0 0 22 8">
              <path d="M 0 4 L 16 4 M 12 1 L 16 4 L 12 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>BUYER</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '64%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: '64%', top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>QUOTES</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {suppliers}<span style={{ color: '#94A3B8', fontSize: 9 }}>/10</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>QC</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {qc}<span style={{ color: '#94A3B8', fontSize: 9 }}>%</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ETA</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {h}h {m}m
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes pa-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['40,000+', _t('hero.purch.l1')],
        ['320',     _t('hero.purch.l2')],
        ['14–22%',  _t('hero.purch.l3')],
      ]}/>
    </SlugFrame>
  );
}

// ——— Warehousing: video-backed hero (warehouse operations) w/ live inventory telemetry
function WarehousingHero() {
  const [t, setT] = useStateSh(0);
  const whVideoRef = useRefSh(null);
  const [whVideoEnded, setWhVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayWhVideo = () => {
    const v = whVideoRef.current;
    if (!v) return;
    setWhVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay whenever the hero scrolls back into view (after having ended).
  useEffectSh(() => {
    const v = whVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayWhVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Units received counting up so the card feels alive
  const unitsBase = 18420;
  const units = unitsBase + Math.floor(t / 3);
  // Bay utilization wobble around 87%
  const util = Math.round(87 + Math.sin(t * 0.04) * 1.2);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const WH_VIDEO_URL = '../uploads/optimized/warehouse-operations.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, click to replay) ——— */}
        <video
          ref={whVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setWhVideoEnded(true)}
          onClick={replayWhVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/warehouse-operations.jpg">
          <source src={WH_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 176, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'wh-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>LIVE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>HUB-ONT-04</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>FTZ 202</span>
            <span style={{ fontSize: 10, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px' }}>· ONTARIO, CA</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${util}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: `${util}%`, top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>RECEIVED</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {units.toLocaleString()} <span style={{ color: '#94A3B8', fontSize: 9 }}>u</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>BAYS</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {util}<span style={{ color: '#94A3B8', fontSize: 9 }}>%</span>
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes wh-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {whVideoEnded && (
        <MetricStrip items={[
          ['3.2M sqft', _t('hero.warehouse.l1')],
          ['9',         _t('hero.warehouse.l2')],
          ['99.96%',    _t('hero.warehouse.l3')],
        ]}/>
      )}
    </SlugFrame>
  );
}

// ——— Warehouse Relocation: video-backed hero w/ project timeline telemetry
function WarehouseRelocationHero() {
  const [t, setT] = useStateSh(0);
  const wrVideoRef = useRefSh(null);
  const [wrVideoEnded, setWrVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayWrVideo = () => {
    const v = wrVideoRef.current;
    if (!v) return;
    setWrVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = wrVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayWrVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Progress through a 14-day move, stepping forward so it feels alive.
  const dayBase = 6;
  const day = Math.min(14, dayBase + Math.floor(t / 240));
  const pct = Math.round((day / 14) * 100);
  const pallets = 8420 + Math.floor(t / 4);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const WR_VIDEO_URL = '../uploads/optimized/warehouse-operations-v2.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, no replay UI) ——— */}
        <video
          ref={wrVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setWrVideoEnded(true)}
          onClick={replayWrVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/warehouse-operations-v2.jpg">
          <source src={WR_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 200, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'wr-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>ON-TRACK</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>PRJ-0438</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>CHI-03</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>IND-07</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${pct}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: `${pct}%`, top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>DAY</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {day} <span style={{ color: '#94A3B8', fontSize: 9 }}>/ 14</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>PALLETS</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {pallets.toLocaleString()}
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes wr-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['0',        _t('hero.relo.l1')],
        ['14 days',  _t('hero.relo.l2')],
        ['In-house', _t('hero.relo.l3')],
      ]}/>
    </SlugFrame>
  );
}

// ——— Automotive Logistics: video-backed hero w/ VIN/shipment telemetry
function AutomotiveHero() {
  const [t, setT] = useStateSh(0);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const etaBase = 164;
  const eta = Math.max(1, etaBase - Math.floor(t / 60));
  const h = String(Math.floor(eta / 60)).padStart(1, '0');
  const m = String(eta % 60).padStart(2, '0');
  const units = 1280 + Math.floor(t / 5);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const AUTO_VIDEO_URL = '../uploads/optimized/warehouse-relocation.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <video
          autoPlay muted loop playsInline preload="metadata"
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', pointerEvents: 'none',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/warehouse-relocation.jpg">
          <source src={AUTO_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 200, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'auto-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>LIVE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>VIN-4J2G-88</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>VCO</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>DET</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '68%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
            <div style={{ position: 'absolute', left: '68%', top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>UNITS</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {units.toLocaleString()}
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ETA</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {h}h {m}m
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes auto-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['RO/RO',   _t('hero.auto.l1')],
        ['JIT/JIS', _t('hero.auto.l2')],
        ['98.9%',   _t('hero.auto.l3')],
      ]}/>
    </SlugFrame>
  );
}

// ——— Booking Orchestration: enterprise network visualization
// Central Walio node connects to carriers, ports, lanes with animated data packets.
// Replaces the Cargo Insurance hero — this is the "booking management allocation" animation.
function OrchestrationHero() {
  const [t, setT] = useStateSh(0);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  // VIEWBOX: 560 × 480
  const CX = 280, CY = 240;

  // Satellite nodes — carriers, ports, modalities.
  // Arranged as two orbits (r1=130, r2=195) so it feels deliberate, not chaotic.
  const nodes = [
    // Inner ring — carriers
    { label: 'MAERSK',  sub: 'Carrier',  r: 130, a: -110, kind: 'carrier' },
    { label: 'MSC',     sub: 'Carrier',  r: 130, a:  -40, kind: 'carrier' },
    { label: 'CMA CGM', sub: 'Carrier',  r: 130, a:   40, kind: 'carrier' },
    { label: 'HAPAG',   sub: 'Carrier',  r: 130, a:  130, kind: 'carrier' },
    // Outer ring — ports & lanes
    { label: 'SHA',     sub: 'Origin',   r: 195, a: -155, kind: 'port' },
    { label: 'LAX',     sub: 'Dest',     r: 195, a:  -75, kind: 'port' },
    { label: 'CHI',     sub: 'Inland',   r: 195, a:    0, kind: 'lane' },
    { label: 'ROT',     sub: 'Hub',      r: 195, a:   80, kind: 'port' },
    { label: 'HKG',     sub: 'Air',      r: 195, a:  160, kind: 'lane' },
  ];

  const pos = (n) => {
    const rad = (n.a * Math.PI) / 180;
    return { x: CX + Math.cos(rad) * n.r, y: CY + Math.sin(rad) * n.r };
  };

  // Build curved connection paths from center to each node
  const paths = nodes.map((n, i) => {
    const p = pos(n);
    // Slight quadratic curve — bend perpendicular to the straight line
    const mx = (CX + p.x) / 2;
    const my = (CY + p.y) / 2;
    const dx = p.x - CX, dy = p.y - CY;
    const len = Math.hypot(dx, dy);
    // perpendicular offset — alternate sign for organic feel
    const sign = i % 2 === 0 ? 1 : -1;
    const offset = 14 * sign;
    const nx = -dy / len * offset;
    const ny =  dx / len * offset;
    return {
      d: `M ${CX} ${CY} Q ${mx + nx} ${my + ny} ${p.x} ${p.y}`,
      node: n,
      pos: p,
      delay: (i * 0.35) % 2.8,
    };
  });

  // Live allocation telemetry that ticks through carriers to feel "orchestrated"
  const allocIdx = Math.floor(t / 180) % 4;
  const allocOptions = [
    { carrier: 'MAERSK', lane: 'SHA → LAX', transit: '14d', rate: '$2,840', conf: 96 },
    { carrier: 'MSC',    lane: 'SHA → LAX', transit: '16d', rate: '$2,620', conf: 91 },
    { carrier: 'CMA CGM',lane: 'SHA → LAX', transit: '15d', rate: '$2,730', conf: 94 },
    { carrier: 'HAPAG',  lane: 'SHA → LAX', transit: '17d', rate: '$2,580', conf: 89 },
  ];
  const alloc = allocOptions[allocIdx];
  const bookings = 18420 + Math.floor(t / 2);
  const lanesActive = 312 + Math.floor(Math.sin(t * 0.01) * 3);

  return (
    <div style={{ position: 'relative', width: '100%', aspectRatio: '1.15',
      background: 'radial-gradient(ellipse at 50% 40%, #142a6b 0%, #0a1a4a 45%, #050d2a 100%)',
      border: '1px solid rgba(96,140,255,0.18)', borderRadius: 20, overflow: 'hidden',
      boxShadow: '0 30px 60px -20px rgba(8,20,64,0.45), inset 0 1px 0 rgba(255,255,255,0.06)' }}>

      {/* ——— Precision grid background ——— */}
      <svg viewBox="0 0 100 100" preserveAspectRatio="none"
        style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', opacity: 0.7 }}>
        <defs>
          <pattern id="orch-grid-fine" width="2" height="2" patternUnits="userSpaceOnUse">
            <path d="M 2 0 L 0 0 0 2" fill="none" stroke="rgba(140,180,255,0.06)" strokeWidth="0.08"/>
          </pattern>
          <pattern id="orch-grid-coarse" width="10" height="10" patternUnits="userSpaceOnUse">
            <path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(140,180,255,0.09)" strokeWidth="0.15"/>
          </pattern>
          <radialGradient id="orch-vignette" cx="50%" cy="40%" r="70%">
            <stop offset="0%" stopColor="rgba(11,18,32,0)"/>
            <stop offset="100%" stopColor="rgba(5,10,26,0.55)"/>
          </radialGradient>
        </defs>
        <rect width="100" height="100" fill="url(#orch-grid-fine)"/>
        <rect width="100" height="100" fill="url(#orch-grid-coarse)"/>
        <rect width="100" height="100" fill="url(#orch-vignette)"/>
      </svg>

      {/* ——— Ambient glow behind hub ——— */}
      <div aria-hidden style={{ position: 'absolute', left: '50%', top: '50%',
        width: 340, height: 340, transform: 'translate(-50%, -50%)',
        background: 'radial-gradient(circle, rgba(80,140,255,0.38) 0%, rgba(80,140,255,0) 65%)',
        filter: 'blur(12px)', pointerEvents: 'none' }}/>

      {/* ——— Network SVG ——— */}
      <svg viewBox="0 0 560 480" preserveAspectRatio="xMidYMid meet"
        style={{ position: 'absolute', inset: 0, width: '100%', height: '100%' }}>
        <defs>
          <linearGradient id="orch-line" x1="0" y1="0" x2="1" y2="0">
            <stop offset="0%"  stopColor="rgba(120,170,255,0.9)"/>
            <stop offset="100%" stopColor="rgba(120,170,255,0.15)"/>
          </linearGradient>
          <radialGradient id="orch-hub-core" cx="50%" cy="50%" r="50%">
            <stop offset="0%"  stopColor="#eaf2ff"/>
            <stop offset="45%" stopColor="#86b3ff"/>
            <stop offset="100%" stopColor="#2a5fd8"/>
          </radialGradient>
          <radialGradient id="orch-hub-halo" cx="50%" cy="50%" r="50%">
            <stop offset="0%"  stopColor="rgba(140,190,255,0.55)"/>
            <stop offset="70%" stopColor="rgba(140,190,255,0)"/>
          </radialGradient>
          <filter id="orch-glow" x="-50%" y="-50%" width="200%" height="200%">
            <feGaussianBlur stdDeviation="2.4" result="b"/>
            <feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
          </filter>
        </defs>

        {/* Concentric rings (decorative orbits) */}
        {[130, 195, 240].map((r, i) => (
          <circle key={i} cx={CX} cy={CY} r={r}
            fill="none" stroke="rgba(120,170,255,0.12)" strokeWidth="0.7"
            strokeDasharray={i === 2 ? "1 4" : "0"}/>
        ))}

        {/* Pulsing outermost ring */}
        <circle cx={CX} cy={CY} r="240" fill="none"
          stroke="rgba(120,170,255,0.22)" strokeWidth="0.8">
          <animate attributeName="r" values="240;260;240" dur="6s" repeatCount="indefinite"/>
          <animate attributeName="opacity" values="0.22;0;0.22" dur="6s" repeatCount="indefinite"/>
        </circle>

        {/* Connection lines */}
        {paths.map((p, i) => (
          <path key={`line-${i}`} d={p.d} fill="none"
            stroke="url(#orch-line)" strokeWidth="0.9" opacity="0.85"/>
        ))}

        {/* Data packets flowing in along each path toward the hub */}
        {paths.map((p, i) => (
          <g key={`pkt-${i}`}>
            <circle r="2.2" fill="#cfe2ff" filter="url(#orch-glow)">
              <animateMotion dur="2.4s" repeatCount="indefinite" begin={`${p.delay}s`}
                path={`M ${p.pos.x} ${p.pos.y} Q ${(CX + p.pos.x)/2} ${(CY + p.pos.y)/2} ${CX} ${CY}`}/>
              <animate attributeName="opacity" values="0;1;1;0" dur="2.4s"
                begin={`${p.delay}s`} repeatCount="indefinite"/>
            </circle>
            <circle r="1.2" fill="#ffffff">
              <animateMotion dur="2.4s" repeatCount="indefinite" begin={`${p.delay + 0.2}s`}
                path={`M ${p.pos.x} ${p.pos.y} Q ${(CX + p.pos.x)/2} ${(CY + p.pos.y)/2} ${CX} ${CY}`}/>
              <animate attributeName="opacity" values="0;1;1;0" dur="2.4s"
                begin={`${p.delay + 0.2}s`} repeatCount="indefinite"/>
            </circle>
          </g>
        ))}

        {/* Satellite nodes */}
        {paths.map((p, i) => {
          const highlighted = p.node.kind === 'carrier' && p.node.label === alloc.carrier;
          return (
            <g key={`node-${i}`}>
              {/* Soft halo */}
              <circle cx={p.pos.x} cy={p.pos.y} r="14"
                fill={highlighted ? 'rgba(120,200,140,0.22)' : 'rgba(120,170,255,0.10)'}>
                {highlighted && (
                  <animate attributeName="r" values="14;20;14" dur="1.8s" repeatCount="indefinite"/>
                )}
              </circle>
              {/* Node */}
              <circle cx={p.pos.x} cy={p.pos.y} r="6"
                fill={highlighted ? '#6ee7a6' : '#9bc0ff'}
                stroke={highlighted ? '#34d27a' : 'rgba(255,255,255,0.6)'}
                strokeWidth="1" filter="url(#orch-glow)"/>
              {/* Label chip */}
              <g transform={`translate(${p.pos.x}, ${p.pos.y + 20})`}>
                <rect x={-(p.node.label.length * 3.4 + 8)} y="-1" rx="3"
                  width={p.node.label.length * 3.4 * 2 + 16} height="14"
                  fill="rgba(10,20,50,0.7)" stroke="rgba(140,180,255,0.25)" strokeWidth="0.5"/>
                <text x="0" y="9" textAnchor="middle"
                  fontSize="8" fontWeight="700" letterSpacing="0.5"
                  fill={highlighted ? '#6ee7a6' : '#cfe2ff'}
                  fontFamily="JetBrains Mono, monospace">{p.node.label}</text>
              </g>
            </g>
          );
        })}

        {/* ——— Central hub ——— */}
        {/* Outer halo */}
        <circle cx={CX} cy={CY} r="48" fill="url(#orch-hub-halo)">
          <animate attributeName="r" values="48;56;48" dur="3.2s" repeatCount="indefinite"/>
        </circle>
        {/* Ring */}
        <circle cx={CX} cy={CY} r="28" fill="none"
          stroke="rgba(200,220,255,0.5)" strokeWidth="1"
          strokeDasharray="3 3">
          <animateTransform attributeName="transform" type="rotate"
            from={`0 ${CX} ${CY}`} to={`360 ${CX} ${CY}`} dur="20s" repeatCount="indefinite"/>
        </circle>
        {/* Core */}
        <circle cx={CX} cy={CY} r="22" fill="url(#orch-hub-core)"
          stroke="rgba(255,255,255,0.8)" strokeWidth="0.8" filter="url(#orch-glow)"/>
        {/* W monogram */}
        <text x={CX} y={CY + 5} textAnchor="middle"
          fontSize="18" fontWeight="800" fill="#0a1a4a"
          fontFamily="Inter, sans-serif" letterSpacing="-0.04em">W</text>
      </svg>

      {/* ——— Live allocation telemetry card ——— */}
      <div style={{ position: 'absolute', top: 22, left: 22,
        background: 'rgba(10,22,55,0.72)',
        backdropFilter: 'blur(14px) saturate(140%)',
        WebkitBackdropFilter: 'blur(14px) saturate(140%)',
        border: '1px solid rgba(140,180,255,0.22)',
        borderRadius: 12, padding: '12px 14px',
        boxShadow: '0 14px 28px -12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08)',
        minWidth: 224, fontFamily: 'Inter, sans-serif', zIndex: 3 }}>
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          marginBottom: 10 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
            <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#6ee7a6',
              boxShadow: '0 0 0 3px rgba(110,231,166,0.2)',
              animation: 'orch-pulse 1.6s ease-in-out infinite' }}/>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#6ee7a6',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>ORCHESTRATING</span>
          </div>
          <span style={{ fontSize: 9, fontWeight: 700, color: '#9bc0ff',
            fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>ALLOC-ENGINE</span>
        </div>

        <div style={{ fontSize: 9, fontWeight: 700, color: '#7a9bd4',
          letterSpacing: '1.2px', marginBottom: 4,
          fontFamily: 'JetBrains Mono, monospace' }}>BEST ALLOCATION</div>
        <div style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 10 }}>
          <span style={{ fontSize: 18, fontWeight: 800, color: '#ffffff',
            letterSpacing: '-0.02em', fontFamily: 'Inter, sans-serif' }}>{alloc.carrier}</span>
          <span style={{ fontSize: 11, fontWeight: 600, color: '#cfe2ff',
            fontFamily: 'JetBrains Mono, monospace' }}>{alloc.lane}</span>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 10,
          fontFamily: 'JetBrains Mono, monospace',
          paddingTop: 10, borderTop: '1px solid rgba(140,180,255,0.12)' }}>
          <div>
            <div style={{ fontSize: 8, color: '#7a9bd4', fontWeight: 700,
              letterSpacing: '1.1px', marginBottom: 2 }}>RATE</div>
            <div style={{ fontSize: 13, color: '#ffffff', fontWeight: 700 }}>{alloc.rate}</div>
          </div>
          <div>
            <div style={{ fontSize: 8, color: '#7a9bd4', fontWeight: 700,
              letterSpacing: '1.1px', marginBottom: 2 }}>TRANSIT</div>
            <div style={{ fontSize: 13, color: '#ffffff', fontWeight: 700 }}>{alloc.transit}</div>
          </div>
          <div>
            <div style={{ fontSize: 8, color: '#7a9bd4', fontWeight: 700,
              letterSpacing: '1.1px', marginBottom: 2 }}>CONF</div>
            <div style={{ fontSize: 13, color: '#6ee7a6', fontWeight: 700 }}>{alloc.conf}%</div>
          </div>
        </div>
      </div>

      {/* ——— Secondary stat chip (top-right) ——— */}
      <div style={{ position: 'absolute', top: 22, right: 22,
        display: 'flex', flexDirection: 'column', gap: 8, zIndex: 3 }}>
        <div style={{
          background: 'rgba(10,22,55,0.72)',
          backdropFilter: 'blur(14px)', WebkitBackdropFilter: 'blur(14px)',
          border: '1px solid rgba(140,180,255,0.22)',
          borderRadius: 10, padding: '8px 12px',
          fontFamily: 'JetBrains Mono, monospace', textAlign: 'right' }}>
          <div style={{ fontSize: 8, color: '#7a9bd4', fontWeight: 700,
            letterSpacing: '1.1px' }}>LANES ACTIVE</div>
          <div style={{ fontSize: 15, color: '#ffffff', fontWeight: 700,
            fontVariantNumeric: 'tabular-nums', marginTop: 1 }}>{lanesActive}</div>
        </div>
        <div style={{
          background: 'rgba(10,22,55,0.72)',
          backdropFilter: 'blur(14px)', WebkitBackdropFilter: 'blur(14px)',
          border: '1px solid rgba(140,180,255,0.22)',
          borderRadius: 10, padding: '8px 12px',
          fontFamily: 'JetBrains Mono, monospace', textAlign: 'right' }}>
          <div style={{ fontSize: 8, color: '#7a9bd4', fontWeight: 700,
            letterSpacing: '1.1px' }}>BOOKINGS / YR</div>
          <div style={{ fontSize: 15, color: '#ffffff', fontWeight: 700,
            fontVariantNumeric: 'tabular-nums', marginTop: 1 }}>{bookings.toLocaleString()}</div>
        </div>
      </div>

      {/* ——— Bottom metric strip (dark variant) ——— */}
      <div style={{ position: 'absolute', left: 24, right: 24, bottom: 20,
        display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 12,
        background: 'rgba(10,22,55,0.72)',
        backdropFilter: 'blur(14px)', WebkitBackdropFilter: 'blur(14px)',
        padding: 14, borderRadius: 12,
        border: '1px solid rgba(140,180,255,0.22)',
        boxShadow: '0 14px 28px -12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06)',
        zIndex: 3 }}>
        {[
          ['40+', 'carriers integrated'],
          ['< 90s', 'quote → book'],
          ['99.2%', 'allocation accuracy'],
        ].map(([v, l], i) => (
          <div key={i} style={{ borderLeft: i > 0 ? '1px solid rgba(140,180,255,0.15)' : 'none',
            paddingLeft: i > 0 ? 12 : 0 }}>
            <div style={{ fontSize: 18, fontWeight: 700, letterSpacing: '-0.02em',
              color: '#ffffff', fontFamily: 'JetBrains Mono, monospace' }}>{v}</div>
            <div style={{ fontSize: 10, color: '#7a9bd4', letterSpacing: '0.05em',
              textTransform: 'uppercase', fontWeight: 600, marginTop: 3 }}>{l}</div>
          </div>
        ))}
      </div>

      {/* Scanline sweep for premium feel */}
      <div aria-hidden style={{ position: 'absolute', inset: 0, pointerEvents: 'none',
        background: 'linear-gradient(180deg, transparent 0%, rgba(140,190,255,0.08) 50%, transparent 100%)',
        height: '28%', animation: 'orch-scan 7s linear infinite', zIndex: 1 }}/>

      <style>{`
        @keyframes orch-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
        @keyframes orch-scan {
          0%   { transform: translateY(-30%); opacity: 0; }
          15%  { opacity: 1; }
          85%  { opacity: 1; }
          100% { transform: translateY(360%); opacity: 0; }
        }
      `}</style>
    </div>
  );
}

// ——— Cargo Insurance: video-backed hero w/ live policy binding telemetry
function CargoInsuranceHero() {
  const [t, setT] = useStateSh(0);
  const ciVideoRef = useRefSh(null);
  const [ciVideoEnded, setCiVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayCiVideo = () => {
    const v = ciVideoRef.current;
    if (!v) return;
    setCiVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = ciVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayCiVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Bind countdown — feels like a policy being written in real time
  const bindSec = Math.max(1, 14 - Math.floor(t / 60) % 15);
  const insured = 124800 + Math.floor(t / 2) * 25;
  const premium = (insured * 0.0042).toFixed(0);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const CI_VIDEO_URL = '../uploads/optimized/cargo-insurance.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, no replay UI) ——— */}
        <video
          ref={ciVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setCiVideoEnded(true)}
          onClick={replayCiVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/cargo-insurance.jpg">
          <source src={CI_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint for consistency with sibling service heroes */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live policy binding telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 210, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'ci-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>BOUND</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>POL-ABG-4829</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>SHA</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>LAX</span>
            <span style={{ marginLeft: 'auto', fontSize: 9, fontWeight: 700, color: '#1846B0',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px',
              background: '#DCE9FB', padding: '2px 6px', borderRadius: 4 }}>ALL-RISK</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '100%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>INSURED</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                ${(insured/1000).toFixed(1)}K
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>PREMIUM</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                ${premium}
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes ci-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {ciVideoEnded && (
        <MetricStrip items={[
          ['$48M',    _t('hero.cargoins.l1')],
          ['11 days', _t('hero.cargoins.l2')],
          ['A+',      _t('hero.cargoins.l3')],
        ]}/>
      )}
    </SlugFrame>
  );
}

// ——— Replenishment: video-backed demand-forecast + auto-PO telemetry
function ReplenishmentHero() {
  const [t, setT] = useStateSh(0);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  // Live-feeling metrics
  const skus = (1_842_120 + Math.floor(t * 3.2)).toLocaleString();
  const accuracy = (93.1 + Math.sin(t * 0.03) * 0.3).toFixed(1);
  const poEta = Math.max(1, 48 - Math.floor(t / 120));

  // Sparkline — 24 points of safety-stock coverage oscillating around a target band
  const spark = Array.from({ length: 24 }, (_, i) => {
    const phase = (t * 0.015) + i * 0.42;
    return 50 + Math.sin(phase) * 14 + Math.sin(phase * 0.5) * 6;
  });
  const sparkPath = spark
    .map((y, i) => `${i === 0 ? 'M' : 'L'} ${(i / (spark.length - 1)) * 130} ${40 - (y / 100) * 34}`)
    .join(' ');

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const REPLEN_VIDEO_URL = '../uploads/optimized/replenishment.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer ——— */}
        <video
          autoPlay muted loop playsInline preload="metadata"
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', pointerEvents: 'none',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/replenishment.jpg">
          <source src={REPLEN_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Forecast engine card (top-left) ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          transform: 'scale(0.7)', transformOrigin: 'top left',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 188, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'replen-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>FORECASTING</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>Q3-MODEL-v7</span>
          </div>

          <div style={{ fontSize: 10, fontWeight: 600, color: '#64748B',
            letterSpacing: '0.04em', textTransform: 'uppercase', marginBottom: 2 }}>{_t('hero.replen.l1')}</div>
          <div style={{ fontSize: 18, fontWeight: 800, color: '#0B1220',
            letterSpacing: '-0.02em', fontFamily: 'JetBrains Mono, monospace',
            fontVariantNumeric: 'tabular-nums', marginBottom: 8 }}>{skus}</div>

          {/* Sparkline */}
          <svg viewBox="0 0 130 40" width="160" height="42"
            style={{ display: 'block', marginBottom: 4 }}>
            <defs>
              <linearGradient id="replen-spark-fill" x1="0" x2="0" y1="0" y2="1">
                <stop offset="0%" stopColor="#1E57D6" stopOpacity="0.28"/>
                <stop offset="100%" stopColor="#1E57D6" stopOpacity="0"/>
              </linearGradient>
            </defs>
            {/* target band */}
            <rect x="0" y="12" width="130" height="14" fill="#1E57D6" opacity="0.08"/>
            {/* fill */}
            <path d={`${sparkPath} L 130 40 L 0 40 Z`} fill="url(#replen-spark-fill)"/>
            {/* line */}
            <path d={sparkPath} fill="none" stroke="#1E57D6" strokeWidth="1.4"
              strokeLinecap="round" strokeLinejoin="round"/>
            {/* head dot */}
            <circle cx="130" cy={40 - (spark[spark.length - 1] / 100) * 34} r="2.2" fill="#1E57D6"/>
          </svg>

          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginTop: 4 }}>
            <span style={{ fontSize: 10, fontWeight: 600, color: '#64748B',
              letterSpacing: '0.04em', textTransform: 'uppercase' }}>{_t('hero.replen.l2')}</span>
            <span style={{ fontSize: 12, fontWeight: 800, color: '#1E57D6',
              fontFamily: 'JetBrains Mono, monospace',
              fontVariantNumeric: 'tabular-nums' }}>{accuracy}%</span>
          </div>
        </div>

        {/* ——— Auto-PO tag (right side) ——— */}
        <div style={{ position: 'absolute', top: 32, right: 22,
          transform: 'scale(0.7)', transformOrigin: 'top right',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '10px 12px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 172, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6 }}>
            <svg width="12" height="12" viewBox="0 0 24 24" fill="none">
              <path d="M21 12a9 9 0 1 1-3-6.7L21 8" stroke="#1E57D6"
                strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
              <path d="M21 3v5h-5" stroke="#1E57D6"
                strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#1E57D6',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>AUTO-PO RAISED</span>
          </div>
          <div style={{ fontSize: 12, fontWeight: 700, color: '#0B1220',
            letterSpacing: '-0.01em', marginBottom: 6 }}>PO-48271 · 3,400 units</div>

          {/* Hub route */}
          <div style={{ display: 'flex', alignItems: 'center', gap: 6,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <span style={{ fontSize: 11, fontWeight: 800, color: '#0B1220' }}>SZX</span>
            <svg width="28" height="8" viewBox="0 0 28 8">
              <path d="M 0 4 L 22 4 M 18 1 L 22 4 L 18 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 11, fontWeight: 800, color: '#0B1220' }}>DFW-HUB</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginTop: 8, paddingTop: 6, borderTop: '1px solid #eaecf0' }}>
            <span style={{ fontSize: 9, fontWeight: 600, color: '#64748B',
              letterSpacing: '0.04em', textTransform: 'uppercase' }}>{_t('hero.replen.l3')}</span>
            <span style={{ fontSize: 11, fontWeight: 800, color: '#0B1220',
              fontFamily: 'JetBrains Mono, monospace',
              fontVariantNumeric: 'tabular-nums' }}>{poEta}h</span>
          </div>
        </div>

        <style>{`
          @keyframes replen-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>
    </SlugFrame>
  );
}

// ——— Parcel: international rate-shopping animation
// A live "get rates" panel animates in; carriers populate one-by-one with
// price + transit days; the cheapest is auto-selected; a route map pulses
// from origin to destination; carrier chips orbit the shipment.
function ParcelHero() {
  const [t, setT] = useStateSh(0);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  // Cycle through origin/destination pairs (slow). 18s per lane.
  const lanes = [
    { from: 'LAX', fromCity: 'Los Angeles', fromFlag: '🇺🇸', to: 'LHR', toCity: 'London',     toFlag: '🇬🇧', kgs: '2.4', zone: 'IntlZ4' },
    { from: 'NYC', fromCity: 'New York',    fromFlag: '🇺🇸', to: 'FRA', toCity: 'Frankfurt',  toFlag: '🇩🇪', kgs: '1.8', zone: 'IntlZ5' },
    { from: 'SFO', fromCity: 'San Francisco', fromFlag: '🇺🇸', to: 'NRT', toCity: 'Tokyo',    toFlag: '🇯🇵', kgs: '3.1', zone: 'IntlZ7' },
    { from: 'MIA', fromCity: 'Miami',       fromFlag: '🇺🇸', to: 'GRU', toCity: 'São Paulo',  toFlag: '🇧🇷', kgs: '2.0', zone: 'IntlZ8' },
  ];
  const laneIdx = Math.floor(t / (18 * 60)) % lanes.length;
  const lane = lanes[laneIdx];
  const laneLocal = t % (18 * 60);

  // Rates — per-lane, priced realistically. Cheapest row is highlighted.
  // These numbers drift +/- a tiny amount each tick so it looks live.
  const ratesByLane = [
    [ // LAX → LHR
      { code: 'DHL',   name: 'DHL Express',     service: 'Worldwide Exp',  days: '2d',  base: 46.20, tint: '#FFCC00', ink: '#0B1220' },
      { code: 'FDX',   name: 'FedEx',           service: 'Intl Priority',  days: '2–3d', base: 52.80, tint: '#4D148C', ink: '#fff'   },
      { code: 'UPS',   name: 'UPS',             service: 'Worldwide Saver', days: '3d',  base: 49.40, tint: '#8B6A3A', ink: '#fff'   },
      { code: 'USPS',  name: 'USPS',            service: 'Priority Mail',  days: '6–10d', base: 38.10, tint: '#004B87', ink: '#fff'   },
      { code: 'DPD',   name: 'DPD',             service: 'Classic Intl',   days: '4–5d', base: 41.60, tint: '#DC0032', ink: '#fff'   },
      { code: 'ARX',   name: 'Aramex',          service: 'Priority Parcel',days: '5d',   base: 36.90, tint: '#E8122B', ink: '#fff'   },
    ],
    [ // NYC → FRA
      { code: 'DHL',   name: 'DHL Express',     service: 'Worldwide Exp',  days: '1–2d', base: 39.70, tint: '#FFCC00', ink: '#0B1220' },
      { code: 'FDX',   name: 'FedEx',           service: 'Intl Priority',  days: '2d',   base: 44.10, tint: '#4D148C', ink: '#fff'   },
      { code: 'UPS',   name: 'UPS',             service: 'Worldwide Exp',  days: '2–3d', base: 42.30, tint: '#8B6A3A', ink: '#fff'   },
      { code: 'USPS',  name: 'USPS',            service: 'Priority Intl',  days: '5–8d', base: 31.80, tint: '#004B87', ink: '#fff'   },
      { code: 'DPD',   name: 'DPD',             service: 'Classic Intl',   days: '3–4d', base: 34.60, tint: '#DC0032', ink: '#fff'   },
      { code: 'GLS',   name: 'GLS',             service: 'EuroBusiness',   days: '3d',   base: 32.10, tint: '#0B2E7A', ink: '#fff'   },
    ],
    [ // SFO → NRT
      { code: 'DHL',   name: 'DHL Express',     service: 'Worldwide Exp',  days: '2–3d', base: 58.40, tint: '#FFCC00', ink: '#0B1220' },
      { code: 'FDX',   name: 'FedEx',           service: 'Intl Priority',  days: '2d',   base: 64.20, tint: '#4D148C', ink: '#fff'   },
      { code: 'UPS',   name: 'UPS',             service: 'Worldwide Saver', days: '3d',  base: 59.80, tint: '#8B6A3A', ink: '#fff'   },
      { code: 'USPS',  name: 'USPS',            service: 'Priority Intl',  days: '7–12d',base: 44.20, tint: '#004B87', ink: '#fff'   },
      { code: 'YMT',   name: 'Yamato',          service: 'TA-Q-BIN Intl',  days: '4d',   base: 48.90, tint: '#1E8E3E', ink: '#fff'   },
      { code: 'SGT',   name: 'Sagawa',          service: 'Overseas Parcel',days: '5–6d', base: 42.60, tint: '#0B62B6', ink: '#fff'   },
    ],
    [ // MIA → GRU
      { code: 'DHL',   name: 'DHL Express',     service: 'Worldwide Exp',  days: '3d',   base: 51.30, tint: '#FFCC00', ink: '#0B1220' },
      { code: 'FDX',   name: 'FedEx',           service: 'Intl Priority',  days: '3–4d', base: 56.80, tint: '#4D148C', ink: '#fff'   },
      { code: 'UPS',   name: 'UPS',             service: 'Worldwide Exp',  days: '3d',   base: 54.20, tint: '#8B6A3A', ink: '#fff'   },
      { code: 'USPS',  name: 'USPS',            service: 'Priority Intl',  days: '8–12d',base: 40.10, tint: '#004B87', ink: '#fff'   },
      { code: 'CRR',   name: 'Correios',        service: 'Encomenda Intl', days: '6–9d', base: 36.40, tint: '#FDB913', ink: '#0B1220' },
      { code: 'JAD',   name: 'Jadlog',          service: 'Package Intl',   days: '5–7d', base: 39.80, tint: '#ED1C24', ink: '#fff'   },
    ],
  ];

  const rawRates = ratesByLane[laneIdx];
  // Tiny live drift per row
  const rates = rawRates.map((r, i) => ({
    ...r,
    price: (r.base + Math.sin((t + i * 23) * 0.011) * 0.35).toFixed(2),
  }));

  // Stagger in: show 1 carrier every 18 frames, then hold, then cycle.
  const reveal = Math.min(rates.length, Math.floor(laneLocal / 12));
  const cheapest = rates.reduce((acc, r, i) => (+r.price < +rates[acc].price ? i : acc), 0);

  // Little numeric counters
  const carriersIntegrated = 40 + Math.floor(Math.sin(t * 0.01) * 2);
  const savedPct = 34 + Math.floor(Math.sin(t * 0.008) * 2);
  const labelMs = 104 + Math.floor(Math.sin(t * 0.02) * 8);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };

  // Orbiting carrier chips around the globe
  const orbitCarriers = ['DHL', 'FDX', 'UPS', 'USPS', 'DPD', 'TNT', 'YMT', 'GLS'];

  return (
    <SlugFrame palette={palette}>
      {/* ——— Soft background: world dots + routing arcs ——— */}
      <svg viewBox="0 0 600 500" preserveAspectRatio="xMidYMid slice"
        style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', opacity: 0.45 }}>
        <defs>
          <radialGradient id="parcel-glow" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="rgba(30,87,214,0.18)"/>
            <stop offset="100%" stopColor="rgba(30,87,214,0)"/>
          </radialGradient>
          <pattern id="parcel-dots" width="8" height="8" patternUnits="userSpaceOnUse">
            <circle cx="1" cy="1" r="0.8" fill="rgba(30,87,214,0.28)"/>
          </pattern>
        </defs>
        <circle cx="300" cy="250" r="220" fill="url(#parcel-glow)"/>
        {/* soft continents as dot clusters */}
        <g fill="url(#parcel-dots)">
          <path d="M 80 160 Q 140 140 200 170 Q 230 200 210 240 Q 170 270 120 260 Q 80 240 80 200 Z"/>
          <path d="M 260 140 Q 340 130 400 150 Q 430 180 410 220 Q 370 250 300 240 Q 260 220 260 180 Z"/>
          <path d="M 420 200 Q 490 190 540 220 Q 560 260 530 300 Q 480 320 430 300 Q 400 270 420 240 Z"/>
          <path d="M 170 300 Q 240 290 280 320 Q 290 360 260 380 Q 210 390 180 370 Q 160 340 170 310 Z"/>
        </g>
        {/* animated routing arc — origin → destination */}
        <g>
          <path d="M 130 240 Q 300 110 470 230"
            stroke="rgba(30,87,214,0.35)" strokeWidth="1.2" strokeDasharray="2 3" fill="none"/>
          <circle r="4" fill="#1E57D6">
            <animateMotion dur="4.2s" repeatCount="indefinite"
              path="M 130 240 Q 300 110 470 230"/>
          </circle>
          <circle r="4" fill="#1E57D6">
            <animateMotion dur="4.2s" repeatCount="indefinite" begin="1.4s"
              path="M 130 240 Q 300 110 470 230"/>
          </circle>
          <circle r="4" fill="#1E57D6">
            <animateMotion dur="4.2s" repeatCount="indefinite" begin="2.8s"
              path="M 130 240 Q 300 110 470 230"/>
          </circle>
          {/* origin + destination pins */}
          <g transform="translate(130 240)">
            <circle r="10" fill="#fff" stroke="#1E57D6" strokeWidth="2"/>
            <circle r="4" fill="#1E57D6"/>
          </g>
          <g transform="translate(470 230)">
            <circle r="10" fill="#fff" stroke="#1E57D6" strokeWidth="2"/>
            <circle r="4" fill="#1E57D6"/>
          </g>
        </g>
      </svg>

      {/* ——— Main rate-shopping card (glass, center) ——— */}
      <div style={{ position: 'absolute', top: '50%', left: '50%',
        transform: 'translate(-50%, -50%)',
        width: 'min(78%, 520px)',
        background: 'rgba(255,255,255,0.96)',
        backdropFilter: 'blur(14px)', WebkitBackdropFilter: 'blur(14px)',
        border: '1px solid rgba(208,225,248,0.9)',
        borderRadius: 16,
        boxShadow: '0 28px 56px -18px rgba(16,24,40,0.25), 0 8px 16px -8px rgba(30,87,214,0.18)',
        fontFamily: 'Inter, sans-serif',
        overflow: 'hidden' }}>

        {/* Header — lane selector */}
        <div style={{ padding: '12px 14px 10px',
          borderBottom: '1px solid #eef2f7',
          display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          background: 'linear-gradient(180deg, #fbfdff 0%, #f5f9ff 100%)' }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
            <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
              boxShadow: '0 0 0 3px rgba(34,197,94,0.18)',
              animation: 'parcel-pulse 1.6s ease-in-out infinite' }}/>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>LIVE RATES</span>
          </div>
          <div style={{ display: 'flex', alignItems: 'center', gap: 8,
            fontFamily: 'JetBrains Mono, monospace', fontSize: 11, color: '#0B1220', fontWeight: 700 }}>
            <span>{lane.fromFlag}</span>
            <span>{lane.from}</span>
            <svg width="26" height="8" viewBox="0 0 26 8">
              <path d="M 0 4 L 20 4 M 16 1 L 20 4 L 16 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span>{lane.to}</span>
            <span>{lane.toFlag}</span>
          </div>
          <div style={{ fontFamily: 'JetBrains Mono, monospace',
            fontSize: 9, color: '#64748B', fontWeight: 700, letterSpacing: '1.1px' }}>
            {lane.kgs}KG · {lane.zone}
          </div>
        </div>

        {/* Rate rows */}
        <div style={{ padding: '6px 0' }}>
          {rates.map((r, i) => {
            const visible = i < reveal;
            const isCheapest = i === cheapest && reveal >= rates.length;
            return (
              <div key={r.code + laneIdx} style={{
                display: 'grid',
                gridTemplateColumns: '34px 1fr auto auto 24px',
                alignItems: 'center',
                gap: 10,
                padding: '7px 14px',
                opacity: visible ? 1 : 0,
                transform: visible ? 'translateX(0)' : 'translateX(-8px)',
                transition: 'opacity 280ms ease, transform 280ms ease, background 240ms ease',
                background: isCheapest ? 'linear-gradient(90deg, rgba(30,87,214,0.06), rgba(30,87,214,0) 80%)' : 'transparent',
                borderLeft: isCheapest ? '2px solid #1E57D6' : '2px solid transparent',
              }}>
                {/* Carrier chip */}
                <div style={{ width: 30, height: 22, borderRadius: 5,
                  background: r.tint, color: r.ink,
                  display: 'grid', placeItems: 'center',
                  fontFamily: 'Inter, sans-serif',
                  fontSize: 9, fontWeight: 800, letterSpacing: '0.02em',
                  boxShadow: '0 2px 4px rgba(16,24,40,0.1)' }}>
                  {r.code}
                </div>
                {/* Carrier name + service */}
                <div style={{ minWidth: 0 }}>
                  <div style={{ fontSize: 12, fontWeight: 700, color: '#0B1220',
                    letterSpacing: '-0.005em', lineHeight: 1.2,
                    overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
                    {r.name}
                  </div>
                  <div style={{ fontSize: 10, color: '#64748B', fontWeight: 500,
                    lineHeight: 1.2, marginTop: 1 }}>
                    {r.service}
                  </div>
                </div>
                {/* Transit */}
                <div style={{ fontFamily: 'JetBrains Mono, monospace',
                  fontSize: 10, fontWeight: 700, color: '#475467',
                  background: '#F2F4F7', padding: '2px 6px', borderRadius: 4 }}>
                  {r.days}
                </div>
                {/* Price */}
                <div style={{ fontFamily: 'JetBrains Mono, monospace',
                  fontSize: 13, fontWeight: 700,
                  color: isCheapest ? '#1846B0' : '#0B1220',
                  fontVariantNumeric: 'tabular-nums', textAlign: 'right', minWidth: 56 }}>
                  ${r.price}
                </div>
                {/* Check */}
                <div style={{ display: 'grid', placeItems: 'center',
                  width: 20, height: 20, borderRadius: 9999,
                  background: isCheapest ? '#1E57D6' : 'transparent',
                  border: isCheapest ? 'none' : '1.5px solid #E4E7EC',
                  transition: 'background 240ms ease' }}>
                  {isCheapest && (
                    <svg width="11" height="11" viewBox="0 0 12 12" fill="none">
                      <path d="M 2.5 6.3 L 5 8.5 L 9.5 3.8" stroke="#fff"
                        strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"/>
                    </svg>
                  )}
                </div>
              </div>
            );
          })}
          {/* scanning bar while rates stream in */}
          {reveal < rates.length && (
            <div style={{ height: 2, margin: '4px 14px 0',
              background: '#EFF2F6', borderRadius: 9999, overflow: 'hidden' }}>
              <div style={{ height: '100%', width: '40%',
                background: 'linear-gradient(90deg, transparent, #1E57D6, transparent)',
                animation: 'parcel-scan 1.2s linear infinite' }}/>
            </div>
          )}
        </div>

        {/* Footer — savings vs list */}
        <div style={{ padding: '10px 14px',
          borderTop: '1px solid #eef2f7',
          background: 'linear-gradient(180deg, #fbfdff 0%, #f2f7ff 100%)',
          display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          fontFamily: 'JetBrains Mono, monospace' }}>
          <div style={{ fontSize: 9, color: '#64748B', fontWeight: 700, letterSpacing: '1.1px' }}>
            ABGS NEGOTIATED
          </div>
          <div style={{ display: 'flex', alignItems: 'baseline', gap: 6 }}>
            <span style={{ fontSize: 10, color: '#98A2B3', fontWeight: 600,
              textDecoration: 'line-through' }}>
              ${(rates[cheapest].base * 1.52).toFixed(2)}
            </span>
            <span style={{ fontSize: 13, fontWeight: 700, color: '#1846B0' }}>
              ${rates[cheapest].price}
            </span>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#039855',
              background: '#ECFDF3', padding: '2px 5px', borderRadius: 4,
              letterSpacing: '0.5px' }}>
              −{savedPct}%
            </span>
          </div>
        </div>
      </div>

      {/* ——— Live metrics strip (bottom) ——— */}
      <div style={{ position: 'absolute', left: 18, right: 18, bottom: 16,
        display: 'flex', justifyContent: 'space-between',
        background: 'rgba(255,255,255,0.88)',
        backdropFilter: 'blur(8px)', WebkitBackdropFilter: 'blur(8px)',
        border: '1px solid rgba(208,225,248,0.8)',
        borderRadius: 10, padding: '8px 12px',
        fontFamily: 'JetBrains Mono, monospace',
        boxShadow: '0 10px 24px -12px rgba(16,24,40,0.2)' }}>
        {[
          { label: _t('hero.parcel.l1'), value: `${carriersIntegrated}+` },
          { label: _t('hero.parcel.l2'), value: `−${savedPct}%` },
          { label: _t('hero.parcel.l3'), value: '220' },
          { label: _t('hero.parcel.l4'), value: `${labelMs}ms` },
        ].map((m, i) => (
          <div key={i} style={{ textAlign: 'center', flex: 1,
            borderRight: i < 3 ? '1px solid #E4E7EC' : 'none' }}>
            <div style={{ fontSize: 8, color: '#64748B', fontWeight: 700,
              letterSpacing: '1.1px' }}>{m.label}</div>
            <div style={{ fontSize: 12, color: '#0B1220', fontWeight: 800,
              marginTop: 2 }}>{m.value}</div>
          </div>
        ))}
      </div>

      {/* ——— Top-right badge ——— */}
      <div style={{ position: 'absolute', top: 16, right: 16,
        display: 'inline-flex', alignItems: 'center', gap: 6,
        background: 'rgba(255,255,255,0.92)',
        border: '1px solid rgba(208,225,248,0.9)',
        borderRadius: 9999, padding: '5px 9px',
        fontFamily: 'JetBrains Mono, monospace',
        fontSize: 9, fontWeight: 700, color: '#1846B0',
        letterSpacing: '0.08em',
        boxShadow: '0 6px 14px -6px rgba(30,87,214,0.25)' }}>
        <svg width="10" height="10" viewBox="0 0 12 12" fill="none">
          <path d="M 6 1 L 6 11 M 1 6 L 11 6" stroke="#1E57D6" strokeWidth="1.4" strokeLinecap="round"/>
          <circle cx="6" cy="6" r="4.2" stroke="#1E57D6" strokeWidth="1.1" fill="none"/>
        </svg>
        RATE ENGINE v4.2
      </div>

      <style>{`
        @keyframes parcel-pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: 0.55; transform: scale(1.12);} }
        @keyframes parcel-scan  { 0% { transform: translateX(-100%);} 100% { transform: translateX(250%);} }
      `}</style>
    </SlugFrame>
  );
}

// ——— Returns: video-backed reverse-logistics hero w/ live grading telemetry
function ReturnsHero() {
  const [t, setT] = useStateSh(0);
  const returnsVideoRef = useRefSh(null);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayReturnsVideo = () => {
    const v = returnsVideoRef.current;
    if (!v) return;
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = returnsVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting && v.ended) replayReturnsVideo(); });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Live-feeling metrics
  const graded = (12847 + Math.floor(t / 6)).toLocaleString();
  const restockRate = (93.8 + Math.sin(t * 0.03) * 0.5).toFixed(1);
  const inspectMs = Math.round(420 + Math.sin(t * 0.08) * 60);
  const stages = ['Received', 'Inspecting', 'Graded', 'Restocked'];
  const stageIdx = Math.floor(t / 150) % stages.length;

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const RETURNS_VIDEO_URL = '../uploads/optimized/returns.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer ——— */}
        <video
          ref={returnsVideoRef}
          autoPlay muted playsInline preload="metadata"
          onClick={replayReturnsVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/returns.jpg">
          <source src={RETURNS_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint for consistency with sibling service heroes */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Grading-line card (top-left) ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          transform: 'scale(0.72)', transformOrigin: 'top left',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 210, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'returns-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>GRADING LINE</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>RMA-48271</span>
          </div>

          <div style={{ fontSize: 10, fontWeight: 600, color: '#64748B',
            letterSpacing: '0.04em', textTransform: 'uppercase', marginBottom: 2 }}>{_t('hero.returns.l1')}</div>
          <div style={{ fontSize: 18, fontWeight: 800, color: '#0B1220',
            letterSpacing: '-0.02em', fontFamily: 'JetBrains Mono, monospace',
            fontVariantNumeric: 'tabular-nums', marginBottom: 10 }}>{graded}</div>

          {/* Stage pipeline */}
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 4 }}>
            {stages.map((s, i) => (
              <div key={s} style={{
                padding: '5px 0', borderRadius: 6,
                background: i === stageIdx ? '#1E57D6' : (i < stageIdx ? '#DCE9FB' : '#F1F5F9'),
                color: i === stageIdx ? '#fff' : (i < stageIdx ? '#1846B0' : '#94A3B8'),
                fontSize: 8, fontWeight: 800, textAlign: 'center',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '0.06em',
                transition: 'background 900ms ease, color 900ms ease'
              }}>{s.toUpperCase()}</div>
            ))}
          </div>

          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginTop: 10, paddingTop: 8, borderTop: '1px solid #eaecf0' }}>
            <span style={{ fontSize: 10, fontWeight: 600, color: '#64748B',
              letterSpacing: '0.04em', textTransform: 'uppercase' }}>{_t('hero.returns.l2')}</span>
            <span style={{ fontSize: 12, fontWeight: 800, color: '#1E57D6',
              fontFamily: 'JetBrains Mono, monospace',
              fontVariantNumeric: 'tabular-nums' }}>{inspectMs}ms</span>
          </div>
        </div>

        {/* ——— Grade breakdown (top-right) ——— */}
        <div style={{ position: 'absolute', top: 32, right: 22,
          transform: 'scale(0.72)', transformOrigin: 'top right',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 186, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 8 }}>
            <svg width="12" height="12" viewBox="0 0 24 24" fill="none">
              <path d="M21 12a9 9 0 1 1-3-6.7L21 8" stroke="#1E57D6"
                strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
              <path d="M21 3v5h-5" stroke="#1E57D6"
                strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#1E57D6',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>DISPOSITION</span>
          </div>

          {[
            { k: 'Restock A',  v: 62, c: '#1E57D6' },
            { k: 'Restock B',  v: 24, c: '#60A5FA' },
            { k: 'Discount',   v: 10, c: '#93C5FD' },
            { k: 'Dispose',    v:  4, c: '#CBD5F5' },
          ].map(row => (
            <div key={row.k} style={{ marginBottom: 6 }}>
              <div style={{ display: 'flex', justifyContent: 'space-between',
                fontSize: 10, fontWeight: 600, color: '#475467', marginBottom: 2 }}>
                <span>{row.k}</span>
                <span style={{ fontFamily: 'JetBrains Mono, monospace',
                  fontVariantNumeric: 'tabular-nums', color: '#0B1220', fontWeight: 800 }}>{row.v}%</span>
              </div>
              <div style={{ height: 4, background: '#F1F5F9', borderRadius: 9999, overflow: 'hidden' }}>
                <div style={{ width: `${row.v}%`, height: '100%', background: row.c,
                  borderRadius: 9999, transition: 'width 400ms ease' }}/>
              </div>
            </div>
          ))}

          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginTop: 6, paddingTop: 6, borderTop: '1px solid #eaecf0' }}>
            <span style={{ fontSize: 9, fontWeight: 600, color: '#64748B',
              letterSpacing: '0.04em', textTransform: 'uppercase' }}>{_t('hero.returns.l3')}</span>
            <span style={{ fontSize: 11, fontWeight: 800, color: '#12b76a',
              fontFamily: 'JetBrains Mono, monospace',
              fontVariantNumeric: 'tabular-nums' }}>{restockRate}%</span>
          </div>
        </div>

        <style>{`
          @keyframes returns-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>
    </SlugFrame>
  );
}

// ——— Product Classification: video-backed HS/HTS classification hero with live telemetry
function ProductClassificationHero() {
  const [t, setT] = useStateSh(0);
  const pcVideoRef = useRefSh(null);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayPcVideo = () => {
    const v = pcVideoRef.current;
    if (!v) return;
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = pcVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting && v.ended) replayPcVideo(); });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Live-feeling metrics
  const skusClassified = (1847 + Math.floor(t / 4)).toLocaleString();
  const accuracy = (99.2 + Math.sin(t * 0.04) * 0.15).toFixed(2);
  // Candidate HS codes cycle through — simulate an AI suggestion + attorney review cycle
  const candidates = ['8471.30', '8517.62', '8528.72', '9013.80'];
  const cIdx = Math.floor((t / 180) % candidates.length);
  const hsCode = candidates[cIdx];
  const confidence = Math.min(99, 86 + Math.round(Math.sin(t * 0.05) * 6 + (cIdx * 2)));

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const PC_VIDEO_URL = '../uploads/optimized/product-classification.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer ——— */}
        <video
          ref={pcVideoRef}
          autoPlay muted playsInline preload="metadata"
          onClick={replayPcVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/product-classification.jpg">
          <source src={PC_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint for consistency with sibling service heroes */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live classification telemetry card (top-left) ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 196, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'pc-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>HS MATCH</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>SKU-{48271 + cIdx}</span>
          </div>

          {/* HS code display */}
          <div style={{ fontSize: 10, fontWeight: 600, color: '#64748B',
            letterSpacing: '0.04em', textTransform: 'uppercase', marginBottom: 2 }}>{_t('hero.classify.htsCode')}</div>
          <div style={{ fontSize: 22, fontWeight: 800, color: '#0B1220',
            letterSpacing: '-0.01em', fontFamily: 'JetBrains Mono, monospace',
            fontVariantNumeric: 'tabular-nums', marginBottom: 10, transition: 'opacity 300ms ease' }}>
            {hsCode}
          </div>

          {/* Confidence bar */}
          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginBottom: 4 }}>
            <span style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
              letterSpacing: '1.2px', fontFamily: 'JetBrains Mono, monospace' }}>CONFIDENCE</span>
            <span style={{ fontSize: 10, color: '#0B1220', fontWeight: 800,
              fontFamily: 'JetBrains Mono, monospace', fontVariantNumeric: 'tabular-nums' }}>
              {confidence}%
            </span>
          </div>
          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${confidence}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999,
              transition: 'width 400ms ease' }}/>
          </div>

          {/* Stats row */}
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>SKUs TODAY</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>{skusClassified}</div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ACCURACY</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>
                {accuracy}<span style={{ color: '#94A3B8', fontSize: 9 }}>%</span>
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes pc-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['2.1M',  _t('hero.classify.l1')],
        ['99.4%', _t('hero.classify.l2')],
        ['24',    _t('hero.classify.l3')],
      ]}/>
    </SlugFrame>
  );
}

// ——— Trade Advisory: video-backed advisory hero with live engagement telemetry
function TradeAdvisoryHero() {
  const [t, setT] = useStateSh(0);
  const taVideoRef = useRefSh(null);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayTaVideo = () => {
    const v = taVideoRef.current;
    if (!v) return;
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = taVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting && v.ended) replayTaVideo(); });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Live-feeling metrics
  const savings = (2.38 + (t / 6000)).toFixed(2);
  // Advisory scenarios cycle through
  const scenarios = [
    { code: 'FTA · USMCA', impact: '−12.4%' },
    { code: 'SEC 301 · $9903', impact: '−18.2%' },
    { code: 'FIRST SALE', impact: '−7.8%' },
    { code: 'FTZ · ADMIT', impact: '−24.1%' },
  ];
  const sIdx = Math.floor((t / 180) % scenarios.length);
  const scenario = scenarios[sIdx];
  const riskScore = Math.max(8, 14 - Math.floor(t / 240) % 10);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const TA_VIDEO_URL = '../uploads/optimized/trade-advisory.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer ——— */}
        <video
          ref={taVideoRef}
          autoPlay muted playsInline preload="metadata"
          onClick={replayTaVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/trade-advisory.jpg">
          <source src={TA_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint for consistency with sibling service heroes */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live advisory telemetry card (top-left) ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          transform: 'scale(0.8)', transformOrigin: 'top left',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 204, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'ta-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>ADVISORY</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>CASE-{4821 + sIdx}</span>
          </div>

          {/* Scenario being modeled */}
          <div style={{ fontSize: 10, fontWeight: 600, color: '#64748B',
            letterSpacing: '0.04em', textTransform: 'uppercase', marginBottom: 2 }}>{_t('hero.advisory.scenario')}</div>
          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            gap: 8, marginBottom: 10 }}>
            <div style={{ fontSize: 13, fontWeight: 800, color: '#0B1220',
              letterSpacing: '-0.01em', fontFamily: 'JetBrains Mono, monospace' }}>
              {scenario.code}
            </div>
            <div style={{ fontSize: 14, fontWeight: 800, color: '#1E57D6',
              fontFamily: 'JetBrains Mono, monospace',
              fontVariantNumeric: 'tabular-nums' }}>{scenario.impact}</div>
          </div>

          {/* Risk score bar */}
          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginBottom: 4 }}>
            <span style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
              letterSpacing: '1.2px', fontFamily: 'JetBrains Mono, monospace' }}>AUDIT RISK</span>
            <span style={{ fontSize: 10, color: '#0B1220', fontWeight: 800,
              fontFamily: 'JetBrains Mono, monospace', fontVariantNumeric: 'tabular-nums' }}>
              {riskScore}/100
            </span>
          </div>
          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${riskScore}%`,
              background: 'linear-gradient(90deg, #22C55E, #1E57D6)', borderRadius: 9999,
              transition: 'width 400ms ease' }}/>
          </div>

          {/* Stats row */}
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>SAVINGS/YR</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>
                $<span>{savings}</span><span style={{ color: '#94A3B8', fontSize: 9 }}>M</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>RULINGS</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>1,240</div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes ta-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>
    </SlugFrame>
  );
}

// ——— Duty Optimization: video-backed hero with live savings stack telemetry
function DutyOptimizationHero() {
  const [t, setT] = useStateSh(0);
  const doVideoRef = useRefSh(null);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayDoVideo = () => {
    const v = doVideoRef.current;
    if (!v) return;
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = doVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting && v.ended) replayDoVideo(); });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Mechanisms cycle through — FTA / First-sale / FTZ / Tariff engineering
  const mechanisms = [
    { code: 'FTA · USMCA',       impact: '−12.4%' },
    { code: 'FIRST SALE',        impact: '−7.8%' },
    { code: 'FTZ · ADMIT',       impact: '−24.1%' },
    { code: 'TARIFF ENG · 8471', impact: '−9.6%' },
  ];
  const mIdx = Math.floor((t / 180) % mechanisms.length);
  const mech = mechanisms[mIdx];
  // Effective duty rate dropping live
  const effRate = (9.4 - Math.sin(t * 0.04) * 0.4 - (mIdx * 0.2)).toFixed(1);
  // Stack depth — how many mechanisms are layered on this engagement
  const stackDepth = Math.min(100, 42 + Math.round(Math.sin(t * 0.05) * 8 + (mIdx * 12)));

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const DO_VIDEO_URL = '../uploads/optimized/duty-optimization.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, autostops) ——— */}
        <video
          ref={doVideoRef}
          autoPlay muted playsInline preload="metadata"
          onClick={replayDoVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/duty-optimization.jpg">
          <source src={DO_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint for consistency with sibling service heroes */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live duty savings telemetry card (top-left, 80%) ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          transform: 'scale(0.8)', transformOrigin: 'top left',
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 204, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'do-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>SAVINGS STACK</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>ENG-{2184 + mIdx}</span>
          </div>

          {/* Mechanism being stacked */}
          <div style={{ fontSize: 10, fontWeight: 600, color: '#64748B',
            letterSpacing: '0.04em', textTransform: 'uppercase', marginBottom: 2 }}>{_t('hero.duty.mechanism')}</div>
          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            gap: 8, marginBottom: 10 }}>
            <div style={{ fontSize: 13, fontWeight: 800, color: '#0B1220',
              letterSpacing: '-0.01em', fontFamily: 'JetBrains Mono, monospace' }}>
              {mech.code}
            </div>
            <div style={{ fontSize: 14, fontWeight: 800, color: '#1E57D6',
              fontFamily: 'JetBrains Mono, monospace',
              fontVariantNumeric: 'tabular-nums' }}>{mech.impact}</div>
          </div>

          {/* Stack depth */}
          <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between',
            marginBottom: 4 }}>
            <span style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
              letterSpacing: '1.2px', fontFamily: 'JetBrains Mono, monospace' }}>STACK DEPTH</span>
            <span style={{ fontSize: 10, color: '#0B1220', fontWeight: 800,
              fontFamily: 'JetBrains Mono, monospace', fontVariantNumeric: 'tabular-nums' }}>
              {stackDepth}%
            </span>
          </div>
          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${stackDepth}%`,
              background: 'linear-gradient(90deg, #22C55E, #1E57D6)', borderRadius: 9999,
              transition: 'width 400ms ease' }}/>
          </div>

          {/* Stats row */}
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>EFF. DUTY</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>
                {effRate}<span style={{ color: '#94A3B8', fontSize: 9 }}>%</span>
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>FTZ ACCTS</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700,
                fontVariantNumeric: 'tabular-nums' }}>38</div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes do-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>
    </SlugFrame>
  );
}

// ——— Tradeshow Logistics: convention floor video + live event telemetry
function TradeshowHero() {
  const [t, setT] = useStateSh(0);
  const tsVideoRef = useRefSh(null);
  const [tsVideoEnded, setTsVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayTsVideo = () => {
    const v = tsVideoRef.current;
    if (!v) return;
    setTsVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view
  useEffectSh(() => {
    const v = tsVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => { if (e.isIntersecting && v.ended) replayTsVideo(); });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Progress bar tracks video playback (or just animates if video missing)
  const forkProgress = (t * 0.5) % 100;

  // ETA countdown
  const etaBase = 252;
  const etaMin = Math.max(1, etaBase - Math.floor(t / 60));
  const eh = String(Math.floor(etaMin / 60));
  const em = String(etaMin % 60).padStart(2, '0');

  // CWT counter
  const cwt = (1840 + Math.floor(t / 8)).toLocaleString();

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const TS_VIDEO_URL = '../uploads/optimized/tradeshow.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>

        {/* ——— Convention floor video ——— */}
        <video
          ref={tsVideoRef}
          autoPlay muted playsInline preload="metadata"
          onEnded={() => setTsVideoEnded(true)}
          onClick={replayTsVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }} poster="../assets/posters/tradeshow.jpg">
          <source src={TS_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint so the video blends with the rest of the palette */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.10) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live Show-Day telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, right: 22,
          background: 'rgba(255,255,255,0.96)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 200, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'ts-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>SHOW DAY</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>BOOTH #3056</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>ADV</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>LVCC</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0,
              width: `${Math.min(100, 14 + forkProgress * 0.78)}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999,
              transition: 'width 200ms linear' }}/>
            <div style={{ position: 'absolute',
              left: `${Math.min(100, 14 + forkProgress * 0.78)}%`, top: -2, width: 8, height: 8,
              borderRadius: 9999, background: '#fff', border: '2px solid #1E57D6',
              boxShadow: '0 0 0 3px rgba(30,87,214,0.15)',
              transform: 'translateX(-4px)' }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>CWT</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>{cwt}</div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>TARGET</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {eh}h {em}m
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes ts-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      <MetricStrip items={[
        ['940+',  _t('hero.tradeshow.l1')],
        ['99.6%', _t('hero.tradeshow.l2')],
        ['3,800', _t('hero.tradeshow.l3')],
      ]}/>
    </SlugFrame>
  );
}

// ——— Transloading: video hero + cross-dock telemetry card
function TransloadingHero() {
  const [t, setT] = useStateSh(0);
  const tlVideoRef = useRefSh(null);
  const [tlVideoEnded, setTlVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayTlVideo = () => {
    const v = tlVideoRef.current;
    if (!v) return;
    setTlVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  // Auto-replay when hero scrolls back into view after ending
  useEffectSh(() => {
    const v = tlVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayTlVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const sortPct = 88 + Math.floor(Math.sin(t * 0.04) * 6 + 6);
  const etaH = 24 - Math.floor((t / 90) % 12);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const TL_VIDEO_URL = '../uploads/grok-video-59dfff60-e4ba-4073-a192-ddc1e157bb9d-1c243751.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <video
          ref={tlVideoRef}
          autoPlay muted playsInline preload="auto"
          onEnded={() => setTlVideoEnded(true)}
          onClick={replayTlVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }}>
          <source src={TL_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 230, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'tl-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>SORTING</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>DOCK-7</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>OCEAN → 53′ VAN</span>
            <span style={{ marginLeft: 'auto', fontSize: 9, fontWeight: 700, color: '#1846B0',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px',
              background: '#DCE9FB', padding: '2px 6px', borderRadius: 4 }}>CROSS-DOCK</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${sortPct}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 10,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>DOCK-IN</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>06:14</div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>SORT</div>
              <div style={{ fontSize: 13, color: '#12b76a', fontWeight: 700 }}>{sortPct}%</div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>DEPART</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>+{etaH}h</div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes tl-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {tlVideoEnded && (
        <MetricStrip items={[['<24h','dock dwell'],['6+','inbound modes'],['24/7','ops']]}/>
      )}
    </SlugFrame>
  );
}

// ——— Personal Storage: video hero + climate telemetry card
function PersonalStorageHero() {
  const [t, setT] = useStateSh(0);
  const psVideoRef = useRefSh(null);
  const [psVideoEnded, setPsVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayPsVideo = () => {
    const v = psVideoRef.current;
    if (!v) return;
    setPsVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = psVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayPsVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const temp = (68 + Math.sin(t * 0.04) * 1.2).toFixed(1);
  const rh   = (44 + Math.sin(t * 0.03) * 2.5).toFixed(0);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const PS_VIDEO_URL = '../uploads/grok-video-7d2c1041-1567-49d5-b014-a0a39a34645d.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <video
          ref={psVideoRef}
          autoPlay muted playsInline preload="auto"
          onEnded={() => setPsVideoEnded(true)}
          onClick={replayPsVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }}>
          <source src={PS_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 220, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'ps-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>CLIMATE OK</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>BAY 14×40</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>PALLET STORAGE</span>
            <span style={{ marginLeft: 'auto', fontSize: 9, fontWeight: 700, color: '#1846B0',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px',
              background: '#DCE9FB', padding: '2px 6px', borderRadius: 4 }}>24/7</span>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 10,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>TEMP</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>{temp}°F</div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>HUMIDITY</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>{rh}% RH</div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes ps-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {psVideoEnded && (
        <MetricStrip items={[['Pickup','or drop-off'],['1mo','min term'],['48h','move-in']]}/>
      )}
    </SlugFrame>
  );
}

// ——— Vehicle & Boat Storage: video hero + battery / engine-start telemetry
function VehicleBoatHero() {
  const [t, setT] = useStateSh(0);
  const vbVideoRef = useRefSh(null);
  const [vbVideoEnded, setVbVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayVbVideo = () => {
    const v = vbVideoRef.current;
    if (!v) return;
    setVbVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = vbVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayVbVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const battPct = 88 + Math.floor(Math.sin(t * 0.04) * 6 + 6);
  const days = (14 - Math.floor((t / 90) % 14));

  const palette = { bg1: '#EEF2FA', bg2: '#DCE5F4', border: '#CCD7EC' };
  const VB_VIDEO_URL = '../uploads/grok-video-a3ad9977-e8bd-4e1b-a4c3-dbafe7c6a0f0-05821504.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <video
          ref={vbVideoRef}
          autoPlay muted playsInline preload="auto"
          onEnded={() => setVbVideoEnded(true)}
          onClick={replayVbVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }}>
          <source src={VB_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 210, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'vb-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>MONITORED</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>BAY-12</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>CORVETTE C8</span>
            <span style={{ marginLeft: 'auto', fontSize: 9, fontWeight: 700, color: '#1846B0',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px',
              background: '#DCE9FB', padding: '2px 6px', borderRadius: 4 }}>INDOOR</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: `${battPct}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>BATT</div>
              <div style={{ fontSize: 13, color: '#12b76a', fontWeight: 700 }}>
                {battPct}%
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>NEXT START</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {days}d
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes vb-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {vbVideoEnded && (
        <MetricStrip items={[['Indoor + covered','options'],['14d','engine starts'],['24/7','monitored']]}/>
      )}
    </SlugFrame>
  );
}

// ——— Storage & Distribution: pallet warehouse video + live picking telemetry
function StorageDistributionHero() {
  const [t, setT] = useStateSh(0);
  const sdVideoRef = useRefSh(null);
  const [sdVideoEnded, setSdVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replaySdVideo = () => {
    const v = sdVideoRef.current;
    if (!v) return;
    setSdVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = sdVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replaySdVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const accuracy = (99.92 + (Math.sin(t * 0.05) * 0.05 + 0.05)).toFixed(2);
  const palletsOut = 142 + Math.floor((t / 60) % 12);

  const palette = { bg1: '#F0F6FF', bg2: '#DCE9FB', border: '#CCDCF5' };
  const SD_VIDEO_URL = '../uploads/grok-video-fca651ff-ba6a-475b-982e-4c6fce49c51d.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <video
          ref={sdVideoRef}
          autoPlay muted playsInline preload="auto"
          onEnded={() => setSdVideoEnded(true)}
          onClick={replaySdVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }}>
          <source src={SD_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live wave telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 230, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'sd-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>PICKING</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>WAVE 14:00</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>OUTBOUND · 53′ VAN</span>
            <span style={{ marginLeft: 'auto', fontSize: 9, fontWeight: 700, color: '#1846B0',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px',
              background: '#DCE9FB', padding: '2px 6px', borderRadius: 4 }}>WMS LIVE</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0,
              width: `${68 + Math.floor(Math.sin(t * 0.04) * 12 + 12)}%`,
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 10,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>PALLETS</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>{palletsOut}</div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>ACCURACY</div>
              <div style={{ fontSize: 13, color: '#12b76a', fontWeight: 700 }}>{accuracy}%</div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes sd-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {sdVideoEnded && (
        <MetricStrip items={[['99.97%','accuracy'],['3','daily waves'],['Manhattan','active WMS']]}/>
      )}
    </SlugFrame>
  );
}

// ——— Buy & Hold: parcel-consolidation video + live "5 → 1 box" savings card
function BuyAndHoldHero() {
  const [t, setT] = useStateSh(0);
  const bhVideoRef = useRefSh(null);
  const [bhVideoEnded, setBhVideoEnded] = useStateSh(false);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayBhVideo = () => {
    const v = bhVideoRef.current;
    if (!v) return;
    setBhVideoEnded(false);
    try { v.currentTime = 0; } catch {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = bhVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayBhVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  // Live consolidation telemetry — counters tick during playback
  const boxesIn = 4 + Math.floor((t / 90) % 8);
  const savedPct = 40 + Math.min(28, Math.floor((t / 14) % 30));

  const palette = { bg1: '#F4F8FE', bg2: '#E5EEFB', border: '#D5E2F6' };
  const BH_VIDEO_URL = '../uploads/grok-video-1b066bc8-70c7-4477-9c5a-2aefd316406a.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        {/* ——— Video motion layer (plays once, click to replay) ——— */}
        <video
          ref={bhVideoRef}
          autoPlay muted playsInline preload="auto"
          onEnded={() => setBhVideoEnded(true)}
          onClick={replayBhVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }}>
          <source src={BH_VIDEO_URL} type="video/mp4"/>
        </video>

        {/* Brand-blue tint for consistency with sibling service heroes */}
        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.08) 100%)',
          pointerEvents: 'none' }}/>

        {/* ——— Live consolidation telemetry card ——— */}
        <div style={{ position: 'absolute', top: 22, left: 22,
          background: 'rgba(255,255,255,0.95)',
          backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
          border: '1px solid rgba(191,219,254,0.95)',
          borderRadius: 12, padding: '12px 14px',
          boxShadow: '0 14px 28px -12px rgba(16,24,40,0.22)',
          minWidth: 210, fontFamily: 'Inter, sans-serif' }}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
            marginBottom: 8 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
              <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
                boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
                animation: 'bh-pulse 1.6s ease-in-out infinite' }}/>
              <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
                fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>HOLDING</span>
            </div>
            <span style={{ fontSize: 9, fontWeight: 700, color: '#64748B',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>SUITE-WB-204</span>
          </div>

          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 10 }}>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>USA</span>
            <svg width="30" height="8" viewBox="0 0 30 8">
              <path d="M 0 4 L 24 4 M 20 1 L 24 4 L 20 7" stroke="#1E57D6" strokeWidth="1.4"
                fill="none" strokeLinecap="round" strokeLinejoin="round"/>
            </svg>
            <span style={{ fontSize: 13, fontWeight: 800, color: '#0B1220', letterSpacing: '-0.01em' }}>WORLD</span>
            <span style={{ marginLeft: 'auto', fontSize: 9, fontWeight: 700, color: '#1846B0',
              fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px',
              background: '#DCE9FB', padding: '2px 6px', borderRadius: 4 }}>1 PARCEL</span>
          </div>

          <div style={{ position: 'relative', height: 4, borderRadius: 9999,
            background: '#EFF2F6', marginBottom: 10, overflow: 'hidden' }}>
            <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: '100%',
              background: 'linear-gradient(90deg, #2E6AE8, #1E57D6)', borderRadius: 9999 }}/>
          </div>

          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8,
            fontFamily: 'JetBrains Mono, monospace' }}>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>BOXES</div>
              <div style={{ fontSize: 13, color: '#0B1220', fontWeight: 700 }}>
                {boxesIn}
              </div>
            </div>
            <div>
              <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
                letterSpacing: '1.2px', marginBottom: 1 }}>SAVED</div>
              <div style={{ fontSize: 13, color: '#12b76a', fontWeight: 700 }}>
                {savedPct}%
              </div>
            </div>
          </div>
        </div>

        <style>{`
          @keyframes bh-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
        `}</style>
      </div>

      {bhVideoEnded && (
        <MetricStrip items={[['40–70%','shipping saved'],['60d','free hold'],['220+','countries']]}/>
      )}
    </SlugFrame>
  );
}

// ——— Compras Internacionales: video of warehouse + worldwide reach badges,
// with live receiving/shipping telemetry. Plays once on load (with auto-replay
// when scrolled back into view); click anywhere on the video to replay.
function ComprasInternacionalesHero() {
  const [t, setT] = useStateSh(0);
  const ciVideoRef = useRefSh(null);
  useEffectSh(() => {
    let r; const loop = () => { setT(x => x + 1); r = requestAnimationFrame(loop); };
    r = requestAnimationFrame(loop);
    return () => cancelAnimationFrame(r);
  }, []);

  const replayCiVideo = () => {
    const v = ciVideoRef.current;
    if (!v) return;
    try { v.currentTime = 0; } catch (_) {}
    const p = v.play();
    if (p && typeof p.catch === 'function') p.catch(() => {});
  };

  useEffectSh(() => {
    const v = ciVideoRef.current;
    if (!v || typeof IntersectionObserver === 'undefined') return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting && v.ended) replayCiVideo();
      });
    }, { threshold: 0.35 });
    io.observe(v);
    return () => io.disconnect();
  }, []);

  const packagesIn = 3 + Math.floor((t / 80) % 9);
  const consolidatedOut = 1 + Math.floor((t / 200) % 4);
  const savedPct = 42 + Math.min(26, Math.floor((t / 16) % 28));

  const palette = { bg1: '#F4F8FE', bg2: '#E5EEFB', border: '#D5E2F6' };
  const CI_VIDEO_URL = '../uploads/grok-video-97b06b4b-1b6a-419f-a46e-e8dab79121d5-4cc6ba5f.mp4';

  return (
    <SlugFrame palette={palette}>
      <div style={{ position: 'absolute', inset: 0, overflow: 'hidden' }}>
        <video
          ref={ciVideoRef}
          autoPlay muted playsInline preload="auto"
          onClick={replayCiVideo}
          style={{ position: 'absolute', inset: 0, width: '100%', height: '100%',
            objectFit: 'cover', cursor: 'pointer',
            WebkitMaskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)',
            maskImage: 'linear-gradient(180deg, #000 0%, #000 82%, rgba(0,0,0,0.85) 94%, rgba(0,0,0,0.7) 100%)' }}>
          <source src={CI_VIDEO_URL} type="video/mp4"/>
        </video>

        <div aria-hidden style={{ position: 'absolute', inset: 0,
          background: 'linear-gradient(180deg, rgba(240,246,255,0.08) 0%, rgba(30,87,214,0.10) 100%)',
          pointerEvents: 'none' }}/>
      </div>

      {/* Warehouse callout — top left */}
      <div style={{ position: 'absolute', left: 22, top: 22,
        background: 'rgba(255,255,255,0.96)',
        backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
        border: '1px solid rgba(191,219,254,0.95)',
        borderRadius: 12, padding: '10px 12px',
        boxShadow: '0 18px 36px -14px rgba(16,24,40,0.28)',
        fontFamily: 'Inter, sans-serif', minWidth: 168 }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6 }}>
          <span style={{ width: 6, height: 6, borderRadius: 9999, background: '#22C55E',
            boxShadow: '0 0 0 3px rgba(34,197,94,0.2)',
            animation: 'ci-pulse 1.6s ease-in-out infinite' }}/>
          <span style={{ fontSize: 9, fontWeight: 700, color: '#22C55E',
            fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.4px' }}>
            {_t('hero.compras.receiving', 'RECEIVING')}
          </span>
        </div>
        <div style={{ fontSize: 13, fontWeight: 800, color: '#0B1220',
          letterSpacing: '-0.01em', marginBottom: 2 }}>
          {_t('hero.compras.warehouse', 'US Warehouse')}
        </div>
        <div style={{ fontSize: 10, color: '#64748B',
          fontFamily: 'JetBrains Mono, monospace', letterSpacing: '0.04em' }}>
          SUITE-WB-{(204 + (t / 200 | 0) % 12)}
        </div>
      </div>

      {/* Live telemetry — bottom right */}
      <div style={{ position: 'absolute', bottom: 80, right: 22,
        background: 'rgba(255,255,255,0.96)',
        backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
        border: '1px solid rgba(191,219,254,0.95)',
        borderRadius: 12, padding: '12px 14px',
        boxShadow: '0 18px 36px -14px rgba(16,24,40,0.28)',
        fontFamily: 'Inter, sans-serif', minWidth: 220 }}>
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          marginBottom: 10 }}>
          <span style={{ fontSize: 10, fontWeight: 700, color: '#1846B0',
            fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1.2px' }}>
            {_t('hero.compras.liveflow', 'LIVE FLOW')}
          </span>
          <span style={{ fontSize: 9, fontWeight: 700, color: '#94A3B8',
            fontFamily: 'JetBrains Mono, monospace', letterSpacing: '1px' }}>24H</span>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 10,
          fontFamily: 'JetBrains Mono, monospace' }}>
          <div>
            <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
              letterSpacing: '1.2px', marginBottom: 2 }}>
              {_t('hero.compras.received', 'RECEIVED')}
            </div>
            <div style={{ fontSize: 14, color: '#0B1220', fontWeight: 700,
              fontVariantNumeric: 'tabular-nums' }}>{packagesIn}</div>
          </div>
          <div>
            <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
              letterSpacing: '1.2px', marginBottom: 2 }}>
              {_t('hero.compras.shipped', 'SHIPPED')}
            </div>
            <div style={{ fontSize: 14, color: '#0EA5E9', fontWeight: 700,
              fontVariantNumeric: 'tabular-nums' }}>{consolidatedOut}</div>
          </div>
          <div>
            <div style={{ fontSize: 8, color: '#94A3B8', fontWeight: 700,
              letterSpacing: '1.2px', marginBottom: 2 }}>
              {_t('hero.compras.savings', 'SAVED')}
            </div>
            <div style={{ fontSize: 14, color: '#12b76a', fontWeight: 700,
              fontVariantNumeric: 'tabular-nums' }}>{savedPct}%</div>
          </div>
        </div>
      </div>

      {/* Micro-flow chips — across the bottom */}
      <div style={{ position: 'absolute', left: 22, bottom: 22, right: 22,
        display: 'flex', gap: 8, flexWrap: 'nowrap',
        fontFamily: 'Inter, sans-serif' }}>
        {[
          { ic: '📦', labelKey: 'hero.compras.flow.receive',     fb: 'Receive' },
          { ic: '📸', labelKey: 'hero.compras.flow.photos',      fb: 'Photos' },
          { ic: '📦', labelKey: 'hero.compras.flow.consolidate', fb: 'Consolidate' },
          { ic: '✈️', labelKey: 'hero.compras.flow.ship',        fb: 'Ship' },
        ].map((s, i) => (
          <div key={i} style={{ flex: 1, minWidth: 0,
            background: 'rgba(255,255,255,0.95)',
            backdropFilter: 'blur(8px)', WebkitBackdropFilter: 'blur(8px)',
            border: '1px solid rgba(191,219,254,0.85)',
            borderRadius: 10, padding: '8px 10px',
            display: 'flex', alignItems: 'center', gap: 6,
            boxShadow: '0 8px 18px -10px rgba(16,24,40,0.18)' }}>
            <span style={{ fontSize: 14, lineHeight: 1 }}>{s.ic}</span>
            <span style={{ fontSize: 11, fontWeight: 700, color: '#0B1220',
              letterSpacing: '-0.005em', whiteSpace: 'nowrap',
              overflow: 'hidden', textOverflow: 'ellipsis' }}>{_t(s.labelKey, s.fb)}</span>
            {i < 3 && (
              <svg width="14" height="8" viewBox="0 0 14 8" style={{ marginLeft: 'auto', flexShrink: 0 }}>
                <path d="M 0 4 L 11 4 M 8 1 L 11 4 L 8 7" stroke="#1E57D6" strokeWidth="1.2"
                  fill="none" strokeLinecap="round" strokeLinejoin="round" opacity="0.6"/>
              </svg>
            )}
          </div>
        ))}
      </div>

      {/* Top-right badges */}
      <div style={{ position: 'absolute', top: 22, right: 22,
        display: 'flex', flexDirection: 'column', gap: 6, alignItems: 'flex-end' }}>
        <div style={{
          background: 'linear-gradient(135deg, #1E57D6 0%, #2E6AE8 100%)',
          color: '#fff',
          borderRadius: 9999, padding: '7px 13px 7px 9px',
          display: 'inline-flex', alignItems: 'center', gap: 7,
          boxShadow: '0 14px 28px -10px rgba(30,87,214,0.45)',
          fontFamily: 'Inter, sans-serif', fontSize: 11.5, fontWeight: 700,
          letterSpacing: '-0.005em' }}>
          <span style={{ width: 18, height: 18, borderRadius: 9999,
            background: 'rgba(255,255,255,0.18)',
            display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
            fontSize: 10 }}>📍</span>
          {_t('hero.compras.badge.address', 'US address included')}
        </div>
        <div style={{
          background: 'rgba(255,255,255,0.96)',
          color: '#0B1220',
          border: '1px solid rgba(34,197,94,0.45)',
          borderRadius: 9999, padding: '6px 11px 6px 8px',
          display: 'inline-flex', alignItems: 'center', gap: 6,
          boxShadow: '0 10px 22px -10px rgba(16,24,40,0.22)',
          fontFamily: 'Inter, sans-serif', fontSize: 11, fontWeight: 700,
          letterSpacing: '-0.005em' }}>
          <span style={{ width: 14, height: 14, borderRadius: 9999,
            background: '#22C55E', color: '#fff',
            display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
            fontSize: 9, fontWeight: 800 }}>✓</span>
          {_t('hero.compras.badge.taxfree', 'Tax-free warehouse')}
        </div>
      </div>

      <style>{`
        @keyframes ci-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
      `}</style>
    </SlugFrame>
  );
}

// ——— Map to the right hero per slug
const HERO_BY_SLUG = {
  'less-than-container':  () => <LCLHero/>,
  'buyers-consolidation': () => <BuyersConsHero/>,
  'trucking':             () => <TruckingHero/>,
  'break-bulk':           () => <BreakBulkHero/>,
  'air-freight':          () => <AirFreightHero/>,
  'order-management':     () => <OrderMgmtHero/>,
  'mexico-shipping':      () => <MexicoHero/>,
  'd2c-fulfillment':      () => <D2CHero/>,
  'wholesale-fulfillment':() => <WholesaleHero/>,
  'prep':                 () => <PrepHero/>,
  'duty-drawback':        () => <DrawbackHero/>,
  'frozen-logistics':     () => <FrozenHero/>,
  'warehousing':          () => <WarehousingHero/>,
  'storage-distribution': () => <StorageDistributionHero/>,
  'warehouse-relocation': () => <WarehouseRelocationHero/>,
  'automotive-logistics': () => <AutomotiveHero/>,
  'cargo-insurance':      () => <CargoInsuranceHero/>,
  'booking-management':   () => <OrchestrationHero/>,
  'replenishment':        () => <ReplenishmentHero/>,
  'parcel':               () => <ParcelHero/>,
  'purchasing-agent':     () => <PurchasingAgentHero/>,
  'returns':              () => <ReturnsHero/>,
  'product-classification': () => <ProductClassificationHero/>,
  'trade-advisory':       () => <TradeAdvisoryHero/>,
  'duty-optimization':    () => <DutyOptimizationHero/>,
  'tradeshow-logistics':  () => <TradeshowHero/>,
  'transloading':         () => <TransloadingHero/>,
  'vehicle-boat-storage': () => <VehicleBoatHero/>,
  'buy-and-hold':         () => <BuyAndHoldHero/>,
  'personal-storage':     () => <PersonalStorageHero/>,
  'compras-internacionales': () => <ComprasInternacionalesHero/>,
};

function ServiceHero({ slug, icon, accent }) {
  const H = HERO_BY_SLUG[slug];
  if (H) return <H/>;
  return <GenericHero slug={slug} icon={icon} accent={accent}/>;
}

window.ServiceHero = ServiceHero;
