/* =======================================================================
   DR-1024 — Workflow explainers as FIRST-RUN popup modals (Higgsfield-style)
   Shared component (workflow-explainer.jsx). Prefix: wfx-
   Split modal: animated demo (left) + concise copy (right).
   Pops once per workflow; "Don't show again"; small persistent trigger.
   CSS-only motion, reduced-motion + Save-Data safe.
   ======================================================================= */

/* ---- tiny persistent trigger that stays near the heading (no clutter) ---- */
.wfx-trigger {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px; margin-bottom: var(--s-4);
  border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--fg-2);
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  transition: all 180ms var(--ease);
}
.wfx-trigger:hover { color: var(--fg-0); border-color: var(--line-3); background: var(--bg-3); }
.wfx-trigger .ic { color: var(--amber-text); display: inline-flex; }
.wfx-trigger.spoof .ic { color: var(--spoof-text); }

/* ======================================================================= */
/* MODAL                                                                    */
/* ======================================================================= */
.wfx-portal {
  position: fixed; inset: 0; z-index: 240;
  display: grid; place-items: center; padding: 24px;
}
.wfx-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--scrim-ink) 66%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  backdrop-filter: blur(10px) saturate(120%);
  animation: wfxFade 260ms var(--ease-out) both;
}
@keyframes wfxFade { from { opacity: 0; } to { opacity: 1; } }

.wfx-modal {
  position: relative; z-index: 1;
  width: 660px; max-width: 100%;
  display: grid; grid-template-columns: 300px 1fr;
  border-radius: 20px; overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 50px 130px -30px color-mix(in srgb, var(--shadow-ink) 92%, transparent), 0 0 0 1px color-mix(in srgb, var(--fg-0) 3%, transparent) inset;
  animation: wfxPop 460ms cubic-bezier(0.22, 1.2, 0.4, 1) both;
}
@keyframes wfxPop {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.wfx-portal.closing .wfx-backdrop { animation: wfxFade 200ms var(--ease) reverse both; }
.wfx-portal.closing .wfx-modal { animation: wfxPop 200ms var(--ease) reverse both; }
@media (max-width: 620px) {
  .wfx-modal { grid-template-columns: 1fr; width: 420px; }
}

/* ---------------------------------------------------------------- demo (left) */
.wfx-demo {
  position: relative; overflow: hidden;
  min-height: 300px;
  background:
    radial-gradient(120% 90% at 30% 18%, rgba(255,179,0,0.30), transparent 60%),
    radial-gradient(120% 100% at 80% 100%, rgba(255,140,40,0.22), transparent 60%),
    #14110a;
}
.wfx-modal.spoof .wfx-demo {
  background:
    radial-gradient(120% 90% at 30% 18%, rgba(239,72,72,0.30), transparent 60%),
    radial-gradient(120% 100% at 80% 100%, rgba(255,90,90,0.18), transparent 60%),
    #160d0d;
}
.wfx-demo::before { /* dot texture */
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 13px 13px; opacity: 0.5;
}
@media (max-width: 620px) { .wfx-demo { min-height: 220px; } }

/* the scene canvas */
.wfx-scene { position: absolute; inset: 0; }
.wfx-stage {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%,-50%);
  width: 168px; height: 168px;
}
.wfx-frame {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.14);
  background: #0c0a12; box-shadow: 0 18px 40px -16px color-mix(in srgb, var(--shadow-ink) 70%, transparent);
}
.wfx-layer { position: absolute; inset: 0; }

/* media tones (shared with node renderer) */
.wfx-t { position: absolute; inset: 0; }
.wfx-t.warm  { background: linear-gradient(140deg, #5a3d1c, #2a1810); }
.wfx-t.cool  { background: linear-gradient(140deg, #16304a, #0c1622); }
.wfx-t.rose  { background: linear-gradient(140deg, #4a1f33, #200e16); }
.wfx-t.green { background: linear-gradient(140deg, #1d4030, #0c2015); }
.wfx-t.amber { background: linear-gradient(140deg, #5c4310, #1c1206); }
.wfx-t.violet{ background: linear-gradient(140deg, #382a66, #150f2c); }
.wfx-t.slate { background: linear-gradient(140deg, #212a35, #0f1620); }

/* input prompt chip */
.wfx-promptchip {
  position: absolute; inset: 0; padding: 14px;
  display: flex; align-items: center;
  font-size: 11.5px; line-height: 1.4; color: var(--fg-1);
  background: #0c0a12;
}
.wfx-promptchip em { font-style: normal; color: var(--amber-text); }
.wfx-modal.spoof .wfx-promptchip em { color: var(--spoof-text); }
.wfx-caret { display:inline-block; width:1.5px; height:1em; background: var(--amber); margin-left:1px; vertical-align:-2px; }

/* a 3-up photo set */
.wfx-setmini { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; padding: 6px; background:#0c0a12; }
.wfx-setmini span { border-radius: 5px; }

/* output badge */
.wfx-obadge {
  position: absolute; left: 8px; bottom: 8px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.04em;
  padding: 3px 7px; border-radius: 6px; background: rgba(0,0,0,0.62); color: #fff;
  display: inline-flex; align-items: center; gap: 4px;
}
.wfx-play { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,0.92); }

/* generate button in-scene */
.wfx-genbtn {
  position: absolute; left: 50%; bottom: 54px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 14px; border-radius: 8px;
  background: var(--amber); color: var(--on-amber);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--amber) 60%, transparent);
  overflow: hidden;
}
.wfx-modal.spoof .wfx-genbtn { background: var(--spoof); color: var(--on-accent); box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--spoof) 60%, transparent); }
.wfx-genbtn .pf { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, var(--on-accent) 28%, transparent); }

/* click ripple */
.wfx-ripple {
  position: absolute; left: 50%; bottom: 69px; transform: translateX(-50%);
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--on-accent) 85%, transparent); opacity: 0;
}

/* cursor */
.wfx-cursor {
  position: absolute; left: 50%; bottom: 54px;
  width: 20px; height: 20px; color: #fff; z-index: 5;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}

/* ---- the looping timeline (only when [data-play]) ---- */
.wfx-anim-out { opacity: 0; transform: scale(0.92); }
.wfx-anim-in  { opacity: 1; }

.wfx-demo[data-play="on"] .wfx-anim-in    { animation: wfxIn    5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-anim-out   { animation: wfxOut   5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-cursor     { animation: wfxCursor 5.6s cubic-bezier(0.5,0,0.3,1) infinite; }
.wfx-demo[data-play="on"] .wfx-genbtn     { animation: wfxBtn   5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-genbtn .pf { animation: wfxFill  5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-ripple     { animation: wfxRip   5.6s var(--ease) infinite; }

@keyframes wfxCursor {
  0%   { transform: translate(78px, 54px) scale(1);   opacity: 0; }
  8%   { transform: translate(78px, 54px) scale(1);   opacity: 1; }
  26%  { transform: translate(0px, 0px)   scale(1); }
  31%  { transform: translate(0px, 0px)   scale(0.84); }   /* press */
  36%  { transform: translate(0px, 0px)   scale(1); }
  60%  { transform: translate(20px, -16px) scale(1);  opacity: 1; }
  78%  { transform: translate(60px, -40px) scale(1);  opacity: 0; }
  100% { transform: translate(78px, 54px) scale(1);   opacity: 0; }
}
@keyframes wfxBtn {
  0%,29% { transform: translateX(-50%) scale(1); filter: brightness(1); }
  33%    { transform: translateX(-50%) scale(0.95); filter: brightness(1.15); }
  38%,58%{ transform: translateX(-50%) scale(1); filter: brightness(1.05); }
  70%,100%{ transform: translateX(-50%) scale(1); filter: brightness(1); }
}
@keyframes wfxFill {
  0%,33%  { width: 0; opacity: 1; }
  58%     { width: 100%; opacity: 1; }
  64%     { width: 100%; opacity: 0; }
  100%    { width: 0; opacity: 0; }
}
@keyframes wfxRip {
  0%,30%  { opacity: 0; transform: translateX(-50%) scale(0.4); }
  33%     { opacity: 0.9; transform: translateX(-50%) scale(0.6); }
  46%     { opacity: 0; transform: translateX(-50%) scale(2.4); }
  100%    { opacity: 0; }
}
@keyframes wfxIn {
  0%,52%  { opacity: 1; transform: scale(1); }
  60%     { opacity: 0; transform: scale(1.04); }
  92%     { opacity: 0; }
  100%    { opacity: 1; transform: scale(1); }
}
@keyframes wfxOut {
  0%,54%  { opacity: 0; transform: scale(0.92); }
  64%     { opacity: 1; transform: scale(1); }
  90%     { opacity: 1; transform: scale(1); }
  96%     { opacity: 0; transform: scale(0.96); }
  100%    { opacity: 0; transform: scale(0.92); }
}

/* caption that floats under the stage, swaps with the action */
.wfx-democap {
  position: absolute; left: 0; right: 0; bottom: 14px; text-align: center;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.7);
}
.wfx-demo[data-play="on"] .wfx-democap .a { animation: wfxCapA 5.6s steps(1) infinite; }
.wfx-demo[data-play="on"] .wfx-democap .b { animation: wfxCapB 5.6s steps(1) infinite; }
.wfx-democap .b { position: absolute; left: 0; right: 0; opacity: 0; }
@keyframes wfxCapA { 0%,54%{opacity:1;} 60%,100%{opacity:0;} }
@keyframes wfxCapB { 0%,54%{opacity:0;} 60%,100%{opacity:1;} }

/* ---------------------------------------------------------------- info (right) */
.wfx-info { position: relative; padding: 22px 22px 18px; display: flex; flex-direction: column; }
.wfx-new {
  align-self: flex-start;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0.12em;
  padding: 3px 8px; border-radius: 5px; background: var(--amber); color: var(--on-amber); margin-bottom: 12px;
}
.wfx-modal.spoof .wfx-new { background: var(--spoof); color: var(--on-accent); }
.wfx-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg-2);
  display: grid; place-items: center; transition: all 180ms var(--ease);
}
.wfx-close:hover { color: var(--fg-0); border-color: var(--line-3); background: var(--bg-4); transform: rotate(90deg); }

.wfx-h { margin: 0 0 8px; font-size: 21px; font-weight: 700; letter-spacing: -0.025em; color: var(--fg-0); line-height: 1.12; }
.wfx-desc { margin: 0 0 14px; font-size: 13px; color: var(--fg-2); line-height: 1.5; }

.wfx-bullets { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 9px; }
.wfx-bullets li { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; color: var(--fg-1); line-height: 1.4; }
.wfx-bullets li .bi {
  width: 18px; height: 18px; border-radius: 5px; flex: none; margin-top: 1px;
  display: grid; place-items: center;
  background: var(--amber-soft); color: var(--amber-text);
}
.wfx-modal.spoof .wfx-bullets li .bi { background: var(--spoof-soft); color: var(--spoof-text); }
.wfx-bullets li .n { font-family: var(--font-mono); font-size: 10px; font-weight: 600; }

.wfx-foot { margin-top: auto; display: flex; flex-direction: column; gap: 30px; }
.wfx-foot .wfx-dsa { margin-top: 4px; }
.wfx-cta {
  width: 100%; height: 44px; border: 0; border-radius: 11px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 650; color: var(--on-amber);
  background: var(--amber);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), background 160ms var(--ease);
  box-shadow: 0 10px 26px -10px color-mix(in srgb, var(--amber) 60%, transparent);
}
.wfx-cta:hover { transform: translateY(-1px); box-shadow: 0 16px 34px -10px color-mix(in srgb, var(--amber) 75%, transparent); }
.wfx-modal.spoof .wfx-cta { background: var(--spoof); color: var(--on-accent); box-shadow: 0 10px 26px -10px color-mix(in srgb, var(--spoof) 60%, transparent); }
.wfx-modal.spoof .wfx-cta:hover { box-shadow: 0 16px 34px -10px color-mix(in srgb, var(--spoof) 75%, transparent); }

.wfx-dsa {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 12px; color: var(--fg-3); user-select: none; align-self: center;
}
.wfx-dsa input { position: absolute; opacity: 0; width: 0; height: 0; }
.wfx-dsa .box {
  width: 16px; height: 16px; border-radius: 5px; flex: none;
  border: 1.5px solid var(--line-3); background: var(--bg-3);
  display: grid; place-items: center; color: transparent;
  transition: all 160ms var(--ease);
}
.wfx-dsa input:checked + .box { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.wfx-modal.spoof .wfx-dsa input:checked + .box { background: var(--spoof); border-color: var(--spoof); color: var(--on-accent); }
.wfx-dsa:hover { color: var(--fg-1); }
.wfx-dsa input:focus-visible + .box { outline: 2px solid var(--amber-bright); outline-offset: 2px; }

/* focus rings */
.wfx-trigger:focus-visible, .wfx-close:focus-visible, .wfx-cta:focus-visible {
  outline: 2px solid var(--amber-bright); outline-offset: 3px;
}

/* =======================================================================
   PER-SCENE CHOREOGRAPHIES
   ======================================================================= */

/* hide cursor affordances + motion-only bits when not playing
   (covers reduced-motion AND Save-Data, since both set data-play="off") */
.wfx-demo:not([data-play="on"]) .wfx-cursor,
.wfx-demo:not([data-play="on"]) .wfx-ripple,
.wfx-demo:not([data-play="on"]) .wfx-genbtn .pf,
.wfx-demo:not([data-play="on"]) .wfx-scan,
.wfx-demo:not([data-play="on"]) .wfx-mdot,
.wfx-demo:not([data-play="on"]) .wfx-arc { display: none !important; }

/* generate (default) static resolved = show output */
.wfx-demo:not([data-play="on"]) .wfx-anim-in  { opacity: 0; }
.wfx-demo:not([data-play="on"]) .wfx-anim-out { opacity: 1; transform: none; }

/* shared "reveal" overlay (play + badge) */
.wfx-reveal { opacity: 0; display: grid; place-items: center; }
.wfx-reveal-soft { opacity: 0; }
.wfx-demo[data-play="on"] .wfx-reveal      { animation: wfxReveal 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-reveal-soft { animation: wfxReveal 5.6s var(--ease) infinite; }
.wfx-demo:not([data-play="on"]) .wfx-reveal,
.wfx-demo:not([data-play="on"]) .wfx-reveal-soft { opacity: 1; }
@keyframes wfxReveal { 0%,54% { opacity: 0; } 64% { opacity: 1; } 92% { opacity: 1; } 100% { opacity: 0; } }

/* ---- FLOW: three flows converge into one ---- */
.wfx-stage.flow { overflow: visible; }
.wfx-flowline {
  position: absolute; left: 50%; top: 50%; width: 130px; height: 130px; margin: -65px;
  border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, color-mix(in srgb, var(--amber) 50%, transparent), transparent 65%);
}
.wfx-orb, .wfx-merge { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; }
.wfx-orb { width: 56px; height: 56px; margin: -28px; }
.wfx-orb .wfx-t { position: absolute; inset: 0; border-radius: 11px; border: 1px solid rgba(255,255,255,0.16); }
.wfx-orb-ic { position: relative; color: #fff; opacity: 0.92; }
.wfx-orb b {
  position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.06em;
  color: color-mix(in srgb, var(--on-accent) 72%, transparent); white-space: nowrap;
}
.wfx-merge { width: 92px; height: 92px; margin: -46px; opacity: 0; transform: scale(0.3); }
.wfx-merge .wfx-t { position: absolute; inset: 0; border-radius: 14px; border: 1px solid rgba(255,255,255,0.22); }
.wfx-merge-core { position: relative; color: #fff; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5)); }
.wfx-demo:not([data-play="on"]) .wfx-orb { opacity: 0; }
.wfx-demo:not([data-play="on"]) .wfx-merge { opacity: 1; transform: scale(1); }
.wfx-demo[data-play="on"] .wfx-orb.o1 { animation: wfxOrb1 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-orb.o2 { animation: wfxOrb2 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-orb.o3 { animation: wfxOrb3 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-merge  { animation: wfxMerge 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-flowline { animation: wfxGlow 5.6s var(--ease) infinite; }
@keyframes wfxOrb1 {
  0% { transform: translate(-48px,-38px) scale(0.6); opacity: 0; }
  12%,40% { transform: translate(-48px,-38px) scale(1); opacity: 1; }
  66% { transform: translate(0,0) scale(0.35); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes wfxOrb2 {
  0% { transform: translate(48px,-38px) scale(0.6); opacity: 0; }
  14%,40% { transform: translate(48px,-38px) scale(1); opacity: 1; }
  66% { transform: translate(0,0) scale(0.35); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes wfxOrb3 {
  0% { transform: translate(0,48px) scale(0.6); opacity: 0; }
  16%,40% { transform: translate(0,48px) scale(1); opacity: 1; }
  66% { transform: translate(0,0) scale(0.35); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes wfxMerge {
  0%,56% { transform: scale(0.3); opacity: 0; }
  68% { transform: scale(1.08); opacity: 1; }
  76% { transform: scale(1); opacity: 1; }
  92% { opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}
@keyframes wfxGlow { 0%,56% { opacity: 0; } 70% { opacity: 0.8; } 92% { opacity: 0.5; } 100% { opacity: 0; } }

/* ---- ANIMATE: still comes to life ---- */
.wfx-arc {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px;
  border: 2px solid color-mix(in srgb, var(--on-accent) 70%, transparent); border-radius: 50%; opacity: 0;
}
.wfx-demo[data-play="on"] .wfx-arc.a1 { animation: wfxArc 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-arc.a2 { animation: wfxArc 5.6s var(--ease) infinite; animation-delay: 0.28s; }
.wfx-demo[data-play="on"] .wfx-arc.a3 { animation: wfxArc 5.6s var(--ease) infinite; animation-delay: 0.56s; }
@keyframes wfxArc {
  0%,40% { transform: scale(0.3); opacity: 0; }
  48% { opacity: 0.75; }
  78% { transform: scale(2.7); opacity: 0; }
  100% { opacity: 0; }
}

/* ---- MOTION: reference path mapped ---- */
.wfx-mpath { position: absolute; inset: 0; width: 100%; height: 100%; color: color-mix(in srgb, var(--on-accent) 55%, transparent); opacity: 0; }
.wfx-demo[data-play="on"] .wfx-mpath { animation: wfxPathShow 5.6s var(--ease) infinite; }
.wfx-demo:not([data-play="on"]) .wfx-mpath { opacity: 0.55; }
@keyframes wfxPathShow { 0%,40% { opacity: 0; } 48% { opacity: 0.85; } 86% { opacity: 0.85; } 96% { opacity: 0; } }
.wfx-mdot {
  position: absolute; width: 11px; height: 11px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 12px rgba(255,255,255,0.9); opacity: 0;
  offset-path: path('M24 132 C44 40 116 150 150 36'); offset-distance: 0%;
}
.wfx-demo[data-play="on"] .wfx-mdot { animation: wfxDot 5.6s var(--ease) infinite; }
@keyframes wfxDot {
  0%,42% { offset-distance: 0%; opacity: 0; }
  48% { opacity: 1; }
  84% { offset-distance: 100%; opacity: 1; }
  90% { opacity: 0; }
  100% { offset-distance: 100%; opacity: 0; }
}
.wfx-refchip {
  position: absolute; left: -10px; top: -14px; width: 66px; height: 46px; z-index: 3;
  border-radius: 8px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--on-accent) 20%, transparent);
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--shadow-ink) 60%, transparent);
}
.wfx-refchip .wfx-t { position: absolute; inset: 0; }
.wfx-refpath { position: absolute; inset: 0; width: 100%; height: 100%; color: color-mix(in srgb, var(--on-accent) 80%, transparent); }
.wfx-refdot { position: absolute; left: 8px; top: 30px; width: 6px; height: 6px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px #fff; }
.wfx-refchip b {
  position: absolute; left: 0; right: 0; bottom: 2px; text-align: center;
  font-family: var(--font-mono); font-size: 7.5px; letter-spacing: 0.06em;
  color: color-mix(in srgb, var(--on-accent) 85%, transparent); text-transform: uppercase;
}

/* ---- SPOOF: pixel re-encode scan ---- */
.wfx-pixgrid {
  position: absolute; inset: 0; opacity: 0; mix-blend-mode: overlay;
  background-image:
    linear-gradient(color-mix(in srgb, var(--on-accent) 14%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--on-accent) 14%, transparent) 1px, transparent 1px);
  background-size: 12px 12px;
}
.wfx-scan {
  position: absolute; left: 0; right: 0; top: 0; height: 20px; opacity: 0;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--on-accent) 55%, transparent), transparent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--on-accent) 50%, transparent);
}
.wfx-demo[data-play="on"] .wfx-pixgrid { animation: wfxPix 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-scan { animation: wfxScan 5.6s var(--ease) infinite; }
@keyframes wfxPix { 0%,40% { opacity: 0; } 52% { opacity: 1; } 78% { opacity: 0.55; } 88% { opacity: 0; } 100% { opacity: 0; } }
@keyframes wfxScan {
  0%,38% { transform: translateY(-22px); opacity: 0; }
  44% { opacity: 1; }
  80% { transform: translateY(168px); opacity: 1; }
  86% { opacity: 0; }
  100% { transform: translateY(168px); opacity: 0; }
}

/* ---- VARIANTS: one → many ---- */
.wfx-stage .wfx-var { position: absolute; inset: 0; opacity: 0; }
.wfx-stage .wfx-var .wfx-t { position: absolute; inset: 0; }
.wfx-var-base { z-index: 2; }
.wfx-demo[data-play="on"] .wfx-var.v1 { animation: wfxVar1 5.6s var(--ease) infinite; }
.wfx-demo[data-play="on"] .wfx-var.v2 { animation: wfxVar2 5.6s var(--ease) infinite; }
.wfx-demo:not([data-play="on"]) .wfx-var { opacity: 1; }
.wfx-demo:not([data-play="on"]) .wfx-var.v1 { transform: rotate(-8deg) translate(-14%,4%) scale(0.92); }
.wfx-demo:not([data-play="on"]) .wfx-var.v2 { transform: rotate(7deg) translate(14%,-2%) scale(0.94); }
@keyframes wfxVar1 {
  0%,40% { transform: rotate(0) translate(0,0) scale(1); opacity: 0; }
  58% { opacity: 1; }
  70%,90% { transform: rotate(-8deg) translate(-14%,4%) scale(0.92); opacity: 1; }
  97%,100% { opacity: 0; }
}
@keyframes wfxVar2 {
  0%,40% { transform: rotate(0) translate(0,0) scale(1); opacity: 0; }
  58% { opacity: 1; }
  70%,90% { transform: rotate(7deg) translate(14%,-2%) scale(0.94); opacity: 1; }
  97%,100% { opacity: 0; }
}

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .wfx-backdrop, .wfx-modal { animation: none !important; }
  .wfx-anim-in { opacity: 0 !important; }
  .wfx-anim-out { opacity: 1 !important; transform: none !important; }
  .wfx-cursor, .wfx-ripple, .wfx-genbtn .pf { display: none !important; }
  .wfx-democap .a { display: none; }
  .wfx-democap .b { position: static; opacity: 1; }
}

/* =======================================================================
   DR-1024 — real template media fills the demo tiles (placeholders → assets).
   Media sits under the .tag/.play/.badge/icon overlays (later DOM siblings),
   clipped to the tile's rounded corners.
   ======================================================================= */
.wfx-t { overflow: hidden; }
.wfx-t > .wfx-media,
.wfx-promptchip > .wfx-media {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block; border: 0;
}
.wfx-setmini span > .wfx-media { border-radius: 5px; }

/* =======================================================================
   DR-1281 — Persistent, collapsible "How it works" RAIL (right-docked).
   Reuses the .wfx-demo scenes verbatim. Shown on wide screens only (≤1100px
   falls back to the on-demand trigger + modal). When expanded, a body class
   pushes .view-wrap content left so the rail never covers anything.
   ======================================================================= */
.wfx-rail {
  position: fixed; top: 56px; right: 0; bottom: 0;
  width: 300px; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-left: 1px solid var(--line-1);
  box-shadow: -18px 0 40px -30px color-mix(in srgb, var(--shadow-ink) 80%, transparent);
  transition: width 220ms var(--ease);
}
.wfx-rail-toggle {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 44px; padding: 0 14px; flex: 0 0 auto;
  border: 0; border-bottom: 1px solid var(--line-1);
  background: var(--bg-3); color: var(--fg-1);
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.wfx-rail-toggle:hover { color: var(--fg-0); }
.wfx-rail-toggle .ic { color: var(--amber-text); display: inline-flex; }
.wfx-rail.spoof .wfx-rail-toggle .ic { color: var(--spoof-text); }
.wfx-rail-toggle-t { flex: 1 1 auto; text-align: left; }
.wfx-rail-chev { display: inline-flex; color: var(--fg-3); transition: transform 200ms var(--ease); }
.wfx-rail-body { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.wfx-rail-body .wfx-demo { min-height: 300px; }
.wfx-rail.spoof .wfx-demo {
  background:
    radial-gradient(120% 90% at 30% 18%, rgba(239,72,72,0.30), transparent 60%),
    radial-gradient(120% 100% at 80% 100%, rgba(255,90,90,0.18), transparent 60%),
    #160d0d;
}
.wfx-rail-info { padding: 14px 16px 20px; }
.wfx-rail-h { font-size: 16px; font-weight: 600; color: var(--fg-0); margin: 0 0 6px; }
.wfx-rail-desc { font-size: 12.5px; line-height: 1.5; color: var(--fg-2); margin: 0 0 12px; }
.wfx-rail .wfx-bullets { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.wfx-rail-more {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg-1);
  border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: all 160ms var(--ease);
}
.wfx-rail-more:hover { color: var(--fg-0); border-color: var(--line-3); }

/* hidden on sections with no explainer (Dashboard / Library / Account) */
.wfx-rail.rail-hidden { display: none; }

/* collapsed — slim vertical tab */
.wfx-rail.collapsed { width: 40px; }
.wfx-rail.collapsed .wfx-rail-body { display: none; }
.wfx-rail.collapsed .wfx-rail-toggle {
  flex-direction: column; height: auto; padding: 14px 0; gap: 10px;
  justify-content: flex-start; border-bottom: 0;
}
.wfx-rail.collapsed .wfx-rail-toggle-t { writing-mode: vertical-rl; text-orientation: mixed; flex: 0 0 auto; }
.wfx-rail.collapsed .wfx-rail-chev { transform: rotate(180deg); }

/* Push page content so the rail never covers anything (wide screens only). */
@media (min-width: 1101px) {
  body.wfx-rail-expanded .view-wrap { padding-right: 308px; }
  /* The push narrows the dense Motion layout; keep its template tiles legible
     by dropping the gallery to 2 columns while the rail is open. */
  body.wfx-rail-expanded [data-mode-panel="generate-suite"].is-motion-control .gen-motion-page {
    grid-template-columns: repeat(2, 1fr);
  }
}
/* Below 1100px the rail steps aside — the on-demand "How it works" trigger +
   modal remain the explainer there. */
@media (max-width: 1100px) {
  .wfx-rail { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .wfx-rail { transition: none; }
}
