/* ============================================================
 * THE CRM ENGINE, deep dive on the data + automation layer
 * Booking-first CRM · CDP · Journeys · Campaigns · Loyalty
 * ============================================================ */

const engineLayers = [
  {
    k: "crm",
    num: "01",
    name: "CRM",
    promise: "Booking-first guest profiles.",
    body: "Every contact is anchored to real reservations across every channel, not a database of email addresses pretending to be guests.",
  },
  {
    k: "cdp",
    num: "02",
    name: "CDP",
    promise: "One guest, even across PMS silos.",
    body: "Automatic deduplication across heterogeneous PMS instances. Anonymous contacts are promoted to CRM the moment they're reachable.",
  },
  {
    k: "journeys",
    num: "03",
    name: "Journeys",
    promise: "Omnichannel automation that knows the stay.",
    body: "Pre-stay, in-stay, and post-stay flows, triggered by real booking data, branching on real guest context, executing on the right channel.",
  },
  {
    k: "campaigns",
    num: "04",
    name: "Campaigns",
    promise: "Email and WhatsApp, built for conversion.",
    body: "AI-assisted templates and visual editors for both channels. Segmentation by stay value, behavior, and lifecycle stage.",
  },
  {
    k: "loyalty",
    num: "05",
    name: "Loyalty",
    promise: "Sophisticated enough for any group.",
    body: "Rule-based tiers, points, and benefits, modeled to match the largest hotel groups. Live with PMS and booking engines.",
  },
];

const engineOps = [
  { label: "Match",        desc: "Same guest, two emails, auto-merged into one canonical profile." },
  { label: "Promote",      desc: "Anonymous web visitor becomes a contact the moment they're reachable." },
  { label: "Trigger",      desc: "Booking confirmation, no-show risk, post-stay window, all driven by PMS events." },
  { label: "Attribute",    desc: "Every booking traced back to the campaign, journey, or conversation that earned it." },
];

const enginePoints = [
  { t: "Built around bookings, not opens.",         d: "Stay value, room type, length-of-stay, and channel-of-origin are first-class fields, across CRM, segments, journeys, and loyalty rules." },
  { t: "Five layers, one source of truth.",         d: "CRM, CDP, journeys, campaigns, loyalty, every layer reads the same profile, fires off the same booking events, and writes back to the same ledger." },
  { t: "Real-time across the group.",               d: "PMS events, journey state, campaign engagement, and tier qualification update in seconds, across every property in the brand." },
  { t: "Revenue you can attribute.",                d: "Direct revenue per channel, journey, campaign, and loyalty tier, visible at the group level, the property level, and the guest level." },
];

/* ---- Custom mini-visuals for layer cards ---- */
const EngineLayerViz = ({ kind }) => {
  if (kind === "crm") return (
    <svg viewBox="0 0 200 80" className="el-vis" preserveAspectRatio="xMidYMid meet">
      {[
        { y: 14, name: "Müller, A.",  val: "€1,840", on: true  },
        { y: 34, name: "Petrov, K.",  val: "€2,120", on: false },
        { y: 54, name: "Tan, M.",     val: "€640",   on: false },
      ].map((r, i) => (
        <g key={i}>
          <rect x="10" y={r.y} width="180" height="14" rx="3"
                fill={r.on ? "color-mix(in srgb, var(--accent) 12%, var(--bg-elev-2))" : "var(--bg-elev-2)"}
                stroke={r.on ? "var(--accent)" : "var(--hairline)"} strokeWidth="0.6"/>
          <circle cx="18" cy={r.y + 7} r="3" fill={r.on ? "var(--accent)" : "var(--ink-4)"}/>
          <text x="26" y={r.y + 9.5} fontSize="6.5" fill={r.on ? "var(--accent)" : "var(--ink-2)"} fontWeight={r.on ? 600 : 400}>{r.name}</text>
          <text x="184" y={r.y + 9.5} fontSize="6.5" textAnchor="end" fontFamily="var(--f-mono)"
                fill={r.on ? "var(--accent)" : "var(--ink-3)"}>{r.val}</text>
        </g>
      ))}
    </svg>
  );
  if (kind === "cdp") return (
    <svg viewBox="0 0 200 80" className="el-vis" preserveAspectRatio="xMidYMid meet">
      <g opacity="0.6">
        {[20, 40, 60].map((y, i) => (
          <g key={i}>
            <circle cx="28" cy={y} r="9" fill="none" stroke="var(--ink-3)" strokeWidth="0.7"/>
            <text x="28" y={y + 2} fontSize="6" textAnchor="middle" fill="var(--ink-3)" fontFamily="var(--f-mono)">PMS·{i + 1}</text>
          </g>
        ))}
      </g>
      {[20, 40, 60].map((y, i) => (
        <line key={i} x1="38" y1={y} x2="120" y2="40" stroke="var(--accent)" strokeWidth="0.5" strokeDasharray="2 2"/>
      ))}
      <circle cx="148" cy="40" r="20" fill="var(--accent)"/>
      <text x="148" y="38" fontSize="7" textAnchor="middle" fill="var(--accent-ink)" fontWeight="600" fontFamily="var(--f-mono)">ONE</text>
      <text x="148" y="46" fontSize="6" textAnchor="middle" fill="var(--accent-ink)" fontFamily="var(--f-mono)">GUEST</text>
    </svg>
  );
  if (kind === "journeys") return (
    <svg viewBox="0 0 200 80" className="el-vis" preserveAspectRatio="xMidYMid meet">
      {/* Trigger node */}
      <rect x="8" y="34" width="34" height="14" rx="3" fill="var(--accent)" />
      <text x="25" y="43" fontSize="6" textAnchor="middle" fill="var(--accent-ink)" fontWeight="600" fontFamily="var(--f-mono)">BK·NEW</text>
      {/* Branches */}
      <path d="M 42 41 Q 70 41, 80 22 L 96 22" fill="none" stroke="var(--accent)" strokeWidth="0.8"/>
      <path d="M 42 41 L 96 41" fill="none" stroke="var(--accent)" strokeWidth="0.8"/>
      <path d="M 42 41 Q 70 41, 80 60 L 96 60" fill="none" stroke="var(--accent)" strokeWidth="0.8"/>
      {/* Step nodes */}
      <rect x="96" y="16" width="36" height="12" rx="2" fill="var(--bg-elev-2)" stroke="var(--c-whatsapp)" strokeWidth="0.7"/>
      <text x="114" y="24" fontSize="5.5" textAnchor="middle" fill="var(--c-whatsapp)" fontFamily="var(--f-mono)">WA · CONFIRM</text>
      <rect x="96" y="35" width="36" height="12" rx="2" fill="var(--bg-elev-2)" stroke="var(--c-email)" strokeWidth="0.7"/>
      <text x="114" y="43" fontSize="5.5" textAnchor="middle" fill="var(--c-email)" fontFamily="var(--f-mono)">EMAIL · UPSELL</text>
      <rect x="96" y="54" width="36" height="12" rx="2" fill="var(--bg-elev-2)" stroke="var(--c-voice)" strokeWidth="0.7"/>
      <text x="114" y="62" fontSize="5.5" textAnchor="middle" fill="var(--c-voice)" fontFamily="var(--f-mono)">VOICE · VIP</text>
      {/* Continuation */}
      <line x1="132" y1="22" x2="160" y2="22" stroke="var(--ink-4)" strokeWidth="0.5" strokeDasharray="1 1"/>
      <line x1="132" y1="41" x2="160" y2="41" stroke="var(--ink-4)" strokeWidth="0.5" strokeDasharray="1 1"/>
      <line x1="132" y1="60" x2="160" y2="60" stroke="var(--ink-4)" strokeWidth="0.5" strokeDasharray="1 1"/>
      <text x="180" y="44" fontSize="6" textAnchor="middle" fill="var(--ink-4)" fontFamily="var(--f-mono)">…</text>
    </svg>
  );
  if (kind === "campaigns") return (
    <svg viewBox="0 0 200 80" className="el-vis" preserveAspectRatio="xMidYMid meet">
      {/* Email mock */}
      <rect x="14" y="14" width="78" height="52" rx="4" fill="var(--bg-elev-2)" stroke="var(--c-email)" strokeWidth="0.7"/>
      <rect x="20" y="20" width="42" height="3" rx="1" fill="var(--c-email)"/>
      <rect x="20" y="26" width="60" height="2" rx="1" fill="var(--ink-3)" opacity="0.4"/>
      <rect x="20" y="31" width="56" height="2" rx="1" fill="var(--ink-3)" opacity="0.4"/>
      <rect x="20" y="36" width="48" height="2" rx="1" fill="var(--ink-3)" opacity="0.4"/>
      <rect x="20" y="46" width="34" height="10" rx="2" fill="var(--c-email)"/>
      <text x="37" y="52.5" fontSize="5" textAnchor="middle" fill="var(--bg)" fontFamily="var(--f-mono)" fontWeight="600">BOOK NOW</text>
      {/* WA mock */}
      <rect x="108" y="14" width="78" height="52" rx="4" fill="color-mix(in srgb, var(--c-whatsapp) 14%, var(--bg-elev-2))" stroke="var(--c-whatsapp)" strokeWidth="0.7"/>
      <circle cx="116" cy="22" r="3" fill="var(--c-whatsapp)"/>
      <rect x="122" y="20" width="36" height="2.5" rx="1" fill="var(--ink-2)"/>
      <rect x="122" y="25" width="28" height="2" rx="1" fill="var(--ink-3)" opacity="0.5"/>
      <rect x="116" y="34" width="58" height="3" rx="1" fill="var(--ink-2)" opacity="0.7"/>
      <rect x="116" y="40" width="50" height="2.5" rx="1" fill="var(--ink-3)" opacity="0.5"/>
      <rect x="116" y="46" width="44" height="2.5" rx="1" fill="var(--ink-3)" opacity="0.5"/>
      <rect x="116" y="55" width="42" height="8" rx="2" fill="var(--c-whatsapp)"/>
      <text x="137" y="60.5" fontSize="5" textAnchor="middle" fill="white" fontFamily="var(--f-mono)" fontWeight="600">RESERVE</text>
    </svg>
  );
  if (kind === "loyalty") return (
    <svg viewBox="0 0 200 80" className="el-vis" preserveAspectRatio="xMidYMid meet">
      {[
        { y: 14, w: 32,  label: "BRONZE",   on: false },
        { y: 28, w: 60,  label: "SILVER",   on: false },
        { y: 42, w: 100, label: "GOLD",     on: false },
        { y: 56, w: 154, label: "PLATINUM", on: true  },
      ].map((b, i) => (
        <g key={i}>
          <rect x="10" y={b.y - 4} width="180" height="9" rx="2" fill="var(--bg-elev-2)"/>
          <rect x="10" y={b.y - 4} width={b.w} height="9" rx="2"
                fill={b.on ? "var(--accent)" : "var(--ink-3)"}
                opacity={b.on ? 1 : 0.5}/>
          <text x="16" y={b.y + 2.5} fontSize="6" fill={b.on ? "var(--accent-ink)" : "var(--bg)"}
                fontFamily="var(--f-mono)" fontWeight="600">{b.label}</text>
          {b.on && (
            <path d={`M ${10 + b.w + 6} ${b.y + 1.5} L ${10 + b.w + 9} ${b.y - 2.5} L ${10 + b.w + 12} ${b.y + 0.5} L ${10 + b.w + 15} ${b.y - 2.5} L ${10 + b.w + 18} ${b.y + 1.5} Z`}
                  fill="var(--accent)"/>
          )}
        </g>
      ))}
    </svg>
  );
  return null;
};

/* ---- Campaigns carousel slides ---- */
const campaignSlides = [
  {
    k: "wa",
    channel: "WhatsApp Broadcasts",
    channelColor: "var(--c-whatsapp)",
    headline: "Reach guests where they actually reply.",
    body: "A guided wizard for outbound WhatsApp campaigns: setup, template, content, audience, schedule. Approved templates, language-matched content, and audience segments built from real booking data, not bought lists.",
    img: "https://cdn.guestmaker.ai/marketing/homepage-v3/assets/screen-campaign-wa.png",
    url: "broadcasts · whatsapp · new",
    chips: [
      { k: "Approved templates",   d: "Meta-approved templates, scoped per language and hotel." },
      { k: "Booking-based audience", d: "Segments from real reservations: post-stay 365d, lapsed, VIP." },
      { k: "Multi-property",       d: "Send across all hotels, or surgical to one brand." },
      { k: "Compliant by default", d: "Opt-in, frequency caps, and 24-hour windows handled automatically." },
    ],
  },
  {
    k: "email",
    channel: "Email Campaigns",
    channelColor: "var(--c-email)",
    headline: "The email channel, rebuilt for hotel groups.",
    body: "An eight-step wizard, basics, goal, audience, template, subject, settings, schedule, review, with auto-save throughout. Goal-driven campaigns (book direct, upsell, win-back), live segment counts, and A/B subject testing built in.",
    img: "https://cdn.guestmaker.ai/marketing/homepage-v3/assets/screen-campaign-email.png",
    url: "broadcasts · email-campaigns · new",
    chips: [
      { k: "Goal-driven",          d: "Select the outcome, direct bookings, upsell, win-back, first." },
      { k: "Live segment counts",  d: "Audience size updates as you refine filters." },
      { k: "A/B subject testing",  d: "Test subject lines on a sample, send the winner to the rest." },
      { k: "Auto-save",            d: "Every step persisted, pick up where you left off, on any device." },
    ],
  },
];

/* ---- CDP carousel slides ---- */
const cdpSlides = [
  {
    k: "profiles",
    channel: "Guest Profiles",
    channelColor: "var(--accent)",
    headline: "Unified guest identities across every hotel.",
    body: "5,673 profiles. Cross-PMS deduplicated. Reachability and confidence scored on every row. Sortable, searchable, exportable, the working surface for analysts, marketers, and auditors alike.",
    img: "https://cdn.guestmaker.ai/marketing/homepage-v3/assets/screen-cdp-profiles.png",
    url: "cdp · profiles",
    chips: [
      { k: "Cross-PMS dedup",     d: "Same guest, multiple PMS instances → one canonical profile." },
      { k: "Reachability scored", d: "Email, phone, opt-in status, surfaced per row." },
      { k: "Confidence scored",   d: "Match certainty exposed, never hidden behind a black box." },
      { k: "Built for scale",     d: "Sort, filter, export across millions of profiles." },
    ],
  },
  {
    k: "golden",
    channel: "Golden Record",
    channelColor: "var(--accent)",
    headline: "Every profile, fully traceable.",
    body: "Drill into a profile to see the Golden Record: canonical fields with provenance, all matched guests across PMS instances, reservations, browsing, and the full match history, every merge auditable, every promotion to CRM logged.",
    img: "https://cdn.guestmaker.ai/marketing/homepage-v3/assets/screen-cdp-detail.png",
    url: "cdp · profiles · David Richter",
    chips: [
      { k: "Provenance per field",  d: "Every value traceable to a source, PMS, channel, or form." },
      { k: "Match history",         d: "See exactly why two guests merged into one profile." },
      { k: "Promoted to CRM",       d: "Anonymous becomes known the moment they're reachable." },
      { k: "Auditable by default",  d: "Compliance-grade record, no silent rewrites." },
    ],
  },
  {
    k: "lifetime",
    channel: "Lifetime Revenue",
    channelColor: "var(--accent)",
    headline: "Stays and revenue, rolled up across the group.",
    body: "Total stays, total revenue, total extras, deduplicated across every PMS silo and every property. The booking is the unit, not the email open. Now you can finally answer: \"what is this guest worth to the group?\"",
    img: "https://cdn.guestmaker.ai/marketing/homepage-v3/assets/screen-booking-history.png",
    url: "cdp · profiles · booking history",
    chips: [
      { k: "Group-level LTV",     d: "Lifetime value across the brand, not one per hotel." },
      { k: "Extras tracked",      d: "Spa, F&B, late checkout, captured alongside room revenue." },
      { k: "Channel attribution", d: "Direct, OTA, or campaign, booking source preserved." },
      { k: "Real-time",           d: "PMS events update lifetime totals within seconds." },
    ],
  },
];

const FeatureCarousel = ({ slides, label }) => {
  const [idx, setIdx] = React.useState(0);
  const trackRef = React.useRef(null);

  React.useEffect(() => {
    const track = trackRef.current;
    if (!track) return;
    let raf;
    const onScroll = () => {
      cancelAnimationFrame(raf);
      raf = requestAnimationFrame(() => {
        const w = track.clientWidth;
        if (!w) return;
        const next = Math.round(track.scrollLeft / w);
        if (next !== idx) setIdx(next);
      });
    };
    track.addEventListener("scroll", onScroll, { passive: true });
    return () => { track.removeEventListener("scroll", onScroll); cancelAnimationFrame(raf); };
  }, [idx]);

  const goTo = (i) => {
    const track = trackRef.current;
    if (!track) return;
    track.scrollTo({ left: i * track.clientWidth, behavior: "smooth" });
    setIdx(i);
  };

  return (
    <div className="cc">
      <div className="cc-track" ref={trackRef}>
        {slides.map((s, i) => (
          <div className="cc-slide" key={s.k} aria-hidden={i !== idx}>
            <div className="cc-channel-row">
              <span className="cc-channel-dot" style={{ background: s.channelColor }} />
              <span className="cc-channel-label" style={{ color: s.channelColor }}>{s.channel}</span>
            </div>
            <h4 className="cc-headline">{s.headline}</h4>
            <p className="cc-body">{s.body}</p>

            <div className="ej-frame" style={{ marginTop: 24 }}>
              <div className="es-bar">
                <div className="lights"><i/><i/><i/></div>
                <div className="es-url"><span className="es-pill" style={{ background: s.channelColor }} /><span>{s.url}</span></div>
                <div style={{ width: 60 }} />
              </div>
              <img src={s.img} alt={s.channel} className="ej-shot" />
            </div>

            <div className="ej-chips">
              {s.chips.map((c, j) => (
                <div key={j} className="ej-chip" style={{ borderLeftColor: s.channelColor }}>
                  <div className="ej-chip-k">{c.k}</div>
                  <div className="ej-chip-d">{c.d}</div>
                </div>
              ))}
            </div>
          </div>
        ))}
      </div>

      <div className="cc-pager" role="tablist" aria-label={label}>
        {slides.map((s, i) => (
          <button
            key={s.k}
            type="button"
            role="tab"
            aria-selected={i === idx}
            aria-label={s.channel}
            className={`cc-dot ${i === idx ? "is-active" : ""}`}
            onClick={() => goTo(i)}
          >
            <span className="cc-dot-label">{s.channel}</span>
          </button>
        ))}
      </div>
    </div>
  );
};

const SectionEngine = () => {
  return (
    <section className="section-pad engine" id="engine">
      <div className="engine-bg" aria-hidden="true" />
      <div className="container">
        {/* === HEAD === */}
        <div className="engine-head">
          <Reveal><div className="eyebrow">The CRM Engine</div></Reveal>
          <Reveal delay={120}>
            <h2 className="h-1" style={{ marginTop: 28, maxWidth: 1080 }}>
              The data and automation layer that turns conversations <span className="italic-accent">into revenue.</span>
            </h2>
          </Reveal>
          <div className="engine-paras">
            <Reveal delay={220}>
              <p className="body" style={{ fontSize: 17 }}>
                Every conversation in the inbox is also a row in a real CRM, anchored to bookings, deduplicated across PMS instances, enriched with stay history and channel preference. The same profile the AI reads to answer a WhatsApp message powers your campaigns, journeys, and loyalty rules.
              </p>
            </Reveal>
            <Reveal delay={320}>
              <p className="body" style={{ fontSize: 17 }}>
                It's a single stack: CRM, CDP, journeys, campaigns, loyalty. Built around bookings, run in real time, attributed to revenue. The kind of system hotel groups have spent a decade trying to assemble from five different vendors.
              </p>
            </Reveal>
          </div>
        </div>

        {/* === LAYERS STRIP === */}
        <div className="engine-layers">
          {engineLayers.map((l, i) => (
            <Reveal key={l.k} delay={i * 80}>
              <div className="el-card">
                <div className="el-viz-wrap"><EngineLayerViz kind={l.k} /></div>
                <div className="el-num">{l.num} / {l.name.toUpperCase()}</div>
                <h3 className="el-title">{l.name}</h3>
                <p className="el-promise">{l.promise}</p>
                <p className="el-body">{l.body}</p>
              </div>
            </Reveal>
          ))}
        </div>

        {/* === CRM HERO ===== */}
        <Reveal>
          <div className="engine-feature">
            <div className="ef-head">
              <div className="eyebrow" style={{ justifyContent: "flex-start" }}>CRM</div>
              <h3 className="h-2" style={{ marginTop: 16, fontSize: "clamp(28px, 3vw, 40px)" }}>
                A guest profile <span className="italic-accent">that actually knows the guest.</span>
              </h3>
              <p className="body" style={{ marginTop: 16, maxWidth: 720, color: "var(--ink-2)" }}>
                Every contact is anchored to real reservations across every channel, never a stale list of email addresses. Reservations, messaging history, languages spoken, website behaviour, safety flags, custom fields, and a curated <strong>Memory</strong>, preferences, context, negative experiences, unresolved issues, all on one page. The same memory the AI reads on every reply.
              </p>
            </div>

            <div className="ej-frame">
              <div className="es-bar">
                <div className="lights"><i/><i/><i/></div>
                <div className="es-url"><span className="es-pill" /><span>data · contacts · Lisa Armstrong</span></div>
                <div style={{ width: 60 }} />
              </div>
              <img src="https://cdn.guestmaker.ai/marketing/homepage-v3/assets/screen-contact.png" alt="Guest profile with memory tab" className="ej-shot" />
            </div>

            <div className="ej-chips">
              {[
                { k: "Booking-anchored",  d: "Profiles built from real reservations, not form submissions." },
                { k: "Curated memory",    d: "Preferences, context, and unresolved issues, surfaced to AI and staff." },
                { k: "Channel history",   d: "Every WhatsApp, email, voice and DM thread, in one timeline." },
                { k: "Custom fields",     d: "Tags, segments, languages, safety flags, modelled per group." },
              ].map((c, i) => (
                <div key={i} className="ej-chip">
                  <div className="ej-chip-k">{c.k}</div>
                  <div className="ej-chip-d">{c.d}</div>
                </div>
              ))}
            </div>
          </div>
        </Reveal>

        {/* === CDP CAROUSEL ===== */}
        <Reveal>
          <div className="engine-feature">
            <div className="ef-head">
              <div className="eyebrow" style={{ justifyContent: "flex-start" }}>CDP</div>
              <h3 className="h-2" style={{ marginTop: 16, fontSize: "clamp(28px, 3vw, 40px)" }}>
                One guest. <span className="italic-accent">Even when your PMS says otherwise.</span>
              </h3>
              <p className="body" style={{ marginTop: 16, maxWidth: 720, color: "var(--ink-2)" }}>
                Hotel groups run multiple PMS instances, sometimes multiple PMS vendors. The same guest stays at three properties under three slightly different identities. The CDP fixes that automatically: deduplicating across PMS silos, attributing every booking back to a single canonical guest, and surfacing real lifetime value at the group level.
              </p>
            </div>

            <FeatureCarousel slides={cdpSlides} label="CDP" />

            {/* === ENGINE OPS RIBBON (lives inside CDP) ===== */}
            <div className="engine-ops" style={{ marginTop: 56, marginBottom: 0 }}>
              <Reveal>
                <div className="eo-label">Continuous engine ops</div>
              </Reveal>
              <div className="eo-list">
                {engineOps.map((o, i) => (
                  <Reveal key={i} delay={i * 80}>
                    <div className="eo-row">
                      <span className="eo-tick"><i/></span>
                      <span className="eo-label-k">{o.label}</span>
                      <span className="eo-desc">{o.desc}</span>
                    </div>
                  </Reveal>
                ))}
              </div>
            </div>
          </div>
        </Reveal>

        {/* === JOURNEYS HERO ===== */}
        <Reveal>
          <div className="engine-feature">
            <div className="ef-head">
              <div className="eyebrow" style={{ justifyContent: "flex-start" }}>Journeys</div>
              <h3 className="h-2" style={{ marginTop: 16, fontSize: "clamp(28px, 3vw, 40px)" }}>
                A visual editor for <span className="italic-accent">omnichannel guest journeys.</span>
              </h3>
              <p className="body" style={{ marginTop: 16, maxWidth: 720, color: "var(--ink-2)" }}>
                Drag-and-drop the entire pre-stay, in-stay, and post-stay lifecycle. Branch on real booking data, room type, length of stay, channel of origin, loyalty tier. Every node is channel-aware: WhatsApp here, email there, voice when it matters.
              </p>
            </div>

            <div className="ej-frame">
              <div className="es-bar">
                <div className="lights"><i/><i/><i/></div>
                <div className="es-url"><span className="es-pill" /><span>journeys · "Confirmación de Reserva" · active</span></div>
                <div style={{ width: 60 }} />
              </div>
              <img src="https://cdn.guestmaker.ai/marketing/homepage-v3/assets/screen-journey.png" alt="Visual workflow editor for journeys" className="ej-shot" />
            </div>

            <div className="ej-chips">
              {[
                { k: "Visual editor",    d: "Branch logic on the canvas, preview on a phone." },
                { k: "Channel-aware",    d: "Each node sends on WhatsApp, Email, or Voice." },
                { k: "PMS triggered",    d: "Booking events fire steps in real time." },
                { k: "Localized",        d: "Multi-language at the node level, not the journey." },
              ].map((c, i) => (
                <div key={i} className="ej-chip">
                  <div className="ej-chip-k">{c.k}</div>
                  <div className="ej-chip-d">{c.d}</div>
                </div>
              ))}
            </div>
          </div>
        </Reveal>

        {/* === CAMPAIGNS CAROUSEL ===== */}
        <Reveal>
          <div className="engine-feature">
            <div className="ef-head">
              <div className="eyebrow" style={{ justifyContent: "flex-start" }}>Campaigns</div>
              <h3 className="h-2" style={{ marginTop: 16, fontSize: "clamp(28px, 3vw, 40px)" }}>
                Outbound campaigns, <span className="italic-accent">on the channels guests answer.</span>
              </h3>
              <p className="body" style={{ marginTop: 16, maxWidth: 720, color: "var(--ink-2)" }}>
                Two channels, one wizard pattern: WhatsApp broadcasts and email campaigns, both built around real booking audiences and the same approved-template flow your team already trusts. Swipe between them.
              </p>
            </div>

            <FeatureCarousel slides={campaignSlides} label="Campaigns" />
          </div>
        </Reveal>

        {/* === LOYALTY ===== */}
        <SectionLoyalty />

        {/* === POINTS ===== */}
        <div className="engine-points">
          {enginePoints.map((p, i) => (
            <Reveal key={i} delay={i * 80}>
              <div className="engine-point">
                <span className="engine-point-num">0{i + 1}</span>
                <h4 className="h-3" style={{ fontSize: 19, marginBottom: 8 }}>{p.t}</h4>
                <p className="body" style={{ fontSize: 14 }}>{p.d}</p>
              </div>
            </Reveal>
          ))}
        </div>

        <Reveal>
          <p className="engine-closer">
            Conversations in.<br/>
            <span className="italic-accent">Revenue out.</span>
          </p>
        </Reveal>
      </div>

      <style>{`
        .engine { position: relative; background: var(--bg); overflow: hidden; }
        .engine-bg {
          position: absolute; width: 700px; height: 700px;
          top: 20%; right: -200px;
          background: radial-gradient(circle, var(--accent-glow), transparent 70%);
          filter: blur(80px); opacity: 0.4; pointer-events: none;
        }
        .engine-head { position: relative; max-width: 1100px; margin-bottom: 80px; }
        .engine-paras {
          display: grid; grid-template-columns: 1fr 1fr; gap: 40px;
          margin-top: 40px; max-width: 1000px;
        }
        @media (max-width: 800px) { .engine-paras { grid-template-columns: 1fr; gap: 24px; } }

        /* === Layer cards strip === */
        .engine-layers {
          display: grid;
          grid-template-columns: repeat(5, 1fr);
          gap: 14px;
          margin-bottom: 96px;
        }
        .el-card {
          padding: 20px;
          background: var(--bg-elev-1);
          border: 1px solid var(--hairline);
          border-radius: 14px;
          display: flex; flex-direction: column;
          height: 100%;
          transition: border-color .25s ease, transform .25s ease;
        }
        .el-card:hover { border-color: var(--accent); transform: translateY(-2px); }
        .el-viz-wrap {
          height: 90px;
          margin-bottom: 16px;
          background: var(--bg);
          border: 1px solid var(--hairline);
          border-radius: 8px;
          padding: 6px;
        }
        .el-vis { width: 100%; height: 100%; display: block; }
        .el-num {
          font-family: var(--f-mono); font-size: 10px;
          color: var(--ink-4); letter-spacing: 0.12em;
          margin-bottom: 8px;
        }
        .el-title {
          font-family: var(--f-display);
          font-size: 22px;
          letter-spacing: -0.01em;
          margin: 0 0 6px;
          line-height: 1.1;
        }
        .el-promise {
          font-size: 13px; color: var(--ink); font-weight: 500;
          line-height: 1.4; margin: 0 0 10px;
        }
        .el-body {
          font-size: 12.5px; color: var(--ink-3);
          line-height: 1.55; margin: 0;
        }
        @media (max-width: 1100px) { .engine-layers { grid-template-columns: repeat(3, 1fr); } }
        @media (max-width: 720px)  { .engine-layers { grid-template-columns: 1fr; } }

        /* === Browser-frame chrome (shared across all feature panels) === */
        .es-bar {
          display: flex; align-items: center; justify-content: space-between;
          padding: 12px 16px;
          background: var(--bg-elev-2);
          border-bottom: 1px solid var(--hairline);
        }
        .lights { display: flex; gap: 6px; }
        .lights i { width: 11px; height: 11px; border-radius: 50%; background: var(--bg-elev-3); display: block; }
        .lights i:first-child { background: #ff5f57; }
        .lights i:nth-child(2) { background: #febc2e; }
        .lights i:nth-child(3) { background: #28c840; }
        .es-url {
          display: inline-flex; align-items: center; gap: 8px;
          padding: 4px 14px;
          background: var(--bg);
          border-radius: 6px;
          font-size: 11px;
          color: var(--ink-3);
          font-family: var(--f-mono);
        }
        .es-pill {
          width: 6px; height: 6px; border-radius: 50%;
          background: var(--accent);
        }

        /* === Feature hero panels (CRM, CDP, Journeys) === */
        .engine-feature {
          margin-bottom: 120px;
        }
        .engine-feature:last-of-type { margin-bottom: 96px; }
        .ef-head { max-width: 760px; margin-bottom: 32px; }
        .ej-frame {
          border-radius: 16px;
          overflow: hidden;
          background: var(--bg-elev-1);
          border: 1px solid var(--hairline);
          box-shadow:
            0 60px 120px -40px rgba(0,0,0,.6),
            0 0 0 1px var(--hairline);
        }
        .ej-shot { width: 100%; display: block; }
        .ej-chips {
          display: grid;
          grid-template-columns: repeat(4, 1fr);
          gap: 12px;
          margin-top: 24px;
        }
        @media (max-width: 800px) { .ej-chips { grid-template-columns: repeat(2, 1fr); } }
        .ej-chip {
          padding: 16px 18px;
          background: var(--bg-elev-1);
          border: 1px solid var(--hairline);
          border-left: 2px solid var(--accent);
          border-radius: 10px;
        }
        .ej-chip-k {
          font-size: 13px; font-weight: 600; color: var(--ink);
          margin-bottom: 4px;
        }
        .ej-chip-d {
          font-size: 12px; color: var(--ink-3); line-height: 1.5;
        }

        /* === Campaigns carousel === */
        .cc {
          position: relative;
        }
        .cc-track {
          display: flex;
          overflow-x: auto;
          overflow-y: hidden;
          scroll-snap-type: x mandatory;
          scroll-behavior: smooth;
          scrollbar-width: none;
          -ms-overflow-style: none;
          gap: 0;
          /* Hide vertical reveal-overflow within slides */
          padding-bottom: 4px;
        }
        .cc-track::-webkit-scrollbar { display: none; }
        .cc-slide {
          flex: 0 0 100%;
          min-width: 0;
          scroll-snap-align: start;
          scroll-snap-stop: always;
          padding-right: 2px;
        }
        .cc-channel-row {
          display: inline-flex; align-items: center; gap: 10px;
          padding: 6px 12px;
          background: var(--bg-elev-1);
          border: 1px solid var(--hairline);
          border-radius: 999px;
          margin-bottom: 14px;
        }
        .cc-channel-dot {
          width: 8px; height: 8px; border-radius: 50%;
          box-shadow: 0 0 8px currentColor;
        }
        .cc-channel-label {
          font-family: var(--f-mono); font-size: 11px;
          letter-spacing: 0.08em; text-transform: uppercase;
          font-weight: 600;
        }
        .cc-headline {
          font-family: var(--f-display);
          font-size: clamp(22px, 2.4vw, 30px);
          letter-spacing: -0.01em;
          line-height: 1.15;
          margin: 0 0 12px;
          max-width: 720px;
          text-wrap: balance;
        }
        .cc-body {
          margin: 0;
          font-size: 15px;
          line-height: 1.6;
          color: var(--ink-2);
          max-width: 720px;
        }

        /* Pager dots */
        .cc-pager {
          display: flex;
          justify-content: center;
          align-items: center;
          gap: 28px;
          margin-top: 32px;
        }
        .cc-dot {
          appearance: none;
          background: transparent;
          border: 0;
          padding: 8px 4px;
          cursor: pointer;
          display: inline-flex;
          flex-direction: column;
          align-items: center;
          gap: 8px;
          color: var(--ink-3);
          transition: color .25s ease;
        }
        .cc-dot::before {
          content: "";
          width: 32px; height: 2px;
          background: var(--hairline-strong);
          border-radius: 1px;
          transition: background .25s ease, width .25s ease;
        }
        .cc-dot.is-active::before {
          background: var(--accent);
          width: 56px;
        }
        .cc-dot.is-active { color: var(--ink); }
        .cc-dot:hover { color: var(--ink); }
        .cc-dot-label {
          font-family: var(--f-mono);
          font-size: 10px;
          letter-spacing: 0.1em;
          text-transform: uppercase;
        }

        /* === Engine ops ribbon === */
        .engine-ops {
          padding: 28px;
          background: var(--bg-elev-1);
          border: 1px solid var(--hairline);
          border-radius: 16px;
          margin-bottom: 96px;
        }
        .eo-label {
          font-family: var(--f-mono); font-size: 11px;
          letter-spacing: 0.12em; text-transform: uppercase;
          color: var(--ink-3); margin-bottom: 18px;
        }
        .eo-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
        @media (max-width: 720px) { .eo-list { grid-template-columns: 1fr; } }
        .eo-row {
          display: grid;
          grid-template-columns: 18px 110px 1fr;
          align-items: center;
          gap: 12px;
          padding: 14px 16px;
          background: var(--bg);
          border-radius: 10px;
          font-size: 13px;
          border: 1px solid var(--hairline);
        }
        .eo-tick {
          display: inline-grid; place-items: center;
          width: 18px; height: 18px;
          border-radius: 50%;
          background: color-mix(in srgb, var(--c-whatsapp) 22%, transparent);
        }
        .eo-tick i {
          width: 7px; height: 7px; border-radius: 50%;
          background: var(--c-whatsapp);
          box-shadow: 0 0 8px var(--c-whatsapp);
          animation: pulse 1.6s infinite;
        }
        .eo-label-k {
          font-weight: 600;
          font-family: var(--f-mono); font-size: 11px;
          letter-spacing: 0.04em;
          color: var(--accent);
        }
        .eo-desc { color: var(--ink-2); font-size: 13px; line-height: 1.5; }

        /* === Points === */
        .engine-points {
          display: grid;
          grid-template-columns: repeat(2, 1fr);
          gap: 32px;
          max-width: 920px;
          margin-bottom: 96px;
        }
        @media (max-width: 720px) { .engine-points { grid-template-columns: 1fr; } }
        .engine-point { padding: 24px 24px 24px 0; border-top: 1px solid var(--hairline-strong); }
        .engine-point-num {
          display: block; font-family: var(--f-mono); font-size: 11px;
          color: var(--accent); letter-spacing: 0.1em; margin-bottom: 16px;
        }

        .engine-closer {
          font-family: var(--f-display);
          font-size: clamp(36px, 4.4vw, 60px);
          line-height: 1.1; letter-spacing: -0.02em;
          text-wrap: balance;
        }
      `}</style>
    </section>
  );
};

window.SectionEngine = SectionEngine;
