/* Right column: animated flowchart stage with SVG edges, traveling pulses, nodes,
 * floating doc-card, generate pill, and decorative corner ticks.
 * Depends on base.css for tokens and keyframes. */

.stage {
  position: relative;
  height: min(640px, 72vh);
  border-radius: 22px;
  background:
    radial-gradient(circle at 55% 40%, rgba(38,99,235,0.08), transparent 55%),
    linear-gradient(180deg, #fbfcfe, #ffffff);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow:
    0 1px 2px rgba(10,15,26,0.04),
    0 20px 60px -30px rgba(38,99,235,0.3),
    0 40px 80px -40px rgba(10,15,26,0.1);
}
.stage::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(10,15,26,0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(10,15,26,0.045) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(circle at 50% 50%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, black 30%, transparent 75%);
}

/* Flat 2D animated flowchart scene */
#flow-root {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 32px 40px;
}
.flow-frame {
  position: relative;
  width: 100%;
  max-width: 860px;
  aspect-ratio: 860 / 400;
}
.flow-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
}
.flow-layer {
  position: absolute; inset: 0;
  pointer-events: none;
}

/* Animated edges (dashed marching) and traveling pulses */
.flow-svg .edge {
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.8;
  stroke-opacity: 0.65;
  stroke-dasharray: 5 7;
  stroke-linecap: round;
  animation: dashMove 2.8s linear infinite;
}
.flow-svg .pulse {
  fill: var(--primary);
  filter: drop-shadow(0 0 5px rgba(38,99,235,0.6));
}

/* Flowchart nodes - positioned as % of the 860×400 frame, centers via translate(-50%,-50%) */
.fd-node {
  position: absolute;
  width: 19.7%;
  min-width: 150px;
  background: #ffffff;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 12px 14px 10px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9) inset,
    0 10px 22px -14px rgba(10,15,26,0.22),
    0 3px 8px -4px rgba(10,15,26,0.09);
  transform: translate(-50%, -50%);
  transform-origin: 50% 50%;
  animation: nodeIn 0.6s cubic-bezier(.2,.8,.2,1) both;
  pointer-events: auto;
}
/* Center anchor positions in % of 860×400 frame */
.fd-node.n-in  { left: 9.9%;  top: 50%; animation-delay: 0.15s; }
.fd-node.n-ex  { left: 54.6%; top: 20%; animation-delay: 0.30s; }
.fd-node.n-cl  { left: 54.6%; top: 80%; animation-delay: 0.45s; }
.fd-node.n-gen { left: 81.4%; top: 50%; animation-delay: 0.60s; }
/* n-out hidden - gen is the visual endpoint; kept in markup for semantic completeness */
.fd-node.n-out { left: 97%;   top: 50%; animation-delay: 0.75s; display: none; }

.fd-node.accent {
  background: linear-gradient(180deg, #1d4ed8, #3b82f6);
  border-color: rgba(255,255,255,0.15);
  box-shadow:
    0 0 0 1px rgba(38,99,235,0.3),
    0 18px 36px -14px rgba(38,99,235,0.55),
    0 4px 12px -4px rgba(38,99,235,0.3);
}
.fd-node .fd-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--fg); letter-spacing: -0.01em; }
.fd-node.accent .fd-head { color: #fff; }
.fd-node .fd-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px rgba(38,99,235,0.12); flex-shrink: 0; }
.fd-node.accent .fd-dot { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.25); }
.fd-node .fd-sub { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--fg-mute); margin-top: 4px; letter-spacing: 0; }
.fd-node.accent .fd-sub { color: rgba(255,255,255,0.78); }
.fd-node .fd-bar { margin-top: 8px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--primary), transparent); width: 60%; }
.fd-node.accent .fd-bar { background: linear-gradient(90deg, rgba(255,255,255,0.85), transparent); width: 70%; }
.fd-node .spinner-sm {
  position: absolute; top: 10px; right: 10px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}

/* Floating doc-preview card (top-left) */
.doc-card {
  position: absolute; top: 22px; left: 22px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
  font-family: "JetBrains Mono", monospace; font-size: 10px;
  color: var(--fg-dim);
  box-shadow: 0 10px 30px -15px rgba(10,15,26,0.25);
  max-width: 180px;
  opacity: 0; transform: translateY(-4px);
  animation: fadeUp 0.9s 1.1s ease forwards;
}
.doc-card .dc-label {
  font-size: 9px; color: var(--fg-mute); text-transform: uppercase; letter-spacing: 0.1em;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.doc-card .dc-label::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
  box-shadow: 0 0 6px rgba(38,99,235,0.6);
  animation: pulse 2s infinite;
}
.doc-card .line-a { height: 4px; border-radius: 2px; background: var(--line-2); margin-bottom: 4px; }
.doc-card .line-a.short { width: 60%; }
.doc-card .line-a.mid { width: 80%; }

/* Generate pill (bottom-right) */
.gen-pill {
  position: absolute; bottom: 22px; right: 22px;
  background: linear-gradient(180deg, #1d4ed8, #3b82f6); color: #fff;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.05em; text-transform: uppercase;
  box-shadow: 0 8px 22px -6px rgba(38,99,235,0.6), inset 0 1px 0 rgba(255,255,255,0.2);
  opacity: 0; transform: translateY(6px);
  animation: fadeUp 0.9s 1.3s ease forwards;
}
.gen-pill .spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}

/* Decorative stage corner ticks */
.stage-corner { position: absolute; width: 14px; height: 14px; border-color: rgba(10,15,26,0.15); border-style: solid; }
.sc-tl { top: 10px; left: 10px; border-width: 1px 0 0 1px; }
.sc-tr { top: 10px; right: 10px; border-width: 1px 1px 0 0; }
.sc-bl { bottom: 10px; left: 10px; border-width: 0 0 1px 1px; }
.sc-br { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; }

@media (max-width: 960px) {
  .stage { height: 440px; }
  .doc-card { top: 14px; left: 14px; }
  .gen-pill { bottom: 14px; right: 14px; }
}
