/* Ratchet Atlas — cartographic intelligence-console chrome around the D3 viewport.
   Shared /tech design-system tokens scoped to .atlas-doc (same convention as
   revolving-door / ai-abuse-registry). The force graph is the hero; the chrome is
   a map plate: graticule ground, tick ruler on the top edge, a margin band at the
   frame's foot carrying the key + live survey readout, and a dossier panel.
   Semantic accents: RED = money (funding edges, funding toggle);
   AMBER = cohort annotation (cluster hulls, cluster chips, method-receipt tags).
   Node/hull/link classes are painted by atlas.js — style only, never rename.
   Motion budget: the tech-kit LED blink is the one motion moment; everything else
   is hover/dim transitions only, killed under reduced-motion. */

.atlas-doc {
  /* shared /tech design-system tokens */
  --ground: #0C0C0F;
  --panel: #14141A;
  --panel2: #1B1B22;
  --line: #2A2A33;
  --text: #E6E4DE;
  --muted: #84838F;
  --red: #CC0000;
  --amber: #E8A33D;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  color: var(--text);
}

/* Display register: mono, uppercase, tracked — scoped so the shared kit
   stays untouched for the other demos. */
.atlas-doc .tk-title {
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: clamp(1.6rem, 4.2vw, 2.4rem);
  color: var(--text);
}
.atlas-doc .tk-sub { color: var(--muted); }

/* ── Standing rule: method, not verdict ──────────────────── */
.atlas-disc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  padding: 0.65rem 1rem;
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #b9b7b1;
}
.atlas-disc strong {
  font-family: var(--mono);
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text);
}
.atlas-disc em { color: var(--text); }

/* ── Control deck: one rack, hairline rows ───────────────── */
.atlas-deck {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 0.9rem;
}
.atlas-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem;
}
.atlas-toolbar + .atlas-toolbar { border-top: 1px solid var(--line); }
.atlas-clabel {
  font-family: var(--mono);
  font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.5rem;
  white-space: nowrap;
}

.atlas-chip {
  font-family: var(--mono);
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--ground);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.atlas-chip:hover { color: var(--text); border-color: var(--muted); }
.atlas-chip:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* sector chips start lit; .off is the dimmed state. atlas.js reset can leave
   both classes on a chip, so .on must win — keep it after .off. */
.atlas-chip.off { opacity: 0.32; }
.atlas-chip.on { opacity: 1; color: var(--text); border-color: #3A3A46; }
/* cluster chips = cohort annotation = amber */
#atlas-clusters .atlas-chip.on {
  color: var(--amber); border-color: var(--amber);
  background: rgba(232, 163, 61, 0.08);
}
/* funding toggle = money = red */
#atlas-funding.on {
  color: var(--text); border-color: var(--red);
  background: rgba(204, 0, 0, 0.12);
}
#atlas-reset { color: var(--amber); border-color: #5a3f18; }
#atlas-reset:hover { border-color: var(--amber); }

/* sector swatch injected by atlas.js — mirrors the node encoding (circle) */
.atlas-chip .sw {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: 0;
}

.atlas-search {
  font-family: var(--mono);
  font-size: 0.74rem;
  background: var(--ground);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.3rem 0.65rem;
  width: 200px; max-width: 100%;
  margin-left: auto;
  outline: none;
}
.atlas-search:focus { border-color: var(--amber); }
.atlas-search::placeholder { color: #5c5b66; }

/* ── Stage: map plate (hero) + dossier ───────────────────── */
.atlas-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0.9rem;
  align-items: start;
}

/* The plate: graticule over recessed glass, survey ticks on the top edge. */
.atlas-canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background-color: #0A0A0D;
  background-image:
    radial-gradient(1000px 520px at 50% 40%, rgba(27, 27, 34, 0.5), transparent 70%),
    linear-gradient(rgba(42, 42, 51, 0.30) 1px, transparent 1px),
    linear-gradient(90deg, rgba(42, 42, 51, 0.30) 1px, transparent 1px);
  background-size: auto, 72px 72px, 72px 72px;
}
.atlas-canvas-wrap::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 6px;
  background: repeating-linear-gradient(90deg,
    rgba(132, 131, 143, 0.35) 0 1px, transparent 1px 24px);
  pointer-events: none;
  z-index: 2;
}
.atlas-canvas {
  width: 100%;
  height: 600px;
  display: block;
  cursor: grab;
}
.atlas-canvas:active { cursor: grabbing; }

/* Margin band at the plate's foot: key + live survey readout. */
.atlas-key {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.9rem;
  border-top: 1px solid var(--line);
  background: var(--ground);
  padding: 0.4rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted);
}
.atlas-key-item { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.atlas-key-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; flex: 0 0 auto;
}
.atlas-key-dot.filled { background: var(--muted); }
.atlas-key-dot.hollow { background: var(--ground); border: 2px solid var(--muted); }
.atlas-key-edge {
  width: 16px; height: 0;
  border-top: 2px solid var(--red);
  display: inline-block; flex: 0 0 auto;
}
.atlas-stat {
  margin-left: auto;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

/* ── Dossier panel (atlas.js owns #atlas-side innerHTML) ─── */
.atlas-side-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  position: sticky;
  top: 1rem;
  display: flex;
  flex-direction: column;
  max-height: 636px;
}
.atlas-side-head {
  font-family: var(--mono);
  font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
  background: var(--ground);
  padding: 0.5rem 0.9rem;
  border-bottom: 1px solid var(--line);
}
.atlas-side {
  padding: 0.8rem 0.9rem;
  overflow-y: auto;
  flex: 1 1 auto;
  font-size: 0.8rem;
}
.atlas-side-empty { color: var(--muted); font-style: italic; line-height: 1.55; }
.atlas-side-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 0.3rem;
}
.atlas-side-kind {
  font-family: var(--mono);
  font-size: 0.6rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
}
.atlas-side-role {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.6;
  color: #c2c0ba;
  margin-bottom: 0.6rem;
}
.atlas-side h4 {
  font-family: var(--mono);
  font-size: 0.6rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--red);
  margin: 0.85rem 0 0.4rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}
.atlas-fp { font-size: 0.78rem; color: #c2c0ba; line-height: 1.6; word-break: break-word; }
.atlas-fp a { color: var(--text); text-decoration-color: rgba(230, 228, 222, 0.25); }
.atlas-fp a:hover { color: var(--red); }

/* method receipts: the verbatim evidence cards */
.atlas-rcpt {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  padding: 0.5rem 0.65rem;
  margin: 0.4rem 0;
}
.atlas-rcpt .mk {
  font-family: var(--mono);
  font-size: 0.56rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--amber);
  border: 1px solid #5a3f18;
  padding: 0.05rem 0.35rem;
  display: inline-block;
}
.atlas-rcpt .sp {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0.35rem 0 0.15rem;
}
.atlas-rcpt a {
  font-family: var(--mono);
  font-size: 0.64rem;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: rgba(230, 228, 222, 0.25);
  text-underline-offset: 2px;
}
.atlas-rcpt a:hover { color: var(--red); text-decoration-color: var(--red); }

.atlas-src {
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1.55;
  margin: 0.25rem 0;
  word-break: break-all;
}
.atlas-src a {
  color: #a8a6b0;
  text-decoration: underline;
  text-decoration-color: rgba(230, 228, 222, 0.25);
  text-underline-offset: 2px;
}
.atlas-src a:hover { color: var(--red); text-decoration-color: var(--red); }
.atlas-side a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* cluster summary card (grouping of influence) */
.atlas-csum {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  color: #c2c0ba;
  line-height: 1.6;
  margin-bottom: 0.7rem;
}
.atlas-profile-link {
  display: inline-block;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--red);
  font-weight: 700;
}

/* ── SVG layers (classes owned by atlas.js) ──────────────── */
.atlas-node { cursor: pointer; }
.atlas-link { stroke: #303039; stroke-width: 1; }
.atlas-link.fund { stroke: var(--red); stroke-width: 1.8; stroke-opacity: 0.85; }
/* labels: mono + dark halo so sector-colored fills from atlas.js stay legible
   over edges (no fill here — the JS per-node fill must win) */
.atlas-label {
  pointer-events: none;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  paint-order: stroke;
  stroke: rgba(10, 10, 13, 0.85);
  stroke-width: 2.5px;
  stroke-linejoin: round;
}
/* cohort hull = amber annotation (money stays red) */
.atlas-hull {
  fill: rgba(232, 163, 61, 0.06);
  stroke: var(--amber);
  stroke-width: 1.2;
  stroke-dasharray: 6 5;
  pointer-events: none;
}
.atlas-dim { opacity: 0.1; }
.atlas-node, .atlas-link, .atlas-label { transition: opacity 0.15s; }

/* ── How to read this ────────────────────────────────────── */
.atlas-help {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  padding: 0.7rem 1rem;
  margin-top: 0.9rem;
  font-size: 0.78rem;
  color: #b9b7b1;
  line-height: 1.6;
}
.atlas-help strong { color: var(--text); }

@media (max-width: 900px) {
  .atlas-stage { grid-template-columns: 1fr; }
  .atlas-side-shell { position: static; max-height: 420px; }
  .atlas-search { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .atlas-chip, .atlas-node, .atlas-link, .atlas-label { transition: none; }
}
