// Sections for the Test Messaging before Committing Media landing page.

/* ── Responsive styles ───────────────────────────────────── */
const RESPONSIVE_CSS = `
  .messaging-hero-wrap {
    max-width: 1320px;
    margin: 0 auto;
    padding: 88px 40px 88px;
    display: flex;
    flex-direction: column;
    gap: 40px;
  }
  .messaging-inside-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 80px;
    align-items: center;
  }
  .messaging-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .messaging-evidence-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
  .messaging-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
  .messaging-cover-col {
    display: flex;
    justify-content: center;
    padding: 20px 40px;
  }
  .messaging-table-row {
    display: grid;
    grid-template-columns: 0.9fr 1fr 1.6fr;
    gap: 24px;
  }

  @media (max-width: 900px) {
    .messaging-hero-wrap {
      gap: 32px;
      padding: 48px 24px 56px !important;
    }
    .messaging-inside-grid {
      grid-template-columns: 1fr;
      gap: 40px;
      padding: 56px 24px !important;
    }
    .messaging-cover-col { display: none; }
    .messaging-stats-grid {
      grid-template-columns: 1fr;
      gap: 0;
    }
    .messaging-stats-grid > div {
      border-right: none !important;
      border-bottom: 1px solid var(--av-rule);
      padding-left: 0 !important;
      padding-right: 0 !important;
      padding-bottom: 20px;
      padding-top: 20px;
    }
    .messaging-stats-grid > div:first-child { padding-top: 0; }
    .messaging-stats-grid > div:last-child { border-bottom: none; padding-bottom: 0; }
    .messaging-evidence-grid {
      grid-template-columns: 1fr;
    }
    .messaging-cards-grid {
      grid-template-columns: 1fr;
    }
    .messaging-section-pad {
      padding: 64px 24px 48px !important;
    }
    .messaging-closing-inner {
      padding: 72px 24px 64px !important;
    }
    .messaging-footer {
      padding: 24px 24px !important;
      flex-direction: column !important;
      align-items: flex-start !important;
      gap: 12px !important;
    }
    .messaging-table-row {
      grid-template-columns: 1fr;
      gap: 6px;
    }
  }

  @media (max-width: 480px) {
    .messaging-hero-wrap { padding: 36px 20px 48px !important; }
    .messaging-inside-grid { padding: 48px 20px !important; }
    .messaging-section-pad { padding: 56px 20px 40px !important; }
    .messaging-closing-inner { padding: 64px 20px 56px !important; }
    .messaging-footer { padding: 24px 20px !important; }
  }
`;

const ResponsiveStyles = () => (
  <style dangerouslySetInnerHTML={{ __html: RESPONSIVE_CSS }} />
);

const softTint = (hex) => `${hex}14`;

/* ── NavBar ──────────────────────────────────────────────── */
const MessagingNavBar = () => (
  <>
    <ResponsiveStyles />
    <header style={{
      background: "var(--av-canvas)",
      borderBottom: "1px solid var(--av-rule)",
    }}>
      <div style={{
        maxWidth: 1320, margin: "0 auto", padding: "0 40px", height: 75,
        display: "flex", justifyContent: "space-between", alignItems: "center",
      }}>
        <a href="https://algoverde.ai" aria-label="AlgoVerde — home"
          style={{ display: "inline-flex", alignItems: "center", textDecoration: "none" }}>
          <MessagingLogo width={170} />
        </a>
      </div>
    </header>
  </>
);

/* ── Hero ─────────────────────────────────────────────────── */
const MessagingHeroSection = ({ Italic, t, accent }) => (
  <section>
    <div className="messaging-hero-wrap">
      <MessagingEyebrow color={t.accentColor}>{t.eyebrowText}</MessagingEyebrow>

      <h1 style={{
        fontFamily: "var(--font-sans)", fontWeight: 600,
        fontSize: "clamp(42px, 6.4vw, 88px)", lineHeight: 0.98, letterSpacing: "-0.038em",
        color: "var(--av-ink)", margin: 0, maxWidth: 1180, textWrap: "balance",
      }}>
        Test messaging before <Italic>committing media</Italic>.
      </h1>

      <p style={{
        fontSize: "clamp(16px, 2vw, 21px)", lineHeight: 1.5, color: "var(--av-ink-soft)",
        fontFamily: "var(--font-sans)", margin: 0, maxWidth: 800, textWrap: "pretty",
      }}>
        Liking a vehicle is not the same as buying it. How automakers find out what
        actually moves buyers from consideration to conversion, before the campaign
        budget is spent.
      </p>

      {/* CTA row */}
      <div style={{ display: "flex", gap: 14, alignItems: "center", flexWrap: "wrap" }}>
        <a href={MESSAGING_PDF} download onClick={() => messagingTrackDownload("hero")} style={{
          background: "var(--av-ink)", color: "#fff", border: "none",
          padding: "17px 28px", borderRadius: 10, fontSize: 15.5, fontWeight: 500,
          cursor: "pointer", fontFamily: "var(--font-sans)", textDecoration: "none",
          display: "inline-flex", alignItems: "center", gap: 12,
          transition: "background 160ms ease, transform 160ms ease",
          letterSpacing: "-0.005em",
        }}
          onMouseEnter={(e) => { e.currentTarget.style.background = accent; e.currentTarget.style.transform = "translateY(-1px)"; }}
          onMouseLeave={(e) => { e.currentTarget.style.background = "var(--av-ink)"; e.currentTarget.style.transform = "none"; }}
        >
          <span>{t.ctaLabel}</span>
        </a>
        <a href="#inside" style={{
          fontSize: 14, fontWeight: 500, color: "var(--av-ink-soft)",
          textDecoration: "none", padding: "14px 8px",
          display: "inline-flex", alignItems: "center", gap: 8,
          transition: "color 160ms ease",
        }}
          onMouseEnter={(e) => e.currentTarget.style.color = accent}
          onMouseLeave={(e) => e.currentTarget.style.color = "var(--av-ink-soft)"}
        >
          <span>See what's inside</span>
          <span>↓</span>
        </a>
      </div>

      {/* Proof row */}
      <div className="messaging-stats-grid" style={{
        marginTop: 16, paddingTop: 36, borderTop: "1px solid var(--av-rule)",
      }}>
        {[
          { k: "Automotive examples", v: <span style={{ color: accent }}>6</span>, note: "From a pickup shopping journey to a frame-by-frame TV spot test" },
          { k: "Commercial questions", v: <span style={{ color: accent }}>3</span>, note: "Consideration, conversion, and why brand performance is changing" },
          { k: "Shared foundation", v: <span style={{ color: accent }}>1</span>, note: "A Living AI Model of your market, where each answer feeds the next question" },
        ].map((s, i) => (
          <div key={i} style={{
            paddingRight: 24, borderRight: i < 2 ? "1px solid var(--av-rule)" : "none",
            paddingLeft: i > 0 ? 24 : 0,
          }}>
            <div style={{
              fontSize: 11, fontWeight: 500, letterSpacing: "0.18em",
              textTransform: "uppercase", color: "var(--av-ink-muted)", marginBottom: 10,
            }}>{s.k}</div>
            <div style={{
              fontSize: 26, fontWeight: 600, letterSpacing: "-0.02em",
              color: "var(--av-ink)", lineHeight: 1.1, marginBottom: 8,
              fontVariantNumeric: "tabular-nums",
            }}>{s.v}</div>
            <div style={{ fontSize: 12, color: "var(--av-ink-muted)", lineHeight: 1.45 }}>{s.note}</div>
          </div>
        ))}
      </div>
    </div>
  </section>
);

/* ── Inside the Paper ────────────────────────────────────── */
const MessagingInsideSection = ({ t, Italic }) => (
  <section id="inside" style={{
    background: "#fff", borderTop: "1px solid var(--av-rule)", borderBottom: "1px solid var(--av-rule)",
  }}>
    <div className="messaging-inside-grid" style={{ maxWidth: 1320, margin: "0 auto", padding: "80px 40px" }}>
      <div className="messaging-cover-col">
        <MessagingCover width={280} rotate={-4} />
      </div>
      <div style={{ display: "flex", flexDirection: "column", gap: 24, maxWidth: 640 }}>
        <MessagingEyebrow color={t.accentColor}>Inside the paper</MessagingEyebrow>
        <h2 style={{
          fontFamily: "var(--font-sans)", fontWeight: 600,
          fontSize: "clamp(32px, 4vw, 44px)", letterSpacing: "-0.025em", lineHeight: 1.05, margin: 0,
        }}>
          From <Italic>consideration</Italic> to conversion.
        </h2>
        <p style={{
          fontSize: "clamp(15px, 1.8vw, 17px)", color: "var(--av-ink-soft)", lineHeight: 1.55, margin: 0,
        }}>
          A buyer can like the vehicle, recognize the ad, and still buy a competitor's model.
          The paper follows the buyer journey stage by stage, with a worked automotive example
          at each point where buyers are lost.
        </p>
        <div style={{ marginTop: 12 }}>
          {[
            "From consideration to conversion",
            "Turning signals into meaning",
            "Make the shortlist, and build trust where it matters",
            "Bridge the gap between recall and action",
            "Test value and price",
            "Brand assessment: from a dashboard to a lightbulb",
            "How to start: pick one decision",
          ].map((title, i) => (
            <MessagingTocChip key={i} idx={["i","ii","iii","iv","v","vi","vii"][i]} color={t.accentColor}>
              {title}
            </MessagingTocChip>
          ))}
        </div>
      </div>
    </div>
  </section>
);

/* ── Problem / Foundation Section ────────────────────────── */
const MessagingProblemSection = ({ accent, Italic, t }) => (
  <section className="messaging-section-pad"
    style={{ maxWidth: 1320, margin: "0 auto", padding: "96px 40px 64px" }}>

    {/* Pull quote */}
    <div style={{
      borderLeft: `4px solid ${accent}`,
      paddingLeft: 28, marginBottom: 56, maxWidth: 820,
    }}>
      <p style={{
        fontFamily: "var(--font-serif)", fontStyle: "italic", fontWeight: 500,
        fontSize: "clamp(20px, 2.5vw, 26px)", lineHeight: 1.45,
        color: "var(--av-ink)", margin: 0,
      }}>
        "Commercial teams are not short of data. They are short of meaning."
      </p>
    </div>

    {/* Three question cards */}
    <div style={{ marginBottom: 28, maxWidth: 720 }}>
      <p style={{ fontSize: "clamp(15px, 1.8vw, 17px)", color: "var(--av-ink-soft)", lineHeight: 1.55, margin: 0 }}>
        The offer, an outdated brand perception, a comparison found online, a poor dealership
        visit: each needs a different response, yet in the sales figures they all look the same.
        AlgoVerde starts from three questions.
      </p>
    </div>
    <div className="messaging-cards-grid" style={{ marginBottom: 64 }}>
      {[
        { n: "A", title: "Consideration", body: "What would bring more buyers to consider our brand?" },
        { n: "B", title: "Conversion", body: "Will our message and offer move them to act?" },
        { n: "C", title: "Brand performance", body: "Why is brand performance changing?" },
      ].map((c) => (
        <div key={c.n} style={{
          background: "#fdeae3", borderRadius: 16, padding: "28px",
          display: "flex", flexDirection: "column", gap: 14,
        }}>
          <span style={{
            width: 30, height: 30, borderRadius: "50%", background: "#E64A19",
            color: "#fff", display: "flex", alignItems: "center", justifyContent: "center",
            fontSize: 12, fontWeight: 700, fontFamily: "var(--font-sans)",
          }}>{c.n}</span>
          <div style={{
            fontFamily: "var(--font-sans)", fontWeight: 600, fontSize: 18,
            color: "var(--av-ink)", letterSpacing: "-0.01em",
          }}>{c.title}</div>
          <p style={{ fontSize: 14, color: "var(--av-ink-soft)", lineHeight: 1.55, margin: 0 }}>{c.body}</p>
        </div>
      ))}
    </div>

    {/* Two-col: separate dashboards vs one foundation */}
    <div className="messaging-evidence-grid">
      <div style={{
        background: "#fff", border: "1px solid var(--av-rule)", borderRadius: 16,
        padding: "36px", display: "flex", flexDirection: "column", gap: 20,
      }}>
        <div style={{
          fontSize: 11, fontWeight: 500, letterSpacing: "0.18em",
          textTransform: "uppercase", color: "var(--av-ink-muted)",
          display: "flex", alignItems: "center", gap: 8,
        }}>
          <span style={{ width: 20, height: 2, background: "var(--av-ink-muted)" }}></span>
          Today
        </div>
        <h3 style={{
          fontFamily: "var(--font-sans)", fontWeight: 600, fontSize: 22,
          letterSpacing: "-0.015em", color: "var(--av-ink)", lineHeight: 1.2, margin: 0,
        }}>Every signal lives in a separate dashboard.</h3>
        <p style={{ fontSize: 14, color: "var(--av-ink-soft)", lineHeight: 1.6, margin: 0 }}>
          Awareness scores, web traffic, campaign results, dealer feedback and sales figures
          each capture one part of the decision. They belong to separate teams and are reviewed
          on separate schedules, and none of them explains why a buyer moved forward or walked away.
        </p>
      </div>

      <div style={{
        background: softTint(accent), border: `1px solid ${accent}33`, borderRadius: 16,
        padding: "36px", display: "flex", flexDirection: "column", gap: 20,
      }}>
        <div style={{
          fontSize: 11, fontWeight: 500, letterSpacing: "0.18em",
          textTransform: "uppercase", color: accent,
          display: "flex", alignItems: "center", gap: 8,
        }}>
          <span style={{ width: 20, height: 2, background: accent }}></span>
          With AlgoVerde
        </div>
        <h3 style={{
          fontFamily: "var(--font-sans)", fontWeight: 600, fontSize: 22,
          letterSpacing: "-0.015em", color: "var(--av-ink)", lineHeight: 1.2, margin: 0,
        }}>One Living AI Model of your market.</h3>
        <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
          {[
            { label: "GenAI Personas" },
            { label: "Synthetic Panels" },
            { label: "Intelligence That Compounds" },
          ].map((row, i) => (
            <div key={i} style={{
              padding: "12px 0",
              borderTop: "1px solid var(--av-rule-soft)",
              display: "flex", gap: 14, alignItems: "center",
            }}>
              <span style={{
                width: 8, height: 8, borderRadius: "50%",
                background: accent, flexShrink: 0,
              }}></span>
              <div style={{ fontSize: 14, fontWeight: 600, color: "var(--av-ink)" }}>{row.label}</div>
            </div>
          ))}
        </div>
        <p style={{ fontSize: 12, color: "var(--av-ink-muted)", lineHeight: 1.5, margin: 0 }}>
          How each one turns scattered signals into answers: inside the paper.
        </p>
      </div>
    </div>
  </section>
);

/* ── Proof: automotive examples ──────────────────────────── */
const MessagingExamplesSection = ({ accent, t, Italic }) => {
  const rows = [
    { stage: "Make the shortlist", project: "Pickup shopping journey", outcome: "Buyers, rejecters and unaware shoppers compared; two barriers exposed between research and the shortlist" },
    { stage: "Test value and price", project: "Digital service value", outcome: "What buyers find useful, what creates hesitation, and how ways of paying change perceived value" },
    { stage: "Brand assessment", project: "Brand perception shifts", outcome: "Tracking results, market context and persona insights read together to explain why metrics moved" },
  ];
  return (
    <section style={{ background: "#fff", borderTop: "1px solid var(--av-rule)", borderBottom: "1px solid var(--av-rule)" }}>
      <div className="messaging-section-pad" style={{ maxWidth: 1320, margin: "0 auto", padding: "96px 40px 80px" }}>
        <div style={{ marginBottom: 48, maxWidth: 760 }}>
          <MessagingEyebrow color={t.accentColor}>From the paper</MessagingEyebrow>
          <h2 style={{
            fontFamily: "var(--font-sans)", fontWeight: 600,
            fontSize: "clamp(32px, 4vw, 48px)", letterSpacing: "-0.028em", lineHeight: 1.05,
            marginTop: 18, marginBottom: 16,
          }}>
            Strong recall. <Italic>No dealership visits</Italic>.
          </h2>
          <p style={{ fontSize: "clamp(15px, 1.8vw, 17px)", color: "var(--av-ink-soft)", lineHeight: 1.6 }}>
            A seasonal sales TV spot was tested frame by frame with GenAI Personas. Brand
            recognition was strong, but intent to visit a dealership was not.
          </p>
        </div>

        <div style={{
          background: accent, borderRadius: 16, color: "#fff",
          padding: "32px 36px", marginBottom: 56, maxWidth: 900,
        }}>
          <p style={{ fontSize: 16, lineHeight: 1.6, margin: 0 }}>
            The cause was the offer, not the creative: buyers read the effective monthly cost
            as higher than the advertised price. That is a fix to make before the media plan
            goes live, not after the sales figures come in.
          </p>
        </div>

        <div style={{ marginBottom: 24 }}>
          <MessagingEyebrow color={t.accentColor}>Across the buyer journey</MessagingEyebrow>
          <h3 style={{
            fontFamily: "var(--font-sans)", fontWeight: 600, fontSize: "clamp(24px, 3vw, 32px)",
            letterSpacing: "-0.02em", marginTop: 16,
          }}>A glimpse of the other examples.</h3>
        </div>

        {rows.map((r, i) => (
          <div key={i} className="messaging-table-row" style={{
            padding: "20px 0", borderBottom: "1px solid var(--av-rule-soft)", alignItems: "baseline",
          }}>
            <div style={{
              fontSize: 11, fontWeight: 500, letterSpacing: "0.12em", textTransform: "uppercase",
              color: "var(--av-ink-muted)",
            }}>{r.stage}</div>
            <div style={{ fontFamily: "var(--font-sans)", fontWeight: 600, fontSize: 15, color: "var(--av-ink)" }}>{r.project}</div>
            <div style={{ fontSize: 14, color: accent, fontWeight: 500, lineHeight: 1.5 }}>{r.outcome}</div>
          </div>
        ))}
        <p style={{ fontSize: 13, color: "var(--av-ink-muted)", lineHeight: 1.5, marginTop: 16, marginBottom: 0 }}>
          Plus brand trust strategy and multicultural audience development, and what each
          example found and recommended. The full breakdown is in the paper.
        </p>
      </div>
    </section>
  );
};

/* ── Closing CTA ─────────────────────────────────────────── */
const MessagingClosingCTA = ({ t, accent, accentTint }) => (
  <section style={{
    background: "var(--av-bg-dark)", color: "#fff", position: "relative", overflow: "hidden",
  }}>
    <div style={{ position: "absolute", top: 0, left: 0, right: 0, height: 2, background: accent }}></div>
    <div className="messaging-closing-inner" style={{
      maxWidth: 1320, margin: "0 auto", padding: "96px 40px 88px",
      display: "flex", flexDirection: "column", alignItems: "center",
      gap: 36, textAlign: "center",
    }}>
      <h2 style={{
        fontFamily: "var(--font-sans)", fontWeight: 600,
        fontSize: "clamp(32px, 5vw, 64px)", letterSpacing: "-0.03em", lineHeight: 1.02,
        margin: 0, color: "#fff", maxWidth: 900, textWrap: "balance",
      }}>
        Simulate, validate,<br />
        <span style={{ fontFamily: "var(--font-serif)", fontStyle: "italic", fontWeight: 500, color: accentTint }}>
          then invest
        </span>.
      </h2>
      <p style={{
        fontSize: "clamp(15px, 1.8vw, 17px)", color: "rgba(255,255,255,0.65)", lineHeight: 1.6,
        margin: 0, maxWidth: 600,
      }}>
        Find out what would move the buyer, evaluate the response, and measure the result,
        starting with one marketing or branding decision.
      </p>
      <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 14, marginTop: 8 }}>
        <a href={MESSAGING_PDF} download onClick={() => messagingTrackDownload("closing")} style={{
          background: "#fff", color: "var(--av-ink)", border: "none",
          padding: "18px 32px", borderRadius: 10, fontSize: 16, fontWeight: 500,
          cursor: "pointer", fontFamily: "var(--font-sans)", textDecoration: "none",
          display: "inline-flex", alignItems: "center", gap: 14,
          transition: "transform 160ms ease, background 160ms ease",
          letterSpacing: "-0.005em",
        }}
          onMouseEnter={(e) => { e.currentTarget.style.transform = "translateY(-2px)"; e.currentTarget.style.background = accentTint; }}
          onMouseLeave={(e) => { e.currentTarget.style.transform = "none"; e.currentTarget.style.background = "#fff"; }}
        >
          <span>{t.ctaLabel}</span>
        </a>
      </div>
    </div>
  </section>
);

Object.assign(window, {
  MessagingNavBar, MessagingHeroSection, MessagingInsideSection,
  MessagingProblemSection, MessagingExamplesSection, MessagingClosingCTA,
});
