/* ============================================================
   HOME PAGE — The Bloom Company rebrand
   ============================================================ */
/* ── Video panel cycling hook ─────────────────────────────── */
function useVideoCycle(count, intervalMs) {
  const [active, setActive] = React.useState(0);
  const [pulsing, setPulsing] = React.useState(-1);
  const timer = React.useRef(null);
  const goTo = React.useCallback((idx) => {
    setActive((prev) => {if (prev === idx) return prev;setPulsing(idx);setTimeout(() => setPulsing(-1), 700);return idx;});
  }, []);
  const start = React.useCallback(() => {
    timer.current = setInterval(() => setActive((prev) => {const next = (prev + 1) % count;setPulsing(next);setTimeout(() => setPulsing(-1), 700);return next;}), intervalMs);
  }, [count, intervalMs]);
  const stop = React.useCallback(() => clearInterval(timer.current), []);
  React.useEffect(() => {start();return stop;}, [start, stop]);
  return { active, pulsing, goTo, start, stop };
}

function HomeHero() {
  const { nav } = useStore();
  const { active, pulsing, goTo, start, stop } = useVideoCycle(4, 4500);

  /* Four panels: real product photo posters + Mixkit free videos */
  const panels = [
  { poster: IMG.hero.main, src: 'uploads/Screen_Recording_20260613_132724_Instagram_web-86423510.mp4', label: 'Party setup' },
  { poster: IMG.hero.float, src: 'uploads/Screen_Recording_20260613_133025_Instagram_web-9d7bb52a.mp4', label: 'Balloon garland' },
  { poster: BB.IMG.cats.favours, src: 'uploads/Screen_Recording_20260613_133541_Instagram_web-f36c53d1.mp4', label: 'Kids celebrating' },
  { poster: BB.IMG.cats.edible, src: 'uploads/Screen_Recording_20260613_133822_Instagram_web-07802c1c.mp4', label: 'Party treats' }];


  /* Try to play all videos (needed on iOS) */
  const refs = React.useRef([]);
  React.useEffect(() => {
    refs.current.forEach((v) => v && v.play().catch(() => {}));
    const resume = () => refs.current.forEach((v) => v && v.play().catch(() => {}));
    document.addEventListener('pointerdown', resume, { once: true });
    return () => document.removeEventListener('pointerdown', resume);
  }, []);

  return (
    <section
      style={{ position: 'relative', width: '100%', height: '100svh', minHeight: 620, overflow: 'hidden', background: 'var(--ink)' }}
      onMouseEnter={stop}
      onMouseLeave={start}>
      
      {/* ── 4-panel grid ─────────────────────────────── */}
      <div style={{
        position: 'absolute', inset: 0,
        display: 'grid',
        gridTemplateColumns: 'repeat(4, 1fr)',
        gridTemplateRows: '1fr',
        gap: 3,
        background: 'linear-gradient(135deg, rgba(138,24,192,.6), rgba(240,32,127,.4))'
      }}>
        {panels.map((p, i) =>
        <div
          key={i}
          data-panel={i}
          onClick={() => {stop();goTo(i);start();}}
          style={{
            position: 'relative',
            overflow: 'hidden',
            cursor: 'pointer',
            gridColumn: i + 1,
            gridRow: '1'
          }}>
          
            {/* Video element */}
            <video
            ref={(el) => refs.current[i] = el}
            autoPlay muted loop playsInline
            poster={p.poster}
            aria-hidden="true"
            style={{
              position: 'absolute', inset: 0, width: '100%', height: '100%',
              objectFit: 'cover',
              animation: active === i ? 'kenburnsActive 18s ease-in-out infinite alternate' : 'kenburns 18s ease-in-out infinite alternate',
              willChange: 'transform'
            }}>
            
              <source src={p.src} type="video/mp4" />
            </video>

            {/* Scrim — dims inactive panels */}
            <div style={{
            position: 'absolute', inset: 0,
            background: active === i ? 'rgba(42,17,51,.06)' : 'rgba(42,17,51,.44)',
            transition: 'background 1.1s ease',
            zIndex: 1
          }} />

            {/* Pulse flash on activation */}
            {pulsing === i &&
          <div style={{
            position: 'absolute', inset: 0, zIndex: 2,
            background: 'rgba(255,255,255,.12)',
            animation: 'panelPulse .7s ease forwards'
          }} />
          }
          </div>
        )}
      </div>

      {/* ── Gradient overlays for text legibility ───── */}
      <div style={{ position: 'absolute', inset: 0, zIndex: 10, pointerEvents: 'none',
        background: 'radial-gradient(ellipse 90% 70% at 50% 50%, transparent 5%, rgba(42,17,51,.65) 100%)' }} />
      <div style={{ position: 'absolute', inset: 0, zIndex: 11, pointerEvents: 'none',
        background: 'linear-gradient(to bottom, rgba(42,17,51,.80) 0%, rgba(42,17,51,.55) 30%, rgba(42,17,51,.55) 70%, rgba(42,17,51,.80) 100%)' }} />

      {/* ── Content ──────────────────────────────────── */}
      <div style={{
        position: 'absolute', inset: 0, zIndex: 20,
        display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
        padding: 'clamp(90px,10vh,120px) clamp(24px,6vw,80px) clamp(70px,9vh,100px)',
        textAlign: 'center',
        pointerEvents: 'none'
      }}>
        {/* Eyebrow */}
        <p style={{
          display: 'inline-flex', alignItems: 'center', gap: 14,
          fontFamily: 'var(--sans)', fontSize: 11, fontWeight: 500, letterSpacing: '.28em', textTransform: 'uppercase',
          color: 'rgba(255,255,255,.70)', marginBottom: 26,
          animation: 'fadeUpHero .9s .35s both'
        }}>
          <span style={{ display: 'block', width: 36, height: 1, background: 'linear-gradient(90deg, transparent, rgba(240,32,127,.8))' }} />
          Handmade in Lagos &nbsp;&bull;&nbsp; Party Props &nbsp;&bull;&nbsp; Custom Favours &nbsp;&bull;&nbsp; Shipped Worldwide
          <span style={{ display: 'block', width: 36, height: 1, background: 'linear-gradient(90deg, rgba(240,32,127,.8), transparent)' }} />
        </p>

        {/* Headline */}
        <h1 style={{
          fontFamily: 'var(--serif)', fontWeight: 400, lineHeight: .92,
          fontSize: 'clamp(72px,10.5vw,152px)',
          letterSpacing: '-.02em', color: '#fff',
          maxWidth: 980, marginBottom: 22,
          animation: 'fadeUpHero 1.1s .7s both'
        }}>
          Make it<br />
          <em style={{
            fontStyle: 'italic',
            background: 'linear-gradient(135deg, #C060F0 10%, #F0207F 90%)',
            WebkitBackgroundClip: 'text', WebkitTextFillColor: 'transparent',
            backgroundClip: 'text'
          }}>unforgettable.</em>
        </h1>

        {/* CTAs */}
        <div style={{ display: 'flex', gap: 14, flexWrap: 'wrap', justifyContent: 'center', marginBottom: 50, animation: 'fadeUpHero 1.1s 1.2s both', pointerEvents: 'auto' }}>
          <button
            className="btn btn-primary btn-lg"
            onClick={() => nav('shop')}
            style={{ borderRadius: 100, background: 'linear-gradient(135deg,#8A18C0,#F0207F)', border: 'none', color: '#fff', boxShadow: '0 8px 32px rgba(138,24,192,.45)' }}>
            Shop →</button>
          <button
            className="btn btn-lg"
            onClick={() => nav('brief')}
            style={{ borderRadius: 100, background: 'rgba(255,255,255,.12)', border: '1.5px solid rgba(255,255,255,.3)', color: '#fff', backdropFilter: 'blur(8px)', display: 'inline-flex', alignItems: 'center', gap: 8 }}>
            <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8"><path d="M12 5v14M5 12h14" strokeLinecap="round" /></svg>
            Request Custom Order</button>
        </div>

        {/* Stats */}
        <div style={{ display: 'flex', alignItems: 'center', gap: 28, flexWrap: 'wrap', justifyContent: 'center', animation: 'fadeUpHero 1.1s 1.5s both' }}>
          {[['1,800+', 'Parties styled'], ['20+', 'Countries'], ['100%', 'Handmade']].map(([n, l], i, a) =>
          <React.Fragment key={l}>
              <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 3 }}>
                <span style={{ fontFamily: 'var(--serif)', fontSize: 28, color: '#fff', lineHeight: 1 }}>{n}</span>
                <span style={{ fontFamily: 'var(--sans)', fontSize: 11, letterSpacing: '.10em', color: 'rgba(255,255,255,.58)', textTransform: 'uppercase' }}>{l}</span>
              </div>
              {i < a.length - 1 && <div style={{ width: 1, height: 36, background: 'rgba(255,255,255,.18)', flexShrink: 0 }} />}
            </React.Fragment>
          )}
        </div>
      </div>

      {/* ── Scroll indicator ─────────────────────────── */}
      <div style={{ position: 'absolute', bottom: 26, right: 'clamp(20px,4vw,52px)', zIndex: 30,
        display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8,
        animation: 'scrollBounce 2.4s ease-in-out infinite' }}>
        <span style={{ fontFamily: 'var(--sans)', fontSize: 9, letterSpacing: '.22em', textTransform: 'uppercase',
          color: 'rgba(255,255,255,.5)', writingMode: 'vertical-lr' }}>Scroll</span>
        <svg width="16" height="22" viewBox="0 0 16 22" fill="none" style={{ opacity: .5 }}>
          <rect x="5" y="0" width="6" height="13" rx="3" fill="none" stroke="white" strokeWidth="1.5" />
          <rect x="6.5" y="3" width="3" height="4" rx="1.5" fill="white">
            <animate attributeName="y" values="3;7;3" dur="2s" repeatCount="indefinite" />
            <animate attributeName="opacity" values="1;0;1" dur="2s" repeatCount="indefinite" />
          </rect>
          <path d="M2 18l6 4 6-4" stroke="white" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" opacity=".5" />
        </svg>
      </div>

      {/* ── Keyframes (injected once) ─────────────────── */}
      <style>{`
        @keyframes kenburns {
          0%   { transform: scale(1.00) translate(0%,0%); }
          50%  { transform: scale(1.06) translate(-1.2%,-1.5%); }
          100% { transform: scale(1.03) translate(1.2%,0.5%); }
        }
        @keyframes kenburnsActive {
          0%   { transform: scale(1.04) translate(0%,0%); }
          50%  { transform: scale(1.12) translate(-1.8%,-2%); }
          100% { transform: scale(1.07) translate(1.8%,0.8%); }
        }
        @keyframes panelPulse {
          0%   { opacity: .5; }
          100% { opacity: 0; }
        }
        @keyframes fadeUpHero {
          from { opacity: 0; transform: translateY(28px); }
          to   { opacity: 1; transform: translateY(0); }
        }
        @keyframes scrollBounce {
          0%,100% { transform: translateY(0); }
          55%      { transform: translateY(7px); }
        }
      `}</style>
    </section>);

}

function TrustStrip() {
  const items = [
  [I.truck, 'Worldwide Shipping', 'Multiple shipping options'],
  [I.shield, 'Secure NGN & USD checkout', 'Multiple payment options'],
  [I.gift, '100% handmade', 'Every piece crafted in Lagos']];

  return (
    <section style={{ borderBottom: '1px solid var(--line)', background: 'var(--ivory)' }}>
      <div className="container wide" style={{ display: 'flex', flexDirection: 'row', justifyContent: 'center', alignItems: 'center', gap: 48, flexWrap: 'wrap', padding: '34px var(--gutter)' }}>
        {items.map(([Icon, t, s], i) =>
        <div key={i} style={{ display: 'flex', gap: 14, alignItems: 'center' }}>
            <span style={{ width: 46, height: 46, flexShrink: 0, borderRadius: 100, background: 'var(--cream-deep)', display: 'grid', placeItems: 'center', color: 'var(--gold-deep)' }}>{Icon({ width: 22, height: 22 })}</span>
            <div style={{ lineHeight: 1.25 }}><div style={{ fontWeight: 500, fontSize: 14.5 }}>{t}</div><div style={{ fontSize: 12.5, color: 'var(--ink-soft)' }}>{s}</div></div>
          </div>
        )}
      </div>
    </section>);

}

function FeaturedCategories() {
  const { nav } = useStore();
  const [showCustomModal, setShowCustomModal] = React.useState(false);
  return (
    <section className="container wide" style={{ padding: 'clamp(64px,9vw,120px) var(--gutter)' }}>
      {showCustomModal &&
      <div onClick={(e) => {if (e.target === e.currentTarget) setShowCustomModal(false);}} role="dialog" aria-modal="true" style={{ position: 'fixed', inset: 0, zIndex: 9999, background: 'rgba(18,6,26,.72)', backdropFilter: 'blur(7px)', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 20, animation: 'bbFadeIn .4s forwards' }}>
          <div style={{ background: 'var(--ivory)', borderRadius: 24, maxWidth: 520, width: '100%', padding: 'clamp(28px,5vw,52px)', boxShadow: '0 32px 80px rgba(42,17,51,.35)', border: '1px solid var(--line)', animation: 'bbSlideIn .45s forwards', position: 'relative' }}>
            <button onClick={() => setShowCustomModal(false)} aria-label="Close" style={{ position: 'absolute', top: 20, right: 20, width: 36, height: 36, borderRadius: '100%', background: 'var(--cream-deep)', border: 'none', cursor: 'pointer', display: 'grid', placeItems: 'center', color: 'var(--ink-soft)' }} onMouseEnter={(e) => {e.currentTarget.style.background = 'var(--ink)';e.currentTarget.style.color = '#fff';}} onMouseLeave={(e) => {e.currentTarget.style.background = 'var(--cream-deep)';e.currentTarget.style.color = 'var(--ink-soft)';}}>
              <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M18 6 6 18M6 6l12 12" strokeLinecap="round" /></svg>
            </button>
            <p className="eyebrow" style={{ marginBottom: 12 }}>Custom order</p>
            <h2 style={{ fontFamily: 'var(--serif)', fontSize: 'clamp(26px,4vw,38px)', marginBottom: 14, lineHeight: 1.05 }}>Your vision, our <em style={{ fontStyle: 'italic' }}>artistry.</em></h2>
            <div style={{ height: 1, background: 'linear-gradient(90deg,var(--gold-soft),var(--blush-soft),transparent)', marginBottom: 20 }}></div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 12, marginBottom: 24 }}>
              {['Any theme, any colour — we build it from scratch just for you.', 'Share your inspiration images and we’ll elevate them with our signature artistry.', 'Receive a personalised quote within 24–48 hours via WhatsApp.'].map((t, i) =>
            <div key={i} style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
                  <span style={{ color: 'var(--gold)', fontSize: 10, marginTop: 5, flexShrink: 0 }}>✦</span>
                  <p style={{ fontSize: 14.5, color: 'var(--ink-soft)', lineHeight: 1.65 }}>{t}</p>
                </div>
            )}
            </div>
            <div style={{ background: 'linear-gradient(135deg,var(--gold-soft),var(--blush-soft))', borderRadius: 14, padding: '18px 22px', marginBottom: 28, borderLeft: '3px solid var(--gold)' }}>
              <p style={{ fontFamily: 'var(--serif)', fontStyle: 'italic', fontSize: 'clamp(15px,2vw,19px)', color: 'var(--ink)', lineHeight: 1.45 }}>“With us, your ideas don’t just come to life — they bloom into something unforgettable.”</p>
            </div>
            <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'center' }}>
              <button className="btn btn-gold" onClick={() => {setShowCustomModal(false);nav('brief');}} style={{ flex: 1 }}>
                Start my brief <I.arrow width={15} height={15} />
              </button>
              <button className="btn btn-outline" onClick={() => setShowCustomModal(false)} style={{ flexShrink: 0 }}>Maybe later</button>
            </div>
          </div>
        </div>
      }
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', flexWrap: 'wrap', gap: 16, marginBottom: 40 }}>
        <div>
          <p className="eyebrow">Shop by category</p>
          <h2 style={{ fontSize: 'clamp(34px,5vw,60px)', marginTop: 12 }}>Every detail, <em style={{ fontStyle: 'italic' }}>handmade</em></h2>
        </div>
        <button className="link-u" style={{ fontSize: 14 }} onClick={() => nav('shop')}>View all →</button>
      </div>
      <div className="cat-grid">
        {BB.categories.slice(0, 6).map((c, i) =>
        <Reveal key={c.id} delay={i % 3 + 1} className="cat-tile" onClick={() => nav('shop', { cat: c.id })} style={{ cursor: 'pointer' }}>
            <Ph label={c.name} src={IMG.cats[c.id]} variant={c.tag} style={{ height: '100%', minHeight: 200, borderRadius: 'var(--r-lg)' }} />
            <div style={{ position: 'absolute', inset: 0, borderRadius: 'var(--r-lg)', background: 'linear-gradient(to top, rgba(42,17,51,.92) 0%, rgba(42,17,51,.55) 45%, transparent 70%)', display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', padding: 22, color: 'var(--cream)' }}>
              <h3 style={{ fontSize: 25, color: 'var(--cream)' }}>{c.name}</h3>
              <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7, fontSize: 12.5, letterSpacing: '.1em', textTransform: 'uppercase', marginTop: 12, color: 'var(--gold-soft)' }}>Shop now <I.arrow width={15} height={15} /></span>
            </div>
          </Reveal>
        )}
        {/* Customisation CTA tile */}
        <Reveal delay={3} className="cat-tile">
          <button onClick={() => setShowCustomModal(true)} style={{
            width: '100%', height: '100%', minHeight: 200, borderRadius: 'var(--r-lg)',
            background: 'linear-gradient(135deg, var(--gold-soft), var(--blush-soft))',
            border: '2px dashed var(--gold)', cursor: 'pointer',
            display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center',
            gap: 12, padding: 24
          }}>
            <div style={{ width: 52, height: 52, borderRadius: '100%', background: 'linear-gradient(135deg, var(--gold-deep), var(--gold))', display: 'grid', placeItems: 'center', color: '#fff', boxShadow: '0 6px 20px rgba(138,24,192,.28)' }}>
              <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M12 5v14M5 12h14" strokeLinecap="round" /></svg>
            </div>
            <p style={{ fontFamily: 'var(--serif)', fontSize: 22, color: 'var(--ink)', lineHeight: 1.2, textAlign: 'center' }}>Your <em style={{ fontStyle: 'italic' }}>custom</em> theme</p>
            <p style={{ fontFamily: 'var(--sans)', fontSize: 12, color: 'var(--ink-soft)', textAlign: 'center', lineHeight: 1.6, maxWidth: 180 }}>Any theme, any colour — we build it just for you.</p>
            <span style={{ fontFamily: 'var(--sans)', fontSize: 11, letterSpacing: '.14em', textTransform: 'uppercase', color: 'var(--gold-deep)', fontWeight: 500 }}>Request yours →</span>
          </button>
        </Reveal>
      </div>
    </section>);

}

function Bestsellers() {
  const { nav } = useStore();
  const [tab, setTab] = useState('best');
  const list = BB.products.filter((p) => tab === 'best' ? p.tags.includes('best') : p.tags.includes('new')).slice(0, 4);
  return (
    <section style={{ background: 'var(--cream-deep)' }}>
      <div className="container wide" style={{ padding: 'clamp(64px,9vw,120px) var(--gutter)' }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', flexWrap: 'wrap', gap: 18, marginBottom: 42 }}>
          <h2 style={{ fontSize: 'clamp(34px,5vw,60px)' }}>Parents also <em style={{ fontStyle: 'italic' }}>love!</em></h2>
          <div style={{ display: 'flex', gap: 8 }}>
            <button className={`chip ${tab === 'best' ? 'active' : ''}`} onClick={() => setTab('best')}>Bestsellers</button>
            <button className={`chip ${tab === 'new' ? 'active' : ''}`} onClick={() => setTab('new')}>New in</button>
          </div>
        </div>
        <div className="prod-grid">
          {list.map((p, i) => <ProductCard key={p.id} p={p} delay={i % 4 + 1} />)}
        </div>
        <div style={{ textAlign: 'center', marginTop: 48 }}>
          <button className="btn btn-outline btn-lg" onClick={() => nav('shop')}>Shop everything</button>
        </div>
      </div>
    </section>);

}

function InspirationGallery() {
  const { nav } = useStore();
  const photos = [
  { src: IMG.social[0], label: 'Butterfly party bundle' },
  { src: IMG.social[1], label: 'Roblox treats & party bag' },
  { src: IMG.social[2], label: 'Moana gable boxes' },
  { src: IMG.social[3], label: 'Personalised colouring book' },
  { src: IMG.social[4], label: 'Party bundle' },
  { src: IMG.social[5], label: 'Party props' }];

  return (
    <section style={{ background: 'var(--cream-deep)', padding: 'clamp(64px,9vw,110px) var(--gutter)' }}>
      <div className="container wide">
        <div style={{ textAlign: 'center', marginBottom: 48 }}>
          <p className="eyebrow">Real work, real magic</p>
          <h2 style={{ fontSize: 'clamp(32px,4.5vw,56px)', marginTop: 14 }}>Made for moments like <em style={{ fontStyle: 'italic' }}>yours</em></h2>
          <p style={{ fontSize: 16, color: 'var(--ink-soft)', maxWidth: 500, margin: '14px auto 0', lineHeight: 1.7 }}>A glimpse into celebrations we've had the joy of creating — each one handmade, each one unforgettable.</p>
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16 }}>
          {photos.map((p, i) =>
          <Reveal key={i} delay={i % 3 + 1} style={{ position: 'relative', borderRadius: 'var(--r-lg)', overflow: 'hidden', aspectRatio: i === 0 || i === 5 ? '4/5' : '1', cursor: 'pointer' }}
          onClick={() => nav('shop')}>
              <Ph src={p.src} label={p.label} style={{ height: '100%', borderRadius: 'var(--r-lg)' }} />
              <div style={{
              position: 'absolute', inset: 0,
              background: 'linear-gradient(to top, rgba(42,17,51,.80) 0%, transparent 55%)',
              borderRadius: 'var(--r-lg)',
              display: 'flex', alignItems: 'flex-end', padding: 20,
              opacity: 0, transition: 'opacity .35s'
            }}
            onMouseEnter={(e) => e.currentTarget.style.opacity = '1'}
            onMouseLeave={(e) => e.currentTarget.style.opacity = '0'}>
                <span style={{ fontFamily: 'var(--serif)', fontSize: 18, color: '#fff', fontStyle: 'italic' }}>{p.label}</span>
              </div>
            </Reveal>
          )}
        </div>
        <div style={{ textAlign: 'center', marginTop: 40 }}>
          <button className="btn btn-primary btn-lg" onClick={() => nav('shop')}>
            Shop <I.arrow width={16} height={16} />
          </button>
        </div>
      </div>
    </section>);

}

function EditorialSplit() {
  const { nav } = useStore();
  return (
    <section className="container wide" style={{ padding: 'clamp(64px,9vw,120px) var(--gutter)' }}>
      <div className="edit-split" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'clamp(28px,5vw,72px)', alignItems: 'center' }}>
        <Reveal style={{ position: 'relative' }}>
          <Ph label="Founder — Olanrewaju at work in the atelier" src={IMG.about.founder} variant="ph-gold" style={{ aspectRatio: '5/6', borderRadius: 'var(--r-xl)' }} />
          <div style={{ position: 'absolute', bottom: 24, right: -20, background: 'var(--ivory)', padding: '18px 22px', borderRadius: 'var(--r-md)', boxShadow: 'var(--shadow-md)', maxWidth: 230 }}>
            <p style={{ fontFamily: 'var(--serif)', fontStyle: 'italic', fontSize: 19, lineHeight: 1.35 }}>"With us, your ideas don't just come to life — they bloom into something unforgettable."</p>
            <p style={{ fontSize: 11, color: 'var(--ink-soft)', marginTop: 12, letterSpacing: '.12em' }}>— BELLE, FOUNDER</p>
          </div>
        </Reveal>
        <Reveal delay={2}>
          <p className="eyebrow">Belle &amp; Bloom Designs</p>
          <h2 style={{ fontSize: 'clamp(32px,4.5vw,54px)', margin: '14px 0 20px' }}>Two sister brands, <em style={{ fontStyle: 'italic' }}>one shared purpose</em></h2>
          <p style={{ fontSize: 16.5, color: 'var(--ink-soft)', lineHeight: 1.7, marginBottom: 18 }}>
            We are Belle and Bloom Designs — home to two sister brands united by one purpose: crafting beautiful, meaningful pieces that keep your most precious memories alive.
          </p>
          <p style={{ fontSize: 16.5, color: 'var(--ink-soft)', lineHeight: 1.7, marginBottom: 18 }}>
            Through <strong>The Belle and Bloom Company</strong>, we handcraft bespoke party favours, props and décor that transform every celebration into a lasting experience. With <strong>Belle Journals</strong>, we help parents savour life's most tender milestones — through thoughtfully designed baby journals that grow alongside your little one.
          </p>
          <ul style={{ listStyle: 'none', display: 'flex', flexDirection: 'column', gap: 12, marginBottom: 30 }}>
            {['Made with heart — handcrafted with love, care and intention', 'Uniquely yours — custom designs that reflect your story and style', 'Always on time — we respect your deadlines and deliver on our promise'].map((t) =>
            <li key={t} style={{ display: 'flex', gap: 12, alignItems: 'center', fontSize: 15.5 }}>
                <span style={{ width: 26, height: 26, borderRadius: 100, background: 'var(--sage-soft)', color: 'var(--sage-deep)', display: 'grid', placeItems: 'center', flexShrink: 0 }}><I.check width={15} height={15} /></span>{t}
              </li>
            )}
          </ul>
          <button className="btn btn-primary" onClick={() => nav('about')}>Our story</button>
        </Reveal>
      </div>
    </section>);

}

function Testimonials() {
  const [i, setI] = useState(0);
  const t = BB.testimonials;
  useEffect(() => {const id = setInterval(() => setI((p) => (p + 1) % t.length), 5500);return () => clearInterval(id);}, []);
  return (
    <section style={{ background: 'linear-gradient(160deg, var(--sage-soft), var(--cream))' }}>
      <div className="container" style={{ padding: 'clamp(64px,9vw,120px) var(--gutter)', textAlign: 'center', maxWidth: 860 }}>
        <p className="eyebrow">Real parents, real parties</p>
        <div style={{ position: 'relative', minHeight: 220, marginTop: 24 }}>
          {t.map((item, idx) =>
          <blockquote key={idx} style={{ position: idx === i ? 'relative' : 'absolute', inset: 0, opacity: idx === i ? 1 : 0, transition: 'opacity .7s', pointerEvents: idx === i ? 'auto' : 'none' }}>
              <p style={{ fontFamily: 'var(--serif)', fontSize: 'clamp(22px,3.5vw,38px)', lineHeight: 1.35, fontStyle: 'italic' }}>"{item.quote}"</p>
              <div style={{ marginTop: 26, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }}>
                <Stars value={5} size={16} />
                <div style={{ fontWeight: 600, fontSize: 15 }}>{item.name}</div>
                <div style={{ fontSize: 13, color: 'var(--ink-soft)' }}>{item.role}</div>
              </div>
            </blockquote>
          )}
        </div>
        <div style={{ display: 'flex', gap: 8, justifyContent: 'center', marginTop: 30 }}>
          {t.map((_, idx) => <button key={idx} onClick={() => setI(idx)} aria-label={`Testimonial ${idx + 1}`} style={{ width: idx === i ? 28 : 9, height: 9, borderRadius: 100, background: idx === i ? 'var(--gold)' : 'var(--line)', transition: 'all .4s' }} />)}
        </div>
      </div>
    </section>);

}

function TikTokSection() {
  const { nav } = useStore();
  return (
    <section className="container wide" style={{ padding: 'clamp(56px,8vw,100px) var(--gutter)' }}>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 'clamp(32px,5vw,72px)', alignItems: 'center' }}>
        <div>
          <p className="eyebrow">@thebloomcompany</p>
          <h2 style={{ fontSize: 'clamp(30px,4.5vw,52px)', margin: '14px 0 16px' }}>See the craft <em style={{ fontStyle: 'italic' }}>in the making</em></h2>
          <p style={{ fontSize: 16, color: 'var(--ink-soft)', lineHeight: 1.7, marginBottom: 28 }}>
            Watch behind-the-scenes process videos, unboxings, party setups and full decorations on our TikTok and Instagram — updated weekly with fresh party inspiration.
          </p>
          <div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
            <a href="https://www.tiktok.com/@thebloomcompany" target="_blank" rel="noopener noreferrer" className="btn btn-primary">
              <I.tiktok width={17} height={17} /> Follow on TikTok
            </a>
            <a href="#" className="btn btn-outline"><I.ig width={17} height={17} /> Instagram</a>
          </div>
        </div>
        <div className="social-grid">
          {IMG.social.slice(0, 6).map((src, i) =>
          <Reveal key={i} delay={i % 3 + 1} style={{ position: 'relative' }} className="social-tile">
              <Ph label="party setup" src={src} style={{ aspectRatio: '1', borderRadius: 'var(--r-md)' }} />
              <div className="social-ov" style={{ position: 'absolute', inset: 0, background: 'rgba(138,24,192,.48)', borderRadius: 'var(--r-md)', display: 'grid', placeItems: 'center', opacity: 0, transition: 'opacity .35s' }}>
                <I.ig width={26} height={26} style={{ color: 'var(--cream)' }} />
              </div>
            </Reveal>
          )}
        </div>
      </div>
    </section>);

}

/* ── Things To Note Popup ─────────────────────────────────── */
function ThingsToNotePopup() {
  const STORAGE_KEY = 'bb_popup_hidden_date';
  const [visible, setVisible] = React.useState(false);
  const [closing, setClosing] = React.useState(false);
  const [seconds, setSeconds] = React.useState(60);
  const [dontShow, setDontShow] = React.useState(false);
  const timerRef = React.useRef(null);
  const countRef = React.useRef(null);

  React.useEffect(() => {
    const today = new Date().toDateString();
    if (localStorage.getItem(STORAGE_KEY) === today) return;
    const t = setTimeout(() => setVisible(true), 1400);
    return () => clearTimeout(t);
  }, []);

  React.useEffect(() => {
    if (!visible) return;
    timerRef.current = setTimeout(() => dismiss(), 60000);
    countRef.current = setInterval(() => setSeconds((s) => Math.max(0, s - 1)), 1000);
    return () => {clearTimeout(timerRef.current);clearInterval(countRef.current);};
  }, [visible]);

  function dismiss() {
    if (dontShow) localStorage.setItem(STORAGE_KEY, new Date().toDateString());
    clearTimeout(timerRef.current);clearInterval(countRef.current);
    setClosing(true);
    setTimeout(() => {setVisible(false);setClosing(false);setSeconds(60);}, 480);
  }

  if (!visible) return null;

  const circumference = 2 * Math.PI * 13;
  const progress = seconds / 60 * circumference;

  return (
    <div
      onClick={(e) => {if (e.target === e.currentTarget) dismiss();}}
      role="dialog" aria-modal="true" aria-labelledby="ttn-title"
      style={{
        position: 'fixed', inset: 0, zIndex: 9999,
        background: 'rgba(18,6,26,.72)', backdropFilter: 'blur(7px)',
        display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 20,
        animation: closing ? 'ttnOut .48s forwards' : 'ttnIn .45s forwards'
      }}>
      <div style={{
        background: 'var(--ivory)', borderRadius: 24,
        maxWidth: 560, width: '100%',
        padding: 'clamp(28px,5vw,50px)',
        boxShadow: '0 32px 80px rgba(42,17,51,.35)',
        border: '1px solid var(--line)',
        animation: closing ? 'ttnCardOut .48s forwards' : 'ttnCardIn .48s forwards'
      }}>

        {/* Header row */}
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 22 }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
            <div style={{ position: 'relative', width: 34, height: 34, flexShrink: 0 }}>
              <svg width="34" height="34" viewBox="0 0 34 34" style={{ transform: 'rotate(-90deg)' }}>
                <circle cx="17" cy="17" r="13" fill="none" stroke="var(--line)" strokeWidth="2.5" />
                <circle cx="17" cy="17" r="13" fill="none" stroke="var(--gold)" strokeWidth="2.5"
                strokeDasharray={circumference} strokeDashoffset={circumference - progress}
                strokeLinecap="round" style={{ transition: 'stroke-dashoffset 1s linear' }} />
              </svg>
              <span style={{ position: 'absolute', inset: 0, display: 'grid', placeItems: 'center', fontFamily: 'var(--sans)', fontSize: 10, fontWeight: 600, color: 'var(--gold-deep)' }}>{seconds}</span>
            </div>
            <span style={{ fontFamily: 'var(--sans)', fontSize: 11, letterSpacing: '.14em', textTransform: 'uppercase', color: 'var(--ink-faint)' }}>auto-closes</span>
          </div>
          <button onClick={dismiss} aria-label="Close"
          style={{ width: 36, height: 36, borderRadius: '100%', background: 'var(--cream-deep)', border: 'none', cursor: 'pointer', display: 'grid', placeItems: 'center', color: 'var(--ink-soft)', transition: 'background .2s, color .2s' }}
          onMouseEnter={(e) => {e.currentTarget.style.background = 'var(--ink)';e.currentTarget.style.color = '#fff';}}
          onMouseLeave={(e) => {e.currentTarget.style.background = 'var(--cream-deep)';e.currentTarget.style.color = 'var(--ink-soft)';}}>
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M18 6 6 18M6 6l12 12" strokeLinecap="round" /></svg>
          </button>
        </div>

        {/* Eyebrow + title */}
        <p className="eyebrow" style={{ marginBottom: 10 }}>Things to note</p>
        <h2 id="ttn-title" style={{ fontFamily: 'var(--serif)', fontSize: 'clamp(24px,4vw,34px)', marginBottom: 20, lineHeight: 1.05 }}>Your vision, our <em style={{ fontStyle: 'italic' }}>artistry.</em></h2>
        <div style={{ height: 1, background: 'linear-gradient(90deg,var(--gold-soft),var(--blush-soft),transparent)', marginBottom: 22 }}></div>

        {/* Bullets */}
        <div style={{ display: 'flex', flexDirection: 'column', gap: 13, marginBottom: 24 }}>
          {[
          'Our catalogue is simply a starting point — your possibilities are limitless.',
          'Every piece can be tailored in design, colour and finish to perfectly reflect your vision.',
          'We welcome your inspiration images, but each creation will be elevated with our signature artistry and bespoke detailing.',
          'Prices reflect the designs as presented; design complexity may affect final pricing.'].
          map((t, i) =>
          <div key={i} style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
              <span style={{ color: 'var(--gold)', fontSize: 10, marginTop: 5, flexShrink: 0 }}>✦</span>
              <p style={{ fontSize: 14.5, color: 'var(--ink-soft)', lineHeight: 1.65 }}>{t}</p>
            </div>
          )}
        </div>

        {/* Quote */}
        <div style={{ background: 'linear-gradient(135deg,var(--gold-soft),var(--blush-soft))', borderRadius: 16, padding: '18px 22px', marginBottom: 24, borderLeft: '3px solid var(--gold)' }}>
          <p style={{ fontFamily: 'var(--serif)', fontStyle: 'italic', fontSize: 'clamp(15px,2.2vw,19px)', color: 'var(--ink)', lineHeight: 1.45 }}>
            “With us, your ideas don’t just come to life — they bloom into something unforgettable.”
          </p>
        </div>

        {/* Footer */}
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', flexWrap: 'wrap', gap: 12 }}>
          <label style={{ display: 'flex', alignItems: 'center', gap: 8, cursor: 'pointer', fontSize: 13, color: 'var(--ink-soft)', fontFamily: 'var(--sans)', userSelect: 'none' }}>
            <input type="checkbox" checked={dontShow} onChange={(e) => setDontShow(e.target.checked)}
            style={{ accentColor: 'var(--gold)', width: 15, height: 15, cursor: 'pointer' }} />
            Don’t show again today
          </label>
          <button className="btn btn-gold" onClick={dismiss}>Got it, let’s shop</button>
        </div>

      </div>
      <style>{`
        @keyframes ttnIn      { from{opacity:0} to{opacity:1} }
        @keyframes ttnOut     { from{opacity:1} to{opacity:0} }
        @keyframes ttnCardIn  { from{opacity:0;transform:translateY(24px) scale(.97)} to{opacity:1;transform:none} }
        @keyframes ttnCardOut { from{opacity:1;transform:none} to{opacity:0;transform:translateY(14px) scale(.97)} }
      `}</style>
    </div>);

}

function HomePage() {
  return (
    <>
      <ThingsToNotePopup />
      <HomeHero />
      <TrustStrip />
      <FeaturedCategories />
      <Bestsellers />
      <EditorialSplit />
      <Testimonials />
      <TikTokSection />
      <Newsletter />
    </>);

}

Object.assign(window, { HomePage });