/* Page sections — hero, shift, how, use cases, proof, integrations, cta, faq, footer */
const { MeetingMock, FollowupMock, BoardMock, RelationshipMock } = window.CWMocks;

const HOMEPAGE_TYPE = {
  heroTitleSize: "var(--home-hero-title-size)",
  heroTitleLineHeight: "var(--home-hero-title-line-height)",
  heroCopySize: "var(--home-hero-copy-size)",
  heroCopyMax: "var(--home-hero-copy-max)",
  heroCopyMarginTop: "var(--home-hero-copy-margin-top)",
  heroActionsMarginTop: "var(--home-hero-actions-margin-top)",
  heroMetaMarginTop: "var(--home-hero-meta-margin-top)",
  sectionH2Size: "var(--home-section-h2-size)",
  sectionH2LineHeight: "var(--home-section-h2-line-height)",
  featureH3Size: "var(--home-feature-h3-size)",
  compactH2Size: "var(--home-compact-h2-size)",
  ctaH2Size: "var(--home-cta-h2-size)",
};

const buildWhatsappHref = ({ lang = "de", intent = "contact", source = "" } = {}) => {
  const params = new URLSearchParams({ lang, intent });
  if (source) params.set("source", source);
  return `whatsapp.html?${params.toString()}`;
};

/* --- Wordmark --- */
const Wordmark = ({ size = 28 }) => (
  <div style={{ display: "inline-flex", alignItems: "center", gap: 12 }}>
    <img
      src="assets/connectwunder-icon.png"
      alt="ConnectWunder"
      style={{
        width: size, height: size,
        borderRadius: size * 0.22,
        display: "block",
        boxShadow: "0 2px 6px -2px rgba(14,26,58,0.25)",
      }}
    />
    <span style={{ fontFamily: "var(--serif)", fontSize: 18, letterSpacing: "-0.01em" }}>ConnectWunder</span>
  </div>
);

/* --- Nav --- */
const Nav = ({ t, lang, setLang }) => {
  const [menuOpen, setMenuOpen] = React.useState(false);
  const closeMenu = () => setMenuOpen(false);

  return (
    <nav className="top">
      <div className="container home-nav" style={{ display: "flex", alignItems: "center", justifyContent: "space-between", minHeight: 72 }}>
        <Wordmark />
        <div className="home-nav-links" style={{ display: "flex", alignItems: "center", gap: 36, fontSize: 13.5 }}>
          <a href="#shift">{t.nav.product}</a>
          <a href="#use-cases">{t.nav.useCases}</a>
          <a href="#integrations">{t.nav.integrations}</a>
          <a href="#proof">{t.nav.proof}</a>
        </div>
        <div className="home-nav-actions" style={{ display: "flex", alignItems: "center", gap: 14 }}>
          <div className="home-lang-switch" style={{ display: "inline-flex", border: "1px solid var(--hair-strong)", borderRadius: 2, overflow: "hidden" }}>
            {["de", "en"].map(l => (
              <button key={l}
                onClick={() => setLang(l)}
                style={{
                  padding: "6px 10px", fontSize: 11, letterSpacing: "0.1em",
                  background: lang === l ? "var(--navy)" : "transparent",
                  color: lang === l ? "var(--ivory)" : "var(--navy)",
                  border: "none", cursor: "pointer", fontWeight: 500,
                }}>{t.lang[l]}</button>
            ))}
          </div>
          <a
            className="btn btn-primary"
            href={buildWhatsappHref({ lang, intent: "demo", source: "home-nav-demo" })}
          >
            {t.nav.demo} <span className="arrow">→</span>
          </a>
          <button
            type="button"
            className="mobile-menu-toggle home-mobile-menu-toggle"
            aria-expanded={menuOpen ? "true" : "false"}
            aria-label={menuOpen ? "Close navigation menu" : "Open navigation menu"}
            onClick={() => setMenuOpen((open) => !open)}
          >
            <span />
            <span />
            <span />
          </button>
        </div>
        <div className={`mobile-menu-panel home-mobile-menu-panel${menuOpen ? " is-open" : ""}`}>
          <div className="mobile-menu-links">
            <a href="#shift" onClick={closeMenu}>{t.nav.product}</a>
            <a href="#use-cases" onClick={closeMenu}>{t.nav.useCases}</a>
            <a href="#integrations" onClick={closeMenu}>{t.nav.integrations}</a>
            <a href="#proof" onClick={closeMenu}>{t.nav.proof}</a>
          </div>
          <div className="mobile-menu-lang">
            {["de", "en"].map(l => (
              <button
                key={l}
                type="button"
                onClick={() => {
                  setLang(l);
                  closeMenu();
                }}
                style={{
                  padding: "8px 12px",
                  fontSize: 11,
                  letterSpacing: "0.1em",
                  background: lang === l ? "var(--navy)" : "transparent",
                  color: lang === l ? "var(--ivory)" : "var(--navy)",
                  border: "1px solid var(--hair-strong)",
                  cursor: "pointer",
                  fontWeight: 500,
                  borderRadius: 2,
                }}
              >
                {t.lang[l]}
              </button>
            ))}
          </div>
        </div>
      </div>
    </nav>
  );
};

/* --- Hero --- */
const Hero = ({ t, claimIdx, lang }) => {
  const claim = t.hero.claims[claimIdx % t.hero.claims.length];
  return (
    <section style={{ padding: "var(--home-hero-pad-top) 0 var(--home-hero-pad-bottom)", position: "relative" }}>
      {/* soft gold wash top-right */}
      <div className="home-hero-glow" style={{
        position: "absolute", top: 0, right: "-10%", width: "55%", height: "80%",
        background: "radial-gradient(ellipse at top right, color-mix(in oklab, var(--gold-wash) calc(var(--gold-intensity) * 100%), transparent) 0%, transparent 60%)",
        pointerEvents: "none",
      }} />
      <div className="container">
        <div className="home-hero-grid" style={{ display: "grid", gridTemplateColumns: "1.15fr 1fr", gap: "var(--home-hero-grid-gap)", alignItems: "center" }}>
          <div className="fade-up">
            <div className="eyebrow" style={{ marginBottom: 28 }}>{t.hero.eyebrow}</div>
            <h1 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.heroTitleSize, lineHeight: HOMEPAGE_TYPE.heroTitleLineHeight, margin: 0, maxWidth: "11ch" }}>
              {claim[0]}<br />
              <span className="gold-text">{claim[1]}</span><br />
              {claim[2]}
            </h1>
            <p className="home-hero-copy" style={{ fontSize: HOMEPAGE_TYPE.heroCopySize, lineHeight: 1.55, color: "var(--navy-soft)", maxWidth: HOMEPAGE_TYPE.heroCopyMax, marginTop: HOMEPAGE_TYPE.heroCopyMarginTop, textWrap: "pretty" }}>
              {t.hero.sub}
            </p>
            <div className="home-hero-actions" style={{ display: "flex", gap: 12, marginTop: HOMEPAGE_TYPE.heroActionsMarginTop, flexWrap: "wrap" }}>
              <a
                className="btn btn-primary"
                href={buildWhatsappHref({ lang, intent: "demo", source: "home-hero-primary" })}
              >
                {t.hero.ctaPrimary} <span className="arrow">→</span>
              </a>
              <a
                className="btn btn-ghost"
                href={buildWhatsappHref({ lang, intent: "call", source: "home-hero-secondary" })}
              >
                {t.hero.ctaSecondary}
              </a>
            </div>
            <div className="home-hero-meta" style={{ marginTop: HOMEPAGE_TYPE.heroMetaMarginTop, display: "flex", alignItems: "center", gap: 14 }}>
              <div style={{ width: 28, height: 1, background: "var(--hair-strong)" }} />
              <div>
                <div style={{ fontSize: 10.5, letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--ink-muted)", fontWeight: 500 }}>
                  {t.hero.metaLabel}
                </div>
                <div style={{ fontSize: 12.5, color: "var(--navy-soft)", marginTop: 3 }}>
                  {t.hero.metaLine}
                </div>
              </div>
            </div>
          </div>

          {/* hero mock composition */}
          <div className="home-hero-visual" style={{ position: "relative", height: "var(--home-hero-mock-height)" }}>
            <div className="home-hero-mock home-hero-mock-meeting" style={{ position: "absolute", top: 20, right: 0, zIndex: 3 }}>
              <MeetingMock />
            </div>
            <div className="home-hero-mock home-hero-mock-followup" style={{ position: "absolute", bottom: 40, left: 0, zIndex: 2 }}>
              <FollowupMock />
            </div>
            <div className="home-hero-mock home-hero-mock-relationship" style={{ position: "absolute", top: 340, right: 40, zIndex: 1, opacity: 0.92 }}>
              <RelationshipMock />
            </div>
          </div>
        </div>
      </div>
    </section>
  );
};

/* --- Shift --- */
const Shift = ({ t }) => (
  <section id="shift" className="home-section" style={{ padding: "120px 0 100px", borderTop: "1px solid var(--hair)" }}>
    <div className="container">
      <div className="home-intro-grid" style={{ display: "grid", gridTemplateColumns: "1fr 1.6fr", gap: 80, marginBottom: 64 }}>
        <div>
          <div className="eyebrow" style={{ marginBottom: 20 }}>{t.shift.eyebrow}</div>
          <h2 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.sectionH2Size, lineHeight: HOMEPAGE_TYPE.sectionH2LineHeight, margin: 0, maxWidth: "14ch" }}>
            {t.shift.head[0]}<span className="gold-text">{t.shift.head[1]}</span>{t.shift.head[2]}
          </h2>
        </div>
        <p style={{ fontSize: 17, lineHeight: 1.6, color: "var(--navy-soft)", textWrap: "pretty", paddingTop: 8 }}>
          {t.shift.lede}
        </p>
      </div>

      <div className="home-two-col-grid" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 32 }}>
        {t.shift.cols.map((c, i) => (
          <div key={i} className="home-shift-card" style={{
            background: i === 1 ? "var(--navy)" : "transparent",
            color: i === 1 ? "var(--ivory)" : "var(--navy)",
            padding: "40px 36px",
            borderRadius: 4,
            border: i === 0 ? "1px solid var(--hair)" : "1px solid var(--navy)",
            position: "relative",
          }}>
            {i === 1 && (
              <div style={{ position: "absolute", top: 0, left: 0, right: 0, height: 2, background: "color-mix(in oklab, var(--gold) calc(var(--gold-intensity) * 100%), var(--navy))" }} />
            )}
            <div style={{
              fontSize: 10.5, letterSpacing: "0.18em", textTransform: "uppercase", fontWeight: 500,
              color: i === 1 ? "color-mix(in oklab, var(--gold-soft) calc(var(--gold-intensity) * 100%), var(--ivory))" : "var(--ink-muted)",
              marginBottom: 18,
            }}>{c.kicker}</div>
            <h3 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.featureH3Size, lineHeight: 1.12, margin: "0 0 24px", maxWidth: 360 }}>{c.title}</h3>
            <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 14 }}>
              {c.bullets.map((b, j) => (
                <li key={j} style={{ display: "flex", gap: 14, fontSize: 15, lineHeight: 1.5, color: i === 1 ? "rgba(244,238,226,0.82)" : "var(--navy-soft)" }}>
                  <span style={{ flexShrink: 0, width: 18, paddingTop: 9 }}>
                    <span style={{ display: "block", width: 6, height: 1, background: i === 1 ? "color-mix(in oklab, var(--gold) calc(var(--gold-intensity) * 100%), var(--ivory))" : "var(--gold)" }} />
                  </span>
                  <span>{b}</span>
                </li>
              ))}
            </ul>
          </div>
        ))}
      </div>
    </div>
  </section>
);

/* --- How it works --- */
const HowItWorks = ({ t }) => (
  <section className="home-section" style={{ padding: "120px 0 100px", borderTop: "1px solid var(--hair)" }}>
    <div className="container">
      <div style={{ maxWidth: 780, marginBottom: 72 }}>
        <div className="eyebrow" style={{ marginBottom: 20 }}>{t.how.eyebrow}</div>
        <h2 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.sectionH2Size, lineHeight: HOMEPAGE_TYPE.sectionH2LineHeight, margin: "0 0 24px", maxWidth: "14ch" }}>
          {t.how.head[0]}<span className="gold-text">{t.how.head[1]}</span>{t.how.head[2]}
        </h2>
        <p style={{ fontSize: 17, lineHeight: 1.6, color: "var(--navy-soft)", maxWidth: 620, textWrap: "pretty" }}>
          {t.how.lede}
        </p>
      </div>

      {/* Flow visual */}
      <div className="home-flow-grid" style={{
        display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 0,
        borderTop: "1px solid var(--hair)", borderBottom: "1px solid var(--hair)",
      }}>
        {t.how.steps.map((s, i) => (
          <div key={i} className="home-flow-step" style={{
            padding: "36px 28px 40px",
            borderRight: i < 3 ? "1px solid var(--hair)" : "none",
            position: "relative",
          }}>
            <div style={{ display: "flex", alignItems: "baseline", justifyContent: "space-between", marginBottom: 24 }}>
              <span className="mono" style={{ color: "var(--ink-muted)" }}>{s.n}</span>
              <span style={{
                fontFamily: "var(--serif)", fontStyle: "italic", fontSize: 20,
                color: "color-mix(in oklab, var(--gold) calc(var(--gold-intensity) * 100%), var(--navy))",
              }}>{s.k}</span>
            </div>
            <h3 className="serif-display" style={{ fontSize: 22, lineHeight: 1.18, margin: "0 0 14px", color: "var(--navy)" }}>{s.t}</h3>
            <p style={{ fontSize: 14, lineHeight: 1.55, color: "var(--navy-soft)", margin: 0, textWrap: "pretty" }}>{s.d}</p>
          </div>
        ))}
      </div>

      {/* Composed mock below flow */}
      <div className="home-composed-grid" style={{ marginTop: 72, display: "grid", gridTemplateColumns: "1.2fr 1fr", gap: 40, alignItems: "center" }}>
        <div>
          <BoardMock />
        </div>
        <div className="home-composed-copy" style={{ paddingLeft: 20 }}>
          <div style={{
            fontSize: 10.5, letterSpacing: "0.18em", textTransform: "uppercase", color: "var(--ink-muted)", fontWeight: 500, marginBottom: 14,
          }}>Ergebnis · Beispiel</div>
          <h3 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.featureH3Size, lineHeight: 1.12, margin: "0 0 18px", maxWidth: 420 }}>
            Ein Meeting wird zu einem Pipeline-Update und einem Follow-up.
          </h3>
          <p style={{ fontSize: 15, lineHeight: 1.6, color: "var(--navy-soft)", maxWidth: 440, margin: 0 }}>
            Sales spricht. Kontext fließt in Personen, Deals und Boards. AI schlägt den nächsten Schritt vor. Mensch entscheidet, klickt, fertig.
          </p>
        </div>
      </div>
    </div>
  </section>
);

/* --- Use Cases --- */
const UseCases = ({ t }) => (
  <section id="use-cases" className="dark home-section" style={{ padding: "120px 0 120px" }}>
    <div className="container">
      <div className="home-intro-grid" style={{ display: "grid", gridTemplateColumns: "1fr 1.4fr", gap: 80, marginBottom: 64 }}>
        <div>
          <div className="eyebrow" style={{ marginBottom: 20, color: "var(--ivory)" }}>{t.useCases.eyebrow}</div>
          <h2 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.sectionH2Size, lineHeight: HOMEPAGE_TYPE.sectionH2LineHeight, margin: 0, maxWidth: "14ch" }}>
            {t.useCases.head[0]}<span className="gold-text" style={{ color: "color-mix(in oklab, var(--gold-soft) calc(var(--gold-intensity) * 100%), var(--ivory))" }}>{t.useCases.head[1]}</span>{t.useCases.head[2]}
          </h2>
        </div>
        <p style={{ fontSize: 17, lineHeight: 1.6, color: "rgba(244,238,226,0.72)", textWrap: "pretty", paddingTop: 8 }}>
          {t.useCases.lede}
        </p>
      </div>

      <div className="home-three-col-grid" style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 24 }}>
        {t.useCases.cards.map((c, i) => (
          <div key={i} className="home-use-case-card" style={{
            background: "rgba(255,255,255,0.03)",
            border: "1px solid rgba(244,238,226,0.14)",
            padding: "32px 28px 36px",
            borderRadius: 4,
            display: "flex", flexDirection: "column", gap: 18,
            position: "relative",
          }}>
            <div style={{
              fontSize: 10.5, letterSpacing: "0.18em", textTransform: "uppercase", fontWeight: 500,
              color: "color-mix(in oklab, var(--gold-soft) calc(var(--gold-intensity) * 100%), var(--ivory))",
            }}>{c.tag}</div>
            <h3 className="serif-display" style={{ fontSize: 24, lineHeight: 1.14, margin: 0, color: "var(--ivory)" }}>{c.title}</h3>
            <p style={{ fontSize: 14, lineHeight: 1.6, color: "rgba(244,238,226,0.72)", margin: 0, textWrap: "pretty" }}>{c.body}</p>
            <hr className="hairline" style={{ marginTop: 6 }} />
            <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 10 }}>
              {c.outcomes.map((o, j) => (
                <li key={j} style={{ display: "flex", gap: 10, alignItems: "baseline", fontSize: 13, color: "rgba(244,238,226,0.85)" }}>
                  <span style={{ width: 4, height: 4, borderRadius: "50%", background: "color-mix(in oklab, var(--gold) calc(var(--gold-intensity) * 100%), var(--ivory))", flexShrink: 0, transform: "translateY(-2px)" }} />
                  <span>{o}</span>
                </li>
              ))}
            </ul>
          </div>
        ))}
      </div>
    </div>
  </section>
);

/* --- Proof --- */
const Proof = ({ t }) => (
  <section id="proof" className="home-section" style={{ padding: "120px 0 100px" }}>
    <div className="container">
      <div style={{ maxWidth: 760, marginBottom: 72 }}>
        <div className="eyebrow" style={{ marginBottom: 20 }}>{t.proof.eyebrow}</div>
        <h2 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.sectionH2Size, lineHeight: HOMEPAGE_TYPE.sectionH2LineHeight, margin: "0 0 24px", maxWidth: "14ch" }}>
          {t.proof.head[0]}<span className="gold-text">{t.proof.head[1]}</span>{t.proof.head[2]}
        </h2>
        <p style={{ fontSize: 17, lineHeight: 1.6, color: "var(--navy-soft)", maxWidth: 600 }}>
          {t.proof.lede}
        </p>
      </div>

      <div className="home-stats-grid" style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0, borderTop: "1px solid var(--hair)", borderBottom: "1px solid var(--hair)" }}>
        {t.proof.stats.map((s, i) => (
          <div key={i} className="home-stat-card" style={{
            padding: "44px 32px 48px",
            borderRight: i < 2 ? "1px solid var(--hair)" : "none",
          }}>
            <div className="serif-display" style={{
              fontSize: s.big.length > 5 ? 44 : 72,
              lineHeight: 1,
              marginBottom: 20,
              minHeight: 88,
              display: "flex",
              alignItems: "flex-end",
              whiteSpace: "nowrap",
              color: "color-mix(in oklab, var(--gold-deep) calc(var(--gold-intensity) * 60%), var(--navy))",
              fontFeatureSettings: "'lnum'",
            }}>{s.big}</div>
            <div style={{ fontSize: 15, color: "var(--navy)", fontWeight: 500, marginBottom: 6 }}>{s.label}</div>
            <div className="mono" style={{ color: "var(--ink-muted)" }}>{s.note}</div>
          </div>
        ))}
      </div>

      {/* Quote */}
      <div className="home-quote-grid" style={{ marginTop: 80, display: "grid", gridTemplateColumns: "1fr 2fr", gap: 48, alignItems: "start" }}>
        <div className="home-quote-mark" style={{
          fontFamily: "var(--serif)", fontStyle: "italic", fontSize: 72, lineHeight: 1,
          color: "color-mix(in oklab, var(--gold) calc(var(--gold-intensity) * 100%), var(--hair-strong))",
          fontWeight: 400,
        }}>“</div>
        <div>
          <p className="serif-display" style={{ fontSize: "clamp(22px, 2.4vw, 32px)", lineHeight: 1.35, margin: "0 0 28px", color: "var(--navy)", fontStyle: "italic", fontWeight: 400 }}>
            {t.proof.quote.text}
          </p>
          <div style={{ display: "flex", alignItems: "center", gap: 14 }}>
            <div style={{ width: 40, height: 40, borderRadius: "50%", background: "var(--ivory-3)", color: "var(--navy)", fontFamily: "var(--serif)", fontSize: 16, display: "flex", alignItems: "center", justifyContent: "center" }}>SM</div>
            <div>
              <div style={{ fontSize: 14, fontWeight: 500 }}>{t.proof.quote.who}</div>
              <div style={{ fontSize: 12.5, color: "var(--ink-muted)" }}>{t.proof.quote.role}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </section>
);

/* --- Integrations --- */
const Integrations = ({ t }) => (
  <section id="integrations" className="home-section" style={{ padding: "100px 0 100px", borderTop: "1px solid var(--hair)" }}>
    <div className="container">
      <div className="home-intro-grid home-intro-grid-compact" style={{ display: "grid", gridTemplateColumns: "1fr 1.3fr", gap: 80, alignItems: "end", marginBottom: 56 }}>
        <div>
          <div className="eyebrow" style={{ marginBottom: 20 }}>{t.integrations.eyebrow}</div>
          <h2 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.compactH2Size, lineHeight: HOMEPAGE_TYPE.sectionH2LineHeight, margin: 0, maxWidth: "13ch" }}>
            {t.integrations.head}
          </h2>
        </div>
        <p style={{ fontSize: 16, lineHeight: 1.6, color: "var(--navy-soft)", maxWidth: 460, textWrap: "pretty" }}>{t.integrations.lede}</p>
      </div>

      <div className="home-integrations-grid" style={{ display: "grid", gridTemplateColumns: "repeat(6, 1fr)", gap: 0, borderTop: "1px solid var(--hair)", borderBottom: "1px solid var(--hair)" }}>
        {t.integrations.items.map((it, i) => (
          <div key={i} className="home-integration-card" style={{
            padding: "28px 20px",
            borderRight: i < 5 ? "1px solid var(--hair)" : "none",
            display: "flex", flexDirection: "column", justifyContent: "space-between", gap: 28, minHeight: 140,
          }}>
            {/* Abstract mark placeholder */}
            <div style={{ width: 28, height: 28, border: "1px solid var(--hair-strong)", borderRadius: 6, display: "flex", alignItems: "center", justifyContent: "center", fontFamily: "var(--serif)", fontSize: 14, color: "var(--navy)" }}>
              {it.n.split(/\s+/).map(w => w[0]).slice(0,2).join("")}
            </div>
            <div>
              <div style={{ fontSize: 14, fontWeight: 500, color: "var(--navy)" }}>{it.n}</div>
              <div className="mono" style={{
                color: it.s === "Coming soon" ? "var(--ink-muted)" : (it.s === "Core" ? "var(--gold-deep)" : "var(--navy-soft)"),
                marginTop: 4,
              }}>{it.s}</div>
            </div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

/* --- CTA --- */
const CTA = ({ t, lang }) => (
  <section className="dark home-section" style={{ padding: "120px 0", position: "relative", overflow: "hidden" }}>
    <div style={{
      position: "absolute", inset: 0,
      background: "radial-gradient(ellipse at 80% 0%, color-mix(in oklab, var(--gold) calc(var(--gold-intensity) * 18%), transparent) 0%, transparent 60%)",
      pointerEvents: "none",
    }} />
    <div className="container" style={{ textAlign: "center", position: "relative" }}>
      <h2 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.ctaH2Size, lineHeight: 1.02, margin: "0 auto 28px", maxWidth: 940 }}>
        {t.cta.head[0]}<span className="gold-text" style={{ color: "color-mix(in oklab, var(--gold-soft) calc(var(--gold-intensity) * 100%), var(--ivory))" }}>{t.cta.head[1]}</span>{t.cta.head[2]}
      </h2>
      <p style={{ fontSize: 17, lineHeight: 1.6, color: "rgba(244,238,226,0.72)", maxWidth: 560, margin: "0 auto 44px" }}>{t.cta.lede}</p>
      <div className="home-cta-actions" style={{ display: "inline-flex", gap: 12, flexWrap: "wrap", justifyContent: "center" }}>
        <a
          className="btn"
          href={buildWhatsappHref({ lang, intent: "demo", source: "home-bottom-primary" })}
          style={{ background: "var(--ivory)", color: "var(--navy)", border: "1px solid var(--ivory)" }}
        >
          {t.cta.primary} <span style={{ color: "var(--gold-deep)" }}>→</span>
        </a>
        <a
          className="btn btn-ghost"
          href={buildWhatsappHref({ lang, intent: "contact", source: "home-bottom-secondary" })}
          style={{ color: "var(--ivory)", borderColor: "rgba(244,238,226,0.28)" }}
        >
          {t.cta.secondary}
        </a>
      </div>
    </div>
  </section>
);

/* --- FAQ --- */
const FAQ = ({ t }) => {
  const [open, setOpen] = React.useState(0);
  return (
    <section className="home-section" style={{ padding: "120px 0 100px", borderTop: "1px solid var(--hair)" }}>
      <div className="container">
        <div className="home-faq-grid" style={{ display: "grid", gridTemplateColumns: "1fr 1.6fr", gap: 80 }}>
          <div>
            <div className="eyebrow" style={{ marginBottom: 20 }}>{t.faq.eyebrow}</div>
            <h2 className="serif-display" style={{ fontSize: HOMEPAGE_TYPE.sectionH2Size, lineHeight: HOMEPAGE_TYPE.sectionH2LineHeight, margin: 0, maxWidth: "12ch" }}>
              {t.faq.head[0]}<span className="gold-text">{t.faq.head[1]}</span>{t.faq.head[2]}
            </h2>
          </div>
          <div style={{ borderTop: "1px solid var(--hair)" }}>
            {t.faq.items.map((it, i) => (
              <div key={i} style={{ borderBottom: "1px solid var(--hair)" }}>
                <button
                  onClick={() => setOpen(open === i ? -1 : i)}
                  style={{
                    width: "100%", textAlign: "left",
                    background: "transparent", border: "none", cursor: "pointer",
                    padding: "24px 0", display: "flex", alignItems: "center", justifyContent: "space-between", gap: 20,
                    fontFamily: "var(--serif)", fontSize: 22, color: "var(--navy)",
                  }}>
                  <span style={{ textAlign: "left" }}>{it.q}</span>
                  <span className="mono" style={{
                    color: "color-mix(in oklab, var(--gold) calc(var(--gold-intensity) * 100%), var(--navy-soft))",
                    transition: "transform 0.25s ease",
                    transform: open === i ? "rotate(45deg)" : "rotate(0)",
                    fontSize: 16,
                  }}>+</span>
                </button>
                <div style={{
                  maxHeight: open === i ? 300 : 0,
                  overflow: "hidden",
                  transition: "max-height 0.35s ease, padding 0.25s ease",
                  paddingBottom: open === i ? 28 : 0,
                }}>
                  <p style={{ fontSize: 15, lineHeight: 1.65, color: "var(--navy-soft)", margin: 0, maxWidth: 620, textWrap: "pretty" }}>{it.a}</p>
                </div>
              </div>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
};

/* --- Footer --- */
const Footer = ({ t }) => (
  <footer style={{ padding: "80px 0 40px", borderTop: "1px solid var(--hair)", background: "var(--paper)" }}>
    <div className="container">
      <div className="home-footer-grid" style={{ display: "grid", gridTemplateColumns: "1.4fr 1fr 1fr 1fr", gap: 40, marginBottom: 60 }}>
        <div>
          <Wordmark />
          <p style={{ fontSize: 14, lineHeight: 1.55, color: "var(--navy-soft)", marginTop: 20, maxWidth: 300 }}>{t.footer.tagline}</p>
        </div>
        {t.footer.cols.map((c, i) => (
          <div key={i}>
            <div style={{ fontSize: 10.5, letterSpacing: "0.18em", textTransform: "uppercase", color: "var(--ink-muted)", fontWeight: 500, marginBottom: 18 }}>{c.h}</div>
            <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "grid", gap: 10 }}>
              {c.l.map((li, j) => {
                const label = typeof li === "string" ? li : li.label;
                const href = typeof li === "string" ? "#" : li.href;
                return (
                  <li key={j}><a href={href} style={{ fontSize: 13.5, color: "var(--navy-soft)", cursor: "pointer" }}>{label}</a></li>
                );
              })}
            </ul>
          </div>
        ))}
      </div>
      <hr className="hairline" />
      <div className="home-footer-meta" style={{ paddingTop: 24, display: "flex", justifyContent: "space-between", fontSize: 12, color: "var(--ink-muted)" }}>
        <span>{t.footer.copy}</span>
        <span className="mono">built with context</span>
      </div>
    </div>
  </footer>
);

Object.assign(window, {
  CWSections: { Nav, Hero, Shift, HowItWorks, UseCases, Proof, Integrations, CTA, FAQ, Footer },
});
