/* =========================================================================
   topology-anim.css — Topology discovery animation
   ----------------------------------------------------------------------------
   Self-contained styles for the in-engine-wait animation. Every color is a
   var(--token) so the visual auto-flips with the page's data-theme attribute.
   No bespoke palette: read from the same design tokens dashboard.html uses.

   Owned by: TopoAnim (topology-anim.js) — don't reference these classes
   from anywhere else; the CSS contract is private to that module.
   ========================================================================= */

/* Container that the animation mounts into. Caller sets `display:none`
   when not running and removes it when the animation calls .stop(). */
.topo-anim {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 26px;
  box-shadow: var(--shadow-card, 0 8px 32px rgba(0,0,0,0.18));
}

.topo-anim-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--fg);
}

.topo-anim-status {
  font-family: var(--mono, 'IBM Plex Mono', ui-monospace, monospace);
  font-size: 0.78rem;
  color: var(--fg-2);
  height: 16px;             /* reserve space so layout doesn't jump */
  margin-bottom: 16px;
}

.topo-anim-progbar {
  height: 6px;
  background: var(--bg-sunk);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 18px;
}
.topo-anim-progfill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 3px;
}

/* SVG stage — square aspect ratio so the radial layout reads well. */
.topo-anim-stage {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-sunk);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.topo-anim-stage svg { width: 100%; height: 100%; display: block; }

/* Phase pill removed 2026-05-02 — was exposing algorithm structure
   ("Phase 3 / 5") to users. CSS rules deleted alongside the JS DOM
   element. If a future redesign wants ambient progress text, build
   from the title/status copy already provided. */

/* ============================================================
   ANIMATION PRIMITIVES — node, link, halo, role-color flood
   ============================================================ */

/* Each node is a <g> with a circle inside. Class flips drive state. */
.topo-anim .node circle {
  fill: var(--bg-elev);
  stroke: var(--accent);
  stroke-width: 1.6;
  transition:
    fill   0.4s ease,
    stroke 0.4s ease,
    r      0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Spawn pop on appearance */
.topo-anim .node.spawn circle { animation: topo-anim-pulse-in 0.5s ease-out; }
@keyframes topo-anim-pulse-in {
  0%   { r: 0;  opacity: 0; }
  60%  { r: 7;  opacity: 1; }
  100% { r: 5;  opacity: 1; }
}

/* Seed core — pulsing halo */
.topo-anim .node.core circle {
  fill: var(--accent);
  stroke: var(--accent);
}
.topo-anim .node.core .halo {
  fill: var(--accent);
  opacity: 0.25;
  animation: topo-anim-halo-pulse 1.8s ease-in-out infinite;
}
@keyframes topo-anim-halo-pulse {
  0%, 100% { r: 9;  opacity: 0.30; }
  50%      { r: 16; opacity: 0.05; }
}

/* Role color wash — applied during the final phase. Colors map to the
   semantic role tokens used elsewhere on the dashboard:
     core         -> accent (blue)
     distribution -> amber
     access       -> green
   These are dashboard's existing status color tokens, so the role colors
   match the rest of the app.  */
.topo-anim .node.role-core   circle { fill: var(--accent); stroke: var(--accent); }
.topo-anim .node.role-dist   circle { fill: var(--amber);  stroke: var(--amber); }
.topo-anim .node.role-access circle { fill: var(--green);  stroke: var(--green); }

/* Reclassification flicker — flashes a node before its role settles.
   Visual: small bounce to amber, holds, then gets washed by role color. */
.topo-anim .node.flicker circle {
  animation: topo-anim-flicker 0.55s ease-out;
}
@keyframes topo-anim-flicker {
  0%   { fill: var(--bg-elev); stroke: var(--amber); transform: scale(1); }
  40%  { fill: var(--amber);   stroke: var(--amber); transform: scale(1.4); }
  100% { fill: var(--amber);   stroke: var(--amber); transform: scale(1); }
}

/* Links — animated draw via stroke-dasharray. Per-line dashoffset is set
   inline by JS based on actual length; the keyframe only handles the tween. */
.topo-anim .link {
  stroke: var(--accent);
  stroke-width: 1.4;
  fill: none;
  opacity: 0.55;
}
.topo-anim .link.stale {
  animation: topo-anim-fade-out 0.4s ease-out forwards;
}
@keyframes topo-anim-fade-out {
  to { opacity: 0; stroke-dashoffset: 200; }
}

/* Final fade-out of the whole animation when stopping. JS adds .fading
   then removes the element 400ms later. */
.topo-anim.fading {
  opacity: 0;
  transition: opacity 0.4s ease-out;
  pointer-events: none;
}