/* ==========================================================================
   TextCRM Flow Builder Widget  —  "Build the path from hello to paid."
   --------------------------------------------------------------------------
   A horizontally-scrolling, pinned "no-code flow" showcase built on the Hero
   design system. A left editorial intro (eyebrow pill → display headline with
   an Instrument-Serif italic accent line → lead → scroll hint) leads into a
   track of node-cards (Trigger → Condition → AI Agent → Handoff). As the
   visitor scrolls, the section pins and the track glides sideways; each card
   carries a mini flow diagram whose connector wires draw themselves and whose
   node chips pop in, while a progress rail tracks the journey.

   Layout : STACKED by default (works with no JS, on mobile, and in the editor);
            JS upgrades it to a pinned, full-height horizontal track on desktop
            by adding `.is-pinned`.
   Type   : Space Grotesk (display) · Manrope (body + labels)
            · Instrument Serif (italic accent).
   Palette: accent #42c67a · ink #04211a · bg #0a1122 · surface #0f1a32
            (mirrors the TextCRM Hero).
   Motion : GSAP ScrollTrigger horizontal pin, self-drawing wires, node pop-in,
            a traveling packet pulse, synced progress rail + entrance reveal.
            Degrades to a static, readable stack without JS / under reduced
            motion.

   Every visual token below is a CSS custom property so the Elementor Style tab
   (and the global Light color-mode layer) can override it without forking this
   file.
   ========================================================================== */

.textcrm-flow {
	/* ---- Theme tokens (overridable from the Elementor Style tab) ---- */
	--fl-bg:           #0a1122;
	--fl-bg-2:         #0a1122;
	--fl-surface:      #0f1a32;
	--fl-surface-2:    #14223f;
	--fl-line:         rgba(255, 255, 255, 0.07);
	--fl-line-2:       rgba(255, 255, 255, 0.13);
	--fl-text:         #eaf0fb;
	--fl-muted:        #93a1bd;
	--fl-muted-2:      #5e6d8c;
	--fl-accent:       #42c67a;
	--fl-accent-2:     #00c98a;
	--fl-accent-dim:   rgba(66, 198, 122, 0.10);
	--fl-accent-border:rgba(66, 198, 122, 0.30);
	--fl-eyebrow:      #bfe9d2;
	--fl-ink:          #04211a;
	--fl-glow:         rgba(66, 198, 122, 0.18);

	--fl-font-display: 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
	--fl-font-body:    'Manrope', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
	--fl-font-mono:    'Manrope', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
	--fl-font-accent:  'Instrument Serif', 'Times New Roman', Georgia, serif;

	--fl-gutter:   40px;
	--fl-radius:   16px;
	--fl-ease:     cubic-bezier(0.22, 0.61, 0.36, 1);
	--fl-shadow:   0 40px 90px rgba(0, 0, 0, 0.45);

	/* Horizontal-track geometry (used in the pinned desktop layout). */
	--fl-intro-w:  36vw;
	--fl-card-w:   38vw;
	--fl-card-gap: 5vw;
	--fl-card-h:   56vh;

	position: relative;
	width: 100%;
	overflow: hidden;
	box-sizing: border-box;
	background-color: var(--fl-bg);
	color: var(--fl-text);
	font-family: var(--fl-font-body);
	font-size: 16px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	/* No hairlines by default; the Style → Borders toggles add a 1px border. */
	border-top: 0 solid var(--fl-line);
	border-bottom: 0 solid var(--fl-line);
}

.textcrm-flow *,
.textcrm-flow *::before,
.textcrm-flow *::after {
	box-sizing: border-box;
}

.textcrm-flow ::selection {
	background: var(--fl-accent);
	color: var(--fl-ink);
}

/* --------------------------------------------------------------------------
   Soft brand glow — a blurred accent wash for depth.
   -------------------------------------------------------------------------- */
.textcrm-flow__bg {
	position: absolute;
	inset: 0;
	z-index: 0;
	overflow: hidden;
	pointer-events: none;
}

.textcrm-flow__glow {
	position: absolute;
	top: 42%;
	right: 6%;
	width: 680px;
	height: 540px;
	max-width: 72vw;
	transform: translateY(-50%);
	border-radius: 50%;
	background: var(--fl-glow);
	filter: blur(150px);
	pointer-events: none;
	will-change: transform;
}

/* ==========================================================================
   STACKED layout (default — no JS, mobile, editor, reduced motion)
   A clean readable column: intro on top, then each card.
   ========================================================================== */
.textcrm-flow__viewport {
	position: relative;
	z-index: 1;
	width: 100%;
}

.textcrm-flow__track {
	display: flex;
	flex-direction: column;
	gap: clamp(20px, 3vw, 32px);
	width: 100%;
	max-width: 760px;
	margin: 0 auto;
	padding-left: var(--fl-gutter);
	padding-right: var(--fl-gutter);
	padding-block: clamp(64px, 10vh, 120px);
}

/* ---- Intro panel ---- */
.textcrm-flow__intro {
	display: flex;
	flex-direction: column;
	margin-bottom: 4px;
}

.textcrm-flow__eyebrow {
	display: inline-flex;
	align-self: flex-start;
	align-items: center;
	gap: 9px;
	margin-bottom: 22px;
	padding: 7px 15px;
	border: 1px solid var(--fl-accent-border);
	border-radius: 999px;
	background: var(--fl-accent-dim);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	color: var(--fl-eyebrow);
	line-height: 1;
}

.textcrm-flow__eyebrow-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--fl-accent);
	box-shadow: 0 0 0 0 rgba(66, 198, 122, 0.55);
	animation: textcrm-flow-pulse 2.4s ease-out infinite;
	flex-shrink: 0;
}

@keyframes textcrm-flow-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(66, 198, 122, 0.5); }
	70%  { box-shadow: 0 0 0 8px rgba(66, 198, 122, 0); }
	100% { box-shadow: 0 0 0 0 rgba(66, 198, 122, 0); }
}

.textcrm-flow__eyebrow-text {
	font-family: var(--fl-font-mono);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

/* Headline — Space Grotesk display with an elegant Instrument Serif italic
   accent line (the Hero highlight treatment). */
.textcrm-flow__title {
	margin: 0 0 20px;
	font-family: var(--fl-font-display);
	font-weight: 700;
	font-size: clamp(34px, 4.6vw, 58px);
	line-height: 1.05;
	letter-spacing: -0.02em;
	color: var(--fl-text);
}

.textcrm-flow__title-accent {
	display: block;
	font-family: var(--fl-font-accent);
	font-style: italic;
	font-weight: 400;
	font-size: 1.08em;
	letter-spacing: 0;
	color: var(--fl-accent);
}

.textcrm-flow__lead {
	margin: 0;
	max-width: 46ch;
	font-size: 16px;
	line-height: 1.6;
	color: var(--fl-muted);
}

.textcrm-flow__hint {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	margin-top: 26px;
	font-family: var(--fl-font-mono);
	font-size: 12px;
	letter-spacing: 0.04em;
	color: var(--fl-muted-2);
}

.textcrm-flow__hint-ln {
	width: 40px;
	height: 1px;
	background: var(--fl-accent);
}

.textcrm-flow__hint-arrow {
	display: inline-block;
	color: var(--fl-accent);
	animation: textcrm-flow-nudge 1.8s ease-in-out infinite;
}

@keyframes textcrm-flow-nudge {
	0%, 100% { transform: translateX(0); }
	50%      { transform: translateX(5px); }
}

/* ---- Cards ---- */
.textcrm-flow__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	padding: clamp(22px, 2.4vw, 28px);
	border: 1px solid var(--fl-line-2);
	border-radius: var(--fl-radius);
	background: var(--fl-surface);
	box-shadow: var(--fl-shadow);
	transition: border-color 0.4s var(--fl-ease), box-shadow 0.4s var(--fl-ease), transform 0.4s var(--fl-ease);
}

/* Active card — accent emphasis + a gentle lift. */
.textcrm-flow__panel.is-active {
	border-color: var(--fl-accent-border);
	box-shadow: var(--fl-shadow), 0 0 0 1px var(--fl-accent-border), 0 24px 60px -28px var(--fl-accent);
}

.textcrm-flow__step {
	font-family: var(--fl-font-mono);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.14em;
	color: var(--fl-accent);
}

.textcrm-flow__panel-title {
	margin: 14px 0 12px;
	font-family: var(--fl-font-display);
	font-weight: 600;
	font-size: clamp(22px, 2.4vw, 32px);
	line-height: 1.15;
	letter-spacing: -0.01em;
	color: var(--fl-text);
}

.textcrm-flow__panel-desc {
	margin: 0;
	max-width: 40ch;
	font-size: 15px;
	line-height: 1.6;
	color: var(--fl-muted);
}

/* ---- Mini canvas (flow diagram) ---- */
/* Grows to fill the card so the diagram + dot-grid sit just under the copy
   (no dead band between the text and the nodes). */
.textcrm-flow__canvas {
	position: relative;
	flex: 1 1 auto;
	margin-top: clamp(16px, 2.5vh, 28px);
	min-height: 200px;
}

/* Faint blueprint dot-grid (toggle via Style → Layout). */
.textcrm-flow__canvas::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	border-radius: 12px;
	background-image: radial-gradient(currentColor 1px, transparent 1px);
	background-size: 20px 20px;
	color: var(--fl-line);
	opacity: 1;
	-webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, #000 55%, transparent 100%);
	mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, #000 55%, transparent 100%);
}

.textcrm-flow__wires {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	z-index: 1;
	overflow: visible;
}

.textcrm-flow__wires path {
	stroke: var(--fl-line-2);
	stroke-width: 1.5;
	fill: none;
	stroke-linecap: round;
	transition: stroke 0.4s var(--fl-ease);
}

.textcrm-flow__panel.is-active .textcrm-flow__wires path {
	stroke: var(--fl-accent-border);
}

/* Traveling packet pulse (created + animated by JS on the active card). */
.textcrm-flow__pulse {
	fill: var(--fl-accent);
	filter: drop-shadow(0 0 5px var(--fl-accent));
}

/* ---- Node chips ---- */
.textcrm-flow__node {
	position: absolute;
	z-index: 2;
	max-width: 64%;
}

.textcrm-flow__node--lt { left: 0;   top: 14%; }
.textcrm-flow__node--lm { left: 0;   top: 50%; transform: translateY(-50%); }
.textcrm-flow__node--lb { left: 0;   bottom: 14%; }
.textcrm-flow__node--rt { right: 0;  top: 14%; }
.textcrm-flow__node--rm { right: 0;  top: 50%; transform: translateY(-50%); }
.textcrm-flow__node--rb { right: 0;  bottom: 14%; }
.textcrm-flow__node--c  { left: 50%; top: 50%; transform: translate(-50%, -50%); }

/* The visible chip — GSAP animates THIS element so it never fights the parent's
   centering transform. */
.textcrm-flow__node-box {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	padding: 11px 14px;
	border: 1px solid var(--fl-line-2);
	border-radius: 9px;
	background: var(--fl-bg-2);
	font-family: var(--fl-font-mono);
	font-size: 12px;
	color: var(--fl-text);
	white-space: nowrap;
	box-shadow: 0 10px 26px -16px rgba(0, 0, 0, 0.6);
}

.textcrm-flow__node-dot {
	width: 8px;
	height: 8px;
	flex-shrink: 0;
	border-radius: 50%;
	background: var(--fl-accent);
	box-shadow: 0 0 7px var(--fl-accent);
}

.textcrm-flow__node.is-muted .textcrm-flow__node-box {
	color: var(--fl-muted);
}

.textcrm-flow__node.is-muted .textcrm-flow__node-dot {
	background: var(--fl-muted-2);
	box-shadow: none;
}

/* ---- Progress rail (pinned mode only) ---- */
.textcrm-flow__prog {
	display: none;
	gap: 6px;
}

.textcrm-flow__prog i {
	width: 30px;
	height: 3px;
	border-radius: 2px;
	background: var(--fl-line-2);
	transition: background 0.35s var(--fl-ease);
}

.textcrm-flow__prog i.is-on {
	background: var(--fl-accent);
}

/* ==========================================================================
   PINNED horizontal layout — applied by JS (desktop, motion-OK, pin enabled).
   ========================================================================== */
.textcrm-flow.is-pinned .textcrm-flow__viewport {
	height: 100vh;
	height: 100svh;
	overflow: hidden;
}

.textcrm-flow.is-pinned .textcrm-flow__track {
	flex-direction: row;
	align-items: center;
	gap: 0;
	width: max-content;
	max-width: none;
	height: 100%;
	margin: 0;
	padding: 0;
	will-change: transform;
}

/* The intro hugs its content (capped at --fl-intro-w) so the first card sits
   right beside the heading instead of after a wide, half-empty column. */
.textcrm-flow.is-pinned .textcrm-flow__intro {
	flex: 0 0 auto;
	width: auto;
	max-width: var(--fl-intro-w);
	min-width: 320px;
	height: 100%;
	margin-bottom: 0;
	justify-content: center;
	padding-inline: var(--fl-gutter);
	/* Inset the first column so its text lines up with the Unified Inbox's left
	   content edge (its 1600px centred container + 24px gutter). A left margin —
	   not padding — keeps the headline at full width, so the accent line never
	   wraps. Collapses to 0 below ~1632px, where the inbox is full-width too. */
	margin-left: max(0px, calc((100vw - 1600px) / 2 - 16px));
}

.textcrm-flow.is-pinned .textcrm-flow__panel {
	flex: 0 0 var(--fl-card-w);
	width: var(--fl-card-w);
	min-width: 360px;
	height: var(--fl-card-h);
	margin-right: var(--fl-card-gap);
}

.textcrm-flow.is-pinned .textcrm-flow__prog {
	display: flex;
	position: absolute;
	z-index: 3;
	bottom: var(--fl-gutter);
	left: var(--fl-gutter);
}

/* ==========================================================================
   Entrance pre-hidden states — only while JS hasn't claimed the widget. Once
   GSAP runs it adds `.is-gsap` and owns these via inline styles. The <noscript>
   failsafe + the reduced-motion block force the resting state.
   ========================================================================== */
.textcrm-flow--reveal:not(.is-gsap) .textcrm-flow__animate {
	opacity: 0;
	transform: translateY(22px);
}

/* ==========================================================================
   Responsive — tighten the stacked layout on small screens.
   ========================================================================== */
@media (max-width: 992px) {
	.textcrm-flow {
		--fl-gutter: 24px;
	}
}

@media (max-width: 600px) {
	.textcrm-flow {
		--fl-gutter: 16px;
		font-size: 15px;
	}
	.textcrm-flow__panel {
		padding: 20px;
	}
	.textcrm-flow__canvas {
		min-height: 150px;
	}
	.textcrm-flow__node-box {
		padding: 9px 12px;
		font-size: 11px;
	}
	.textcrm-flow__eyebrow-text {
		white-space: normal;
	}
}

/* ==========================================================================
   Reduced motion — kill all animation; show the resting state immediately.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.textcrm-flow *,
	.textcrm-flow *::before,
	.textcrm-flow *::after {
		animation: none !important;
		transition: none !important;
	}
	.textcrm-flow--reveal .textcrm-flow__animate {
		opacity: 1 !important;
		transform: none !important;
	}
}
