/* ============ demo: n8n — the content pipeline as an instrument panel ============
   js/demos/n8n.js draws one SVG (viewBox 360×288). State is classes + opacity +
   stroke-dashoffset only; the packet's position is the one per-frame write. */

.n8d {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  overflow: hidden;
  contain: layout paint;
  user-select: none;
  -webkit-user-select: none;
}

.n8d svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.n8d text {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  fill: var(--ink-3);
  text-rendering: geometricPrecision;
}

.n8d .n8d-cap { letter-spacing: 0.12em; fill: var(--ink-3); }
.n8d .n8d-hi { fill: var(--ink); }
.n8d .n8d-quiet { fill: var(--ink-4); }

/* surfaces */
.n8d-band { fill: var(--bg); }
.n8d-rule { fill: none; stroke: var(--hairline); stroke-width: 1; }
.n8d-dot { fill: var(--ink); opacity: 0.07; }

.n8d-live { fill: var(--ink-4); }
.n8d.is-running .n8d-live { fill: var(--signal); }

/* edges: a hairline, and a trail the packet draws over it */
.n8d-edge,
.n8d-trail {
  fill: none;
  stroke-width: 1;
}
.n8d-edge { stroke: var(--hairline-strong); }
.n8d-trail {
  stroke: var(--ink-2);
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1;
}
.n8d.is-clearing .n8d-trail {
  opacity: 0;
  transition: opacity 400ms var(--ease-ui);
}

/* nodes: frame → signal trace while executing → ink frame + check */
.n8d-f {
  fill: var(--surface-2);
  stroke: var(--hairline-strong);
  stroke-width: 1;
}
.n8d-p {
  fill: none;
  stroke: var(--signal);
  stroke-width: 1.2;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1;
  transition: opacity 220ms var(--ease-ui);
}
.n8d-d {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  opacity: 0;
  transition: opacity 260ms var(--ease-ui);
}
.n8d-c {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.2;
  stroke-linecap: square;
  stroke-linejoin: miter;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 240ms var(--ease-out);
}
.n8d-node.is-done .n8d-d { opacity: 1; }
.n8d-node.is-done .n8d-c { stroke-dashoffset: 0; }
.n8d-node.is-done .n8d-p { opacity: 0; }


/* lanes: the chosen one stays, the others step back */
.n8d-lane { transition: opacity 360ms var(--ease-ui); }
.n8d-lane.is-dim { opacity: 0.36; }

.n8d .n8d-tag { fill: var(--ink-3); }
.n8d .n8d-tint {
  fill: var(--case-tint, #e8667a);
  opacity: 0;
  transition: opacity 300ms var(--ease-ui);
}
.n8d-lane.is-live .n8d-tint { opacity: 1; }
/* step names belong to the chosen lane only — fewer, larger labels */
.n8d .n8d-step {
  fill: var(--ink-2);
  opacity: 0;
  transition: opacity 300ms var(--ease-ui);
}
.n8d .is-live .n8d-step { opacity: 1; }

/* the human review that never happens: dashed, struck, wire cut — never lit */
.n8d-ghost,
.n8d-stub {
  fill: none;
  stroke: var(--ink-4);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}
.n8d-ghost { fill: var(--surface-1); }
.n8d .n8d-ghost-t { fill: var(--ink-3); }
.n8d-strike { fill: none; stroke: var(--ink-3); stroke-width: 1; }

/* the packet: ink in transit, signal while a node holds it */
.n8d-pk { fill: var(--ink); }
.n8d-pk.is-exec { fill: var(--signal); }
.n8d-pk.is-off { opacity: 0; }

/* execution log */
.n8d .n8d-line { fill: var(--ink); transition: opacity 300ms var(--ease-ui); }
.n8d .n8d-ts { fill: var(--ink-3); }
.n8d .n8d-ok { fill: var(--ink-3); }
