/* ==========================================================================
   REVE Chat Version 4 homepage: "Works with the tools you already use." (#integrations)
   Markup: template-parts/rc-v4-homepage/integrations.php; behaviour: js/rc-v4-homepage/integrations.js.
   Design: IntegrationsFlowC (reve-chat-website src/creative/IntegrationsFlowC.jsx + integrationsFlowC.css).
   - Desktop (> 860px): flow map (hub with logo, energy, lightning + plasma arcs; floating integrations;
     dotted lines with light trails; travelling icons) + a panel with clock-style counters and a two-row feed.
   - Mobile (<= 860px): category tabs + tile grid + preview of the selected integration.
   Shared tokens, container, heading, buttons and reveal come from css/rc-v4-base.css.
   Every rule is scoped to .rc-integrations.
   ========================================================================== */

.rc-integrations {
  background: radial-gradient(60% 55% at 50% 55%, rgba(120, 100, 230, 0.07), transparent 70%), #ffffff;
  color: var(--rc-ink);
}
@media (max-width: 1000px) { .rc .rc-integrations { padding: 64px 0; } }
@media (max-width: 700px) { .rc .rc-integrations { padding: 48px 0; } }

/* theme / Bootstrap bleed inside the section */
.rc-integrations a { font-family: inherit; }
.rc-integrations svg { vertical-align: baseline; }
.rc-integrations i { font-style: normal; }

/* heading: centred, one line on desktop */
.rc-integrations .rc-integrations-title { max-width: none; }

/* ---------------- desktop flow map ---------------- */
.rc-integrations-map { position: relative; height: 370px; }

/* dotted connection lines + soft light riding them (the SVG is created by the script once the map has a size) */
.rc-integrations-lines { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; overflow: visible; }
.rc-integrations-lines line { stroke: rgba(20, 18, 31, 0.16); stroke-width: 1; stroke-dasharray: 3 5; transition: stroke 0.4s; }
.rc-integrations-lines .rc-integrations-trail { stroke-linecap: round; filter: blur(4px); opacity: 0; fill: none; }

/* centre hub: logo on the REVE purple gradient; reacts to arriving data through --e (0..1), --ax / --ay and --lc */
.rc-integrations-hub {
  position: absolute; left: 50%; top: 50%; z-index: 2; transform: translate(-50%, -50%);
  gap: 0; width: 180px; padding: 24px 18px; border-radius: 24px; color: #ffffff;
  background-color: var(--rc-purple);
  background-image: linear-gradient(94deg, #412375 0%, #5d369e 48%, #412375 100%);
  box-shadow: 0 0 0 10px rgba(139, 108, 255, 0.1), 0 28px 50px -22px rgba(70, 50, 200, 0.55);
}
.rc-integrations-hub-logo { position: relative; display: grid; place-items: center; width: 120px; height: 65px; font-size: 0; }
.rc-integrations-hub-logo img { display: block; width: 120px; height: 65px; }
@media (min-width: 861px) {
  .rc-integrations-hub {
    --e: 0;
    transform: translate(-50%, -50%) scale(calc(1 + var(--e) * 0.03));
    box-shadow: 0 0 0 calc(10px + var(--e) * 5px) rgba(93, 54, 158, calc(0.12 + var(--e) * 0.12)), 0 0 calc(50px + var(--e) * 40px) rgba(93, 54, 158, calc(0.28 + var(--e) * 0.3)), 0 28px 50px -22px rgba(65, 35, 117, 0.6);
    will-change: transform, box-shadow;
  }
}

/* energy inside the card: colour floods in from the side the data arrives from, over a slow ambient glow */
.rc-integrations-hub-core { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.rc-integrations-hub-core::before {
  content: ''; position: absolute; inset: -30%;
  background: radial-gradient(55% 60% at var(--ax, 50%) var(--ay, 50%), color-mix(in srgb, var(--lc, #ffffff) 35%, rgba(255, 255, 255, 0.75)) 0%, color-mix(in srgb, var(--lc, #b29eff) 80%, transparent) 28%, color-mix(in srgb, var(--lc, #608cff) 40%, transparent) 55%, transparent 78%);
  opacity: min(1, calc(var(--e, 0) * 1.5));
}
.rc-integrations-hub-core::after {
  content: ''; position: absolute; inset: -60%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(160, 130, 255, 0.35) 70deg, transparent 140deg, rgba(90, 140, 255, 0.28) 230deg, transparent 300deg);
  opacity: calc(0.35 + var(--e, 0) * 0.9);
  animation: rc-integrations-spin 10s linear infinite;
}
@keyframes rc-integrations-spin { to { transform: rotate(360deg); } }

/* lightning through the card + plasma arcs behind the logo, in the sending integration's colour (--lc) */
.rc-integrations-hub-bolts { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; overflow: visible; }
.rc-integrations-hub-arcs { position: absolute; left: 50%; top: 50%; width: 150px; height: 84px; transform: translate(-50%, -50%); opacity: 0; pointer-events: none; overflow: visible; }
.rc-integrations-hub-aura {
  position: absolute; left: 50%; top: 50%; width: 150px; height: 90px; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--lc, #b29eff) 85%, transparent), transparent);
  filter: blur(10px); opacity: min(1, calc(var(--e, 0) * 1.3));
}
.rc-integrations-hub-bolts.is-zap, .rc-integrations-hub-arcs.is-zap { animation: rc-integrations-zap 0.5s linear forwards; }
@keyframes rc-integrations-zap { 0% { opacity: 0; } 6% { opacity: 1; } 14% { opacity: 0.25; } 22% { opacity: 1; } 40% { opacity: 0.55; } 55% { opacity: 0.9; } 100% { opacity: 0; } }
.rc-integrations-hub-bolts path, .rc-integrations-hub-arcs path { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.rc-integrations-hub-bolts path:nth-child(1) { stroke: var(--lc, #b79cff); stroke-width: 6px; opacity: 0.55; filter: blur(3px); }
.rc-integrations-hub-bolts path:nth-child(2) { stroke: #ffffff; stroke-width: 1.6px; }
.rc-integrations-hub-bolts path:nth-child(3) { stroke: var(--lc, #b79cff); stroke-width: 1.3px; opacity: 0.9; }
.rc-integrations-hub-arcs path:nth-child(1) { stroke: var(--lc, #b79cff); stroke-width: 3.5px; opacity: 0.7; filter: blur(1.6px); }
.rc-integrations-hub-arcs path:nth-child(2) { stroke: #ffffff; stroke-width: 1.1px; }
.rc-integrations-hub-arcs path:nth-child(3) { stroke: var(--lc, #b79cff); stroke-width: 1px; opacity: 0.85; }

/* floating integrations (position + float written by the script; --hl = highlight while sending) */
.rc-integrations-node {
  position: absolute; left: var(--x); top: var(--y); z-index: 1; transform: translate(-50%, -50%);
  gap: 10px; padding: 9px 16px 9px 11px; border: 1px solid rgba(20, 18, 31, 0.14); border-radius: 999px;
  background: #ffffff; color: var(--rc-ink); box-shadow: 0 8px 18px -12px rgba(40, 30, 110, 0.3);
  font-size: 14.5px; font-weight: 500; line-height: 1.55; white-space: nowrap; will-change: transform;
}
.rc-integrations-node:hover { border-color: var(--c); }
.rc-integrations-node::after {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 9%, transparent), 0 0 20px color-mix(in srgb, var(--c) 20%, transparent);
  opacity: var(--hl, 0);
}
.rc-integrations-node-name { display: block; }

/* brand glyph (svg, or the initial in <b>) used by the map nodes, the mobile tiles and the preview */
.rc-integrations .rc-integrations-glyph {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; overflow: hidden;
  color: var(--c); font-size: 15px; font-weight: 500; line-height: 1.55;
}

/* travelling icons (one per activity kind: chat / order / lead) */
.rc-integrations-particle {
  position: absolute; left: 0; top: 0; z-index: 0; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: #ffffff; color: var(--c); opacity: 0; pointer-events: none; will-change: transform, opacity;
  border: 1px solid color-mix(in srgb, var(--c) 34%, transparent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--c) 26%, transparent), 0 6px 12px -8px rgba(40, 30, 110, 0.4);
}
.rc-integrations-particle-icon { display: none; width: 17px; height: 17px; }
.rc-integrations-particle[data-kind='chat'] [data-icon='chat'],
.rc-integrations-particle[data-kind='order'] [data-icon='order'],
.rc-integrations-particle[data-kind='lead'] [data-icon='lead'] { display: block; }

/* ---------------- activity panel: counters + two-row feed ---------------- */
.rc-integrations-panel {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 56px; align-items: center;
  max-width: 820px; margin: 32px auto 0; padding: 22px 32px;
  border: 1px solid rgba(20, 18, 31, 0.1); border-radius: 18px; background: #ffffff;
  box-shadow: 0 18px 40px -28px rgba(40, 30, 110, 0.4);
}
.rc-integrations-stats { gap: 40px; margin: 0; }
.rc-integrations .rc-integrations-stat-label {
  font-family: var(--rc-font-label); font-size: 11px; font-weight: 400; line-height: 1.55;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--rc-ink-3);
}
.rc-integrations .rc-integrations-stat-value {
  min-width: 2.6em; margin: 2px 0 0; font-size: 30px; font-weight: 500; line-height: 1.1; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* clock-style counter: fixed digit cells, only the changing digit rolls */
.rc-integrations-counter { display: inline-flex; vertical-align: top; }
.rc-integrations-counter-digit { position: relative; display: inline-block; width: 0.64em; height: 1.1em; overflow: hidden; text-align: center; }
.rc-integrations-counter-strip { display: block; transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1); }
.rc-integrations-counter-strip i { display: block; height: 1.1em; font-style: normal; line-height: 1.1; }

.rc-integrations-feed {
  display: grid; gap: 12px; align-content: center; margin: 0; padding: 0 0 0 32px; list-style: none;
  border-left: 1px solid rgba(20, 18, 31, 0.1);
  font-size: 14px; line-height: 1.55; color: var(--rc-ink-2);
}
.rc-integrations-feed-item { gap: 10px; }
.rc-integrations-feed-item:not(:first-child) { opacity: 0.6; }
.rc-integrations-feed-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #9b8fd8; }
.rc-integrations-feed-text { animation: rc-integrations-soft 0.6s ease both; }
.rc-integrations .rc-integrations-feed-name { font-weight: 600; color: var(--rc-ink); }
@keyframes rc-integrations-soft { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- call to action ---------------- */
.rc-integrations-cta { gap: 16px 24px; max-width: 760px; margin-top: 32px; color: var(--rc-ink-2); }
.rc-integrations .rc-integrations-btn { border-color: rgba(20, 18, 31, 0.22); }
.rc-integrations .rc-integrations-btn:hover { background: rgba(20, 18, 31, 0.05); border-color: rgba(20, 18, 31, 0.4); color: var(--rc-ink); }

/* ---------------- mobile: tabs + tile grid + preview (hidden on desktop) ---------------- */
.rc-integrations-mobile { display: none; }

@keyframes rc-integrations-fade { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 860px) {
  .rc-integrations-map, .rc-integrations-panel { display: none; }
  .rc-integrations-mobile { display: block; }

  .rc-integrations-tabs {
    gap: 8px; margin-inline: calc(-1 * var(--rc-gutter)); padding: 0 var(--rc-gutter) 4px;
    overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; scroll-padding-inline: 20px;
  }
  .rc-integrations-tabs::-webkit-scrollbar { display: none; }
  .rc-integrations .rc-integrations-tab {
    flex: none; min-height: 44px; padding: 0 16px; border: 1px solid rgba(20, 18, 31, 0.14); border-radius: 999px; background: #ffffff;
    font-size: 14px; font-weight: 500; line-height: 1.55; color: var(--rc-ink-2); white-space: nowrap; scroll-snap-align: start;
    transition: background-color 0.25s, color 0.25s, border-color 0.25s;
  }
  .rc-integrations .rc-integrations-tab.is-on { background: var(--rc-ink); color: #ffffff; border-color: var(--rc-ink); }

  .rc-integrations-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0 0; padding: 0; list-style: none;
    animation: rc-integrations-fade 0.3s ease;
  }
  .rc-integrations .rc-integrations-tile {
    gap: 10px; width: 100%; min-height: 56px; padding: 10px 12px; text-align: left;
    border: 1px solid rgba(20, 18, 31, 0.12); border-radius: 16px; background: #ffffff; color: var(--rc-ink);
    font-size: 14.5px; font-weight: 500; line-height: 1.2;
    transition: border-color 0.25s, background-color 0.25s, box-shadow 0.25s;
  }
  .rc-integrations .rc-integrations-tile .rc-integrations-glyph { line-height: 1.2; }
  .rc-integrations .rc-integrations-tile.is-on {
    border-color: var(--c); background: color-mix(in srgb, var(--c) 7%, #ffffff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 14%, transparent);
  }
  .rc-integrations-tile-name { display: block; min-width: 0; overflow-wrap: anywhere; }

  .rc-integrations-preview {
    gap: 14px; margin-top: 14px; padding: 16px; border: 1px solid rgba(20, 18, 31, 0.1); border-radius: 18px;
    background: #ffffff; box-shadow: 0 14px 30px -22px rgba(40, 30, 110, 0.45);
    animation: rc-integrations-fade 0.3s ease;
  }
  .rc-integrations-preview-icon {
    display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%;
    background: color-mix(in srgb, var(--c) 10%, #ffffff); color: var(--c);
  }
  .rc-integrations-preview-body { min-width: 0; }
  .rc-integrations .rc-integrations-preview-title { display: block; font-size: 16px; font-weight: 600; line-height: 1.55; letter-spacing: -0.01em; color: var(--rc-ink); }
  .rc-integrations-preview-arrow { padding-inline: 2px; color: var(--rc-ink-3); }
  .rc-integrations .rc-integrations-preview-group {
    display: block; margin-top: 2px; font-family: var(--rc-font-label); font-size: 11px; font-weight: 400; line-height: 1.55;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--rc-ink-3);
  }
  .rc-integrations .rc-integrations-preview-text { margin: 8px 0 0; font-size: 14.5px; line-height: 1.5; color: var(--rc-ink-2); }

  .rc-integrations-cta { flex-direction: column; margin-top: 24px; text-align: center; }
  .rc-integrations .rc-integrations-btn { min-height: 44px; }
}

/* narrow phones (320-360px): tighter tiles */
@media (max-width: 360px) {
  .rc-integrations-grid { gap: 8px; }
  .rc-integrations .rc-integrations-tile { gap: 8px; padding: 8px; font-size: 13px; }
  .rc-integrations .rc-integrations-tile .rc-integrations-glyph { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .rc-integrations-particle, .rc-integrations-trail, .rc-integrations-hub-core, .rc-integrations-hub-arcs { display: none; }
  .rc-integrations-grid, .rc-integrations-preview, .rc-integrations-feed-text { animation: none; }
  .rc-integrations-counter-strip { transition: none; }
}
