/* ============================================================
   UGO MONYE — Collage Hero  (asymmetric 6-panel video mosaic)
   ============================================================
   Six panels of uneven size, each an autoplay/muted/looped video —
   real Ugo Monye reels — layered over a full-colour Ugo Monye
   still as the instant-paint fallback. Two reels (v1, v5) ship in
   this project; the other four (v2, v1_27s, v3, v4) are large and
   served from deploy storage, referenced here by their uploads/
   path — in this editor preview only their poster stills render,
   which is expected. Text overlay cycles headline sets every 6 s.
   To swap imagery: update POSTERS / VIDEOS arrays below.
   ============================================================ */

/* Real Ugo Monye stills — full colour, no wash, used as fallback */
const POSTERS = [
(window.RB_IMGS && window.RB_IMGS["LOOK 01 · AGBADA"]) || "",
(window.RB_IMGS && window.RB_IMGS["FESTIVE · OWAMBE"]) || "",
(window.RB_IMGS && window.RB_IMGS["EDITORIAL · ATELIER"]) || "",
(window.RB_IMGS && window.RB_IMGS["COLLECTION · WEDDING"]) || "",
(window.RB_IMGS && window.RB_IMGS["EDITORIAL · THE GROOM"]) || "",
(window.RB_IMGS && window.RB_IMGS["KAFTAN · EVENING"]) || ""];

/* Real Ugo Monye reels — six clips across the six mosaic panels */
const VIDEOS = [
"https://storage.googleapis.com/prospect-assets-the-collective-synergy-production/ugomonye-storefront/ugo_v1_65s.mp4",
"ugo_v2_36s.mp4",
"https://storage.googleapis.com/prospect-assets-the-collective-synergy-production/ugomonye-storefront/ugo_v1_27s.mp4",
"ugo_v3_30s.mp4",
"ugo_v4_45s.mp4",
"ugo_v5_14s.mp4"];


const SLIDES = [
{
  eyebrow: "Ugo Monye · Made in Lagos",
  h: ["Dressed in", "Royalty."],
  cta: "Shop Bespoke",
  ctaFn: (nav) => nav("shop", {})
},
{
  eyebrow: "The Groom's Atelier · Agbada & Tuxedos",
  h: ["Dressed for", "Forever."],
  cta: "Explore Wedding",
  ctaFn: (nav) => nav("shop", { cat: "Agbada" })
},
{
  eyebrow: "Owambe Season · Bespoke",
  h: ["Show up.", "Show out."],
  cta: "Shop the Collection",
  ctaFn: (nav) => nav("shop", {})
}];


/* ── Single video strip (poster still behind an autoplay video) ── */
function ImageStrip({ src, videoSrc, delay, className = "" }) {
  return (
    <div className={"hcol-strip " + className}>
      <img
        className="hcol-media hcol-poster"
        src={src}
        alt=""
        aria-hidden="true"
        style={{ animationDelay: delay + "ms", opacity: 1 }} />
      {videoSrc ? (
        <video
          className="hcol-media"
          src={videoSrc}
          poster={src}
          autoPlay
          muted
          loop
          playsInline
          aria-hidden="true"
          style={{ animationDelay: delay + "ms" }} />
      ) : null}
    </div>);

}

/* ══════════════════════════════════════════════════════════
   MAIN COMPONENT
   ══════════════════════════════════════════════════════════ */
function HeroCollage({ onNav }) {
  const INTERVAL = 6000;

  const [idx, setIdx] = useState(0);
  const [textIn, setTextIn] = useState(true);

  useEffect(() => {
    const t = setInterval(() => {
      setTextIn(false);
      setTimeout(() => {
        setIdx((i) => (i + 1) % SLIDES.length);
        setTextIn(true);
      }, 450);
    }, INTERVAL);
    return () => clearInterval(t);
  }, []);

  const slide = SLIDES[idx];

  return (
    <section className="hero hcol-root" aria-label="Hero banner">

      {/* ── 6-panel asymmetric video mosaic ── */}
      <div className="hcol-strips" aria-hidden="true">
        <ImageStrip className="hcol-p1" src={POSTERS[0]} videoSrc={VIDEOS[0]} delay={0} />
        <ImageStrip className="hcol-p2" src={POSTERS[1]} videoSrc={VIDEOS[1]} delay={150} />
        <ImageStrip className="hcol-p3" src={POSTERS[2]} videoSrc={VIDEOS[2]} delay={300} />
        <ImageStrip className="hcol-p4" src={POSTERS[3]} videoSrc={VIDEOS[3]} delay={450} />
        <ImageStrip className="hcol-p5" src={POSTERS[4]} videoSrc={VIDEOS[4]} delay={600} />
        <ImageStrip className="hcol-p6" src={POSTERS[5]} videoSrc={VIDEOS[5]} delay={750} />
      </div>

      {/* Cinematic gradient overlay */}
      <div className="hcol-overlay" aria-hidden="true" />

      {/* Gold top rule */}
      <div className="hcol-top-rule" aria-hidden="true" />

      {/* Editorial text */}
      <div
        className={"hcol-content" + (textIn ? " hcol-content-in" : " hcol-content-out")}
        key={idx}>
        
        <p className="hcol-eyebrow mono">{slide.eyebrow}</p>
        <h1 className="display hcol-h">
          <span className="hcol-hline">{slide.h[0]}</span>
          <em className="hcol-hline hcol-hem">{slide.h[1]}</em>
        </h1>
        <div className="hcol-cta-row">
          <Btn onClick={() => slide.ctaFn(onNav)}>{slide.cta}</Btn>
          <Btn variant="ghost" arrow={false} className="on-dark"
          onClick={() => onNav("bespoke", {})}>
            Book a Fitting
          </Btn>
        </div>
      </div>



      {/* Bottom corner label */}
      <div className="hcol-corner mono" aria-hidden="true">
        {((window.BRAND && window.BRAND.name) || "Ugo Monye") + " · " + ((window.BRAND && window.BRAND.seasonTag) || "SS26")}
      </div>

      {/* Scroll pulse line */}
      <div className="hcol-scroll" aria-hidden="true">
        <span className="hcol-scroll-line" />
      </div>

    </section>);

}

Object.assign(window, { HeroCollage });