/* ============================================================
   ComfyUI workflow animation — "Imagine it. Make it local."
   Live, dependency-free illustration for the Lucy AIOS
   capability section. Replaces the static
   assets/aios-preview/03-comfyui-reel.webp plate.

   The plate is a ComfyUI graph drawn in 3D: the panel sits
   tilted on a perspective stage, the nodes are real ComfyUI
   node cards (real titles, real widgets, real sockets), the
   wires light up in execution order, the KSampler preview
   resolves from latent noise into the finished photograph,
   and Save Image writes it out.

   One 4s loop drives every beat. Palette follows the site:
   black, off-white, greys, ComfyUI's own node accent hues,
   and the site red for whatever is currently running.

   Timing rule: every beat is a hard cut, never a ramp that
   can overlap its neighbour. Labels and wires switch state
   instantly so exactly one of each can be on screen.

   Scale rule: the graph is laid out in percent of the canvas,
   but every pixel detail (head height, type size, sockets) is
   expressed in container-query units so the plate keeps the
   same proportions from a phone to an ultrawide. A fixed-px
   UI would either overflow on small screens or shrink into
   illegibility on large ones — this is exactly why the old
   static plate looked "unclear".
   ============================================================ */

.cf {
  --cf-node: #202020;
  --cf-node-head: #2e2e2e;
  --cf-line: #3a3a3a;
  --cf-line-soft: #292929;
  --cf-text: #f5f5f3;
  --cf-muted: #bdbdb8;
  --cf-dim: #83837d;
  --cf-red: #ef625b;
  --cf-perspective: 1500px;
  --cf-tilt-x: 8deg;
  --cf-tilt-y: -13deg;
  --cf-tilt-z: -1.5deg;
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 6px;
  background:
    radial-gradient(120% 90% at 64% 12%, #1e1e1e 0%, #0d0d0d 48%, #080808 100%);
  color: var(--cf-text);
  font: 400 13px/1.5 var(--font-body);
  isolation: isolate;
}

/* ---------- stage ---------- */

.cf-stage {
  position: relative;
  aspect-ratio: 16 / 10;
  perspective: var(--cf-perspective);
  perspective-origin: 60% 46%;
  /* every cqw below resolves against the plate width */
  container-type: inline-size;
}

/* a pool of light under the plate, so it reads as a floating object */
.cf-stage::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 6%;
  bottom: 1%;
  height: 16%;
  background: radial-gradient(ellipse at 58% 50%, rgba(239, 98, 91, .13), transparent 68%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

/* the panel body, tilted back on the stage */
.cf-panel {
  position: absolute;
  inset: 4% 2.5% 7%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  transform:
    rotateX(var(--cf-tilt-x))
    rotateY(var(--cf-tilt-y))
    rotateZ(var(--cf-tilt-z));
  transform-origin: 50% 50%;
  transform-style: preserve-3d;
  border: 1px solid var(--cf-line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #191919 0%, #111111 58%, #0e0e0e 100%);
  box-shadow:
    0 46px 90px -36px rgba(0, 0, 0, .95),
    0 1px 0 rgba(255, 255, 255, .05) inset;
  overflow: hidden;
}

/* ---------- window chrome ---------- */

.cf-bar {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  height: clamp(20px, 3.9cqw, 40px);
  padding: 0 clamp(7px, 1.5cqw, 16px);
  border-bottom: 1px solid var(--cf-line-soft);
  background: #131313;
  font-size: clamp(7px, 1.3cqw, 13px);
}

.cf-bar-dot {
  width: clamp(4px, .85cqw, 9px);
  height: clamp(4px, .85cqw, 9px);
  border-radius: 50%;
  background: #333;
  flex: none;
}

.cf-bar-dot--live {
  background: var(--cf-red);
  box-shadow: 0 0 6px rgba(239, 98, 91, .8);
  animation: cf-blink 0.5s steps(1, end) infinite;
}

.cf-bar-brand {
  color: var(--cf-text);
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.cf-bar-title {
  color: var(--cf-dim);
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cf-bar-spacer { flex: 1; }

.cf-bar-chip {
  padding: 1px clamp(4px, .95cqw, 10px);
  border: 1px solid var(--cf-line);
  border-radius: 999px;
  color: var(--cf-muted);
  white-space: nowrap;
}

.cf-bar-chip--live {
  border-color: rgba(239, 98, 91, .5);
  color: var(--cf-red);
}

.cf-bar-btn {
  padding: 1px clamp(5px, 1.1cqw, 12px);
  border: 1px solid rgba(239, 98, 91, .55);
  border-radius: 4px;
  color: var(--cf-red);
  white-space: nowrap;
  animation: cf-queue-pulse 4s linear infinite;
}

/* ---------- canvas ---------- */

.cf-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  /* ComfyUI's dotted canvas grid */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .11) 1px, transparent 0);
  background-size: clamp(10px, 2.05cqw, 21px) clamp(10px, 2.05cqw, 21px);
  background-position: 6px 6px;
}

/* soft vignette, painted under the nodes so it never dims the photo */
.cf-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(104% 96% at 56% 44%, transparent 60%, rgba(8, 8, 8, .40) 100%);
  pointer-events: none;
}

/* the wires sit under the nodes, exactly like ComfyUI's canvas */
.cf-links {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* One wire, three layers, ONE path geometry.
     .cf-link        the idle track — always drawn, shows the topology
     .cf-link--live  the bright core that grows along the path
     .cf-link--pulse a bright dot travelling along the same path
   All three share the same `d`, and the core is wider than the track,
   so a lit wire is a single clean line of light — never a dark line
   running beside a red one. No filters here: a drop-shadow on a 1.9px
   stroke reads as blur, not glow. */

.cf-link {
  fill: none;
  stroke: #2e2e2e;
  stroke-width: 1.2;
  stroke-linecap: round;
  /* The viewBox is stretched non-uniformly, so pin the stroke width in
     screen pixels instead of letting it scale with the box. */
  vector-effect: non-scaling-stroke;
}

/* The core. The path's pathLength is normalised to 100, so a dash of
   100 units spans exactly the whole path; sliding dashoffset from 100
   to 0 reveals it from the source port to the target port. */
.cf-link--live {
  fill: none;
  stroke: #f2605a;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

/* The pulse: one bead of light travelling along the wire.
   The dash pattern is far longer than the path, so exactly one bead is
   on the wire at any moment — never a string of them. Sliding
   dashoffset walks it from the source port to the target port. */
.cf-link--pulse {
  fill: none;
  stroke: #ffd9d5;
  stroke-width: 3.4;
  stroke-linecap: round;
  /* The dash pattern itself is set per wire, in .cf-wire--wN below:
     one short bead plus a gap far longer than the wire. */
  stroke-dasharray: 1 1200;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

/* ---------- nodes ---------- */

.cf-node {
  position: absolute;
  z-index: 2;
  border: 1px solid var(--cf-line);
  border-radius: 4px;
  background: var(--cf-node);
  box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95);
  color: var(--cf-muted);
  font-size: clamp(7px, 1.18cqw, 12px);
  line-height: 1.35;
}

.cf-node-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  height: clamp(15px, 2.65cqw, 27px);
  padding: 0 clamp(4px, .9cqw, 9px);
  border-radius: 3px 3px 0 0;
  background: var(--cf-node-head);
  color: #f0f0ee;
  font-size: clamp(7px, 1.2cqw, 12.5px);
  letter-spacing: .015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ComfyUI tints each node type with its own hue */
.cf-node-head::before {
  content: "";
  width: clamp(3px, .55cqw, 6px);
  height: clamp(3px, .55cqw, 6px);
  border-radius: 1px;
  background: var(--cf-accent, #6f6f6f);
  flex: none;
}

.cf-node-body {
  padding: clamp(3px, .8cqw, 8px) clamp(4px, .9cqw, 9px) clamp(3px, .8cqw, 8px);
  overflow: hidden;
}

/* a widget row: label on the left, value on the right */
.cf-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: clamp(11px, 2.05cqw, 21px);
  color: var(--cf-dim);
  font-size: clamp(6.5px, 1.14cqw, 11.5px);
  line-height: 1.4;
  white-space: nowrap;
}

.cf-field b {
  font-weight: 600;
  color: var(--cf-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* a multiline text widget, like ComfyUI's CLIP textarea */
.cf-field--text {
  display: block;
  height: auto;
  padding: clamp(2px, .5cqw, 5px) clamp(3px, .6cqw, 7px);
  border: 1px solid #262626;
  border-radius: 3px;
  background: #171717;
  color: #ccccC6;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* a small tag chip, e.g. positive / negative */
.cf-field--tag {
  display: inline-flex;
  align-items: center;
  height: auto;
  padding: 0 clamp(3px, .55cqw, 6px);
  border-radius: 3px;
  background: #262626;
  color: #9d9d97;
  font-size: clamp(5.5px, .95cqw, 10px);
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* the socket on a node edge */
.cf-port {
  position: absolute;
  width: clamp(5px, .95cqw, 10px);
  height: clamp(5px, .95cqw, 10px);
  border-radius: 50%;
  background: #2a2a2a;
  border: 1px solid #565656;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.cf-port--in { left: 0; }

.cf-port--out {
  right: 0;
  left: auto;
  transform: translate(50%, -50%);
}

/* ---------- graph layout (percent of the canvas box) ----------
   Column 1  model source        x 1.5 – 13
   Column 2  prompt + latent     x 17 – 31
   Column 3  KSampler            x 34 – 53
   Column 4  VAE Decode          x 56 – 67
   Column 5  Save Image (photo)  x 70 – 99
   The flow runs strictly left to right so every wire reads
   forwards, exactly like a real ComfyUI graph. The columns are
   spaced wide enough (4% / 3% / 3% / 3% of the canvas) that each
   wire keeps a visible run instead of being crushed into a narrow
   slot between two boxes, and the prompt column is wide enough for
   a node title to read in full instead of being clipped. */

.cf-node--ckpt { left: 1.5%;  top: 4%;   width: 11.5%; height: 14%; }
.cf-node--clip { left: 17%;   top: 4%;   width: 14%;   height: 23%; }
.cf-node--neg { left: 17%;   top: 28%;  width: 14%;   height: 23%; }
.cf-node--latent { left: 17%;   top: 52%;  width: 14%;   height: 22%; }
.cf-node--samp { left: 34%;   top: 8%;   width: 19%;   height: 54%; }
.cf-node--decode { left: 56%;   top: 4%;   width: 11%;   height: 22%; }
.cf-node--save { left: 70%;   top: 26%;  width: 29%;   height: 62%; }

/* the Save Image card is the payoff: let the photo take whatever
   room is left, so it can never spill out of the node box */
.cf-node--save { display: flex; flex-direction: column; }
.cf-node--save .cf-node-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.cf-node--save .cf-output { flex: 1 1 auto; min-height: 0; aspect-ratio: auto; }

/* ---------- KSampler preview: latent resolves into the photo ---------- */

.cf-sampler-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-top: clamp(2px, .55cqw, 6px);
  border: 1px solid var(--cf-line-soft);
  border-radius: 3px;
  overflow: hidden;
  background: #0a0a0a;
}

.cf-sampler-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The denoising strip: eight frames of the same latent, from pure
   blocky noise to a clean read. They are stacked and hard-cut, the
   way a real sampler's preview widget steps through its steps. */
.cf-latent {
  image-rendering: pixelated;
  filter: saturate(.8) brightness(.94);
  opacity: 0;
  animation: cf-latent-step 4s linear infinite;
}

.cf-latent--0 { animation-delay: 0.64s; }
.cf-latent--1 { animation-delay: 0.86s; }
.cf-latent--2 { animation-delay: 1.08s; }
.cf-latent--3 { animation-delay: 1.3s; }
.cf-latent--4 { animation-delay: 1.52s; }
.cf-latent--5 { animation-delay: 1.74s; }
.cf-latent--6 { animation-delay: 1.96s; }
.cf-latent--7 { animation-delay: 2.18s; }

/* the finished frame, revealed once sampling ends */
.cf-resolved {
  opacity: 0;
  animation: cf-resolve-in 4s linear infinite;
}

.cf-sampler-bar {
  height: clamp(2px, .42cqw, 4px);
  margin-top: clamp(2px, .55cqw, 6px);
  border-radius: 2px;
  background: #242424;
  overflow: hidden;
}

.cf-sampler-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--cf-red);
  box-shadow: 0 0 6px rgba(239, 98, 91, .85);
  animation: cf-sampler-progress 4s linear infinite;
}

/* ---------- Save Image output ---------- */

.cf-output {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--cf-line-soft);
  border-radius: 3px;
  overflow: hidden;
  background: #0a0a0a;
  box-shadow: 0 0 0 0 rgba(239, 98, 91, 0);
  animation: cf-output-glow 4s linear infinite;
}

.cf-output img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* The slot is never empty: the target canvas waits dark and desaturated
   until the sampler writes the file, then lights up. Without this the
   right third of the plate would be a black rectangle for most of the
   loop. */
.cf-output > img.cf-output-ghost {
  filter: grayscale(.85) brightness(.3) contrast(1.15);
  opacity: .85;
}

.cf-output > img.cf-output-main {
  opacity: 0;
  transform: scale(1.06);
  animation: cf-output-in 4s linear infinite;
}

/* the flash of a file being written */
.cf-output-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 238, 233, .9), rgba(239, 98, 91, .28) 46%, transparent 72%);
  opacity: 0;
  animation: cf-output-flash 4s linear infinite;
}

/* ---------- the bottom status strip ---------- */

.cf-foot {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: clamp(18px, 3.4cqw, 35px);
  padding: 0 clamp(7px, 1.5cqw, 16px);
  border-top: 1px solid var(--cf-line-soft);
  background: #121212;
  font-size: clamp(7px, 1.3cqw, 13px);
  color: var(--cf-dim);
}

.cf-foot-spacer { flex: 1; }

.cf-foot-chip {
  color: var(--cf-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cf-status-dot {
  width: clamp(4px, .8cqw, 8px);
  height: clamp(4px, .8cqw, 8px);
  border-radius: 50%;
  background: #333;
  flex: none;
  animation: cf-status-dot 4s linear infinite;
}

.cf-status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* status label slot: exactly one label visible at a time */
.cf-slot {
  display: inline-grid;
  vertical-align: middle;
}

.cf-slot > span {
  grid-area: 1 / 1;
  white-space: nowrap;
  opacity: 0;
}

/* ---------- output caption ---------- */

.cf-caption {
  position: absolute;
  left: 1.5%;
  bottom: 3%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: clamp(2px, .5cqw, 5px) clamp(5px, 1.05cqw, 11px);
  border: 1px solid var(--cf-line);
  border-radius: 5px;
  background: rgba(10, 10, 10, .9);
  font-size: clamp(7px, 1.28cqw, 13px);
  color: var(--cf-muted);
  white-space: nowrap;
  animation: cf-caption-in 4s linear infinite;
}

.cf-caption::before {
  content: "";
  width: clamp(3px, .55cqw, 6px);
  height: clamp(3px, .55cqw, 6px);
  border-radius: 50%;
  background: var(--cf-red);
  flex: none;
}

/* ============================================================
   Timeline (4s)
   0.00-0.28s   panel settles in, nodes rise one by one
   0.28-0.65s   wires light in execution order
   0.65-2.40s   KSampler runs: progress fills, latent clears
   2.40-2.65s   VAE Decode lights, resolved frame appears
   2.65-3.05s   Save Image writes the file, flash
   3.05-3.80s   finished state holds (photo visible, status done)
   3.80-4.00s   reset
   ============================================================ */

/* The panel is permanent furniture. It never pops in or out — it is
   the stage the workflow runs on. What changes is only the work
   happening on it: nodes arrive, wires carry data, the image lands.
   A slow breathing tilt keeps it from looking like a still frame. */
@keyframes cf-panel-breathe {
  0%, 100% { transform: rotateX(var(--cf-tilt-x)) rotateY(var(--cf-tilt-y)) rotateZ(var(--cf-tilt-z)) translateY(0); }
  50%      { transform: rotateX(calc(var(--cf-tilt-x) + .4deg)) rotateY(calc(var(--cf-tilt-y) - .3deg)) rotateZ(var(--cf-tilt-z)) translateY(-2.5px); }
}

.cf-panel {
  animation: cf-panel-breathe 4s ease-in-out infinite;
}

/* The panel is permanent furniture, so the graph on it is permanent too.
   Nothing pops in or out: the workflow is always there, and the only
   thing that moves is the work happening on it. */

/* ---------- the node that is currently executing ----------
   One keyframe set per stage, so the lit window is a hard cut and
   never bleeds into the next stage. */

.cf-node--act {
  animation: cf-act 4s linear infinite;
}

/* Load Checkpoint: 0.05s - 0.40s */
@keyframes cf-act-a {
  0% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  1% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  9% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  11% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  100% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
}

/* prompt + latent: 0.30s - 0.70s */
@keyframes cf-act-b {
  0% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  7% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  16% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  18% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  100% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
}

/* KSampler: 0.65s - 2.40s */
@keyframes cf-act-c {
  0% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  16% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  59% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  61% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  100% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
}

/* VAE Decode: 2.40s - 2.65s */
@keyframes cf-act-d {
  0% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  60% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  66% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  68% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  100% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
}

/* Save Image: 2.65s - 3.05s */
@keyframes cf-act-e {
  0% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  66% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  76% { border-color: rgba(239, 98, 91, .7); box-shadow: 0 0 0 1px rgba(239, 98, 91, .24), 0 0 22px -3px rgba(239, 98, 91, .38), 0 12px 26px -16px rgba(0, 0, 0, .95); }
  78% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
  100% { border-color: var(--cf-line); box-shadow: 0 12px 26px -16px rgba(0, 0, 0, .95); }
}

.cf-node--act.cf-act-a { animation-name: cf-act-a; }
.cf-node--act.cf-act-b { animation-name: cf-act-b; }
.cf-node--act.cf-act-c { animation-name: cf-act-c; }
.cf-node--act.cf-act-d { animation-name: cf-act-d; }
.cf-node--act.cf-act-e { animation-name: cf-act-e; }

/* ---------- wires ----------
   Each wire is one path in three layers. The track shows the topology
   from the very first frame; the core grows from the source port to
   the target port when its turn comes; and a bright bead rides the
   growing tip, so the moving light reads as ONE thing travelling along
   the wire — never a dark line running beside a red one.

   The dash arithmetic, measured in Chromium and worth writing down:
     * pathLength normalises a path to 100 and scales the dash array by
       (real path length / pathLength);
     * with vector-effect: non-scaling-stroke that calibrated number is
       used as CSS pixels, so it no longer follows the canvas;
     * pathLength together with non-scaling-stroke makes Chromium
       misread the dash numbers entirely — that is what turned the core
       into a dashed line with the dark track showing through.
   So every wire carries its own dash numbers, sized from its real
   screen length and written in cqw so they survive a resize:

     dash_px = dash_value * L / 100        (L = path length, user units)
     dash_value = 100 * screen_length / L

   The bead is one dash of a few pixels with a gap far longer than the
   wire, so exactly one bead is on the wire at any moment, and its
   offset runs from one bead length before the source port to one bead
   length before the tip — it stays glued to the growing tip.
   */

@keyframes cf-ww1 {
  0%, 4% { opacity: 0; stroke-dashoffset: -83.697cqw; }
  5%    { opacity: 1; stroke-dashoffset: -83.697cqw; }
  10%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw1 {
  0%, 4% { opacity: 0; stroke-dashoffset: 11.77cqw; }
  5%    { opacity: 1; stroke-dashoffset: 11.77cqw; }
  10%    { opacity: 1; stroke-dashoffset: -71.927cqw; }
  12%  { opacity: 0; stroke-dashoffset: -71.927cqw; }
  100%        { opacity: 0; stroke-dashoffset: -71.927cqw; }
}

@keyframes cf-ww2 {
  0%, 6% { opacity: 0; stroke-dashoffset: -47.112cqw; }
  7%    { opacity: 1; stroke-dashoffset: -47.112cqw; }
  13%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw2 {
  0%, 6% { opacity: 0; stroke-dashoffset: 1.916cqw; }
  7%    { opacity: 1; stroke-dashoffset: 1.916cqw; }
  13%    { opacity: 1; stroke-dashoffset: -45.196cqw; }
  15%  { opacity: 0; stroke-dashoffset: -45.196cqw; }
  100%        { opacity: 0; stroke-dashoffset: -45.196cqw; }
}

@keyframes cf-ww3 {
  0%, 8% { opacity: 0; stroke-dashoffset: -79.066cqw; }
  9%    { opacity: 1; stroke-dashoffset: -79.066cqw; }
  18%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw3 {
  0%, 8% { opacity: 0; stroke-dashoffset: 1.977cqw; }
  9%    { opacity: 1; stroke-dashoffset: 1.977cqw; }
  18%    { opacity: 1; stroke-dashoffset: -77.089cqw; }
  20%  { opacity: 0; stroke-dashoffset: -77.089cqw; }
  100%        { opacity: 0; stroke-dashoffset: -77.089cqw; }
}

@keyframes cf-ww4 {
  0%, 9% { opacity: 0; stroke-dashoffset: -48.865cqw; }
  10%    { opacity: 1; stroke-dashoffset: -48.865cqw; }
  16%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw4 {
  0%, 9% { opacity: 0; stroke-dashoffset: 2.837cqw; }
  10%    { opacity: 1; stroke-dashoffset: 2.837cqw; }
  16%    { opacity: 1; stroke-dashoffset: -46.028cqw; }
  18%  { opacity: 0; stroke-dashoffset: -46.028cqw; }
  100%        { opacity: 0; stroke-dashoffset: -46.028cqw; }
}

@keyframes cf-ww5 {
  0%, 11% { opacity: 0; stroke-dashoffset: -47.41cqw; }
  12%    { opacity: 1; stroke-dashoffset: -47.41cqw; }
  18%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw5 {
  0%, 11% { opacity: 0; stroke-dashoffset: 2.411cqw; }
  12%    { opacity: 1; stroke-dashoffset: 2.411cqw; }
  18%    { opacity: 1; stroke-dashoffset: -44.999cqw; }
  20%  { opacity: 0; stroke-dashoffset: -44.999cqw; }
  100%        { opacity: 0; stroke-dashoffset: -44.999cqw; }
}

@keyframes cf-ww6 {
  0%, 12% { opacity: 0; stroke-dashoffset: -58.653cqw; }
  13%    { opacity: 1; stroke-dashoffset: -58.653cqw; }
  18%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw6 {
  0%, 12% { opacity: 0; stroke-dashoffset: 7.623cqw; }
  13%    { opacity: 1; stroke-dashoffset: 7.623cqw; }
  18%    { opacity: 1; stroke-dashoffset: -51.03cqw; }
  20%  { opacity: 0; stroke-dashoffset: -51.03cqw; }
  100%        { opacity: 0; stroke-dashoffset: -51.03cqw; }
}

@keyframes cf-ww7 {
  0%, 7% { opacity: 0; stroke-dashoffset: -87.41cqw; }
  8%    { opacity: 1; stroke-dashoffset: -87.41cqw; }
  21%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw7 {
  0%, 7% { opacity: 0; stroke-dashoffset: 1.095cqw; }
  8%    { opacity: 1; stroke-dashoffset: 1.095cqw; }
  21%    { opacity: 1; stroke-dashoffset: -86.315cqw; }
  23%  { opacity: 0; stroke-dashoffset: -86.315cqw; }
  100%        { opacity: 0; stroke-dashoffset: -86.315cqw; }
}

@keyframes cf-ww8 {
  0%, 58% { opacity: 0; stroke-dashoffset: -50.488cqw; }
  59%    { opacity: 1; stroke-dashoffset: -50.488cqw; }
  64%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw8 {
  0%, 58% { opacity: 0; stroke-dashoffset: 3.449cqw; }
  59%    { opacity: 1; stroke-dashoffset: 3.449cqw; }
  64%    { opacity: 1; stroke-dashoffset: -47.039cqw; }
  66%  { opacity: 0; stroke-dashoffset: -47.039cqw; }
  100%        { opacity: 0; stroke-dashoffset: -47.039cqw; }
}

@keyframes cf-ww9 {
  0%, 64% { opacity: 0; stroke-dashoffset: -49.543cqw; }
  65%    { opacity: 1; stroke-dashoffset: -49.543cqw; }
  70%    { opacity: 1; stroke-dashoffset: 0; }
  95%         { opacity: 1; stroke-dashoffset: 0; }
  100%        { opacity: 0; stroke-dashoffset: 0; }
}

@keyframes cf-hw9 {
  0%, 64% { opacity: 0; stroke-dashoffset: 2.246cqw; }
  65%    { opacity: 1; stroke-dashoffset: 2.246cqw; }
  70%    { opacity: 1; stroke-dashoffset: -47.297cqw; }
  72%  { opacity: 0; stroke-dashoffset: -47.297cqw; }
  100%        { opacity: 0; stroke-dashoffset: -47.297cqw; }
}

/* The wire geometry. The core covers exactly its own length, so the
   dash pattern never shows: one solid line of light, growing forward.
   The bead's gap is twice the wire length, so the bead never repeats. */

/* w1: the core grows 5% -> 10% of the 4s loop */
.cf-wire--w1 .cf-link--live  { stroke-dasharray: 83.697cqw 83.697cqw; animation: cf-ww1 4s linear infinite; }
.cf-wire--w1 .cf-link--pulse { stroke-dasharray: 11.77cqw 167.395cqw; animation: cf-hw1 4s linear infinite; }

/* w2: the core grows 7% -> 13% of the 4s loop */
.cf-wire--w2 .cf-link--live  { stroke-dasharray: 47.112cqw 47.112cqw; animation: cf-ww2 4s linear infinite; }
.cf-wire--w2 .cf-link--pulse { stroke-dasharray: 1.916cqw 94.225cqw; animation: cf-hw2 4s linear infinite; }

/* w3: the core grows 9% -> 18% of the 4s loop */
.cf-wire--w3 .cf-link--live  { stroke-dasharray: 79.066cqw 79.066cqw; animation: cf-ww3 4s linear infinite; }
.cf-wire--w3 .cf-link--pulse { stroke-dasharray: 1.977cqw 158.132cqw; animation: cf-hw3 4s linear infinite; }

/* w4: the core grows 10% -> 16% of the 4s loop */
.cf-wire--w4 .cf-link--live  { stroke-dasharray: 48.865cqw 48.865cqw; animation: cf-ww4 4s linear infinite; }
.cf-wire--w4 .cf-link--pulse { stroke-dasharray: 2.837cqw 97.731cqw; animation: cf-hw4 4s linear infinite; }

/* w5: the core grows 12% -> 18% of the 4s loop */
.cf-wire--w5 .cf-link--live  { stroke-dasharray: 47.41cqw 47.41cqw; animation: cf-ww5 4s linear infinite; }
.cf-wire--w5 .cf-link--pulse { stroke-dasharray: 2.411cqw 94.82cqw; animation: cf-hw5 4s linear infinite; }

/* w6: the core grows 13% -> 18% of the 4s loop */
.cf-wire--w6 .cf-link--live  { stroke-dasharray: 58.653cqw 58.653cqw; animation: cf-ww6 4s linear infinite; }
.cf-wire--w6 .cf-link--pulse { stroke-dasharray: 7.623cqw 117.306cqw; animation: cf-hw6 4s linear infinite; }

/* w7: the core grows 8% -> 21% of the 4s loop */
.cf-wire--w7 .cf-link--live  { stroke-dasharray: 87.41cqw 87.41cqw; animation: cf-ww7 4s linear infinite; }
.cf-wire--w7 .cf-link--pulse { stroke-dasharray: 1.095cqw 174.819cqw; animation: cf-hw7 4s linear infinite; }

/* w8: the core grows 59% -> 64% of the 4s loop */
.cf-wire--w8 .cf-link--live  { stroke-dasharray: 50.488cqw 50.488cqw; animation: cf-ww8 4s linear infinite; }
.cf-wire--w8 .cf-link--pulse { stroke-dasharray: 3.449cqw 100.977cqw; animation: cf-hw8 4s linear infinite; }

/* w9: the core grows 65% -> 70% of the 4s loop */
.cf-wire--w9 .cf-link--live  { stroke-dasharray: 49.543cqw 49.543cqw; animation: cf-ww9 4s linear infinite; }
.cf-wire--w9 .cf-link--pulse { stroke-dasharray: 2.246cqw 99.087cqw; animation: cf-hw9 4s linear infinite; }

/* ---------- the sampler resolving ---------- */

/* One frame of the denoising strip is on screen for 5.4% of the loop.
   The eight frames are offset by 5.5% each, so exactly one is ever
   visible and they tile the sampling window without a gap. */
@keyframes cf-latent-step {
  0%   { opacity: 1; }
  5.4% { opacity: 1; }
  5.5% { opacity: 0; }
  100% { opacity: 0; }
}

@keyframes cf-resolve-in {
  0%, 59.5% { opacity: 0; }
  60%     { opacity: 1; }
  95%     { opacity: 1; }
  100%    { opacity: 0; }
}

@keyframes cf-sampler-progress {
  0%   { width: 0; }
  16%  { width: 0; }
  60%  { width: 100%; }
  95%  { width: 100%; }
  100% { width: 0; }
}

@keyframes cf-output-in {
  0%, 70%  { opacity: 0; transform: scale(1.06); }
  76%      { opacity: 1; transform: scale(1); }
  95%      { opacity: 1; transform: scale(1); }
  100%     { opacity: 0; transform: scale(1); }
}

@keyframes cf-output-flash {
  0%, 70%  { opacity: 0; }
  73%      { opacity: .78; }
  82%      { opacity: 0; }
  100%     { opacity: 0; }
}

@keyframes cf-output-glow {
  0%, 69%  { box-shadow: 0 0 0 0 rgba(239, 98, 91, 0); }
  78%      { box-shadow: 0 0 26px -4px rgba(239, 98, 91, .55); }
  95%      { box-shadow: 0 0 26px -4px rgba(239, 98, 91, .55); }
  100%     { box-shadow: 0 0 0 0 rgba(239, 98, 91, 0); }
}

/* ---------- status labels: exactly one visible at a time ----------
   Each label owns a hard on/off window; the windows are laid out
   back to back with no overlap, so exactly one line is on screen. */

.cf-slot-idle     { animation: cf-slot-idle 4s linear infinite; }
.cf-slot-queue    { animation: cf-slot-queue 4s linear infinite; }
.cf-slot-sampling { animation: cf-slot-sampling 4s linear infinite; }
.cf-slot-save     { animation: cf-slot-save 4s linear infinite; }
.cf-slot-done     { animation: cf-slot-done 4s linear infinite; }

@keyframes cf-slot-idle {
  0% { opacity: 0; } 2% { opacity: 1; } 5% { opacity: 1; } 6% { opacity: 0; } 100% { opacity: 0; }
}
@keyframes cf-slot-queue {
  0%, 7% { opacity: 0; } 8% { opacity: 1; } 16% { opacity: 1; } 17% { opacity: 0; } 100% { opacity: 0; }
}
@keyframes cf-slot-sampling {
  0%, 17% { opacity: 0; } 18% { opacity: 1; } 63% { opacity: 1; } 64% { opacity: 0; } 100% { opacity: 0; }
}
@keyframes cf-slot-save {
  0%, 64% { opacity: 0; } 65% { opacity: 1; } 75% { opacity: 1; } 76% { opacity: 0; } 100% { opacity: 0; }
}
@keyframes cf-slot-done {
  0%, 75% { opacity: 0; } 76% { opacity: 1; } 95% { opacity: 1; } 96% { opacity: 0; } 100% { opacity: 0; }
}

/* ---------- caption and chrome ---------- */

@keyframes cf-caption-in {
  0%, 74%  { opacity: 0; transform: translateY(7px); }
  79%      { opacity: 1; transform: translateY(0); }
  95%      { opacity: 1; transform: translateY(0); }
  100%     { opacity: 0; transform: translateY(0); }
}

@keyframes cf-queue-pulse {
  0%, 7%   { border-color: rgba(239, 98, 91, .2); color: #6c5f5e; }
  12%      { border-color: rgba(239, 98, 91, .8); color: var(--cf-red); box-shadow: 0 0 12px -3px rgba(239, 98, 91, .6); }
  58%      { border-color: rgba(239, 98, 91, .8); color: var(--cf-red); box-shadow: 0 0 12px -3px rgba(239, 98, 91, .6); }
  64%      { border-color: rgba(239, 98, 91, .2); color: #6c5f5e; box-shadow: none; }
  100%     { border-color: rgba(239, 98, 91, .2); color: #6c5f5e; box-shadow: none; }
}

@keyframes cf-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: .28; }
}

@keyframes cf-status-dot {
  0%, 4%    { background: #333; box-shadow: none; }
  8%        { background: var(--cf-red); box-shadow: 0 0 6px rgba(239, 98, 91, .85); }
  72%       { background: var(--cf-red); box-shadow: 0 0 6px rgba(239, 98, 91, .85); }
  78%       { background: #333; box-shadow: none; }
  100%      { background: #333; box-shadow: none; }
}

/* ---------- offscreen pause ---------- */

.cf-paused *,
.cf-paused *::before,
.cf-paused *::after {
  animation-play-state: paused !important;
}

/* ---------- reduced motion: freeze on the finished frame ---------- */

@media (prefers-reduced-motion: reduce) {
  .cf *,
  .cf *::before,
  .cf *::after {
    animation: none !important;
    transition: none !important;
  }
  .cf-panel {
    opacity: 1;
    transform: rotateX(var(--cf-tilt-x)) rotateY(var(--cf-tilt-y)) rotateZ(var(--cf-tilt-z));
  }
  .cf-node { opacity: 1; transform: none; }
  /* no travelling light in the still frame — just the finished graph */
  .cf-link--pulse { opacity: 0; }
  .cf-link--live { opacity: 1; stroke-dashoffset: 0; }
  .cf-latent { opacity: 0; }
  .cf-resolved { opacity: 1; }
  .cf-output > img.cf-output-main { opacity: 1; transform: none; }
  .cf-sampler-bar i { width: 100%; }
  .cf-caption { opacity: 1; transform: none; }
  .cf-status-dot { background: #333; box-shadow: none; }
  .cf .cf-slot > .cf-slot-idle,
  .cf .cf-slot > .cf-slot-queue,
  .cf .cf-slot > .cf-slot-sampling,
  .cf .cf-slot > .cf-slot-save { opacity: 0; }
  .cf .cf-slot > .cf-slot-done { opacity: 1; }
  .cf-link--live { opacity: 1; }
}

/* ---------- the site rule `.aios-visual img` sets width:100% on every
   image inside the figure. Override it so the plate keeps its own boxes. */
.aios-visual.cf img,
.cf img {
  width: auto;
  max-width: none;
  height: auto;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 0;
}

.cf .cf-sampler-preview img,
.cf .cf-output img {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: none;
}

/* ---------- fill mode ----------
   Every animation in the plate must hold its 0% frame during its own
   delay. Without this a staggered node would flash at full opacity for
   the length of its delay and then jump back to hidden. Declared after
   the animation shorthands so it wins on source order.

   The latent strip is the exception: its frames must stay hidden until
   their own turn, so they keep the default fill mode and carry an
   explicit opacity:0 base style. */
.cf *:not(.cf-latent),
.cf *:not(.cf-latent)::before,
.cf *:not(.cf-latent)::after {
  animation-fill-mode: both;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .cf-stage { aspect-ratio: 4 / 3; }
  .cf-panel { inset: 3% 1.5% 6%; }
  .cf-bar-chip { display: none; }
  .cf-caption { display: none; }
}
@media (max-width: 400px) {
  .cf-bar,
  .cf-foot { font-size: max(7.5px, 1.3cqw); }
  .cf-node,
  .cf-node-head { font-size: max(8px, 1.2cqw); }
  .cf-field { font-size: max(7.5px, 1.14cqw); }
  .cf-field--tag { font-size: max(6.5px, .95cqw); }
}
