// site/page-home.jsx, Home page using H1 "cow as co-star" hero
// then the Direction D body sections (real content, cream-dominant).

function PageHome({ onNav }) {
  return (
    <div>
      <HomeHero onNav={onNav} />
      <HomeStatsStrip />
      <HomeMission />
      <HomeModules onNav={onNav} />
      <HomeTransform />
      <HomeCompare onNav={onNav} />
      <HomeLogoWall />
      <HomeInstagram />
      <HomeTestimonials />
      <HomeCowCTA onNav={onNav} />
    </div>
  );
}

// ─── Hero (H1 cow-as-costar) ───────────────────────────────
function HomeHero({ onNav }) {
  return (
    <section style={{ padding: '64px 64px 72px', position: 'relative', overflow: 'hidden' }}>
      <div className="has-grain light" style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', display: 'grid', gridTemplateColumns: '1.05fr 1fr', gap: 64, alignItems: 'center', maxWidth: 1320, margin: '0 auto' }}>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 24, alignItems: 'flex-start' }}>
          <h1 style={{
            fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56, lineHeight: 0.96,
            letterSpacing: '-0.035em', color: S.ink, margin: 0,
          }}>
            Where <em style={{ fontStyle: 'italic', color: S.red, fontWeight: 500 }}>tradition</em><br />
            meets technology.
          </h1>
          <Scribble width={340} />
          <p style={{ fontSize: 16, lineHeight: 1.55, color: S.ink, opacity: 0.72, maxWidth: 540, margin: 0 }}>
            The nation's only platform built specifically for fairs, bringing websites, marketing, operations, and ticketing together in one seamless platform.
          </p>
          <div style={{ display: 'flex', gap: 12, marginTop: 8 }}>
            <StubBtn size="lg" onClick={() => onNav('contact')}>Book a demo</StubBtn>
            <StubBtn size="lg" variant="outline" icon={false} onClick={() => onNav('platform')}>Learn more →</StubBtn>
          </div>
          <div style={{ display: 'flex', gap: 32, paddingTop: 24, borderTop: `1px dashed ${S.border}`, marginTop: 8 }}>
            {[['180+', 'fairs'], ['48 hrs', 'to selling tickets'], ['28%', 'pre-sale lift']].map(([n, l], i) => (
              <div key={i}>
                <div style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 22, color: S.ink, letterSpacing: '-0.02em' }}>{n}</div>
                <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: S.mute, letterSpacing: '0.1em', textTransform: 'uppercase' }}>{l}</div>
              </div>
            ))}
          </div>
        </div>

        {/* Right: real-photo collage with cow sticker */}
        <div style={{ position: 'relative', height: 580 }}>
          {/* Big midway photo (the brand's marquee hero shot) */}
          <div style={{
            position: 'absolute', left: 0, top: 0, width: '100%', height: 460,
            borderRadius: 18, overflow: 'hidden', border: `1.5px solid ${S.ink}`,
            boxShadow: `8px 8px 0 0 ${S.red}`, transform: 'rotate(-1deg)',
          }}>
            <TreatedPhoto src={PHOTOS.midway} treatment="clean" style={{ width: '100%', height: '100%' }} />
            <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, transparent 50%, rgba(16,15,16,0.35) 100%)' }} />
            <div style={{ position: 'absolute', top: 14, right: 14, fontFamily: 'var(--font-mono)', fontSize: 12, color: S.cream, opacity: 0.85, letterSpacing: '0.18em', textTransform: 'uppercase' }}>
              Vol. IV · 2026
            </div>
          </div>

          {/* Small framed photo: tractor pull (top-left, tilted out) */}
          <div style={{ position: 'absolute', left: -40, top: 260, width: 255, transform: 'rotate(-5deg)' }}>
            <div style={{ background: '#fff', padding: 12, border: `1px solid ${S.border}`, boxShadow: '0 16px 32px rgba(40,30,20,0.20)' }}>
              <TreatedPhoto src={PHOTOS.tractor} treatment="sepia" style={{ width: '100%', aspectRatio: '4/3' }} />
              <div style={{ marginTop: 9, fontFamily: 'var(--font-mono)', fontSize: 12, color: S.ink, opacity: 0.65, textAlign: 'center', letterSpacing: '0.05em' }}>Tractor pull · '24</div>
            </div>
          </div>

          {/* Cow + Fairs.com logo lockup (replaces the old Booth B-14 stamp) */}
          <div style={{ position: 'absolute', right: -8, top: 380, transform: 'rotate(4deg)', zIndex: 3 }}>
            <div style={{
              background: S.cream, border: `1.5px solid ${S.ink}`, borderRadius: 14,
              padding: '14px 16px', display: 'flex', alignItems: 'center', gap: 12,
              boxShadow: `5px 5px 0 0 ${S.red}`,
            }}>
              <Cow size={64} style={{ filter: 'none' }} />
              <img src="assets/logo-color.svg" alt="Fairs.com" style={{ height: 24, display: 'block' }} />
            </div>
          </div>

          {/* (Standalone cow removed per design note) */}
        </div>
      </div>
    </section>
  );
}

// ─── Stats strip (180+ / 48 hrs / 28%) — ink-on-cream for contrast ──
function HomeStatsStrip() {
  return (
    <section style={{ background: S.ink, padding: '64px 64px', position: 'relative', overflow: 'hidden' }}>
      {/* Faint red accent decoration */}
      <div style={{ position: 'absolute', top: -80, right: -80, width: 320, height: 320, borderRadius: '50%', background: S.red, opacity: 0.16, filter: 'blur(40px)' }} />
      <div style={{ position: 'absolute', bottom: -120, left: -120, width: 360, height: 360, borderRadius: '50%', background: S.red, opacity: 0.10, filter: 'blur(50px)' }} />
      <div style={{ position: 'relative', maxWidth: 1280, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 32 }}>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, fontWeight: 700, color: S.red, letterSpacing: '0.22em', textTransform: 'uppercase' }}>
            ★ By the numbers · 2026 ★
          </div>
        </div>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', borderTop: `1.5px solid ${S.borderD}`, borderBottom: `1.5px solid ${S.borderD}` }}>
          {REAL_STATS.map((s, i) => (
            <div key={i} style={{
              padding: '36px 32px',
              borderRight: i < REAL_STATS.length - 1 ? `1px dashed rgba(253,249,240,0.18)` : 'none',
              display: 'flex', flexDirection: 'column', gap: 8,
            }}>
              <div style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56, lineHeight: 1, letterSpacing: '-0.03em', color: S.cream }}>{s.num}</div>
              <div style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 22, color: S.red, letterSpacing: '-0.01em' }}>{s.label}</div>
              {s.sub && <div style={{ fontSize: 16, color: 'rgba(253,249,240,0.65)', lineHeight: 1.5 }}>{s.sub}</div>}
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ─── Mission (Educate · Celebrate · Enable) with cow ───────
function HomeMission() {
  return (
    <section style={{ background: S.cream2, padding: '96px 64px', position: 'relative', overflow: 'hidden' }}>
      <div className="has-grain light" style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', maxWidth: 1280, margin: '0 auto' }}>
        <div style={{ display: 'grid', gridTemplateColumns: 'auto 1fr', gap: 48, alignItems: 'flex-end', marginBottom: 56 }}>
          <div style={{ position: 'relative', flex: '0 0 auto' }}>
            <Cow size={260} rotate={-3} />
            <div style={{ position: 'absolute', top: -32, right: -130 }}>
              <SpeechBubble tail="left" tilt={2}>
                We're built for fairs <em style={{ fontStyle: 'italic', color: S.red }}>like yours!</em>
              </SpeechBubble>
            </div>
          </div>
          <div>
            <SectionEyebrow>Our mission</SectionEyebrow>
            <h2 style={{
              fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56, lineHeight: 1.02,
              letterSpacing: '-0.025em', color: S.ink, margin: '12px 0 16px',
            }}>
              Fairs are more than events.<br />
              <em style={{ fontStyle: 'italic', color: S.red, fontWeight: 500 }}>They are where community happens.</em>
            </h2>
            <p style={{ fontSize: 16, lineHeight: 1.55, color: S.ink, opacity: 0.72, maxWidth: 560, margin: 0 }}>
              We help fairs of all sizes grow by pairing the traditions they're built on with the latest
              tools and technology, preserving what makes each fair special while preparing it to thrive
              for generations to come.
            </p>
          </div>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 }}>
          {REAL_PILLARS.map((p, i) => {
            const tilts = [-0.6, 0.4, -0.4];
            return (
              <div key={p.id} style={{
                background: S.cream, padding: 28, borderRadius: 16,
                border: `1.5px solid ${S.ink}`, position: 'relative', overflow: 'hidden',
                boxShadow: `5px 5px 0 0 ${i === 1 ? S.red : S.ink}`,
                transform: `rotate(${tilts[i]}deg)`,
              }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 10, fontFamily: 'var(--font-mono)', fontSize: 12, color: S.red, fontWeight: 700, letterSpacing: '0.2em', textTransform: 'uppercase' }}>★ {p.label}</div>
                <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 22, lineHeight: 1.1, letterSpacing: '-0.02em', color: S.ink, margin: '14px 0 12px' }}>{p.title}</h3>
                <p style={{ fontSize: 16, lineHeight: 1.5, color: S.ink, opacity: 0.7, margin: 0 }}>{p.blurb}</p>
                <div style={{ position: 'absolute', right: -8, bottom: -8, opacity: 0.06, color: S.ink }}>
                  <Ico name={p.icon} size={120} strokeWidth={1} />
                </div>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ─── Modules / Platform tabs ───────────────────────────────
function HomeModules({ onNav }) {
  const [active, setActive] = React.useState(REAL_MODULES[0].id);
  const m = REAL_MODULES.find(x => x.id === active);
  const subRoute = { websites: 'websites', tickets: 'ticketing', reach: 'social', grow: 'marketing' };
  return (
    <section style={{ background: S.cream, padding: '120px 64px', position: 'relative', overflow: 'hidden' }}>
      <div className="has-grain light" style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', maxWidth: 1320, margin: '0 auto' }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 64, alignItems: 'flex-end', marginBottom: 56 }}>
          <div>
            <SectionEyebrow>Our platform</SectionEyebrow>
            <h2 style={{
              fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56, lineHeight: 1.02, letterSpacing: '-0.03em',
              color: S.ink, margin: '16px 0 0', maxWidth: 640,
            }}>
              One unified system<br />
              <em style={{ fontStyle: 'italic', fontWeight: 500, color: S.red }}>to manage your fair.</em>
            </h2>
          </div>
          <p style={{ fontSize: 16, lineHeight: 1.55, color: S.ink, opacity: 0.75, maxWidth: 480, margin: 0 }}>
            Your fair runs on dozens of moving parts. Fairs.com brings them together in one integrated platform, websites, ticketing, social, marketing, vendors, and sponsors.
          </p>
        </div>

        <div className="module-tabs" style={{ display: 'grid', gridTemplateColumns: `repeat(${REAL_MODULES.length}, 1fr)`, borderTop: `1.5px solid ${S.ink}`, borderBottom: `1.5px solid ${S.ink}`, background: S.cream2 }}>
          {REAL_MODULES.map((mod, i) => {
            const a = mod.id === active;
            return (
              <button key={mod.id} onClick={() => setActive(mod.id)} style={{
                background: a ? S.cream : 'transparent', border: 0, padding: '22px 18px',
                fontFamily: 'inherit', cursor: 'pointer', color: S.ink, textAlign: 'left',
                borderRight: i < REAL_MODULES.length - 1 ? `1px dashed rgba(16,15,16,0.2)` : 'none',
                borderBottom: a ? `2px solid ${S.red}` : '2px solid transparent',
                marginBottom: -1, position: 'relative', display: 'flex', flexDirection: 'column', gap: 8,
              }}>
                <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
                  <Ico name={mod.icon} size={20} strokeWidth={1.6} color={a ? S.red : S.ink} />
                  <span style={{ fontFamily: 'var(--font-mono)', fontSize: 12, opacity: 0.45, letterSpacing: '0.14em' }}>№{String(i + 1).padStart(2, '0')}</span>
                </div>
                <div>
                  <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, fontWeight: 700, color: S.red, letterSpacing: '0.16em', textTransform: 'uppercase' }}>{mod.kicker}</div>
                  <div style={{ fontFamily: 'var(--font-display)', fontSize: 22, fontWeight: 500, letterSpacing: '-0.02em', lineHeight: 1, marginTop: 4 }}>{mod.label}</div>
                </div>
              </button>
            );
          })}
        </div>

        <div style={{
          background: S.cream, border: `1.5px solid ${S.ink}`, borderTop: 'none',
          padding: 48, display: 'grid', gridTemplateColumns: '1fr 1.25fr', gap: 56, alignItems: 'center',
        }}>
          <div>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: S.red, fontWeight: 700, letterSpacing: '0.18em', textTransform: 'uppercase' }}>
              {m.kicker} · Module №{String(REAL_MODULES.findIndex(x => x.id === active) + 1).padStart(2, '0')} of {REAL_MODULES.length}
            </div>
            <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 36, lineHeight: 1.1, letterSpacing: '-0.025em', color: S.ink, margin: '14px 0 16px' }}>{m.blurb}</h3>
            <p style={{ fontSize: 16, lineHeight: 1.55, color: S.ink, opacity: 0.75, margin: 0 }}>{m.detail}</p>
            <div style={{ marginTop: 28, display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '14px 24px' }}>
              {m.bullets.map((b, i) => (
                <div key={i} style={{ display: 'flex', gap: 10, alignItems: 'flex-start', fontSize: 16, color: S.ink }}>
                  <div style={{ marginTop: 2, width: 20, height: 20, borderRadius: 999, background: S.red100, display: 'flex', alignItems: 'center', justifyContent: 'center', flex: '0 0 auto' }}>
                    <Ico name="check" size={12} color={S.red} strokeWidth={2.6} />
                  </div>
                  <span>{b}</span>
                </div>
              ))}
            </div>
            <div style={{ marginTop: 32 }}>
              <StubBtn size="md" variant="outline" icon={true} onClick={() => onNav(subRoute[m.id] || 'platform')}>
                Learn more about {m.label.toLowerCase()}
              </StubBtn>
            </div>
          </div>
          <ModulePreview module={m} />
        </div>
      </div>
    </section>
  );
}

// Product UI showcase, one big screenshot per module
function ModulePreview({ module: m }) {
  const PRODUCT_UI = {
    websites: { src: 'assets/ui-websites.avif',     alt: 'Fairs.com Websites: drag-and-drop builder, schedule, vendors, and live site preview' },
    tickets:  { src: PHOTOS.uiTickets,              alt: 'Fairs.com Ticketing: event setup, attendee reports, mobile pass with Apple and Google Wallet, and revenue analytics' },
    reach:    { src: PHOTOS.uiSocial,               alt: 'Fairs.com Social: SMS channel setup, broadcast composer, and unified message scheduling' },
    grow:     { src: PHOTOS.uiMarketing,            alt: 'Fairs.com Marketing: email and SMS campaigns, audience segmentation, and per-send revenue reporting' },
    vendors:  { src: 'assets/product/vendor-applications.png', alt: 'Fairs.com Vendor Management: applications pipeline, booth map, and invoicing' },
    sponsors: { src: 'assets/product/sponsor-tiers.png',       alt: 'Fairs.com Sponsor Management: custom tiers, deal pipeline, and ticket allocation' },
  };
  const ui = PRODUCT_UI[m.id] || PRODUCT_UI.tickets;
  return (
    <div style={{ position: 'relative', minHeight: 480 }}>
      {/* Soft red offset shadow (under the frame) */}
      <div style={{
        position: 'absolute', inset: 0,
        transform: 'translate(12px, 14px)',
        background: S.red, opacity: 0.16, borderRadius: 18,
        filter: 'blur(2px)',
      }} />
      {/* Faint grain wash behind */}
      <div className="has-grain light" style={{ position: 'absolute', inset: -20, pointerEvents: 'none' }} />

      {/* Frame */}
      <div style={{
        position: 'relative',
        background: S.cream,
        border: `1.5px solid ${S.ink}`,
        borderRadius: 18,
        boxShadow: '0 28px 56px rgba(40,30,20,0.16), 0 8px 20px rgba(40,30,20,0.06)',
        padding: 18,
        overflow: 'hidden',
      }}>
        {/* Top chrome strip */}
        <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 14 }}>
          <div style={{ display: 'flex', gap: 6 }}>
            <span style={{ width: 9, height: 9, background: S.red,     borderRadius: 999 }} />
            <span style={{ width: 9, height: 9, background: '#E8C73E', borderRadius: 999 }} />
            <span style={{ width: 9, height: 9, background: '#5FB575', borderRadius: 999 }} />
          </div>
          <div style={{ flex: 1, height: 22, background: S.cream2, borderRadius: 6, border: `1px solid ${S.border}`, display: 'flex', alignItems: 'center', justifyContent: 'center', fontFamily: 'var(--font-mono)', fontSize: 12, color: S.mute, letterSpacing: '0.08em' }}>
            app.fairs.com / {m.label.toLowerCase().replace(/\s+/g, '-')}
          </div>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, fontWeight: 700, color: S.red, letterSpacing: '0.18em', textTransform: 'uppercase' }}>
            ★ Live UI
          </div>
        </div>

        {/* Product screenshot */}
        <div style={{
          position: 'relative', borderRadius: 12, overflow: 'hidden',
          background: S.cream2, border: `1px solid ${S.border}`,
          aspectRatio: '4 / 3',
        }}>
          <img src={ui.src} alt={ui.alt}
            style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center top', display: 'block' }} />
          {/* Subtle inner highlight along the top edge */}
          <div style={{
            position: 'absolute', inset: 0, pointerEvents: 'none',
            background: 'linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0) 28%)',
          }} />
        </div>

        {/* Caption strip below the screenshot */}
        <div style={{
          display: 'flex', alignItems: 'center', justifyContent: 'space-between',
          marginTop: 14, paddingTop: 12, borderTop: `1px dashed ${S.border}`,
        }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
            <span style={{
              width: 28, height: 28, borderRadius: 8,
              background: S.red100, color: S.red,
              display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
            }}>
              <Ico name={m.icon} size={14} strokeWidth={1.8} />
            </span>
            <div style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 16, color: S.ink, letterSpacing: '-0.01em' }}>
              {m.label} · <span style={{ color: S.red, fontStyle: 'italic' }}>{m.kicker.toLowerCase()}</span>
            </div>
          </div>
          <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: S.mute, fontWeight: 700, letterSpacing: '0.16em', textTransform: 'uppercase' }}>
            Product UI · 2026
          </div>
        </div>
      </div>
    </div>
  );
}

// ─── Before/After Transform ─────────────────────────────────
function HomeTransform() {
  return (
    <section style={{ background: S.cream3, padding: '120px 64px', position: 'relative' }}>
      <div className="has-grain" style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', maxWidth: 1280, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 56 }}>
          <SectionEyebrow>Transformation</SectionEyebrow>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56, lineHeight: 1.02, letterSpacing: '-0.03em', color: S.ink, margin: '16px auto 16px', maxWidth: 760 }}>
            {REAL_TRANSFORM.title}
          </h2>
          <p style={{ fontSize: 16, lineHeight: 1.55, color: S.ink, opacity: 0.72, maxWidth: 640, margin: '0 auto' }}>{REAL_TRANSFORM.blurb}</p>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: '1fr 80px 1fr', alignItems: 'stretch' }}>
          <div style={{ background: S.cream, border: `1.5px solid rgba(16,15,16,0.18)`, padding: 36, borderRadius: 16 }}>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: S.mute, fontWeight: 700, letterSpacing: '0.2em', textTransform: 'uppercase' }}>Before</div>
            <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 22, color: S.ink, margin: '8px 0 24px', letterSpacing: '-0.02em', opacity: 0.6 }}>Complex chaos</h3>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
              {REAL_TRANSFORM.before.map((b, i) => (
                <div key={i} style={{ display: 'flex', gap: 12, alignItems: 'center', fontSize: 16, color: S.ink, opacity: 0.65 }}>
                  <Ico name="x" size={16} strokeWidth={2.4} color={S.mute} />
                  <span style={{ textDecoration: 'line-through', textDecorationColor: 'rgba(16,15,16,0.3)' }}>{b}</span>
                </div>
              ))}
            </div>
          </div>
          <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
            <div style={{ width: 56, height: 56, borderRadius: '50%', background: S.red, display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: '0 12px 24px rgba(255,54,54,0.32)' }}>
              <Ico name="arrowRight" size={20} strokeWidth={2.4} color={S.cream} />
            </div>
          </div>
          <div style={{ background: S.cream, border: `1.5px solid ${S.red}`, padding: 36, borderRadius: 16, position: 'relative' }}>
            <div style={{ position: 'absolute', top: 16, right: 16, fontFamily: 'var(--font-mono)', fontSize: 12, color: S.red, fontWeight: 700, letterSpacing: '0.2em', textTransform: 'uppercase', border: `1.5px solid ${S.red}`, padding: '4px 10px', transform: 'rotate(4deg)' }}>★ Fairs.com</div>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: S.red, fontWeight: 700, letterSpacing: '0.2em', textTransform: 'uppercase' }}>With Fairs.com</div>
            <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 22, color: S.ink, margin: '8px 0 24px', letterSpacing: '-0.02em' }}>
              <em style={{ fontStyle: 'italic', color: S.red }}>Streamlined</em> success
            </h3>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
              {REAL_TRANSFORM.after.map((b, i) => (
                <div key={i} style={{ display: 'flex', gap: 12, alignItems: 'flex-start', fontSize: 16, color: S.ink, lineHeight: 1.4 }}>
                  <div style={{ marginTop: 2, width: 18, height: 18, borderRadius: 999, background: S.red100, display: 'flex', alignItems: 'center', justifyContent: 'center', flex: '0 0 auto' }}>
                    <Ico name="check" size={11} color={S.red} strokeWidth={2.6} />
                  </div>
                  <span>{b}</span>
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── Compare vs Saffire + eTix ─────────────────────────────
function HomeCompare({ onNav }) {
  const checkCell = (val, isFairs) => {
    if (typeof val === 'string') {
      return (
        <span style={{
          fontFamily: 'var(--font-display)', fontWeight: 700, fontSize: 16,
          color: S.ink, letterSpacing: '-0.005em',
        }}>{val}</span>
      );
    }
    if (val === true) {
      return (
        <div style={{
          width: 36, height: 36, borderRadius: 8,
          background: isFairs ? S.red : S.ink,
          display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
        }}>
          <Ico name="check" size={20} strokeWidth={3} color={S.cream} />
        </div>
      );
    }
    return (
      <div style={{
        width: 36, height: 36, borderRadius: 8,
        background: 'rgba(16,15,16,0.08)', color: 'rgba(16,15,16,0.32)',
        display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
      }}>
        <Ico name="x" size={18} strokeWidth={2.4} />
      </div>
    );
  };
  return (
    <section style={{ background: S.cream, padding: '120px 64px', position: 'relative' }}>
      <div className="has-grain light" style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', maxWidth: 1200, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 48 }}>
          <StubChip>Built · How we stack up</StubChip>
          <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56, lineHeight: 1.05, letterSpacing: '-0.03em', color: S.ink, margin: '24px 0 16px' }}>
            See what sets the <em style={{ fontStyle: 'italic', color: S.red }}>fair-first</em><br />platform apart.
          </h2>
        </div>

        <MobileCompareTable />
        <div className="cmp-table" style={{ background: S.cream, borderRadius: 16, border: `1.5px solid ${S.ink}`, overflow: 'hidden', boxShadow: '0 18px 40px rgba(40,30,20,0.10)' }}>
          {/* Header: Company Information + 3 brand columns */}
          <div className="cmp-row" style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr' }}>
            <div style={{ padding: '24px 28px', background: S.cream2, borderRight: `1px solid ${S.border}` }}>
              <div style={{ fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 16, color: S.ink, letterSpacing: '-0.01em' }}>Company Information</div>
            </div>
            {REAL_COMPARE.cols.map((c, i) => (
              <div key={i} style={{
                padding: '24px 18px', textAlign: 'center', background: S.cream2,
                borderRight: i < REAL_COMPARE.cols.length - 1 ? `1px solid ${S.border}` : 'none',
                display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
              }}>
                {c.name === 'Fairs.com' ? (
                  <img src="assets/logo-color.svg" alt="Fairs.com" style={{ height: 26 }} />
                ) : (
                  <div style={{ fontFamily: 'var(--font-display)', fontStyle: c.name === 'Saffire' ? 'italic' : 'normal', fontWeight: c.name === 'eTix' ? 800 : 700, fontSize: 22, color: S.ink, letterSpacing: '-0.02em' }}>
                    {c.name === 'eTix' ? <><span style={{ color: S.ink }}>e</span><span>tix</span></> : c.name}
                  </div>
                )}
              </div>
            ))}
          </div>

          {/* Meta rows: Year, Focus */}
          {REAL_COMPARE.meta.map((row, ri) => (
            <div key={ri} className="cmp-row" style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', borderTop: `1px solid ${S.border}` }}>
              <div style={{ padding: '18px 28px', fontSize: 16, fontWeight: 500, color: S.ink, borderRight: `1px solid ${S.border}` }}>{row[0]}</div>
              {row.slice(1).map((v, ci) => (
                <div key={ci} style={{
                  padding: '18px 18px', textAlign: 'center', fontSize: 16, fontWeight: 600, color: S.ink,
                  borderRight: ci < 2 ? `1px solid ${S.border}` : 'none',
                  background: ci === 0 ? 'rgba(255,54,54,0.04)' : 'transparent',
                }}>{v}</div>
              ))}
            </div>
          ))}

          {/* Features section divider */}
          <div className="cmp-row" style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', borderTop: `1.5px solid ${S.ink}`, background: S.cream2 }}>
            <div style={{ padding: '16px 28px', fontFamily: 'var(--font-display)', fontWeight: 600, fontSize: 16, color: S.ink, letterSpacing: '-0.01em', borderRight: `1px solid ${S.border}` }}>Features</div>
            <div style={{ borderRight: `1px solid ${S.border}` }} />
            <div style={{ borderRight: `1px solid ${S.border}` }} />
            <div />
          </div>

          {/* Feature rows */}
          {REAL_COMPARE.features.map((row, ri) => (
            <div key={ri} className="cmp-row" style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', borderTop: `1px solid ${S.border}` }}>
              <div style={{ padding: '18px 28px', fontSize: 16, fontWeight: 500, color: S.ink, borderRight: `1px solid ${S.border}` }}>{row[0]}</div>
              {row.slice(1).map((v, ci) => (
                <div key={ci} style={{
                  padding: '14px 18px', textAlign: 'center',
                  borderRight: ci < 2 ? `1px solid ${S.border}` : 'none',
                  background: ci === 0 ? 'rgba(255,54,54,0.04)' : 'transparent',
                  display: 'flex', alignItems: 'center', justifyContent: 'center',
                }}>
                  {checkCell(v, ci === 0)}
                </div>
              ))}
            </div>
          ))}

        </div>

        <div style={{ display: 'flex', gap: 16, justifyContent: 'center', marginTop: 40 }}>
          <StubBtn size="md" onClick={() => onNav('contact')}>Book a demo</StubBtn>
          <StubBtn size="md" variant="outline" icon={false} onClick={() => onNav('platform')}>Learn more →</StubBtn>
        </div>
      </div>
    </section>
  );
}

// ─── Logo scroll (real customer fair logos, from fairs.com) ──
// White backgrounds are pre-removed from the PNGs so logos sit
// directly on the cream section background at full size.
const CUSTOMER_LOGOS = Array.from({ length: 53 }, (_, i) =>
  'assets/customer-logos/fair-logo-' + String(i + 1).padStart(2, '0') + '.png');

function HomeLogoWall() {
  // One full set of logos; rendered twice so the CSS loop is seamless.
  const Row = ({ hidden }) => (
    <div aria-hidden={hidden ? 'true' : undefined} style={{ display: 'flex', alignItems: 'center', gap: 56, paddingRight: 56, flex: '0 0 auto' }}>
      {CUSTOMER_LOGOS.map((src, i) => (
        <img key={i} src={src} alt={hidden ? '' : 'Customer fair logo'} style={{ height: 120, width: 'auto', maxWidth: 280, objectFit: 'contain', display: 'block', flex: '0 0 auto', borderRadius: 8 }} />
      ))}
    </div>
  );
  return (
    <section style={{ background: S.cream2, padding: '96px 64px', position: 'relative' }}>
      <div className="has-grain" style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', maxWidth: 1280, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 48 }}>
          <SectionEyebrow>Our progress</SectionEyebrow>
          <h3 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 36, marginTop: 16, letterSpacing: '-0.025em', color: S.ink, lineHeight: 1.1 }}>
            Trusted by <em style={{ fontStyle: 'italic', color: S.red }}>180+ fairs</em> across North America.
          </h3>
          <p style={{ fontSize: 16, color: S.mute, marginTop: 12 }}>Over 180 fairs have joined our mission since our launch in 2023.</p>
        </div>
        {/* Scrolling logo strip; pauses on hover */}
        <div style={{ position: 'relative', overflow: 'hidden' }}>
          <div className="logo-marquee">
            <Row />
            <Row hidden />
          </div>
          <div style={{ position: 'absolute', left: 0, top: 0, bottom: 0, width: 72, background: `linear-gradient(90deg, ${S.cream2}, transparent)`, pointerEvents: 'none' }} />
          <div style={{ position: 'absolute', right: 0, top: 0, bottom: 0, width: 72, background: `linear-gradient(270deg, ${S.cream2}, transparent)`, pointerEvents: 'none' }} />
        </div>
      </div>
    </section>
  );
}

// ─── Instagram feed (Elfsight) ─────────────────────────────
// Same widget the live fairs.com home uses, embedded via Elfsight's
// platform script. The widget div is hydrated client-side once the
// platform.js script loads.
function HomeInstagram() {
  React.useEffect(() => {
    const id = 'elfsight-platform-js';
    if (document.getElementById(id)) return;
    const s = document.createElement('script');
    s.id = id;
    s.src = 'https://elfsightcdn.com/platform.js';
    s.async = true;
    document.body.appendChild(s);
  }, []);

  return (
    <section style={{ background: S.ink, padding: '120px 64px', position: 'relative', overflow: 'hidden' }}>
      <div className="has-grain" style={{ position: 'absolute', inset: 0, opacity: 0.5 }} />
      {/* ambient red glow */}
      <div style={{ position: 'absolute', top: -100, right: -100, width: 320, height: 320, borderRadius: '50%', background: S.red, opacity: 0.16, filter: 'blur(40px)' }} />
      <div style={{ position: 'absolute', bottom: -140, left: -140, width: 360, height: 360, borderRadius: '50%', background: S.red, opacity: 0.10, filter: 'blur(50px)' }} />
      <div style={{ position: 'relative', maxWidth: 1280, margin: '0 auto' }}>
        <div className="home-insta-head" style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 48, alignItems: 'end', marginBottom: 48 }}>
          <div>
            <SectionEyebrow>Our impact</SectionEyebrow>
            <h2 style={{
              fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56,
              lineHeight: 1.02, letterSpacing: '-0.03em', color: S.cream,
              margin: '16px 0 0',
            }}>
              Connect with us <em style={{ fontStyle: 'italic', color: S.red, fontWeight: 500 }}>on socials.</em>
            </h2>
          </div>
          <div>
            <p style={{ fontSize: 16, lineHeight: 1.55, color: S.cream, opacity: 0.78, margin: 0, maxWidth: 520 }}>
              The fundamentals of modern ticketing and marketing, fair industry updates, and wins worth celebrating with our partner fairs — that's what we share.
            </p>
          </div>
        </div>
        {/* Elfsight Instagram Feed | Fairs Insta Feed */}
        <div className="elfsight-app-492ed261-e416-4893-bb3e-8a7a71d6ac2e" data-elfsight-app-lazy></div>
      </div>
    </section>
  );
}

// ─── Testimonials (real, carousel) ─────────────────────────
function HomeTestimonials() {
  const [i, setI] = useCarousel(REAL_TESTIMONIALS.length, 7000);
  const t = REAL_TESTIMONIALS[i];
  return (
    <section style={{ background: S.cream, padding: '120px 64px', position: 'relative' }}>
      <div className="has-grain light" style={{ position: 'absolute', inset: 0 }} />
      <div style={{ position: 'relative', maxWidth: 1100, margin: '0 auto' }}>
        <div style={{ textAlign: 'center', marginBottom: 40 }}>
          <SectionEyebrow>What fair managers say</SectionEyebrow>
        </div>
        <div style={{ position: 'relative', textAlign: 'center', minHeight: 280 }}>
          <div style={{ display: 'inline-flex', gap: 6, marginBottom: 24 }}>
            {Array.from({ length: t.stars }).map((_, k) => <span key={k} style={{ color: S.red, fontSize: 22 }}>★</span>)}
          </div>
          <blockquote style={{
            fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 36, lineHeight: 1.3,
            letterSpacing: '-0.02em', margin: 0, color: S.ink, maxWidth: 920, marginLeft: 'auto', marginRight: 'auto',
          }}>"{t.quote}"</blockquote>
          <div style={{ marginTop: 32, display: 'inline-flex', gap: 14, alignItems: 'center', padding: '14px 22px', background: S.cream2, borderRadius: 999, border: `1px solid ${S.border}` }}>
            <div style={{ width: 40, height: 40, borderRadius: 999, background: S.kraft, display: 'flex', alignItems: 'center', justifyContent: 'center', fontFamily: 'var(--font-display)', fontWeight: 700, color: S.ink, fontSize: 16 }}>
              {t.name.split(' ').map(w => w[0]).join('')}
            </div>
            <div style={{ textAlign: 'left' }}>
              <div style={{ fontWeight: 700, fontSize: 16 }}>{t.name}</div>
              <div style={{ fontFamily: 'var(--font-mono)', fontSize: 12, color: S.mute, letterSpacing: '0.06em' }}>{t.role} · {t.fair}</div>
            </div>
          </div>
        </div>
        <div style={{ display: 'flex', gap: 8, justifyContent: 'center', marginTop: 32 }}>
          {REAL_TESTIMONIALS.map((_, k) => (
            <button key={k} onClick={() => setI(k)} style={{
              width: k === i ? 28 : 8, height: 8, border: 0, padding: 0, cursor: 'pointer',
              background: k === i ? S.ink : 'rgba(16,15,16,0.2)', borderRadius: 999, transition: 'all .2s',
            }} />
          ))}
        </div>
      </div>
    </section>
  );
}

// ─── Cow CTA with big ticket — ink background, big red ticket pops ──
function HomeCowCTA({ onNav }) {
  return (
    <section style={{ background: S.ink, padding: '120px 64px', position: 'relative', overflow: 'hidden' }}>
      <div style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%,-50%)', width: 800, height: 800, borderRadius: '50%', background: S.red, opacity: 0.10, filter: 'blur(80px)' }} />
      <div style={{ position: 'relative', maxWidth: 1100, margin: '0 auto', textAlign: 'center' }}>
        <h2 style={{ fontFamily: 'var(--font-display)', fontWeight: 500, fontSize: 56, lineHeight: 0.98, letterSpacing: '-0.035em', color: S.cream, margin: '16px 0 24px' }}>
          See it run <em style={{ fontStyle: 'italic', color: S.red }}>before your next event.</em>
        </h2>
        <p style={{ fontSize: 16, color: 'rgba(253,249,240,0.72)', maxWidth: 620, margin: '0 auto' }}>A 30-minute consultation with a Fairs.com expert.</p>

        <div className="home-cow-cta-row" style={{ position: 'relative', marginTop: 56, display: 'flex', justifyContent: 'center', alignItems: 'flex-end' }}>
          <div style={{ position: 'relative', marginRight: -28, marginBottom: 28, zIndex: 2, display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 16 }}>
            <SpeechBubble tail="left" tilt={-3}>
              See why so many fairs <em style={{ fontStyle: 'italic', color: S.red }}>swear by it!</em>
            </SpeechBubble>
            <Cow size={200} flip rotate={-6} />
          </div>
          <div style={{ transform: 'rotate(-1deg)', cursor: 'pointer', width: '100%', maxWidth: 720 }} onClick={() => onNav('contact')}>
            <BigDemoTicket />
          </div>
        </div>
      </div>
    </section>
  );
}

function BigDemoTicket() {
  const w = 720, h = 200;
  return (
    <svg viewBox={`0 0 ${w} ${h}`} preserveAspectRatio="xMidYMid meet" style={{ display: 'block', width: '100%', height: 'auto', maxWidth: w, filter: 'drop-shadow(0 22px 32px rgba(40,30,20,0.22))' }}>
      <defs>
        <mask id="home-bigticket">
          <rect width={w} height={h} fill="white" />
          <circle cx={w - 200} cy="0" r="14" fill="black" />
          <circle cx={w - 200} cy={h} r="14" fill="black" />
          <circle cx="0" cy={h/2} r="14" fill="black" />
          <circle cx={w} cy={h/2} r="14" fill="black" />
        </mask>
      </defs>
      <g mask="url(#home-bigticket)">
        <rect width={w} height={h} fill={S.red} rx="10" />
        <line x1={w - 200} y1="18" x2={w - 200} y2={h - 18} stroke="rgba(253,249,240,0.4)" strokeWidth="2" strokeDasharray="4 6" />
      </g>
      <g fontFamily="Plus Jakarta Sans" fill={S.cream}>
        <text x="44" y="50" fontSize="12" fontWeight="700" letterSpacing="0.22em">ADMIT ONE · DEMO</text>
        <text x="44" y="120" fontSize="54" fontWeight="500" letterSpacing="-0.025em">Book a demo →</text>
        <text x="44" y="158" fontSize="14" fontStyle="italic" opacity="0.9">30-minute consultation with a Fairs.com expert</text>
        <text x={w - 100} y="88" fontSize="46" fontWeight="700" textAnchor="middle">★</text>
        <text x={w - 100} y="116" fontSize="11" textAnchor="middle" letterSpacing="0.18em" opacity="0.9">DEMO PASS</text>
      </g>
    </svg>
  );
}

Object.assign(window, { PageHome });
