/* ============================================================
   Subaru cases: real content, registered into window.CASE_PANELS.
   Source: igenevieve.com/work/mysubaruredesign + /work/subaru-of-america
   Voice modeled on professional UX case studies: crisp problem
   framing, first-person UX verbs, measurable outcomes.
   ============================================================ */
(function () {
  const K = window.CSKit;

  function col(span) { return { gridColumn: "span " + span, display: "flex", flexDirection: "column" }; }

  /* ===================== MYSUBARU REDESIGN ===================== */

  function kw(N, words) { return words; }

  function RedesignResearch() {
    const { SectionHead, Stat, Panel, Bento, ListBlock, Quote } = window.CSKit;
    function Cloud(props) {
      return (
        <Panel title={props.title}>
          <div style={{ display: "flex", flexWrap: "wrap", gap: 10 }}>
            {props.words.map(function (w, i) {
              return <span key={w} style={{ fontSize: i === 0 ? 18 : 15, fontWeight: i === 0 ? 500 : 400, color: i === 0 ? "var(--accent)" : "var(--label-secondary)", padding: "7px 14px", borderRadius: 999, background: "var(--fill-tertiary)", border: "1px solid var(--pf-hairline)" }}>{w}</span>;
            })}
          </div>
        </Panel>
      );
    }
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 72 }}>
        <SectionHead kicker="Research" title="What drivers expect, and where the app fell short"
          lead="I started by mapping the market to learn what owners actually expect from a connected-vehicle app today, then ran research to surface the unmet needs and feelings behind low engagement." />

        <section>
          <K.Eyebrow>Market analysis</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Two themes defined what drivers want</h3>
          <Bento>
            <div style={col(6)}>
              <Panel kicker="Theme one" title="A personalized, integrated system that saves time and money across multiple areas">
                <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
                  <Quote>I want one place that handles my service, billing, and trips, not five logins.</Quote>
                  <Quote>It should already know my car and stop making me re enter everything.</Quote>
                </div>
              </Panel>
            </div>
            <div style={col(6)}>
              <Panel kicker="Theme two" title="Preemptive features that guide them through recommendations and alerts">
                <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
                  <Quote>Tell me before something is wrong, not after I am stranded.</Quote>
                  <Quote>A nudge for the right service at the right time would actually help.</Quote>
                </div>
              </Panel>
            </div>
            <div style={col(6)}><Stat value="70%">expected only standard remote services from the app, showing how low and habit-bound the baseline was.</Stat></div>
            <div style={col(6)}><Stat value="80%">would adopt an unfamiliar solution if it clearly resolved a real problem in how they use the vehicle.</Stat></div>
          </Bento>
        </section>

        <section>
          <K.Eyebrow>Value-driven services and data</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Predictive maintenance and trip planning stood out as the key needs</h3>
          <div className="pf-glass" style={{ padding: "clamp(28px, 3vw, 44px)", marginBottom: 22 }}>
            <div className="pf-eyebrow" style={{ marginBottom: 16 }}>Key insight</div>
            <p className="pf-h3" style={{ margin: 0, fontSize: "clamp(16px, 1.4vw, 19px)", fontWeight: 300 }}>
              Timely, predictive maintenance alerts and trip planning that saves time and money were the needs owners valued most.
            </p>
          </div>
          <Bento>
            <div style={col(6)}><Cloud title="Service" words={["time", "schedule", "maintenance", "cost", "reminder", "history", "dealer"]} /></div>
            <div style={col(6)}><Cloud title="Trip" words={["trips", "mileage", "miles", "map", "route", "monthly", "fuel"]} /></div>
          </Bento>
        </section>

        <section>
          <K.Eyebrow>Competitive analysis</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Trip features earn use when they add vehicle-specific intelligence beyond a standard map</h3>
          <Bento>
            <div style={col(6)}>
              <Panel title="Standard maps">
                <ListBlock items={["Route", "Estimated arrival", "Traffic"]} />
              </Panel>
            </div>
            <div style={col(6)}>
              <Panel title="Connected-vehicle trip planning" thick>
                <ListBlock items={["Range and fuel-aware routing", "Mileage tracking", "Charge and EV estimation", "Vehicle-specific planning"]} />
              </Panel>
            </div>
          </Bento>
        </section>

        <section>
          <K.Eyebrow>Pain points and psychological drivers</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Time and stress are the burden; safety and control are the drivers</h3>
          <Bento>
            <div style={col(6)}><Stat value="74%">cited feelings of safety and control as what they care about most, beyond practical features, followed by convenience and peace of mind.</Stat></div>
            <div style={Object.assign({}, col(6), { display: "flex", flexDirection: "column", gap: 16, justifyContent: "center" })}>
              <Quote>Driving is stressful enough. I want the car to quietly have my back.</Quote>
              <Quote>There is never one place I trust to tell me everything about my car.</Quote>
            </div>
          </Bento>
        </section>

        <section className="pf-glass pf-glass--thick" style={{ padding: "clamp(34px, 5vw, 64px)", textAlign: "center" }}>
          <div className="pf-eyebrow" style={{ marginBottom: 22 }}>How might we</div>
          <p className="pf-h2" style={{ margin: "0 auto", maxWidth: 900, fontSize: "clamp(19px, 2vw, 27px)", fontWeight: 300 }}>
            Increase engagement by making the ownership app more{" "}
            <span style={{ color: "var(--accent)" }}>personalized</span>,{" "}
            <span style={{ color: "var(--accent)" }}>anticipatory</span>, and{" "}
            <span style={{ color: "var(--accent)" }}>emotionally supportive</span>, so drivers feel safer, more certain, less stressed, and more efficient?
          </p>
        </section>
      </div>
    );
  }

  function RedesignIdeation() {
    const { SectionHead, Panel, Bento, Figure, ListBlock } = window.CSKit;
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 72 }}>
        <SectionHead kicker="Homepage" title="A homepage that answers “how is my car?” first"
          lead="The original homepage offered three commands and no immediate vehicle information, and checking status took multiple steps. Guided by three principles, the redesign leads with condition and alerts, and keeps actions one tap away." />

        <section>
          <K.Eyebrow>Design principles</K.Eyebrow>
          <Bento>
            <div style={col(4)}><Panel title="Evolve with personal habits"><p className="pf-body" style={{ margin: 0 }}>Adapt to how each owner actually uses their vehicle, rather than a fixed default.</p></Panel></div>
            <div style={col(4)}><Panel title="Guide preemptively"><p className="pf-body" style={{ margin: 0 }}>Surface the right action before the owner has to go looking for it.</p></Panel></div>
            <div style={col(4)}><Panel title="Communicate with support"><p className="pf-body" style={{ margin: 0 }}>Speak in a reassuring, low-stress voice so the car feels like it has your back.</p></Panel></div>
          </Bento>
        </section>

        <section>
          <Bento>
            <div style={col(6)}>
              <Panel kicker="Before" title="Three commands, no status">
                <ListBlock items={["Only three remote commands surfaced", "No vehicle condition on the homepage", "Several steps to see whether anything was wrong"]} />
              </Panel>
            </div>
            <div style={col(6)}>
              <Panel kicker="After" title="Condition first, actions ready" thick>
                <ListBlock items={["Vehicle condition and alert cards lead the page", "An expandable, fixed quick-action tab", "Persistent bottom navigation for orientation"]} />
              </Panel>
            </div>
            <div style={col(6)}><Figure label="Homepage: before and after the redesign" h={300} /></div>
            <div style={col(6)}><Figure label="Vehicle condition and alert cards" h={300} /></div>
          </Bento>
        </section>

        <section>
          <K.Eyebrow>Quick actions</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Commands that expand and rearrange around the owner</h3>
          <Bento>
            <div style={col(5)}>
              <Panel title="Expandable and customizable">
                <p className="pf-body" style={{ margin: 0 }}>
                  A compact list of commands expands from a plus control. Owners can drag and customize the
                  quick-action set so the actions they use most stay within thumb reach.
                </p>
              </Panel>
            </div>
            <div style={col(7)}><Figure label="Quick-action tab: collapsed, expanded, and drag-to-customize" h={280} /></div>
          </Bento>
        </section>

        <section>
          <K.Eyebrow>Vehicle alerts</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>The car shows you what is wrong, where it is wrong</h3>
          <Bento>
            <div style={col(7)}><Figure label="Rotating vehicle illustration: low tire pressure turns tires red; an open window highlights red" h={300} /></div>
            <div style={col(5)}>
              <Panel title="See it, then act on it" thick>
                <p className="pf-body" style={{ margin: 0 }}>
                  A rotating illustration displays issues directly on the vehicle. Alert cards beneath route
                  straight into the relevant quick action, like navigating to a service station. Card priority
                  was ordered by user testing.
                </p>
              </Panel>
            </div>
          </Bento>
        </section>

        <section>
          <K.Eyebrow>Design system</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Defining and expanding the component library</h3>
          <Bento>
            <div style={col(6)}><Figure label="Component definitions contributed during the redesign" h={240} /></div>
            <div style={col(6)}><Figure label="Tokens and patterns extended across surfaces" h={240} /></div>
          </Bento>
        </section>
      </div>
    );
  }

  function RedesignTesting() {
    const { SectionHead, Panel, Bento, ListBlock, Figure } = window.CSKit;
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 72 }}>
        <SectionHead kicker="Validation" title="Testing the experience as a private chauffeur"
          lead="To validate the redesign, I framed the MySubaru app as a private chauffeur and ran an A/B test in a simulated ownership scenario, comparing a grounded version against one extended with community features." />

        <section>
          <Bento>
            <div style={col(6)}>
              <Panel kicker="Version A" title="Grounded ownership">
                <ListBlock items={["Remote services", "Trip planning", "Navigation", "Vehicle condition testing"]} />
              </Panel>
            </div>
            <div style={col(6)}>
              <Panel kicker="Version B" title="Extended, on top of A" thick>
                <ListBlock items={["Everything in Version A", "Social and community features"]} />
              </Panel>
            </div>
          </Bento>
        </section>

        <section>
          <Figure label="User testing and validation sessions" h={300} />
        </section>
      </div>
    );
  }

  /* The live Figma-site prototype. Lives under the Agentic AI case's Testing tab. */
  function AgenticTesting() {
    const SRC = "https://trial-handle-00777350.figma.site";
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 28 }}>
        <header style={{ maxWidth: 880 }}>
          <h2 className="pf-h2" style={{ margin: 0, fontSize: "clamp(21px, 2.2vw, 30px)" }}>Testing</h2>
          <p className="pf-lead" style={{ margin: "16px 0 0" }}>The live prototype, embedded from its Figma site.</p>
        </header>
        <div className="pf-glass pf-glass--thick" style={{ padding: "clamp(16px, 1.6vw, 24px)" }}>
          <div style={{ position: "relative", width: "100%", borderRadius: 18, overflow: "hidden", background: "var(--pf-placeholder)", border: "1px solid var(--pf-placeholder-line)" }}>
            <iframe title="Agentic AI prototype" src={SRC} loading="lazy"
              style={{ display: "block", width: "100%", height: "min(80vh, 860px)", border: 0, background: "transparent" }} />
          </div>
          <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", flexWrap: "wrap", gap: 16, marginTop: 18 }}>
            <p className="pf-body" style={{ margin: 0, maxWidth: 560, fontSize: 14 }}>Published from Figma Sites. Opens full-screen in a new tab.</p>
            <a href={SRC} target="_blank" rel="noopener noreferrer" className="pf-btn pf-btn--primary gv-lift">
              Open prototype
              <i data-lucide="arrow-up-right" style={{ width: 16, height: 16, opacity: 0.8 }} />
            </a>
          </div>
        </div>
      </div>
    );
  }

  /* Metric box — label over a big number */
  function Metric(props) {
    return (
      <div className="pf-glass" style={{ padding: "clamp(20px, 2vw, 28px)", display: "flex", flexDirection: "column", justifyContent: "space-between", minHeight: 120 }}>
        <div style={{ fontSize: 13, fontWeight: 400, letterSpacing: "0.01em", color: "var(--label-secondary)", lineHeight: 1.4 }}>{props.label}</div>
        <div className="pf-num" style={{ fontSize: "clamp(22px, 2vw, 28px)", fontWeight: 300, marginTop: 14, color: props.accent ? "var(--accent)" : "var(--label-primary)" }}>{props.value}</div>
      </div>
    );
  }

  /* Checkpoint — number, title, description */
  function Checkpoint(props) {
    return (
      <div className="pf-glass" style={{ padding: "clamp(22px, 2vw, 30px)", display: "flex", gap: 18 }}>
        <span className="pf-num" style={{ fontSize: 22, color: "var(--accent)", flexShrink: 0, width: 30 }}>{props.n}</span>
        <div>
          <div className="pf-h3" style={{ fontSize: "clamp(17px, 1.5vw, 20px)", marginBottom: 8 }}>{props.title}</div>
          <p className="pf-body" style={{ margin: 0, fontSize: 15 }}>{props.children}</p>
        </div>
      </div>
    );
  }

  /* Average daily returning unique visitors — 2025 vs 2024 line chart */
  function ReturningVisitorsChart() {
    const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
    const D25 = [165.1, 199.2, 222.1, 128.4, 110, 115.2, 118.1, 130.2, 122.3, 131.8, 165.6, 189.1];
    const D24 = [118.8, 130.6, 128.5, 113.2, 109, 105.5, 103.5, 115.5, 121.9, 39.2, 41.4, 44];
    const W = 960, H = 440, L = 52, R = 24, T = 46, B = 60;
    const pw = W - L - R, ph = H - T - B, yMax = 250;
    const x = function (i) { return L + (pw / 11) * i; };
    const y = function (v) { return T + ph - (v / yMax) * ph; };
    const pts = function (d) { return d.map(function (v, i) { return x(i) + "," + y(v); }).join(" "); };
    const area = pts(D25) + " " + x(11) + "," + y(0) + " " + x(0) + "," + y(0);
    const grid = [0, 50, 100, 150, 200, 250];
    return (
      <div className="pf-glass" style={{ padding: "clamp(32px, 3.4vw, 52px) clamp(20px, 2.2vw, 32px)", maxWidth: 760, margin: "0 auto" }} data-om-raster="true">
        <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", flexWrap: "wrap", gap: 12, marginBottom: 16 }}>
          <div className="pf-eyebrow">Monthly average daily returning unique visitors (thousands)</div>
          <div style={{ display: "flex", gap: 16, fontSize: 12, color: "var(--label-tertiary)" }}>
            <span style={{ display: "inline-flex", alignItems: "center", gap: 7 }}><span style={{ width: 16, height: 1.4, background: "var(--accent)", display: "inline-block" }} />2025</span>
            <span style={{ display: "inline-flex", alignItems: "center", gap: 7 }}><span style={{ width: 16, height: 0, borderTop: "1.2px dashed var(--label-tertiary)", display: "inline-block" }} />2024</span>
          </div>
        </div>
        <svg viewBox={"0 0 " + W + " " + H} width="100%" role="img" aria-label="Line chart of monthly average daily returning unique visitors, 2025 versus 2024" style={{ display: "block", overflow: "visible" }}>
          {grid.map(function (g) {
            return (
              <g key={g}>
                <line x1={L} x2={W - R} y1={y(g)} y2={y(g)} stroke="var(--pf-hairline)" strokeWidth="1" />
                <text x={L - 10} y={y(g) + 3} textAnchor="end" fontSize="9" fontWeight="300" fill="var(--label-tertiary)">{g}K</text>
              </g>
            );
          })}
          <polygon points={area} fill="var(--accent)" opacity="0.055" />
          <polyline points={pts(D24)} fill="none" stroke="var(--label-tertiary)" strokeWidth="1.1" strokeDasharray="5 5" strokeLinejoin="round" opacity="0.7" />
          <polyline points={pts(D25)} fill="none" stroke="var(--accent)" strokeWidth="1.4" strokeLinejoin="round" />
          {D24.map(function (v, i) {
            return <circle key={"a" + i} cx={x(i)} cy={y(v)} r="2" fill="none" stroke="var(--label-tertiary)" strokeWidth="1" opacity="0.7" />;
          })}
          {D25.map(function (v, i) {
            return (
              <g key={"b" + i}>
                <circle cx={x(i)} cy={y(v)} r="2.4" fill="var(--accent)" />
                <text x={x(i)} y={y(v) - 9} textAnchor="middle" fontSize="8.5" fontWeight="300" fill="var(--label-secondary)">{v}</text>
              </g>
            );
          })}
          {MONTHS.map(function (m, i) {
            return <text key={m} x={x(i)} y={H - 30} textAnchor="middle" fontSize="9.5" fontWeight="300" fill="var(--label-tertiary)">{m}</text>;
          })}
        </svg>
        <p className="pf-body" style={{ margin: "12px 0 0", fontSize: 12.5, fontWeight: 300, color: "var(--label-tertiary)" }}>
          Notable monthly year-over-year increases: Mar +93.6K, Oct +92.6K, Nov +124.2K, Dec +145.1K. Largest gains land in Q4, especially November and December.
        </p>
      </div>
    );
  }

  function RedesignOutcome() {
    const { SectionHead, Bento, Stat } = window.CSKit;
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 64 }}>
        <SectionHead kicker="Outcome" title="Redesign and retention that compounded into daily use"
          lead="Reframing the homepage around vehicle condition, clarifying value, and rebuilding the information architecture moved owners from occasional remote commands to daily, returning use." />

        {/* headline stat + metric grid */}
        <Bento>
          <div style={col(5)}>
            <div className="pf-glass pf-glass--thick" style={{ padding: "clamp(28px, 3vw, 44px)", display: "flex", flexDirection: "column", height: "100%", justifyContent: "center" }}>
              <div className="pf-num" style={{ fontSize: "clamp(26px, 2.6vw, 34px)", fontWeight: 300, lineHeight: 1, color: "var(--accent)" }}>+40.6%</div>
              <p className="pf-h3" style={{ margin: "22px 0 0", fontSize: "clamp(16px, 1.4vw, 19px)", fontWeight: 300 }}>
                Average daily total unique visitors grew from 399.8K to 562.1K, adding 162.3K daily users.
              </p>
              <p className="pf-body" style={{ margin: "16px 0 0", fontSize: 14, color: "var(--label-tertiary)" }}>
                Year-end active usage growth, Nov to Dec 2024 versus Nov to Dec 2025.
              </p>
            </div>
          </div>
          <div style={col(7)}>
            <div className="pf-bento" style={{ gridTemplateColumns: "repeat(2, 1fr)", gridAutoRows: "auto", height: "100%" }}>
              <Metric label="Service Enrollment Rate" value="96%" />
              <Metric label="Active Usage, Year End" value="+40.6%" accent />
              <Metric label="Value Feature Adoption Rate" value="52.9%" />
              <Metric label="Daily Returning Users" value="+53.4%" accent />
            </div>
          </div>
        </Bento>

        {/* what drove it: four checkpoints */}
        <section>
          <K.Eyebrow>What drove it</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Four checkpoints, from value clarity to information architecture</h3>
          <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
            <Checkpoint n="1" title="Value clarity as a prerequisite to decision making">
              Pricing clarification on the Admin Portal, helping retailers understand, communicate, and make the sale.
            </Checkpoint>
            <Checkpoint n="2" title="POS enablement">
              A contactless payment flow that lifts conversion at the point of sale, including an interactive board that demonstrates service value.
            </Checkpoint>
            <Checkpoint n="3" title="Cross-surface consistency">
              Mobile user activation with responsive design and aligned systems across every surface.
            </Checkpoint>
            <Checkpoint n="4" title="Information architecture redesign">
              Helping users find the information that matters and reach remote services when they need them, improving retention.
            </Checkpoint>
          </div>
        </section>

        {/* returning-visitor retention */}
        <section>
          <K.Eyebrow>Retention signal</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Average daily returning unique visitors, 2025 versus 2024</h3>
          <p className="pf-body" style={{ maxWidth: 760, marginBottom: 28 }}>
            Returning visitors are a retention signal: users recognizing value over time are more likely to convert, renew, and contribute to revenue growth.
          </p>
          <Bento>
            <div style={col(4)}><Stat value="+53.4%">annual growth in average daily returning unique visitors, 97.6K daily in 2024 to 149.8K in 2025.</Stat></div>
            <div style={col(4)}><Stat value="+52.2K">additional returning visitors per day, averaged across the twelve monthly averages.</Stat></div>
            <div style={col(4)}>
              <div className="pf-glass" style={{ padding: "clamp(22px, 2vw, 30px)", height: "100%" }}>
                <div className="pf-eyebrow" style={{ marginBottom: 16 }}>Annual summary</div>
                <SummaryRow label="2024 daily average" value="97,603" />
                <SummaryRow label="2025 daily average" value="149,762" accent />
                <SummaryRow label="Absolute increase" value="52,159" />
                <SummaryRow label="Growth rate" value="53.4%" accent last />
              </div>
            </div>
            <div style={col(12)}><ReturningVisitorsChart /></div>
          </Bento>
          <p className="pf-body" style={{ margin: "20px 0 0", fontSize: 13.5, color: "var(--label-tertiary)" }}>
            Returning unique visitors equals total unique visitors minus new visitors. Annual average is the mean of the twelve monthly averages.
          </p>
        </section>
      </div>
    );
  }

  function SummaryRow(props) {
    return (
      <div style={{ display: "flex", alignItems: "baseline", justifyContent: "space-between", gap: 12, padding: "12px 0", borderBottom: props.last ? "none" : "1px solid var(--pf-hairline)" }}>
        <span style={{ fontSize: 13, color: "var(--label-secondary)" }}>{props.label}</span>
        <span className="pf-num" style={{ fontSize: 16, fontWeight: 300, color: props.accent ? "var(--accent)" : "var(--label-primary)" }}>{props.value}</span>
      </div>
    );
  }

  /* ===================== MYSUBARU ONBOARDING ===================== */

  /* Vertical bar chart — on-palette, for the barriers-to-use data */
  function BarChart(props) {
    const data = props.data, max = props.max || 80;
    const W = 820, H = 360, L = 40, R = 14, T = 16, B = 66;
    const pw = W - L - R, ph = H - T - B, n = data.length;
    const slot = pw / n, bw = Math.min(52, slot * 0.46);
    const y = function (v) { return T + ph - (v / max) * ph; };
    const grid = [0, 20, 40, 60, 80];
    return (
      <svg viewBox={"0 0 " + W + " " + H} width="100%" role="img" aria-label="Bar chart of reasons owners do not use the app" style={{ display: "block", overflow: "visible", maxWidth: 680, margin: "0 auto" }}>
        {grid.map(function (g) {
          return (
            <g key={g}>
              <line x1={L} x2={W - R} y1={y(g)} y2={y(g)} stroke="var(--pf-hairline)" strokeWidth="1" />
              <text x={L - 8} y={y(g) + 3} textAnchor="end" fontSize="9" fontWeight="300" fill="var(--label-tertiary)">{g}%</text>
            </g>
          );
        })}
        {data.map(function (d, i) {
          const cx = L + slot * i + slot / 2;
          const bh = (d.value / max) * ph;
          const words = d.label.split(" ");
          return (
            <g key={d.label}>
              <rect x={cx - bw / 2} y={y(d.value)} width={bw} height={bh} rx="6" fill="var(--accent)" opacity={i === 0 ? 0.7 : 0.5} />
              <text x={cx} y={y(d.value) - 7} textAnchor="middle" fontSize="9" fontWeight="300" fill="var(--label-secondary)">{d.value}%</text>
              <text x={cx} y={H - B + 18} textAnchor="middle" fontSize="9" fontWeight="300" fill="var(--label-tertiary)">
                {words.map(function (w, wi) { return <tspan key={wi} x={cx} dy={wi === 0 ? 0 : 12}>{w}</tspan>; })}
              </text>
            </g>
          );
        })}
      </svg>
    );
  }

  /* Donut — single-value emphasis */
  function Donut(props) {
    const pct = props.pct, r = 82, c = 2 * Math.PI * r, on = (pct / 100) * c;
    return (
      <svg viewBox="0 0 200 200" width="150" height="150" role="img" aria-label={pct + " percent"} style={{ display: "block" }}>
        <circle cx="100" cy="100" r={r} fill="none" stroke="var(--pf-hairline)" strokeWidth="12" />
        <circle cx="100" cy="100" r={r} fill="none" stroke="var(--accent)" strokeWidth="12" strokeLinecap="round"
          strokeDasharray={on + " " + (c - on)} strokeDashoffset={c * 0.25} transform="rotate(-90 100 100)" opacity="0.85" />
        <text x="100" y="110" textAnchor="middle" fontSize="30" fontWeight="300" fill="var(--accent)">{pct}%</text>
      </svg>
    );
  }

  /* Meta cell for the Opening */
  function MetaCell(props) {
    return (
      <div className="pf-glass" style={{ gridColumn: "span 3", padding: "clamp(20px, 2vw, 28px)" }}>
        <div className="pf-eyebrow" style={{ marginBottom: 12 }}>{props.label}</div>
        <div className="pf-h3" style={{ fontSize: 17 }}>{props.value}</div>
      </div>
    );
  }

  function OnboardingOpening(props) {
    const c = props.case;
    const { Panel, Bento, ListBlock } = window.CSKit;
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 64 }}>
        <div style={{ maxWidth: 820 }}>
          <h2 className="pf-h2" style={{ margin: 0, fontSize: "clamp(21px, 2.2vw, 30px)" }}>{c.title}</h2>
          <p className="pf-lead" style={{ margin: "16px 0 0" }}>{c.summary}</p>
        </div>
        <div className="pf-bento" style={{ gridAutoRows: "auto" }}>
          <MetaCell label="Role" value={c.role} />
          <MetaCell label="Platform" value={c.platform} />
          <MetaCell label="Year" value={c.year} />
          <MetaCell label="Organization" value={c.org} />
        </div>
        <div style={{ display: "flex", flexWrap: "wrap", gap: 12 }}>
          {c.tags.map(function (t) { return <span key={t} className="pf-chip">{t}</span>; })}
        </div>

        {/* Why I prioritized onboarding enrollment */}
        <section>
          <K.Eyebrow>Why this project</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Onboarding enrollment was the key business signal</h3>
          <p className="pf-body" style={{ maxWidth: 780, marginBottom: 28 }}>
            Enrollment is the bridge that carries a new owner from purchase to real value. Four signals told me it
            was the highest-leverage place to work.
          </p>
          <Bento>
            <div style={col(6)}>
              <Panel title="Enrollment lived across surfaces, with transfer inconsistencies">
                <p className="pf-body" style={{ margin: 0 }}>
                  To enroll, owners moved across the head unit, mobile device, and web portals: download the app,
                  sync with the head unit, confirm by email, and lean on retailer help at point of sale. Each
                  hand-off was a place to lose them.
                </p>
              </Panel>
            </div>
            <div style={col(6)}>
              <Panel title="Executives set clear KPIs on enrollment and subscription conversion">
                <p className="pf-body" style={{ margin: 0 }}>
                  Leadership tracked point-of-sale enrollment and initial enrollment directly. The moment right
                  after purchase begins the ownership journey, and it is where a complete experience is won or lost.
                </p>
              </Panel>
            </div>
            <div style={col(6)}>
              <Panel thick title="71% of owners are most open to learning during purchase">
                <p className="pf-body" style={{ margin: 0 }}>
                  In our survey, 71% preferred to meet MySubaru the moment they bought the car, then again when they
                  downloaded the app. Waiting at the retailer, they have the time and attention to learn.
                </p>
              </Panel>
            </div>
            <div style={col(6)}>
              <Panel title="The STARLINK to MySubaru change blurred pricing and package clarity">
                <p className="pf-body" style={{ margin: 0 }}>
                  New tier names, reshuffled services, and an incremental pricing strategy created confusion inside
                  and outside the company. People did not know what had changed, or what MySubaru now provides.
                </p>
              </Panel>
            </div>
            <div style={col(12)}>
              <Panel kicker="What changed" title="STARLINK became MySubaru">
                <div style={{ display: "flex", flexWrap: "wrap", gap: "clamp(20px, 5vw, 80px)", alignItems: "center" }}>
                  <div>
                    <div className="pf-eyebrow" style={{ marginBottom: 12 }}>STARLINK</div>
                    <ListBlock items={["Safety", "Security", "Concierge"]} />
                  </div>
                  <span aria-hidden="true" style={{ fontSize: 22, color: "var(--label-tertiary)" }}>becomes</span>
                  <div>
                    <div className="pf-eyebrow" style={{ marginBottom: 12, color: "var(--accent)" }}>MySubaru</div>
                    <ListBlock items={["Companion", "Companion+"]} />
                  </div>
                </div>
              </Panel>
            </div>
          </Bento>
        </section>

        {/* The North Star */}
        <section>
          <K.Eyebrow>The North Star</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Driving enrollment into the advanced tier</h3>
          <div className="pf-glass pf-glass--thick" style={{ padding: "clamp(28px, 3vw, 48px)", textAlign: "center" }}>
            <p className="pf-h3" style={{ margin: "0 auto", maxWidth: 860, fontSize: "clamp(17px, 1.7vw, 23px)", fontWeight: 300 }}>
              Subaru Connected Service earns most of its profit from the <span style={{ color: "var(--accent)" }}>advanced tier</span>,
              so the goal was to move more owners into it.
            </p>
            <p className="pf-body" style={{ margin: "20px auto 0", maxWidth: 820 }}>
              Reading the revenue composition, this case focuses on three levers inside the profitability model:
              attachment rate at point of sale, enrollment start rate, and enrollment completion. Onboarding is
              where all three are set.
            </p>
          </div>
        </section>
      </div>
    );
  }

  function OnboardingResearch() {
    const { SectionHead, Stat, Panel, Bento, ListBlock, Quote, Figure } = window.CSKit;
    const barriers = [
      { label: "Unclear Value", value: 73 },
      { label: "Cost", value: 44 },
      { label: "Compatibility", value: 39 },
      { label: "Too Complicated", value: 29 },
      { label: "Awareness", value: 24 },
      { label: "Using Alternatives", value: 9 },
      { label: "Sign up barriers", value: 4 },
    ];
    const groups = [
      { title: "Doubting the value", items: ["Unclear Value", "Using Alternatives", "Cost"] },
      { title: "Seeing it as hard to use", items: ["Sign up barriers", "Compatibility"] },
      { title: "Having a knowledge gap", items: ["Awareness", "Too Complicated"] },
    ];
    const frictions = [
      { k: "Information", d: "Customers are not aware of the service." },
      { k: "Journey", d: "Customers encounter usability issues." },
      { k: "Value", d: "Customers are not convinced of the value." },
    ];
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 72 }}>
        <SectionHead kicker="Discovery stage" title="On-site research with owners, in the field"
          lead="I ran on-site intercept research with Subaru enthusiasts at the Ambassador Camping Event, pairing a user survey with a focus group to hear, first-hand, why connected services were not landing." />

        {/* barriers bar chart */}
        <section>
          <K.Eyebrow>What holds owners back</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Unclear value dwarfs every other reason for not using the app</h3>
          <div className="pf-glass" style={{ padding: "clamp(34px, 3.6vw, 56px) clamp(20px, 2.2vw, 34px)", marginBottom: 22 }} data-om-raster="true">
            <div className="pf-eyebrow" style={{ marginBottom: 18 }}>Reasons cited by owners who do not use the app</div>
            <BarChart data={barriers} max={80} />
          </div>
          <Bento>
            {groups.map(function (g) {
              return (
                <div key={g.title} style={col(4)}>
                  <div className="pf-glass" style={{ padding: "clamp(20px, 2vw, 28px)", height: "100%" }}>
                    <div className="pf-h3" style={{ fontSize: 17, marginBottom: 14 }}>{g.title}</div>
                    <div style={{ display: "flex", flexWrap: "wrap", gap: 8 }}>
                      {g.items.map(function (it) { return <span key={it} className="pf-chip">{it}</span>; })}
                    </div>
                  </div>
                </div>
              );
            })}
          </Bento>
        </section>

        {/* value gap: donut + quote */}
        <section>
          <K.Eyebrow>The core gap</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Most non-users simply do not recognize the value</h3>
          <Bento>
            <div style={col(5)}>
              <div className="pf-glass" style={{ padding: "clamp(24px, 2.4vw, 36px)", height: "100%", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 20, textAlign: "center" }}>
                <Donut pct={75} />
                <p className="pf-body" style={{ margin: 0 }}>
                  Among owners who do not use the app, 75% do not know, understand, or recognize its value.
                </p>
              </div>
            </div>
            <div style={col(7)}>
              <div style={{ display: "flex", flexDirection: "column", gap: 16, height: "100%", justifyContent: "center" }}>
                <Quote>
                  I just don't find any value in it, to be honest. The only thing I liked was being able to locate
                  the vehicle if it's stolen. And the remote start screen. None of those are enough to pay for.
                </Quote>
                <p className="pf-body" style={{ margin: 0 }}>
                  Owners generally do not understand what they are paying for, if they are paying at all. The
                  product was capable; the value was invisible.
                </p>
              </div>
            </div>
          </Bento>
        </section>

        {/* three frictions */}
        <section>
          <K.Eyebrow>Three kinds of friction</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Awareness, usability, and value</h3>
          <Bento>
            {frictions.map(function (f) {
              return (
                <div key={f.k} style={col(4)}>
                  <div className="pf-glass" style={{ padding: "clamp(24px, 2.2vw, 34px)", height: "100%" }}>
                    <div className="pf-num" style={{ fontSize: 15, color: "var(--accent)", letterSpacing: "0.06em", marginBottom: 14 }}>{f.k}</div>
                    <p className="pf-body" style={{ margin: 0, fontSize: 17, color: "var(--label-primary)" }}>{f.d}</p>
                  </div>
                </div>
              );
            })}
          </Bento>
        </section>

        {/* locating friction */}
        <section className="pf-glass pf-glass--thick" style={{ padding: "clamp(34px, 5vw, 64px)", textAlign: "center" }}>
          <div className="pf-eyebrow" style={{ marginBottom: 22 }}>Locating friction</div>
          <p className="pf-h2" style={{ margin: "0 auto", maxWidth: 900, fontSize: "clamp(19px, 2vw, 27px)", fontWeight: 300 }}>
            Where are these friction points located along the <span style={{ color: "var(--accent)" }}>onboarding</span> and <span style={{ color: "var(--accent)" }}>returning</span> journey?
          </p>
        </section>
      </div>
    );
  }

  function OnboardingIdeation() {
    const { SectionHead, Panel, Bento, ListBlock, Figure } = window.CSKit;
    function Shot(props) {
      return (
        <div className="pf-glass" style={{ padding: "clamp(14px, 1.4vw, 22px)", height: "100%", display: "flex", flexDirection: "column", gap: 12 }}>
          <div style={{ borderRadius: 14, overflow: "hidden", background: "#f4f6f9", border: "1px solid var(--pf-hairline)" }}>
            <img src={props.src} alt={props.caption} loading="lazy" style={{ display: "block", width: "100%", height: "auto" }} />
          </div>
          {props.caption ? <div style={{ fontSize: 13, color: "var(--label-tertiary)", letterSpacing: "0.01em" }}>{props.caption}</div> : null}
        </div>
      );
    }
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 56 }}>
        <SectionHead kicker="Solution" title="Three checkpoints that clear value, payment, and sign-up"
          lead="Each onboarding checkpoint targets one of the frictions from research, and spans the surfaces where owners actually move: the dealership, the point of sale, and the MySubaru app." />

        <section id="cp-1" style={{ scrollMarginTop: 330 }}>
          <K.Eyebrow>Checkpoint I, Clarify value</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Clarify tier value, starting inside the dealership</h3>
          <Bento>
            <div style={col(5)}>
              <Panel title="Align internally, then to the customer">
                <p className="pf-body" style={{ margin: 0 }}>
                  Tiers were confusing, with multiple payment terms and stacking levels. I designed a card-sorting
                  system in the retailer admin portal so staff could select and deselect tiers, then mirrored a
                  clear tier-detail view into the customer's mobile app.
                </p>
              </Panel>
            </div>
            <div style={col(7)}><Shot src="assets/onboarding-cardsorting-2400.png" caption="Card-sorting system: retailer admin portal plans on the left, the customer's subscription management view on the right." /></div>
            <div style={col(12)}><Shot src="assets/onboarding-adminportal-2400.png" caption="The retailer admin portal where staff manage a customer's active plans, billing, and vehicle details." /></div>
          </Bento>
        </section>

        <section id="cp-2" style={{ scrollMarginTop: 330 }}>
          <K.Eyebrow>Checkpoint II, Contactless payment</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Fast, contactless payment at point of sale</h3>
          <Bento>
            <div style={col(7)}><Figure label="QR code at point of sale opens a service selection page in the browser" h={260} /></div>
            <div style={col(5)}>
              <Panel title="Scan, select, pay" thick>
                <p className="pf-body" style={{ margin: 0 }}>
                  A QR code enables contactless payment, taking the owner directly to a service selection page in
                  the browser so enrollment can begin without friction at the counter.
                </p>
              </Panel>
            </div>
          </Bento>
        </section>

        <section id="cp-3" style={{ scrollMarginTop: 330 }}>
          <K.Eyebrow>Checkpoint III, Guided sign-up</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Intuitive sign-up with clear guidance</h3>
          <Bento>
            <div style={col(5)}>
              <Panel title="A guided account creation journey">
                <p className="pf-body" style={{ margin: 0 }}>
                  After point-of-sale payment, an email points owners to download the MySubaru app. The old app
                  had no account creation at all, so I proposed a guided journey: three required steps, links to
                  dealership setup, and a deliberately skipped PIN and biometric step to keep the path simple.
                </p>
              </Panel>
            </div>
            <div style={col(7)}><Figure label="Account creation: three required steps, dealership setup links, simplified path" h={280} /></div>
          </Bento>
        </section>
      </div>
    );
  }

  function OnboardingOutcome() {
    const { SectionHead, Bento } = window.CSKit;
    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 64 }}>
        <SectionHead kicker="Outcome" title="Onboarding and activation that moved owners into the tier that matters"
          lead="Clarifying tier value, removing payment friction at the counter, and giving the app a guided sign-up it never had lifted enrollment and adoption of the value-driving features." />

        <Bento>
          <div style={col(6)}>
            <div className="pf-glass pf-glass--thick" style={{ padding: "clamp(28px, 3vw, 44px)", height: "100%", display: "flex", flexDirection: "column", justifyContent: "center" }}>
              <div className="pf-num" style={{ fontSize: "clamp(26px, 2.6vw, 34px)", fontWeight: 300, lineHeight: 1, color: "var(--accent)" }}>96%</div>
              <p className="pf-h3" style={{ margin: "20px 0 0", fontSize: "clamp(16px, 1.4vw, 19px)", fontWeight: 300 }}>All-level MySubaru enrollment rate.</p>
            </div>
          </div>
          <div style={col(6)}>
            <div className="pf-glass pf-glass--thick" style={{ padding: "clamp(28px, 3vw, 44px)", height: "100%", display: "flex", flexDirection: "column", justifyContent: "center" }}>
              <div className="pf-num" style={{ fontSize: "clamp(26px, 2.6vw, 34px)", fontWeight: 300, lineHeight: 1, color: "var(--accent)" }}>52.9%</div>
              <p className="pf-h3" style={{ margin: "20px 0 0", fontSize: "clamp(16px, 1.4vw, 19px)", fontWeight: 300 }}>Value-driving feature adoption rate.</p>
            </div>
          </div>
        </Bento>

        <div className="pf-bento" style={{ gridTemplateColumns: "repeat(4, 1fr)", gridAutoRows: "auto" }}>
          <Metric label="Service Enrollment Rate" value="96%" accent />
          <Metric label="Active Usage, Year End" value="+40.6%" />
          <Metric label="Value Feature Adoption Rate" value="52.9%" accent />
          <Metric label="Daily Returning Users" value="+53.4%" />
        </div>

        <section>
          <K.Eyebrow>What drove it</K.Eyebrow>
          <h3 className="pf-h2" style={sectionH3}>Three onboarding checkpoints, each mapped to a friction</h3>
          <div style={{ display: "flex", flexDirection: "column", gap: 14 }}>
            <Checkpoint n="1" title="Value clarity as a prerequisite to decision making">
              Pricing clarification on the Admin Portal, helping retailers understand, communicate, and make the sale.
            </Checkpoint>
            <Checkpoint n="2" title="POS enablement">
              A contactless payment flow that lifts conversion at the point of sale, including an interactive board that demonstrates service value.
            </Checkpoint>
            <Checkpoint n="3" title="Cross-surface consistency">
              Mobile user activation with responsive design and aligned systems across every surface.
            </Checkpoint>
          </div>
          <p className="pf-body" style={{ margin: "20px 0 0", fontSize: 13.5, color: "var(--label-tertiary)" }}>
            A fourth checkpoint, the information-architecture redesign, carried into the retention work covered in the MySubaru Experience Redesign case.
          </p>
        </section>
      </div>
    );
  }

  /* Panel registration for the three Subaru cases now lives in
     subaru-onboarding.jsx, subaru-redesign.jsx and subaru-agentic.jsx,
     which load after this file. This file is kept for the components
     they still reuse: window.OnboardingMap (rendered by the case shell
     via c.heroMap) and window.KioskPrototype, plus the shared charts. */
  window.CASE_PANELS = window.CASE_PANELS || {};

  /* ===================== Interactive enrollment-journey map =====================
     Recreated from the Figma anchor map. Four checkpoints across a day-long
     enrollment journey; clicking a checkpoint springs a highlight frame onto it
     and it stays fixed there. Arrows step between checkpoints. On-palette. */
  const JOURNEY = [
    {
      n: "I", title: "Clarify Pricing Tiers Value", surface: "Dealership, Admin Portal", friction: "Value",
      q: "What is being sold? What service is included? Why is it valuable?",
      steps: ["Car purchase", "Dealers introduce package information"],
      time: "5:00 – 6:00, Internal alignment, then say hi to MySubaru",
      icons: ["assets/onb-ic-2.png", "assets/onb-ic-1.png"],
    },
    {
      n: "II", title: "Fast Payment at POS", surface: "Point of sale, Contactless", friction: "Journey",
      q: "Retailers should have minimum friction helping customers subscribe.",
      steps: ["Subscribe through contactless payment", "Receive an email to onboard"],
      time: "7:00, Morning, learning",
      icons: ["assets/onb-ic-3.png", "assets/onb-ic-7.png"],
    },
    {
      n: "III", title: "Cross-surface Consistency", surface: "Email, MySubaru app", friction: "Information",
      q: "When I leave the POS, can I continue onboarding easily?",
      steps: ["Create an account on app", "Start using remote features", "Log in"],
      time: "12:00 – 15:00, Finish setting up",
      icons: ["assets/onb-ic-6.png", "assets/onb-ic-1.png"],
    },
    {
      n: "IV", title: "Retention & Enhancements", surface: "App, Devices", friction: "Value",
      q: "Do I want to keep using the service, and become an advocate?",
      steps: ["Maintain subscriptions", "Subscribe to packages on app", "Success"],
      time: "18:00 – 21:00, Almost there, then rest",
      icons: ["assets/onb-ic-4.png", "assets/onb-ic-5.png"],
    },
  ];
  const FRICTIONS = {
    Information: "Not aware of Companion, Companion+, or the benefits.",
    Value: "Not convinced of value, plan fit, or upgrade path.",
    Journey: "Technical issues: login, eligibility, hand-offs, payments.",
  };

  function OnboardingMap(props) {
    const [step, setStep] = useState(0);
    const wrapRef = useRef(null);
    const colRefs = useRef({});
    const [frame, setFrame] = useState({ left: 0, width: 0, ready: false });
    const measure = useCallback(function () {
      const el = colRefs.current[step], wrap = wrapRef.current;
      if (!el || !wrap) return;
      setFrame({ left: el.offsetLeft, width: el.offsetWidth, ready: true });
    }, [step]);
    useEffect(function () { measure(); }, [measure]);
    useEffect(function () {
      window.addEventListener("resize", measure);
      return function () { window.removeEventListener("resize", measure); };
    }, [measure]);
    const cp = JOURNEY[step];
    const go = function (d) { setStep(function (s) { return Math.max(0, Math.min(JOURNEY.length - 1, s + d)); }); };

    return (
      <div className="pf-glass pf-glass--thick" style={{ padding: "clamp(18px, 2vw, 30px)" }}>
        <div style={{ display: "flex", alignItems: "baseline", justifyContent: "space-between", flexWrap: "wrap", gap: 12, marginBottom: 8 }}>
          <div className="pf-h3" style={{ fontSize: "clamp(17px, 1.6vw, 21px)" }}>Subscription enrollment across surfaces</div>
          <div className="pf-eyebrow">Awareness → Realization → Adoption → Retention → Advocacy</div>
        </div>
        <p className="pf-body" style={{ margin: "0 0 20px", fontSize: 13.5, color: "var(--label-tertiary)" }}>
          A day-long enrollment journey across four checkpoints. Select a checkpoint to focus it.
        </p>

        {/* checkpoint track */}
        <div ref={wrapRef} className="onb-track" style={{ position: "relative", display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: 12 }}>
          {/* spring highlight frame */}
          <span aria-hidden="true" style={{
            position: "absolute", top: -6, bottom: -6, left: frame.left - 6, width: frame.width + 12,
            border: "2px solid var(--accent)", borderRadius: 16, background: "color-mix(in srgb, var(--accent) 7%, transparent)",
            transition: frame.ready ? "left 480ms cubic-bezier(.34,1.4,.5,1), width 480ms cubic-bezier(.34,1.4,.5,1)" : "none",
            opacity: frame.width ? 1 : 0, pointerEvents: "none", zIndex: 1,
          }} />
          {JOURNEY.map(function (c, i) {
            const on = i === step;
            return (
              <button key={c.n} ref={function (el) { colRefs.current[i] = el; }} onClick={function () { setStep(i); }}
                aria-pressed={on} aria-label={"Checkpoint " + c.n + ": " + c.title}
                className="onb-col" style={{
                  position: "relative", zIndex: 2, textAlign: "left", cursor: "pointer",
                  border: "1px solid var(--pf-border)", borderRadius: 14, padding: "16px 16px 18px",
                  background: on ? "var(--pf-glass-tint-thick)" : "var(--pf-glass-tint)", color: "inherit",
                  display: "flex", flexDirection: "column", gap: 10, transition: "background 300ms var(--glass-ease)",
                }}>
                <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
                  <span className="pf-num" style={{ fontSize: 13, color: "var(--accent)", letterSpacing: "0.06em" }}>{c.n}</span>
                  <span style={{ fontSize: 10.5, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--label-tertiary)" }}>{c.surface}</span>
                </div>
                <div className="pf-h3" style={{ fontSize: 15, lineHeight: 1.25 }}>{c.title}</div>
                <div style={{ display: "flex", alignItems: "flex-end", gap: 10, height: 56, margin: "2px 0 2px" }}>
                  {c.icons.map(function (ic, k) {
                    return <img key={ic + k} src={ic} alt="" aria-hidden="true" style={{ height: k === 0 ? 54 : 44, width: "auto", objectFit: "contain", filter: on ? "none" : "saturate(0.9) opacity(0.9)", transition: "filter 300ms" }} />;
                  })}
                </div>
                <div style={{ display: "flex", flexWrap: "wrap", gap: 6, marginTop: "auto" }}>
                  {c.steps.map(function (s) {
                    return <span key={s} style={{ fontSize: 11, color: on ? "var(--label-secondary)" : "var(--label-tertiary)", background: "var(--fill-tertiary)", border: "1px solid var(--pf-hairline)", borderRadius: 8, padding: "4px 8px" }}>{s}</span>;
                  })}
                </div>
              </button>
            );
          })}
        </div>

        {/* timeline bar */}
        <div style={{ position: "relative", height: 2, background: "var(--pf-hairline)", borderRadius: 2, margin: "22px 6px 0" }}>
          <span aria-hidden="true" style={{ position: "absolute", top: -3, width: 8, height: 8, borderRadius: "50%", background: "var(--accent)", left: "calc(" + (step / (JOURNEY.length - 1)) * 100 + "% - 4px)", transition: "left 480ms cubic-bezier(.34,1.4,.5,1)" }} />
        </div>
        <div style={{ display: "flex", justifyContent: "space-between", margin: "10px 2px 0" }}>
          {["0:00", "7:00", "15:00", "21:00"].map(function (t) { return <span key={t} style={{ fontSize: 11, color: "var(--label-tertiary)" }}>{t}</span>; })}
        </div>

        {/* focused checkpoint detail */}
        <div style={{ display: "grid", gridTemplateColumns: "1.4fr 1fr", gap: 16, marginTop: 22 }} className="onb-detail">
          <div className="pf-glass" style={{ padding: "clamp(18px, 1.8vw, 26px)" }}>
            <div className="pf-eyebrow" style={{ marginBottom: 12, color: "var(--accent)" }}>Checkpoint {cp.n}, {cp.title}</div>
            <p className="pf-body" style={{ margin: 0, fontSize: 15, color: "var(--label-primary)" }}>{cp.q}</p>
            <p className="pf-body" style={{ margin: "12px 0 0", fontSize: 12.5, color: "var(--label-tertiary)" }}>{cp.time}</p>
          </div>
          <div className="pf-glass" style={{ padding: "clamp(18px, 1.8vw, 26px)" }}>
            <div className="pf-eyebrow" style={{ marginBottom: 12 }}>Friction addressed, {cp.friction}</div>
            <p className="pf-body" style={{ margin: 0, fontSize: 14 }}>{FRICTIONS[cp.friction]}</p>
          </div>
        </div>

        {/* arrows */}
        <div style={{ display: "flex", alignItems: "center", justifyContent: "center", gap: 20, marginTop: 22 }}>
          <button onClick={function () { go(-1); }} disabled={step === 0} className="gv-lift" aria-label="Previous checkpoint"
            style={{ width: 44, height: 44, borderRadius: "50%", border: "1px solid var(--pf-border)", background: "var(--pf-glass-tint)", cursor: step === 0 ? "default" : "pointer", opacity: step === 0 ? 0.3 : 1, display: "inline-flex", alignItems: "center", justifyContent: "center", color: "var(--label-primary)" }}>
            <i data-lucide="chevron-left" style={{ width: 18, height: 18 }} />
          </button>
          <span style={{ fontSize: 12, letterSpacing: "0.08em", color: "var(--label-tertiary)" }}>{step + 1} / {JOURNEY.length}</span>
          <button onClick={function () { go(1); }} disabled={step === JOURNEY.length - 1} className="gv-lift" aria-label="Next checkpoint"
            style={{ width: 44, height: 44, borderRadius: "50%", border: "1px solid var(--pf-border)", background: "var(--pf-glass-tint)", cursor: step === JOURNEY.length - 1 ? "default" : "pointer", opacity: step === JOURNEY.length - 1 ? 0.3 : 1, display: "inline-flex", alignItems: "center", justifyContent: "center", color: "var(--label-primary)" }}>
            <i data-lucide="chevron-right" style={{ width: 18, height: 18 }} />
          </button>
        </div>
      </div>
    );
  }
  window.OnboardingMap = OnboardingMap;

  /* ===================== Checkpoint II kiosk prototype (animated tour) ===================== */
  function KioskPrototype(props) {
    const frameRef = useRef(null);
    const [playing, setPlaying] = useState(true);
    const [loaded, setLoaded] = useState(false);
    const reduced = window.usePrefersReducedMotion ? window.usePrefersReducedMotion() : false;

    function post(action) {
      const ifr = frameRef.current;
      if (ifr && ifr.contentWindow) {
        try { ifr.contentWindow.postMessage({ source: "kiosk-ctrl", action: action }, "*"); } catch (e) {}
      }
    }

    // Autoplay is owned by the kiosk frame; parent just toggles it.
    useEffect(function () {
      if (reduced) { post("autoplay-off"); return; }
      post(playing ? "autoplay-on" : "autoplay-off");
    }, [playing, reduced, loaded]);

    return (
      <div style={{ display: "flex", flexDirection: "column", gap: 28 }}>
        <header style={{ maxWidth: 820 }}>
          <h2 className="pf-h2" style={{ margin: 0, fontSize: "clamp(21px, 2.2vw, 30px)" }}>Interactive board</h2>
          <p className="pf-lead" style={{ margin: "16px 0 0" }}>
            This belongs to <strong style={{ color: "var(--label-primary)", fontWeight: 500 }}>Checkpoint II, point of sale</strong>. It lives on the screen inside the retailer store and plays app highlights through short scenarios while customers wait for their vehicle to be handed off.
          </p>
          <p className="pf-body" style={{ margin: "14px 0 0", maxWidth: 720 }}>
            The tour advances on its own, and the board remains fully interactive should you wish to explore it directly.
          </p>
        </header>

        <div className="pf-glass pf-glass--thick" style={{ padding: "clamp(16px, 1.8vw, 28px)" }}>
          <div style={{ position: "relative", width: "100%", aspectRatio: "16 / 9", borderRadius: 16, overflow: "hidden", background: "#0B1F3A" }}>
            <iframe ref={frameRef} title="MySubaru kiosk tour" src="assets/mysubaru-kiosk-tour.html"
              onLoad={function () { setLoaded(true); }}
              style={{ position: "absolute", inset: -1, width: "calc(100% + 2px)", height: "calc(100% + 2px)", border: 0, background: "#0B1F3A" }} />
          </div>
          <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", flexWrap: "wrap", gap: 16, marginTop: 18 }}>
            <button onClick={function () { setPlaying(!playing); }} className="pf-btn gv-lift" aria-label={playing ? "Pause tour" : "Play tour"}>
              <i data-lucide={playing ? "pause" : "play"} style={{ width: 16, height: 16, opacity: 0.85 }} />
              {playing ? "Pause tour" : "Play tour"}
            </button>
            <div style={{ display: "flex", alignItems: "center", gap: 12 }}>
              <button onClick={function () { setPlaying(false); post("back"); }} className="gv-lift" aria-label="Previous screen"
                style={{ width: 44, height: 44, borderRadius: "50%", border: "1px solid var(--pf-border)", background: "var(--pf-glass-tint)", cursor: "pointer", display: "inline-flex", alignItems: "center", justifyContent: "center", color: "var(--label-primary)" }}>
                <i data-lucide="chevron-left" style={{ width: 18, height: 18 }} />
              </button>
              <button onClick={function () { setPlaying(false); post("next"); }} className="gv-lift" aria-label="Next screen"
                style={{ width: 44, height: 44, borderRadius: "50%", border: "1px solid var(--pf-border)", background: "var(--pf-glass-tint)", cursor: "pointer", display: "inline-flex", alignItems: "center", justifyContent: "center", color: "var(--label-primary)" }}>
                <i data-lucide="chevron-right" style={{ width: 18, height: 18 }} />
              </button>
            </div>
            <span className="pf-body" style={{ margin: 0, fontSize: 13, color: "var(--label-tertiary)" }}>In-store kiosk, retailer waiting area</span>
          </div>
        </div>
      </div>
    );
  }
  window.KioskPrototype = KioskPrototype;
})();

const sectionH3 = { margin: "0 0 28px", fontSize: "clamp(19px, 2vw, 26px)", fontWeight: 300, maxWidth: 900 };
