/* global React, INK, CREAM, PULSE, GENS, GradText, CTAButton, Reveal, useReveal, SB_EASE, MShell, MHead, UGCStatus */
// UGC Campaigns — mobile layout (skews alternate).
// eyebrows are hero-only on mobile — keep the heading, drop the pill
const MUGCBadgeHead = ({ title, sub }) => <MHead title={title} sub={sub} />;
const MUGCCard = ({ lean = 'right', children, pad = 12 }) => (
  <div style={{ borderRadius: 18, background: '#fff', boxShadow: '0 12px 32px rgba(28,27,27,0.10), inset 0 0 0 1px rgba(28,27,27,0.08)', padding: pad, marginTop: 26, textAlign: 'left',
    transform: lean === 'left' ? 'rotate(-1.2deg) perspective(1200px) rotateY(3deg)' : 'rotate(1.2deg) perspective(1200px) rotateY(-3deg)' }}>{children}</div>
);

// hero
const MUGC_ROWS = [
  { g: GENS[0], n: 'Scarlett', p: 'IG Reel', s: 'posted' },
  { g: GENS[5], n: 'Nova', p: 'TikTok', s: 'scheduled' },
  { g: GENS[3], n: 'Jade', p: 'TikTok', s: 'nudged' }];

const MUGCHero = () => (
  <section style={{ background: CREAM, padding: '0 22px 56px' }}>
    <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '16px 0 30px' }}>
      <span style={{ display: 'inline-flex', alignItems: 'center', gap: 7 }}>
        <img loading="lazy" decoding="async" src="assets/logo-icon.png" alt="" style={{ width: 19, height: 19, objectFit: 'contain' }} />
        <span style={{ fontSize: 16, fontWeight: 800, letterSpacing: '-0.03em', color: INK }}>sozee</span>
      </span>
    </div>
    <div style={{ textAlign: 'center' }}>
      <Reveal>
        <div style={{ display: 'inline-flex', alignItems: 'center', gap: 7, marginBottom: 16, borderRadius: 9999, padding: '6px 12px', background: '#fff', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.1)' }}>
          <a href="/" style={{ fontSize: 10.5, fontWeight: 600, color: 'rgba(28,27,27,0.55)' }}>Solutions</a>
          <span style={{ fontSize: 10, color: 'rgba(28,27,27,0.35)' }}>/</span>
          <span style={{ fontSize: 10.5, fontWeight: 700, color: INK }}>UGC Campaigns</span>
        </div>
      </Reveal>
      <Reveal delay={90}>
        <h1 style={{ font: '800 44px/1 var(--font-sans)', letterSpacing: '-0.03em', color: INK, margin: '0 0 16px', textWrap: 'balance' }}>
          UGC at scale,<br /><GradText>without the chase.</GradText>
        </h1>
      </Reveal>
      <Reveal delay={170}>
        <p style={{ fontSize: 14.5, lineHeight: 1.58, color: 'var(--text-secondary)', margin: '0 0 24px' }}>
          Brief once. Products land in every creator’s studio, posts verify on publish, payouts release on proof.
        </p>
      </Reveal>
      <Reveal delay={250} style={{ marginBottom: 34 }}><CTAButton size="sm">Launch a campaign</CTAButton></Reveal>
    </div>
    <Reveal delay={200} y={26}>
      <div style={{ transform: 'rotate(1.2deg) perspective(1200px) rotateY(-3deg)', borderRadius: 20, background: '#fff', boxShadow: '0 20px 44px rgba(28,27,27,0.12), inset 0 0 0 1px rgba(28,27,27,0.08)', padding: 12, textAlign: 'left' }}>
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 9 }}>
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 6 }}>
            <span style={{ width: 18, height: 18, borderRadius: 6, background: INK, display: 'grid', placeItems: 'center', fontSize: 9, fontWeight: 800, color: '#fff' }}>A</span>
            <span style={{ fontSize: 11, fontWeight: 800, color: INK }}>Velvet Drop · live</span>
          </span>
          <span style={{ fontSize: 8, fontWeight: 700, color: '#15803D', background: 'rgba(34,197,94,0.12)', border: '1px solid rgba(34,197,94,0.3)', borderRadius: 9999, padding: '2px 7px' }}>28 / 34 posted</span>
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
          {MUGC_ROWS.map((r) =>
            <div key={r.n} style={{ display: 'flex', alignItems: 'center', gap: 7, borderRadius: 9, background: 'rgb(250,247,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.07)', padding: '6px 8px' }}>
              <span style={{ width: 22, height: 22, borderRadius: '50%', overflow: 'hidden', flexShrink: 0 }}>
                <img loading="lazy" decoding="async" src={r.g.src} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 14%' }} /></span>
              <span style={{ fontSize: 10, fontWeight: 700, color: INK, flex: 1 }}>{r.n} <span style={{ fontSize: 8.5, fontWeight: 600, color: 'rgba(28,27,27,0.45)' }}>· {r.p}</span></span>
              <UGCStatus s={r.s} />
            </div>)}
        </div>
        <div style={{ marginTop: 8, fontSize: 8.5, fontWeight: 600, color: 'var(--text-tertiary)', textAlign: 'center' }}>“Posted” is a fact, not a screenshot.</div>
      </div>
    </Reveal>
  </section>
);

// § 01 materials
const MUGCMaterials = () => {
  const [ref, on] = useReveal(0.3);
  const Row = ({ title, items, d0 }) => (
    <div style={{ marginBottom: 9 }}>
      <div style={{ fontSize: 8.5, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', color: 'var(--text-tertiary)', marginBottom: 6 }}>{title}</div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 6 }}>
        {items.map(([src, n], i) =>
          <div key={n} style={{ borderRadius: 9, background: 'rgb(250,247,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', padding: '7px 5px 6px', textAlign: 'center',
            opacity: on ? 1 : 0, transition: `opacity 0.4s ${SB_EASE} ${d0 + i * 70}ms` }}>
            <img loading="lazy" decoding="async" src={src} alt={n} style={{ width: '100%', height: 40, objectFit: 'contain', marginBottom: 4 }} />
            <div style={{ fontSize: 7.5, fontWeight: 700, color: INK, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{n}</div>
          </div>)}
      </div>
    </div>);
  return (
    <MShell bg="#fff">
      <MUGCBadgeHead label="UGC Campaigns · Materials" ac="#C77D3A" title={<span>Ship pixels,<br /><GradText>not packages.</GradText></span>}
        sub="Products to the object library, wardrobe to the outfit library — synced to every accepted studio the same minute." />
      <MUGCCard lean="left">
        <div ref={ref}>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 9 }}>
            <span style={{ fontSize: 11, fontWeight: 800, color: INK }}>Aurelle brand kit</span>
            <span style={{ fontSize: 8, fontWeight: 700, color: 'var(--brand-purple-700)', background: 'var(--brand-purple-50)', border: '1px solid var(--brand-purple-200)', borderRadius: 9999, padding: '2px 7px' }}>Synced · 12 studios</span>
          </div>
          <Row title="Object library" items={[['assets/control/collar-silver.png', 'Sculpt Collar'], ['assets/control/heels-black.webp', 'Aurelle Heel'], ['assets/control/top-red.webp', 'Slip Top']]} d0={80} />
          <Row title="Outfit library" items={[['assets/garments/top-velvet-emerald.webp', 'Velvet Halter'], ['assets/garments/bottom-mini-oxblood.webp', 'Oxblood Mini'], ['assets/garments/shoe-stiletto-gold.webp', 'Gold Stiletto']]} d0={290} />
          <div className="m-nosb" style={{ display: 'flex', gap: 4, overflowX: 'auto' }}>
            {['✓ No samples', '✓ No shipping', '✓ Pixel-consistent'].map(c =>
              <span key={c} style={{ borderRadius: 9999, padding: '4px 9px', fontSize: 8.5, fontWeight: 600, background: 'rgb(246,243,242)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', color: 'rgba(28,27,27,0.65)', whiteSpace: 'nowrap', flexShrink: 0 }}>{c}</span>)}
          </div>
        </div>
      </MUGCCard>
    </MShell>);
};

// § 02 posting
const MUGC_TRACK = [
  { g: GENS[0], n: 'Scarlett', done: 4, s: 'posted', note: 'Verified 9:02 PM' },
  { g: GENS[5], n: 'Nova', done: 3, s: 'scheduled', note: 'Publishes Fri' },
  { g: GENS[3], n: 'Jade', done: 1, s: 'nudged', note: '⚡ Auto-nudge sent' }];

const MUGCTracker = () => {
  const [ref, on] = useReveal(0.3);
  return (
    <MShell>
      <MUGCBadgeHead label="UGC Campaigns · Posting" ac="#4D73F2" title={<span>They post.<br /><GradText>You’ll know.</GradText></span>}
        sub="Tracked brief → posted. Publishing runs through Sozee, so “posted” is verified — and slackers get auto-nudged." />
      <MUGCCard lean="right">
        <div ref={ref} style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
          {MUGC_TRACK.map((r, i) =>
            <div key={r.n} style={{ borderRadius: 10, background: 'rgb(250,247,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', padding: '8px 9px',
              opacity: on ? 1 : 0, transition: `opacity 0.4s ${SB_EASE} ${i * 90}ms` }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 6 }}>
                <span style={{ width: 20, height: 20, borderRadius: '50%', overflow: 'hidden', flexShrink: 0 }}>
                  <img loading="lazy" decoding="async" src={r.g.src} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 14%' }} /></span>
                <span style={{ fontSize: 10, fontWeight: 700, color: INK, flex: 1 }}>{r.n}</span>
                <UGCStatus s={r.s} />
              </div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
                {['Brief', 'Created', 'Approved', 'Posted'].map((st, k) => (
                  <React.Fragment key={st}>
                    <span style={{ width: 11, height: 11, borderRadius: '50%', display: 'grid', placeItems: 'center', fontSize: 6.5, fontWeight: 800, flexShrink: 0,
                      background: k < r.done ? PULSE : '#fff', color: k < r.done ? '#fff' : 'rgba(28,27,27,0.35)',
                      boxShadow: k < r.done ? 'none' : 'inset 0 0 0 1px rgba(28,27,27,0.18)' }}>{k < r.done ? '✓' : ''}</span>
                    {k < 3 && <span style={{ flex: 1, height: 1.5, background: k < r.done - 1 ? 'var(--brand-purple-400)' : 'rgba(28,27,27,0.12)' }} />}
                  </React.Fragment>))}
              </div>
              <div style={{ marginTop: 5, fontSize: 8.5, fontWeight: 600, color: r.s === 'nudged' ? '#B45309' : 'rgba(28,27,27,0.5)' }}>{r.note}</div>
            </div>)}
        </div>
      </MUGCCard>
    </MShell>);
};

// § 03 analytics
const MUGCAnalytics = () => {
  const [ref, on] = useReveal(0.3);
  return (
    <MShell bg="#fff">
      <MUGCBadgeHead label="UGC Campaigns · Analytics" ac="#813CED" title={<span>Numbers from<br /><GradText>the source.</GradText></span>}
        sub="Views, engagement and link taps per creator and post — read from the publishing pipeline, never self-reported." />
      <MUGCCard lean="left">
        <div ref={ref}>
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 6, marginBottom: 9 }}>
            {[['Views', '2.1M'], ['Eng.', '8.4%'], ['Taps', '31k']].map(([l, v]) =>
              <div key={l} style={{ borderRadius: 9, background: 'rgb(250,247,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.07)', padding: '7px 9px' }}>
                <div style={{ fontSize: 7, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', color: 'var(--text-tertiary)', marginBottom: 2 }}>{l}</div>
                <div style={{ fontSize: 12.5, fontWeight: 800, color: INK }}>{v}</div>
              </div>)}
          </div>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
            {[['Scarlett', 100, '412k ✓'], ['Nova', 70, '287k ✓'], ['Jade', 0, '—']].map(([n, w, v], i) =>
              <div key={n} style={{ display: 'grid', gridTemplateColumns: '58px 1fr 52px', alignItems: 'center', gap: 7 }}>
                <span style={{ fontSize: 9, fontWeight: 600, color: 'var(--text-secondary)' }}>{n}</span>
                <span style={{ height: 14, borderRadius: 5, background: 'rgb(240,236,235)', overflow: 'hidden' }}>
                  <span style={{ display: 'block', height: '100%', borderRadius: 5, background: PULSE, width: on ? `${w}%` : '2%', transition: `width 0.8s ${SB_EASE} ${i * 100}ms` }} /></span>
                <span style={{ fontSize: 8.5, fontWeight: 700, color: INK, textAlign: 'right' }}>{v}</span>
              </div>)}
          </div>
        </div>
      </MUGCCard>
    </MShell>);
};

// § 04 payouts
const MUGCPayouts = () => {
  const [ref, on] = useReveal(0.3);
  return (
    <MShell>
      <MUGCBadgeHead label="UGC Campaigns · Payouts" ac="#3A8F6B" title={<span>Escrow in.<br /><GradText>Receipts out.</GradText></span>}
        sub="Fund once. Creators are paid the moment their post verifies; missed deadlines return to you." />
      <MUGCCard lean="right">
        <div ref={ref}>
          <div style={{ borderRadius: 10, boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.1)', padding: '8px 9px', marginBottom: 8 }}>
            <div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 8.5, marginBottom: 5 }}>
              <span style={{ fontWeight: 700, color: INK }}>$4,800 escrowed</span>
              <span style={{ color: 'rgba(28,27,27,0.5)' }}>$1,600 released</span>
            </div>
            <div style={{ height: 7, borderRadius: 9999, background: 'rgb(235,231,231)', overflow: 'hidden' }}>
              <div style={{ width: on ? '33%' : '4%', height: '100%', background: PULSE, borderRadius: 9999, transition: `width 0.9s ${SB_EASE} 250ms` }} />
            </div>
          </div>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
            {[['Scarlett · $400', 'Paid', '#15803D', 'rgba(34,197,94,0.12)'], ['Nova · $400', 'Holds', '#4D73F2', 'rgba(77,115,242,0.1)'], ['Jade · $400', 'Escrow', 'rgba(28,27,27,0.55)', 'rgb(246,243,242)']].map(([n, s, c, bg]) =>
              <div key={n} style={{ display: 'flex', alignItems: 'center', gap: 7, borderRadius: 9, background: 'rgb(250,247,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.07)', padding: '6px 9px' }}>
                <span style={{ fontSize: 9.5, fontWeight: 700, color: INK, flex: 1 }}>{n}</span>
                <span style={{ fontSize: 8, fontWeight: 700, color: c, background: bg, borderRadius: 9999, padding: '2px 8px' }}>{s}</span>
              </div>)}
          </div>
          <div style={{ marginTop: 8, fontSize: 8.5, fontWeight: 600, color: 'var(--text-tertiary)' }}>One receipt — not twelve invoices and wires.</div>
        </div>
      </MUGCCard>
    </MShell>);
};

// § 05 how it runs
const MUGCHow = () => (
  <MShell bg="#fff">
    <MUGCBadgeHead label="UGC Campaigns · How it runs" ac="#B0489B" title={<span>Live in<br /><GradText>four moves.</GradText></span>}
      sub="The whole campaign runs inside one board." />
    <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 10, marginTop: 26 }}>
      {[['01', 'Brief it'], ['02', 'Stock the kit'], ['03', 'They create & post'], ['04', 'Payouts release']].map(([n, t], i) =>
        <Reveal key={n} delay={i * 80} y={16}>
          <div style={{ borderRadius: 13, background: CREAM, boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', padding: '14px 12px', textAlign: 'left', transform: `rotate(${i % 2 ? 0.8 : -0.8}deg)` }}>
            <div style={{ fontSize: 9, fontWeight: 800, letterSpacing: '0.1em', color: 'var(--brand-purple-700)', marginBottom: 6 }}>§ {n}</div>
            <div style={{ fontSize: 12.5, fontWeight: 700, color: INK }}>{t}</div>
          </div>
        </Reveal>)}
    </div>
  </MShell>
);

const MUGCPage = () => (
  <React.Fragment>
    <div style={{ fontFamily: 'var(--font-sans)', maxWidth: 430, margin: '0 auto', boxShadow: '0 0 0 1px rgba(28,27,27,0.06), 0 0 60px rgba(28,27,27,0.08)', overflow: 'clip' }}>
      <div data-screen-label="Hero — UGC Campaigns"><MUGCHero /></div>
      <div data-screen-label="01 Materials"><MUGCMaterials /></div>
      <div data-screen-label="02 Posting"><MUGCTracker /></div>
      <div data-screen-label="03 Analytics"><MUGCAnalytics /></div>
      <div data-screen-label="04 Payouts"><MUGCPayouts /></div>
      <div data-screen-label="05 The creator side"><window.MCreatorSideSection /></div>
      <div data-screen-label="06 How it runs"><MUGCHow /></div>
      <div data-screen-label="07 Plans"><window.MBPPlans badge="UGC Campaigns · Plans" /></div>
      <div data-screen-label="08 FAQ"><window.MBrandFAQSection /></div>
      <div data-screen-label="CTA + Footer"><window.MFinalSection /></div>
    </div>
    <window.MCISticky />
    <window.SozeeNavMobile siteHref="/" localLabels={{ '/ugc-campaigns': 'Hero — UGC Campaigns' }} />
  </React.Fragment>
);

Object.assign(window, { MUGCPage });
