/* Eightbitco Flow Engine styles — the site's blocks, animated into executing workflows.
   Depends on the brand tokens already defined in styles.css (--ebc-accent #8B7DFF, --bg,
   --surf, --line, --mut, --dim). Self-contained beyond those. */

.ebf {
  position: relative;
  width: 100%;
  height: var(--ebf-h, 360px);
  overflow: hidden;
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.ebf.ebf-grabbing { cursor: grabbing; }

/* ---- background mode: ambient backdrop bleeding off a hero edge ---- */
/* Non-interactive, dimmed, and masked so it dissolves left-to-right behind the
   hero copy. The positioning/overflow of the *host* is set by the page (see the
   hero's .hero-flow-bg wrapper); here we just make the flow behave as a backdrop. */
.ebf.ebf-bg {
  /* .ebf base sets position:relative + a fixed height; a background flow must
     instead fill whatever box the page's wrapper defines (top/bottom/right/width).
     Override position so top/bottom actually stretch it, and drop the fixed height. */
  position: absolute;
  height: auto;
  cursor: default;
  pointer-events: none;    /* clicks/scroll pass through to the hero */
  touch-action: auto;
  opacity: 0.85;
  /* fade the graph out toward the left so it melts under the headline;
     also soften the very top/bottom so it doesn't hit hard edges */
  -webkit-mask-image:
    linear-gradient(to right, transparent 0%, rgba(0,0,0,0.25) 26%, #000 62%),
    linear-gradient(to bottom, transparent 0, #000 12%, #000 88%, transparent 100%);
  mask-image:
    linear-gradient(to right, transparent 0%, rgba(0,0,0,0.25) 26%, #000 62%),
    linear-gradient(to bottom, transparent 0, #000 12%, #000 88%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
/* in the backdrop, the flow reads as texture — no interactive chrome, softer nodes */
.ebf.ebf-bg .ebf-node { background: color-mix(in srgb, var(--surf) 82%, transparent); }
.ebf.ebf-bg .ebf-hint, .ebf.ebf-bg .ebf-ctrls { display: none; }
.ebf.ebf-bg .ebf-world { transition: transform .25s cubic-bezier(.22,.61,.36,1); } /* smooth parallax drift */

/* world layer: transformed (pan/zoom); nodes + svg live inside at world coords */
.ebf-world { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }

/* zoom/fit controls */
.ebf-ctrls { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.ebf-ctrl {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--surf, #1C1D21); color: var(--mut, #8F9091);
  border: 1px solid var(--line, #242830); border-radius: 3px;
  font: 500 14px 'IBM Plex Mono', monospace; cursor: pointer; line-height: 1;
  transition: color .15s, border-color .15s;
}
.ebf-ctrl:hover { color: #fff; border-color: var(--ebc-accent, #8B7DFF); }
.ebf-hint {
  position: absolute; left: 12px; bottom: 12px; z-index: 5; pointer-events: none;
  font: 400 10px 'IBM Plex Mono', monospace; letter-spacing: 0.08em;
  color: var(--dim, #4C515C); text-transform: uppercase;
}

/* ---- connections (SVG, inside world) ---- */
.ebf-svg { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.ebf-edge {
  fill: none;
  stroke: var(--line, #242830);
  stroke-width: 1.5;
}
.ebf-edge-flow {
  fill: none;
  stroke: var(--ebc-accent, #8B7DFF);
  stroke-width: 2.5;
  stroke-linecap: round;
  /* --len is set per-path (in JS) to the path's own length, so the fill draws
     the WHOLE line edge-to-edge regardless of length. */
  stroke-dasharray: var(--len, 1000);
  stroke-dashoffset: var(--len, 1000);
  opacity: 0;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--ebc-accent) 65%, transparent));
}
.ebf-edge-flow.flowing {
  animation: ebf-draw 0.62s ease-in-out forwards;
}
@keyframes ebf-draw {
  0%   { stroke-dashoffset: var(--len, 1000); opacity: 1; }
  70%  { stroke-dashoffset: 0; opacity: 1; }               /* line fully drawn to next step */
  100% { stroke-dashoffset: 0; opacity: 0.9; }             /* holds, then the next step lights */
}

/* ---- nodes (HTML, positioned in %) ---- */
.ebf-nodes { position: absolute; inset: 0; }
.ebf-node {
  position: absolute;
  box-sizing: border-box;
  background: var(--surf, #1C1D21);
  border: 1px solid var(--line, #242830);
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  overflow: hidden;
  transition: border-color .35s ease, box-shadow .35s ease, background .35s ease;
}
.ebf-node .ebf-kind {
  font: 500 9px 'IBM Plex Mono', monospace;
  letter-spacing: 0.16em;
  color: var(--dim, #4C515C);
  text-transform: uppercase;
}
.ebf-node .ebf-label {
  /* fixed size — the whole world scales with zoom, so labels never clip */
  font: 500 13px/1.2 'IBM Plex Mono', monospace;
  color: #E7E7EA;
  white-space: nowrap;
}
/* status dot, top-right */
.ebf-node .ebf-dot {
  position: absolute;
  top: 10px; right: 10px;
  width: 6px; height: 6px;
  background: var(--dim, #4C515C);
  transition: background .3s ease, box-shadow .3s ease;
}

/* kind accents (idle) — a thin left keyline hints the node type */
.ebf-node.ebf-trigger { border-left: 2px solid #6a6f7a; }
.ebf-node.ebf-ai      { border-left: 2px solid color-mix(in srgb, var(--ebc-accent) 55%, var(--line)); }
.ebf-node.ebf-output  { border-left: 2px solid #6a6f7a; }

/* ---- execution states ---- */
.ebf-node.active {
  border-color: var(--ebc-accent, #8B7DFF);
  background: color-mix(in srgb, var(--ebc-accent) 12%, var(--surf));
  box-shadow: 0 0 0 1px var(--ebc-accent), 0 0 22px -4px color-mix(in srgb, var(--ebc-accent) 70%, transparent);
}
.ebf-node.active .ebf-dot {
  background: var(--ebc-accent, #8B7DFF);
  box-shadow: 0 0 8px 1px var(--ebc-accent);
  animation: ebf-blink .5s ease-in-out infinite alternate;
}
.ebf-node.active .ebf-label { color: #fff; }
@keyframes ebf-blink { from { opacity: .5 } to { opacity: 1 } }

.ebf-node.done {
  border-color: color-mix(in srgb, var(--ebc-accent) 45%, var(--line));
}
.ebf-node.done .ebf-dot {
  background: var(--ebc-accent, #8B7DFF);
  box-shadow: none;
  /* becomes a subtle "completed" tick via clip */
  clip-path: polygon(14% 44%, 0 58%, 40% 100%, 100% 16%, 86% 4%, 38% 66%);
  width: 9px; height: 9px; top: 9px; right: 9px;
}

/* ---- atomic single-node "atom" for heroes: a lone node that pulses ---- */
.ebf-atom { height: auto; overflow: visible; cursor: default; display: inline-block; touch-action: auto; }
.ebf-atom .ebf-node {
  position: relative; left: auto; top: auto; height: auto;
  animation: ebf-atom-pulse 2.6s ease-in-out infinite;
}
@keyframes ebf-atom-pulse {
  0%, 100% { border-color: var(--line); box-shadow: none; }
  45%, 55% { border-color: var(--ebc-accent); box-shadow: 0 0 20px -6px color-mix(in srgb, var(--ebc-accent) 70%, transparent); }
}
.ebf-atom .ebf-node .ebf-dot { animation: ebf-blink 1.3s ease-in-out infinite alternate; background: var(--ebc-accent); }

/* respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ebf-edge-flow.flowing, .ebf-atom .ebf-node, .ebf-node.active .ebf-dot { animation: none !important; }
  .ebf-edge-flow.flowing { opacity: 1; stroke-dashoffset: 0; }
}
