/* Swarm illustration: every rule is scoped under .swarm; tokens fall back to the brand values. */
.swarm {
  --sw-canvas: var(--canvas, #11161d);
  --sw-surface: var(--surface, #171e27);
  --sw-border: var(--border, #2b3542);
  --sw-border-strong: var(--border-strong, #4a586a);
  --sw-text: var(--text, #e9eef4);
  --sw-muted: var(--text-muted, #acb9c8);
  --sw-primary: var(--primary, #8fb0ff);
  --sw-success: var(--success, #a5e2be);
  --sw-warning: var(--warning, #f7d797);
  --sw-danger: #f5a3a3;
  --sw-mono: var(--mono, "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace);
  position: relative;
  padding: 96px 0 88px;
  background: var(--sw-canvas);
  color: var(--sw-text);
  overflow: hidden;
}
.swarm-inner { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.swarm-head { max-width: 44rem; margin-bottom: 36px; }
.swarm-eyebrow { font: 500 12px/1 var(--sw-mono); color: var(--sw-primary); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 14px; }
.swarm h2 { font-size: clamp(1.6rem, 3.4vw, 2.25rem); letter-spacing: -.025em; line-height: 1.15; margin: 0 0 14px; font-weight: 700; }
.swarm h2 em { font-style: normal; background: linear-gradient(100deg, var(--sw-primary), #4d7cf3); -webkit-background-clip: text; background-clip: text; color: transparent; }
.swarm-lede { color: var(--sw-muted); font-size: 1.0625rem; margin: 0; }

.swarm-stage {
  position: relative;
  margin: 0;
  border: 1px solid var(--sw-border);
  border-radius: 14px;
  background:
    radial-gradient(60% 70% at 38% 50%, rgb(42 79 184 / 20%), transparent 70%),
    radial-gradient(40% 60% at 88% 50%, rgb(77 124 243 / 10%), transparent 70%),
    #0d1218;
  overflow: hidden;
}
/* Scanlines and a slow sweep over the stage. */
.swarm-stage::before, .swarm-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.swarm-stage::before { background: repeating-linear-gradient(to bottom, rgb(143 176 255 / 3.5%) 0 1px, transparent 1px 4px); z-index: 1; }
.swarm-stage::after {
  background: linear-gradient(to bottom, transparent, rgb(143 176 255 / 5%) 50%, transparent);
  height: 30%; inset: auto 0 auto 0; top: -30%;
  animation: sw-sweep 9s linear infinite; z-index: 1;
}
@keyframes sw-sweep { to { top: 100%; } }
.swarm-svg { display: block; width: 100%; height: auto; }

.swarm-legend {
  position: relative; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 8px 20px;
  padding: 14px 20px;
  border-top: 1px solid var(--sw-border);
  background: rgb(23 30 39 / 60%);
  font: 12px/1.2 var(--sw-mono); color: var(--sw-muted);
}
.swarm-legend span { display: inline-flex; align-items: center; gap: 8px; }
.swarm-key { display: inline-block; width: 12px; height: 12px; flex: none; }
.swarm-key--busy, .swarm-key--idle { clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.swarm-key--busy { background: linear-gradient(135deg, #b3c9ff, #4d7cf3 50%, #2a4fb8); }
.swarm-key--idle { background: linear-gradient(135deg, #4a586a, #35414f 50%, #2b3542); }
.swarm-key--dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sw-primary); box-shadow: 0 0 8px var(--sw-primary); margin: 0 2px; }
.swarm-key--raw, .swarm-key--safe, .swarm-key--block { width: 14px; height: 3px; border-radius: 2px; }
.swarm-key--raw { background: var(--sw-warning); }
.swarm-key--safe { background: var(--sw-primary); }
.swarm-key--block { background: var(--sw-danger); }

/* SVG parts drawn by swarm.js. */
.swarm-svg text { font-family: var(--sw-mono); }
.sw-lat { fill: var(--sw-surface); stroke: var(--sw-border-strong); stroke-width: 2; }
.sw-tag { font-size: 11.5px; fill: var(--sw-muted); paint-order: stroke; stroke: #0d1218; stroke-width: 4px; stroke-linejoin: round; }
.sw-tag--dim { fill: #6b7a8c; font-size: 10px; }
.sw-tag--primary { fill: var(--sw-primary); }
.sw-zone { fill: rgb(17 22 29 / 35%); stroke: var(--sw-border-strong); stroke-width: 1.5; stroke-dasharray: 2 6; stroke-linecap: round; }
.sw-zone-title { font-size: 12px; font-weight: 500; letter-spacing: .08em; fill: var(--sw-text); }
.sw-zone-sub { font-size: 11px; fill: var(--sw-muted); }
.sw-icon { fill: none; stroke: var(--sw-primary); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.sw-icon--deny { stroke: var(--sw-danger); }
.sw-edge { stroke: var(--sw-primary); stroke-opacity: .16; stroke-width: 1.5; stroke-dasharray: 4 7; stroke-linecap: round; transition: stroke-opacity .4s; }
.sw-edge.is-active { stroke-opacity: .6; }
.sw-route { stroke-width: 1.5; stroke-dasharray: 3 6; stroke-linecap: round; fill: none; }
.sw-route--net { stroke: var(--sw-primary); stroke-opacity: .28; }

/* Worker cell: slate when idle, brand cube and gradient rim when busy. */
.sw-hex { fill: var(--sw-surface); stroke: var(--sw-border-strong); stroke-width: 2.5; stroke-linejoin: round; }
.sw-rim { fill: none; stroke: url(#sw-g); stroke-width: 3; stroke-linejoin: round; opacity: 0; transition: opacity .5s; }
.sw-halo { fill: url(#sw-halo); opacity: 0; transition: opacity .6s; }
.sw-ring { fill: none; stroke: var(--sw-primary); stroke-opacity: .3; stroke-width: 1.2; stroke-dasharray: 2 5; stroke-linecap: round; }
.sw-cube polygon { stroke: var(--sw-surface); stroke-width: 1.2; stroke-linejoin: round; transition: fill .5s; }
.sw-cube .t { fill: #4a586a; }
.sw-cube .l { fill: #35414f; }
.sw-cube .r { fill: #2b3542; }
.sw-w.is-busy .sw-cube .t { fill: #b3c9ff; }
.sw-w.is-busy .sw-cube .l { fill: #4d7cf3; }
.sw-w.is-busy .sw-cube .r { fill: #2a4fb8; }
.sw-w.is-busy .sw-rim { opacity: 1; }
.sw-w.is-busy .sw-halo { opacity: .7; }
.sw-led { fill: #2b3542; }
.sw-led:first-of-type { fill: var(--sw-success); opacity: .45; animation: sw-breathe 3.2s ease-in-out infinite; }
.sw-w.is-busy .sw-led { fill: var(--sw-primary); opacity: 1; animation: sw-blink var(--d, .7s) steps(1, end) var(--o, 0s) infinite; }
.sw-w.is-busy .sw-led:first-of-type { fill: var(--sw-success); }
.sw-w--frontier.is-busy .sw-led:last-of-type { fill: var(--sw-warning); }
@keyframes sw-blink { 0% { opacity: 1; } 50% { opacity: .15; } }
@keyframes sw-breathe { 50% { opacity: .9; } }

/* Exfiltration filter. */
.sw-filter-glow { fill: url(#sw-fglow); }
.sw-filter-line { stroke: var(--sw-primary); stroke-width: 2; stroke-dasharray: 10 6; animation: sw-flow 1.4s linear infinite; }
.sw-filter-teeth { stroke: var(--sw-primary); stroke-opacity: .25; stroke-width: 1.2; }
.sw-filter-scan { stroke: #d6e2ff; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 70 2000; filter: url(#sw-blur); animation: sw-scan 4.5s cubic-bezier(.45, 0, .55, 1) infinite alternate; }
.sw-filter-flash { opacity: 0; }
@keyframes sw-flow { to { stroke-dashoffset: -32; } }
@keyframes sw-scan { from { stroke-dashoffset: 70; } to { stroke-dashoffset: calc(var(--len, 500px) * -1); } }

/* Traffic. */
.sw-pk-core { fill: var(--sw-primary); }
.sw-pk-glow { fill: var(--sw-primary); opacity: .3; filter: url(#sw-blur); }
.sw-pk--raw .sw-pk-core, .sw-pk--raw .sw-pk-glow { fill: var(--sw-warning); }
.sw-pk--ans .sw-pk-core, .sw-pk--ans .sw-pk-glow { fill: var(--sw-success); }
.sw-pk--raw .sw-tag { fill: var(--sw-warning); }
.sw-pk--ans .sw-tag { fill: var(--sw-success); }
.sw-pk--safe .sw-tag { fill: var(--sw-primary); }
.sw-pk .sw-tag { font-size: 11.5px; stroke: none; }
.sw-pill rect { fill: #0d1218; fill-opacity: .92; stroke: var(--sw-primary); stroke-opacity: .45; }
.sw-pk--raw .sw-pill rect { stroke: var(--sw-warning); }
.sw-pk--ans .sw-pill rect { stroke: var(--sw-success); }
.sw-name { fill: #6b7a8c; letter-spacing: .04em; }
.sw-w.is-busy .sw-name { fill: var(--sw-primary); }
.sw-redact { fill: #6b7a8c; }
.sw-note { font-size: 11.5px; opacity: 0; }
.sw-note rect { fill: #0d1218; fill-opacity: .92; stroke-opacity: .55; }
.sw-note--ok text { fill: var(--sw-success); }
.sw-note--ok rect { stroke: var(--sw-success); }
.sw-note--block text { fill: var(--sw-danger); font-weight: 500; }
.sw-note--block rect { stroke: var(--sw-danger); }
.sw-float { font-size: 10px; fill: var(--sw-primary); opacity: 0; }

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

@media (max-width: 640px) {
  .swarm { padding: 64px 0 56px; }
  .swarm-inner { padding: 0 16px; }
  .swarm-legend { padding: 12px 14px; gap: 8px 14px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .swarm *, .swarm *::before, .swarm *::after { animation: none !important; transition: none !important; }
  .swarm-stage::after { display: none; }
}
