/* global React */
/* Analytics · Deliverability · Onboarding · Next Steps — final section */

const anStyles = {
  /* Analytics intro */
  section: {
    background: "var(--k-cotton)",
    color: "var(--k-charcoal)",
    padding: "140px 56px 100px",
    borderTop: "1px solid var(--k-stone)",
  },
  inner: { maxWidth: 1320, margin: "0 auto" },
  head: { display: "grid", gridTemplateColumns: "1.1fr 1fr", gap: 80, alignItems: "end", marginBottom: 56 },
  eyebrow: { fontSize: 11, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--k-poppy)", marginBottom: 24, fontWeight: 600 },
  title: { fontFamily: "var(--serif)", fontWeight: 400, fontSize: "clamp(36px, 4.5vw, 64px)", lineHeight: 1.1, letterSpacing: "-0.01em", margin: 0 },
  sub: { fontSize: 17, lineHeight: 1.65, color: "var(--k-muted)", maxWidth: 500 },

  /* Screenshot blocks */
  shotBlock: { background: "var(--k-charcoal)", color: "var(--k-cotton)", borderRadius: 12, overflow: "hidden", marginBottom: 28 },
  shotInner: { display: "grid", gridTemplateColumns: "1fr 1.3fr", gap: 0, alignItems: "stretch" },
  shotInnerReverse: { gridTemplateColumns: "1.3fr 1fr" },
  shotText: { padding: "48px 44px", display: "flex", flexDirection: "column", gap: 16, justifyContent: "center" },
  shotEye: { fontSize: 11, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--k-poppy)", fontWeight: 700 },
  shotT: { fontFamily: "var(--serif)", fontSize: 32, lineHeight: 1.15, margin: 0, fontWeight: 400, letterSpacing: "-0.005em" },
  shotB: { fontSize: 14.5, lineHeight: 1.65, color: "var(--k-stone)" },
  shotList: { display: "flex", flexDirection: "column", gap: 10, marginTop: 6 },
  shotItem: { display: "grid", gridTemplateColumns: "16px 1fr", gap: 12, fontSize: 13.5, lineHeight: 1.55, color: "var(--k-cotton)" },
  shotBullet: { width: 7, height: 7, borderRadius: 999, background: "var(--k-poppy)", marginTop: 7 },
  shotImgWrap: { background: "#15131A", padding: 28, display: "flex", alignItems: "center", justifyContent: "center" },
  shotImg: { width: "100%", borderRadius: 8, boxShadow: "0 24px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,253,247,0.06)", display: "block" },

  /* Deliverability section */
  delivSection: {
    background: "var(--nb-cream-2)",
    padding: "120px 56px 140px",
    borderTop: "1px solid var(--nb-line)",
    borderBottom: "1px solid var(--nb-line)",
    color: "var(--nb-ink)",
  },
  delivHead: { display: "grid", gridTemplateColumns: "1.1fr 1fr", gap: 80, alignItems: "end", marginBottom: 48 },
  delivEye: { fontSize: 11, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--nb-rust)", marginBottom: 24, fontWeight: 700 },
  delivT: { fontFamily: "var(--serif)", fontSize: "clamp(34px, 4vw, 56px)", lineHeight: 1.1, letterSpacing: "-0.01em", margin: 0, fontWeight: 400 },
  delivSub: { fontSize: 16, lineHeight: 1.65, color: "var(--nb-navy)", maxWidth: 500 },

  delivPillars: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 16, marginBottom: 36 },
  delivCard: { background: "var(--nb-bone)", border: "1px solid var(--nb-line)", borderRadius: 10, padding: "24px 24px 28px", display: "flex", flexDirection: "column", gap: 10, minHeight: 200 },
  delivCardN: { fontFamily: "var(--serif)", fontSize: 32, color: "var(--nb-rust)", lineHeight: 1, fontWeight: 400 },
  delivCardT: { fontSize: 16, lineHeight: 1.3, fontWeight: 600, color: "var(--nb-ink)" },
  delivCardB: { fontSize: 13, lineHeight: 1.55, color: "var(--nb-navy)" },

  /* Per-brand deliverability scorecard */
  delivBlock: {
    background: "var(--nb-bone)", border: "1px solid var(--nb-line)",
    borderRadius: 12, padding: 40, marginBottom: 36,
  },
  delivBlockHead: { display: "grid", gridTemplateColumns: "1.1fr 1fr", gap: 40, alignItems: "end", marginBottom: 32 },
  delivBlockT: { fontFamily: "var(--serif)", fontSize: "clamp(24px, 2.6vw, 36px)", lineHeight: 1.15, margin: 0, fontWeight: 400, letterSpacing: "-0.01em" },
  delivBlockSub: { fontSize: 14, lineHeight: 1.6, color: "var(--nb-navy)", maxWidth: 440 },
  delivGrid: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 14 },
  delivCol: { background: "var(--nb-cream)", border: "1px solid var(--nb-line)", padding: 18, borderRadius: 6 },
  delivBrand: { fontSize: 10, padding: "3px 8px", color: "#fff", display: "inline-block", letterSpacing: "0.14em", fontWeight: 700, marginBottom: 12, borderRadius: 2 },
  delivStat: { fontFamily: "var(--serif)", fontSize: 30, lineHeight: 1, fontWeight: 400, color: "var(--nb-ink)", letterSpacing: "-0.01em" },
  delivKey: { fontSize: 10, letterSpacing: "0.16em", textTransform: "uppercase", color: "var(--nb-soft)", fontWeight: 600, marginTop: 4 },
  delivMini: { display: "flex", alignItems: "end", gap: 3, marginTop: 12, height: 32 },
  delivMiniBar: (h, c) => ({ flex: 1, height: h + "%", background: c, opacity: 0.85, borderRadius: 1 }),
  delivStatus: { fontSize: 10, marginTop: 10, fontWeight: 700, letterSpacing: "0.1em" },

  /* Onboarding section */
  onbSection: {
    background: "var(--k-cotton)",
    padding: "120px 56px 100px",
    borderTop: "1px solid var(--k-stone)",
  },
  onbHead: { display: "grid", gridTemplateColumns: "1.1fr 1fr", gap: 80, alignItems: "end", marginBottom: 56 },
  onbT: { fontFamily: "var(--serif)", fontSize: "clamp(34px, 4vw, 56px)", lineHeight: 1.1, letterSpacing: "-0.01em", margin: 0, fontWeight: 400 },
  onbRail: {
    display: "grid", gridTemplateColumns: "repeat(8, 1fr)",
    gap: 8,
    background: "var(--k-cotton)",
    border: "1px solid var(--k-stone)",
    borderRadius: 12,
    padding: 28,
    marginBottom: 64,
  },
  onbStep: { display: "flex", flexDirection: "column", gap: 10, padding: "8px 10px" },
  onbMonth: { fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--k-poppy)", fontWeight: 700 },
  onbBar: { height: 6, background: "var(--k-poppy)", borderRadius: 3 },
  onbStepT: { fontSize: 13, fontWeight: 600, color: "var(--k-charcoal)", lineHeight: 1.25 },
  onbStepB: { fontSize: 11, lineHeight: 1.45, color: "var(--k-muted)" },

  /* Next steps */
  nextSection: {
    background: "var(--k-charcoal)",
    color: "var(--k-cotton)",
    padding: "120px 56px 100px",
    borderTop: "1px solid rgba(255,253,247,0.08)",
  },
  nextHead: { textAlign: "center", maxWidth: 920, margin: "0 auto 64px" },
  nextEye: { fontSize: 11, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--k-poppy)", marginBottom: 24, fontWeight: 700 },
  nextT: { fontFamily: "var(--serif)", fontWeight: 400, fontSize: "clamp(44px, 5.4vw, 80px)", lineHeight: 1.0, letterSpacing: "-0.015em", margin: 0 },
  nextSub: { fontSize: 18, lineHeight: 1.6, color: "var(--k-stone)", marginTop: 28, maxWidth: 720, marginLeft: "auto", marginRight: "auto" },

  stepsGrid: {
    display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0,
    background: "var(--k-charcoal)",
    border: "1px solid rgba(255,253,247,0.18)",
    borderRadius: 12, overflow: "hidden",
    marginBottom: 64,
  },
  stepCol: {
    padding: "40px 36px 44px",
    borderRight: "1px solid rgba(255,253,247,0.12)",
    display: "flex", flexDirection: "column", gap: 14,
  },
  stepColLast: { borderRight: "none" },
  stepN: { fontFamily: "var(--serif)", fontSize: 64, lineHeight: 1, color: "var(--k-poppy)", fontWeight: 400 },
  stepWhen: { fontSize: 10, letterSpacing: "0.22em", textTransform: "uppercase", color: "var(--k-stone)", fontWeight: 600 },
  stepT: { fontFamily: "var(--serif)", fontSize: 26, lineHeight: 1.15, margin: 0, fontWeight: 400, letterSpacing: "-0.005em" },
  stepB: { fontSize: 14, lineHeight: 1.6, color: "var(--k-stone)" },
  stepOutcome: { marginTop: "auto", paddingTop: 16, borderTop: "1px solid rgba(255,253,247,0.12)", fontFamily: "var(--serif)", fontStyle: "italic", color: "var(--k-poppy)", fontSize: 15, lineHeight: 1.3 },

  /* Footer */
  foot: {
    paddingTop: 32, marginTop: 32,
    borderTop: "1px solid rgba(255,253,247,0.18)",
    display: "flex", justifyContent: "space-between", alignItems: "center",
    fontSize: 11, letterSpacing: "0.18em", textTransform: "uppercase",
    color: "var(--k-stone)", flexWrap: "wrap", gap: 24,
  },
  footWord: { fontFamily: "var(--serif)", fontStyle: "italic", fontSize: 24, letterSpacing: "-0.005em", textTransform: "none", color: "var(--k-cotton)" },
};

const DELIV_PILLARS = [
  { n: "01", t: "Owned in-platform", b: "Deliverability is no longer outsourced. Sender reputation managed inside Klaviyo by your Deliverability Strategist — not by a third party with no visibility of the campaign that caused the issue." },
  { n: "02", t: "Per-brand reputation", b: "Each of the four brand accounts has its own sending domain, dedicated IP and warm-up. One brand&rsquo;s complaint rate never propagates to the others — and FS comms sit on a separate trust profile entirely." },
  { n: "03", t: "Real-time monitoring", b: "Inbox-placement, bounce, complaint and engagement curves monitored in real time. The platform flags drift before it becomes a deliverability event — not after the next-day batch." },
  { n: "04", t: "Staggered + fallback", b: "Send-time staggering, bounceback fallback to SMS or push when email fails, smart retries. Built in — not built around." },
];

const ONB_STEPS = [
  { month: "Jun",  t: "Kick off",                b: "Review business goals · align on success · monday.com setup, next steps and project owners." },
  { month: "Jul",  t: "Content design",          b: "Design base email templates · build high-engagement revenue-generating flows (welcome, cart abandon)." },
  { month: "Aug",  t: "Integration",             b: "Enable primary integrations · upload email lists · segment by engagement data · validate sources." },
  { month: "Sept", t: "Data review",             b: "Validate data sources, types, integration performance. Pre-warm-up review with active subscriber lists." },
  { month: "Sept", t: "Warming · launch",        b: "Execute customised warming plan · turn on high-engagement flows with new strategy · review best practices." },
  { month: "Oct",  t: "Monitoring · reporting",  b: "Monitor KPIs across engagement, revenue, business objectives. Iterate accordingly." },
  { month: "Nov",  t: "Secondary use cases",     b: "Build out priority 2 use cases · deeper segmentation, targeting, advanced automation journeys." },
  { month: "Dec",  t: "Graduation",              b: "Celebrate milestones and objectives achieved · align on baseline metrics for ongoing CSM partnership." },
];

const NEXT_STEPS = [
  {
    n: "1", when: "June · Week 1",
    t: "CRM use-case session",
    b: "We&rsquo;ll build something out in an N Brown environment. A live test drive, with your team operating Klaviyo, to make sure it delivers the use cases the four brand accounts and FS team need.",
    outcome: "Confidence — through hands-on, not slides.",
  },
  {
    n: "2", when: "June · Week 2",
    t: "Technical discovery",
    b: "A focused session with your technical and marketing teams to map Klaviyo&rsquo;s integration with your existing stack. Data flows, API capabilities, timeline considerations, no surprises before go-live.",
    outcome: "Architecture aligned across CRM, FS and Data.",
  },
  {
    n: "3", when: "June · Week 3",
    t: "Formulate business case",
    b: "There are a lot of currently missed opportunities where we think we can deliver value quickly. Let&rsquo;s shape what that looks like as a quantified business case for N Brown — TCO, productivity, revenue.",
    outcome: "A commercial case ready for the next stage.",
  },
];

function AnalyticsAndNext() {
  return (
    <React.Fragment>
      {/* === Analytics === */}
      <section id="analytics" style={anStyles.section} data-screen-label="09 Analytics">
        <div style={anStyles.inner}>
          <div style={anStyles.head}>
            <div>
              <div style={anStyles.eyebrow}>Pre-built analytics that retailers care about</div>
              <h2 style={anStyles.title}>
                Day-one decision-ready.<br/>
                <span className="serif-i" style={{color: "var(--k-poppy)"}}>No analyst queue.</span>
              </h2>
            </div>
            <p style={anStyles.sub}>
              Built-in dashboards for the metrics retail leaders ask for first — audience
              breadth, channel mix, cross-sell opportunity, CLV multiplier, message
              frequency, RFM. Real-time funnel analysis at every touchpoint.
            </p>
          </div>

          {/* Audience stats screenshot */}
          <div style={anStyles.shotBlock}>
            <div style={anStyles.shotInner}>
              <div style={anStyles.shotText}>
                <div style={anStyles.shotEye}>Audience Insights · across your portfolio</div>
                <h3 style={anStyles.shotT}>
                  2.35M unified profiles. <span className="serif-i" style={{color: "var(--k-poppy)"}}>One dashboard.</span>
                </h3>
                <p style={anStyles.shotB}>
                  Total profiles, email subscribers, SMS subscribers and average engagement
                  across all four brands — refreshed in real time, with month-on-month
                  movement called out for trading leadership.
                </p>
                <div style={anStyles.shotList}>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Overview, Channel Distribution, Cross-Channel Strategy</span></div>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Cross-sell Opportunity Gap · Profile Overlap · CLV Multiplier Effect</span></div>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Message Frequency analytics with auto-flagged optimal ranges</span></div>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>RFM scoring · VIP to churn-risk · ready for win-back targeting</span></div>
                </div>
              </div>
              <div style={anStyles.shotImgWrap}>
                <img src={window.__asset("audienceStats", "assets/audience-stats.png")} alt="Audience Insights · 2.35M profiles · 333,490 email subscribers · 596,060 SMS · 46.8% engagement" style={anStyles.shotImg}/>
              </div>
            </div>
          </div>

          {/* CLV breakdown screenshot */}
          <div style={anStyles.shotBlock}>
            <div style={{...anStyles.shotInner, ...anStyles.shotInnerReverse}}>
              <div style={anStyles.shotImgWrap}>
                <img src={window.__asset("clvMultiplier", "assets/clv-multiplier.png")} alt="Customer lifetime value multiplier effect · $42, $138, $287, $512 across 1, 2, 3, 4+ brands" style={anStyles.shotImg}/>
              </div>
              <div style={anStyles.shotText}>
                <div style={anStyles.shotEye}>CLV Multiplier · The cross-brand opportunity</div>
                <h3 style={anStyles.shotT}>
                  Customers shopping 4+ brands carry <span className="serif-i" style={{color: "var(--k-poppy)"}}>12.2× the CLV</span>.
                </h3>
                <p style={anStyles.shotB}>
                  The single biggest commercial argument for one platform across the
                  portfolio. Move customers from 1 brand to 2, CLV jumps by an average
                  £96. Move them to 4+, you&rsquo;re looking at £512 lifetime — vs £42
                  on a single brand.
                </p>
                <div style={anStyles.shotList}>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span><strong style={{color: "var(--k-cotton)"}}>720K single-brand customers</strong> — the maximum cross-sell pool</span></div>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Best-performing combo: <strong style={{color: "var(--k-cotton)"}}>JD Williams + Heritage Brands</strong>, £185 average</span></div>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Highest CLV bracket = 4+ brands, £512 average, 12.2× single-brand</span></div>
                </div>
              </div>
            </div>
          </div>

          {/* Engagement curve screenshot */}
          <div style={anStyles.shotBlock}>
            <div style={anStyles.shotInner}>
              <div style={anStyles.shotText}>
                <div style={anStyles.shotEye}>Engagement &amp; Unsubscribe · by total weekly messages</div>
                <h3 style={anStyles.shotT}>
                  The sweet spot, found automatically.
                </h3>
                <p style={anStyles.shotB}>
                  Open rate, click rate, conversion rate, unsubscribe rate — all plotted
                  against weekly message volume across the portfolio. The 4–7 messages /
                  week band is the engagement-retention sweet spot; the platform flags
                  audiences drifting above 8.
                </p>
                <div style={anStyles.shotList}>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Open rates drop 38% when frequency exceeds 8 / week</span></div>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Unsubscribe rate begins to spike past message 8</span></div>
                  <div style={anStyles.shotItem}><span style={anStyles.shotBullet}/><span>Cross-brand frequency capping at the customer level, not the brand</span></div>
                </div>
              </div>
              <div style={anStyles.shotImgWrap}>
                <img src={window.__asset("engagementCurve", "assets/engagement-curve.png")} alt="Engagement and unsubscribe rates by total messages received" style={anStyles.shotImg}/>
              </div>
            </div>
          </div>
        </div>
      </section>

      {/* === Deliverability === */}
      <section style={anStyles.delivSection} data-screen-label="09 Deliverability">
        <div style={anStyles.inner}>
          <div style={anStyles.delivHead}>
            <div>
              <div style={anStyles.delivEye}>Deliverability · Owned, not outsourced</div>
              <h2 style={anStyles.delivT}>
                350M sends a year.<br/>
                <span className="serif-i" style={{color: "var(--nb-rust)"}}>Inbox placement managed in-house.</span>
              </h2>
            </div>
            <p style={anStyles.delivSub}>
              Today, deliverability is managed by a third party — outside the
              platform that ran the campaign. Klaviyo brings it back in-house, with
              a dedicated Deliverability Strategist on the account and per-brand
              reputation visible in real time.
            </p>
          </div>

          <div style={anStyles.delivPillars}>
            {DELIV_PILLARS.map(p => (
              <div key={p.n} style={anStyles.delivCard}>
                <div style={anStyles.delivCardN}>{p.n}</div>
                <div style={anStyles.delivCardT}>{p.t}</div>
                <div style={anStyles.delivCardB}>{p.b}</div>
              </div>
            ))}
          </div>

          <div style={anStyles.delivBlock}>
            <div style={anStyles.delivBlockHead}>
              <div>
                <div style={anStyles.delivEye}>Live in-platform · Deliverability dashboard</div>
                <h3 style={anStyles.delivBlockT}>
                  Score, breakdown and inbox-provider reports — one screen.
                </h3>
              </div>
              <p style={anStyles.delivBlockSub}>
                A live look at the deliverability dashboard inside Klaviyo:
                aggregate score with the five contributing metrics, the full
                breakdown per inbox provider, and engagement-over-time by
                provider with benchmark. Bounceback fallback, staggered
                deployment and inbox-placement monitoring all in-platform —
                continuous, not periodic.
              </p>
            </div>

            <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 18, marginBottom: 18 }}>
              <div style={{ borderRadius: 10, overflow: "hidden", border: "1px solid var(--nb-line)", background: "#fff" }}>
                <img
                  src={window.__asset("delivScore", "assets/deliv-score.png")}
                  alt="Klaviyo Deliverability score · 81/Good · open rate, click rate, bounce rate, unsubscribe rate, spam complaint rate against recommended thresholds"
                  style={{ width: "100%", height: "auto", display: "block" }}
                />
              </div>
              <div style={{ borderRadius: 10, overflow: "hidden", border: "1px solid var(--nb-line)", background: "#fff" }}>
                <img
                  src={window.__asset("delivEngagement", "assets/deliv-engagement.png")}
                  alt="Positive engagement metrics — open rate over time by inbox provider (Gsuite, Other, Amazon SES, Gmail, Office365) against benchmark"
                  style={{ width: "100%", height: "auto", display: "block" }}
                />
              </div>
            </div>

            <div style={{ borderRadius: 10, overflow: "hidden", border: "1px solid var(--nb-line)", background: "#fff" }}>
              <img
                src={window.__asset("delivReports", "assets/deliv-reports.png")}
                alt="Inbox-provider report · key metrics (open, click, bounce, unsubscribe, spam) broken out per provider over 2.5M recipients"
                style={{ width: "100%", height: "auto", display: "block" }}
              />
            </div>
          </div>
        </div>
      </section>

      {/* === Onboarding === */}
      <section style={anStyles.onbSection} data-screen-label="10 Onboarding">
        <div style={anStyles.inner}>
          <div style={anStyles.onbHead}>
            <div>
              <div style={anStyles.eyebrow}>Example onboarding plan · June to December</div>
              <h2 style={anStyles.onbT}>
                Six months. <span className="serif-i" style={{color: "var(--k-poppy)"}}>Live, then optimised.</span>
              </h2>
            </div>
            <p style={anStyles.sub}>
              Kick off in June. High-engagement flows live by September. Secondary
              use cases by November. Graduation to ongoing CSM partnership in December.
            </p>
          </div>

          <div style={anStyles.onbRail}>
            {ONB_STEPS.map((s, i) => (
              <div key={i} style={anStyles.onbStep}>
                <div style={anStyles.onbMonth}>{s.month}</div>
                <div style={anStyles.onbBar}/>
                <div style={anStyles.onbStepT}>{s.t}</div>
                <div style={anStyles.onbStepB}>{s.b}</div>
              </div>
            ))}
          </div>
        </div>
      </section>

    </React.Fragment>
  );
}
