/* THE SWARM — the constellation view.
   Wider and darker than the rest of the site: this page is meant to be looked
   at rather than read, so the chrome recedes and the graph gets the light. */

.swarm-body { background: #030503; }

/* `display: grid` on .sw-empty beats the user-agent rule for [hidden], so the
   empty-state panel stays painted over a graph that is drawing fine. Every
   toggle on this page goes through the attribute, so the fix goes here once
   rather than at each call site. */
[hidden] { display: none !important; }

.swarm {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

/* ── title ─────────────────────────────────────────────────────────── */

.sw-head { text-align: center; margin: 8px 0 20px; }

.sw-head h1 {
  margin: 0;
  font: 600 clamp(22px, 3.4vw, 38px)/1.15 var(--sans);
  letter-spacing: -0.02em;
  color: var(--ink);
}

.sw-sub {
  margin: 10px 0 0;
  font: 500 12px/1.5 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sw-sub i { color: var(--line-2); font-style: normal; margin: 0 6px; }
.sw-sub span { color: var(--ink-2); }

/* ── the stage ─────────────────────────────────────────────────────── */

.sw-stage {
  position: relative;
  height: clamp(400px, 58vh, 640px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(60% 60% at 50% 50%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%),
    #040704;
  overflow: hidden;
}

#graph { display: block; width: 100%; height: 100%; }

.sw-empty {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
}
.sw-empty b { font: 600 16px/1.4 var(--sans); color: var(--ink); }
.sw-empty span { font: 13px/1.6 var(--sans); color: var(--ink-3); max-width: 42ch; }

/* The tour card, top-left, like a callout in a documentary. */
.sw-card {
  position: absolute;
  top: 16px; left: 16px;
  min-width: 210px;
  max-width: 300px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, #040704 88%, transparent);
  backdrop-filter: blur(6px);
  animation: sw-in 260ms ease-out;
}
@keyframes sw-in { from { opacity: 0; transform: translateY(-6px); } }

.sw-card-niche {
  font: 600 13px/1.3 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.sw-card-verb {
  margin-top: 5px;
  font: 11px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sw-card-verb i { font-style: normal; margin: 0 5px; color: var(--line-2); }
.sw-card-line {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  font: 12px/1.5 var(--sans);
  color: var(--ink-2);
}

.sw-tour {
  position: absolute;
  bottom: 14px; left: 16px;
  display: flex; align-items: center; gap: 10px;
}
.sw-tour-btn {
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: color-mix(in srgb, #040704 80%, transparent);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}
.sw-tour-btn:hover { color: var(--accent); border-color: var(--accent-dim); }
.sw-tour-at {
  font: 11px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sw-tip {
  position: absolute;
  pointer-events: none;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #040704;
  font: 11px/1.5 var(--mono);
  color: var(--ink-2);
  white-space: pre;
  z-index: 4;
}

/* ── the five panels ───────────────────────────────────────────────── */

.sw-panels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.sw-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  padding: 13px 14px 14px;
  min-height: 172px;
  display: flex;
  flex-direction: column;
}

.sw-panel h2 {
  margin: 0 0 10px;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sw-none { margin: 0; font: 12px/1.5 var(--sans); color: var(--ink-3); }

.sw-note {
  margin: 8px 0 0;
  font: 10px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sw-note i { font-style: normal; color: var(--line-2); margin: 0 4px; }

.sw-scroll {
  flex: 1;
  overflow-y: auto;
  max-height: 132px;
  font: 11px/1.6 var(--mono);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

.sw-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  white-space: nowrap;
}
.sw-row:last-child { border-bottom: 0; }
.sw-row .id { color: var(--accent); }
.sw-row .why { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.sw-row .amt { margin-left: auto; color: var(--ink-2); }
.sw-row .amt.zero { color: var(--critical); }

/* capital flow */
.sw-flow { flex: 1; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 132px; }
.sw-bar { display: grid; grid-template-columns: 1fr; gap: 3px; }
.sw-bar-top {
  display: flex; justify-content: space-between; gap: 8px;
  font: 10px/1.3 var(--mono); color: var(--ink-3);
}
.sw-bar-top b { color: var(--ink-2); font-weight: 500; }
.sw-bar-track { height: 5px; border-radius: 3px; background: var(--bg-3); overflow: hidden; }
.sw-bar-fill { height: 100%; border-radius: 3px; background: var(--critical); }
.sw-bar.in .sw-bar-fill { background: var(--accent); }

/* cohort matrix */
.sw-matrix { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.sw-mrow { display: flex; gap: 3px; align-items: center; }
.sw-mrow > span:first-child {
  width: 20px; flex: none;
  font: 10px/1 var(--mono); color: var(--ink-3);
}
.sw-cell {
  flex: 1;
  height: 15px;
  border-radius: 2px;
  background: var(--bg-3);
  border: 1px solid var(--line);
}

/* burn */
.sw-spark { width: 100%; height: 74px; display: block; }

.sw-figs {
  display: flex;
  gap: 14px;
  margin-top: auto;
  padding-top: 10px;
  font: 10px/1.4 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sw-figs b { display: block; font: 600 15px/1.2 var(--mono); color: var(--ink); letter-spacing: 0; }
.sw-figs-col { flex-direction: column; gap: 7px; }

.sw-big {
  font: 600 clamp(30px, 4vw, 46px)/1 var(--mono);
  color: var(--critical);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ── ghost desk ────────────────────────────────────────────────────── */

.sw-ghost {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px 24px;
}

.sw-ghost-head h2 {
  margin: 0 0 8px;
  font: 600 10px/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sw-ghost-head p {
  margin: 0;
  font: 13px/1.65 var(--sans);
  color: var(--ink-2);
  max-width: 68ch;
}
.sw-ghost-head b { color: var(--ink); font-weight: 600; }

.sw-ghost-figs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  grid-column: 1 / -1;
}
.sw-ghost-figs > div { background: var(--bg-2); padding: 10px 12px; }
.sw-ghost-figs b {
  display: block;
  font: 600 17px/1.2 var(--mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.sw-ghost-figs span {
  display: block;
  margin-top: 3px;
  font: 10px/1.3 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
/* The zero that is the point. */
.sw-ghost-figs > div:last-child b { color: var(--accent); }

.sw-ghost-rows { grid-column: 1 / -1; max-height: 116px; }

.sw-survey {
  grid-column: 1 / -1;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font: 12px/1.6 var(--sans);
  color: var(--ink-3);
}
.sw-survey b { color: var(--ink-2); font-weight: 600; }
.sw-survey-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  margin-top: 8px;
}
.sw-survey-rows span {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-3);
  font: 11px/1.3 var(--mono);
  color: var(--ink-3);
}
.sw-survey-rows b { color: var(--critical); }

/* ── footer strip ──────────────────────────────────────────────────── */

.sw-foot {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.sw-foot i { font-style: normal; color: var(--line-2); }
.sw-foot b { color: var(--ink-2); font-weight: 600; }
.sw-status { color: var(--accent) !important; }

.sw-legal {
  margin: 14px auto 0;
  max-width: 76ch;
  text-align: center;
  font: 11px/1.6 var(--mono);
  color: var(--ink-3);
}

/* ── narrower screens ──────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .sw-panels { grid-template-columns: repeat(2, 1fr); }
  .sw-panel-survival { grid-column: 1 / -1; }
  .sw-ghost { grid-template-columns: 1fr; }
  .sw-ghost-figs { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  .swarm { padding: 20px 12px 48px; }
  .sw-panels { grid-template-columns: 1fr; }

  /* The card is 300px of opaque panel. On a 351px stage that is the graph,
     covered. So on a narrow screen the stage stops being a canvas with things
     floating on it and becomes a column: graph, then card, then controls. */
  .sw-stage {
    height: auto;
    display: flex;
    flex-direction: column;
  }
  #graph {
    flex: none;
    height: 46vh;
    min-height: 290px;
  }
  .sw-card {
    position: static;
    max-width: none;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    backdrop-filter: none;
    background: transparent;
  }
  .sw-tour {
    position: static;
    padding: 0 14px 13px;
  }
  /* Hover has no meaning on a touch screen and the tip would sit under a
     finger anyway. */
  .sw-tip { display: none; }
}

/* Motion here is a simulation running, not decoration, so it keeps going —
   but the camera flight is the part that actually causes trouble, and that
   stops. */
@media (prefers-reduced-motion: reduce) {
  .sw-card { animation: none; }
}
