/* Revolving Door Map — intelligence-console chrome around the sigma.js viewport.
   Shared /tech design-system tokens scoped to .rd-doc (same convention as
   ai-abuse-registry). The WebGL graph is the hero; the chrome stays quiet:
   one control deck with a label rail, a targeting-bracket viewport with a
   live HUD readout, and a dossier panel that pins receipts.
   Sector hexes below mirror graph.js sectorColor exactly — change together.
   Motion budget: the tech-kit LED blink is the one motion moment — nothing
   here animates. Hover/focus transitions only, killed under reduced-motion. */

[x-cloak] { display: none !important; }

.rd-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 type: monospace, uppercase, tracked — scoped so the shared kit
   stays untouched for the other demos. */
.rd-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);
}
.rd-doc .tk-sub { color: var(--muted); }

/* Body register inside the console is system sans; mono is reserved for
   labels, data, and receipts. (The markdown body renders outside .rd-wrap.) */
.rd-wrap {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  margin: 1.5rem 0;
}

/* ── Control deck: one rack, hairline rows, label rail ───── */
.rd-deck {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 0.9rem;
}
.rd-toolbar { display: flex; align-items: stretch; }
.rd-toolbar + .rd-toolbar { border-top: 1px solid var(--line); }
.rd-toolbar-label {
  flex: 0 0 6.4rem;
  display: flex; align-items: center;
  padding: 0.5rem 0.8rem;
  border-right: 1px solid var(--line);
  background: var(--ground);
  font-family: var(--mono);
  font-size: 0.62rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
}
.rd-chips {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.7rem;
}

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

/* Sector on-states carry the graph's own node colors (mirror graph.js). */
.rd-chip-gov.on   { color: #88ccff; border-color: #88ccff; background: rgba(136,204,255,.10); }
.rd-chip-fin.on   { color: #ffb000; border-color: #ffb000; background: rgba(255,176,0,.10); }
.rd-chip-imf.on   { color: #b388ff; border-color: #b388ff; background: rgba(179,136,255,.10); }
.rd-chip-cfr.on   { color: var(--red); border-color: var(--red); background: rgba(204,0,0,.10); }
.rd-chip-tank.on  { color: #4dd07a; border-color: #4dd07a; background: rgba(77,208,122,.10); }
.rd-chip-intel.on { color: #ff7a3a; border-color: #ff7a3a; background: rgba(255,122,58,.10); }
.rd-chip-def.on   { color: #aaaaaa; border-color: #aaaaaa; background: rgba(170,170,170,.10); }
.rd-chip-tech.on  { color: #7df9ff; border-color: #7df9ff; background: rgba(125,249,255,.10); }
.rd-chip-multi.on { color: #a05fff; border-color: #a05fff; background: rgba(160,95,255,.10); }
.rd-chip-jud.on   { color: #dca64a; border-color: #dca64a; background: rgba(220,166,74,.10); }
.rd-chip-aca.on   { color: #5fd0c0; border-color: #5fd0c0; background: rgba(95,208,192,.10); }
.rd-chip-med.on   { color: #e58fc0; border-color: #e58fc0; background: rgba(229,143,192,.10); }
.rd-chip-lab.on   { color: #d6b85f; border-color: #d6b85f; background: rgba(214,184,95,.10); }
.rd-chip-occ.on   { color: #9b6bd6; border-color: #9b6bd6; background: rgba(155,107,214,.10); }
/* The two state clusters are deliberately dark on the map; lift the chip
   text for legibility and let the border/tint carry the node color. */
.rd-chip-chn.on   { color: var(--text); border-color: #8b0000; background: rgba(139,0,0,.25); }
.rd-chip-rus.on   { color: var(--text); border-color: #566573; background: rgba(86,101,115,.22); }

.rd-chip-net.on  { color: var(--text); border-color: var(--red); background: rgba(204,0,0,.08); }
.rd-chip-kind.on { color: var(--text); border-color: var(--muted); background: var(--panel2); }
.rd-chip-reset   { margin-left: 0; color: var(--amber); border-color: #5a3f18; }
.rd-chip-reset:hover { color: var(--amber); border-color: var(--amber); }

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

/* ── Stage: viewport (hero) + dossier panel ──────────────── */
.rd-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 0.9rem;
  align-items: start;
}
.rd-canvas-wrap {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  border: 1px solid var(--line);
  /* recessed console glass: faint center glow over a dot grid */
  background-color: #0A0A0D;
  background-image:
    radial-gradient(1100px 550px at 50% 38%, rgba(27, 27, 34, 0.55), transparent 70%),
    radial-gradient(rgba(42, 42, 51, 0.5) 1px, transparent 1.4px);
  background-size: auto, 26px 26px;
}
/* targeting brackets, amber, static */
.rd-canvas-wrap::before,
.rd-canvas-wrap::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border: 0 solid rgba(232, 163, 61, 0.55);
  pointer-events: none;
  z-index: 2;
}
.rd-canvas-wrap::before { top: 8px; left: 8px; border-top-width: 1px; border-left-width: 1px; }
.rd-canvas-wrap::after  { bottom: 8px; right: 8px; border-bottom-width: 1px; border-right-width: 1px; }

.rd-canvas {
  display: block;
  width: 100%;
  height: 600px;
  cursor: grab;
}
.rd-canvas:active { cursor: grabbing; }

/* live readout, top-right of the viewport */
.rd-hud {
  position: absolute;
  top: 0.6rem; right: 0.75rem;
  z-index: 2;
  pointer-events: none;
  font-family: var(--mono);
  font-size: 0.64rem; letter-spacing: 0.16em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  background: rgba(12, 12, 15, 0.72);
  border: 1px solid var(--line);
  padding: 0.28rem 0.6rem;
}

/* ── Dossier panel ───────────────────────────────────────── */
.rd-side {
  background: var(--panel);
  border: 1px solid var(--line);
  position: sticky;
  top: 1rem;
  font-size: 0.8rem;
}
.rd-side-title {
  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);
}
.rd-side-title.pinned { color: var(--amber); }
.rd-side-body { padding: 0.8rem 0.9rem; }
.rd-side-empty {
  color: var(--muted);
  font-style: italic;
  line-height: 1.55;
}
.rd-side-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.rd-side-sector {
  font-family: var(--mono);
  font-size: 0.62rem; letter-spacing: 0.18em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.rd-side-role {
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.6;
  color: #c2c0ba;
}
.rd-side-sources {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}
.rd-side-sources-title {
  font-family: var(--mono);
  font-size: 0.6rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.rd-src-type {
  font-family: var(--mono);
  font-size: 0.56rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--amber);
  border: 1px solid #5a3f18;
  padding: 0.05rem 0.3rem;
  margin-right: 0.35rem;
  white-space: nowrap;
}
.rd-side-source {
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.55;
  margin-bottom: 0.3rem;
  word-break: break-all;
}
.rd-side-source a {
  color: #a8a6b0;
  text-decoration: underline;
  text-decoration-color: rgba(230, 228, 222, 0.25);
  text-underline-offset: 2px;
}
.rd-side-source a:hover { color: var(--red); text-decoration-color: var(--red); }
.rd-side-source a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.rd-side-unpin {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 0.7rem;
}

/* ── Key (sector legend) — dots mirror graph.js sectorColor ─ */
.rd-legend {
  border-top: 1px solid var(--line);
  padding: 0.7rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.rd-legend-title {
  font-family: var(--mono);
  font-size: 0.6rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.rd-legend-row {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: #c2c0ba;
}
.rd-legend-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  border: 1px solid var(--line);
}
.rd-legend-dot.dot-gov    { background: #88ccff; }
.rd-legend-dot.dot-fin    { background: #ffb000; }
.rd-legend-dot.dot-imf    { background: #b388ff; }
.rd-legend-dot.dot-cfr    { background: var(--red); }
.rd-legend-dot.dot-tank   { background: #4dd07a; }
.rd-legend-dot.dot-intel  { background: #ff7a3a; }
.rd-legend-dot.dot-def    { background: #aaaaaa; }
.rd-legend-dot.dot-tech   { background: #7df9ff; }
.rd-legend-dot.dot-multi  { background: #a05fff; }
.rd-legend-dot.dot-jud    { background: #dca64a; }
.rd-legend-dot.dot-aca    { background: #5fd0c0; }
.rd-legend-dot.dot-med    { background: #e58fc0; }
.rd-legend-dot.dot-lab    { background: #d6b85f; }
.rd-legend-dot.dot-occ    { background: #9b6bd6; }
.rd-legend-dot.dot-china  { background: #8b0000; }
.rd-legend-dot.dot-russia { background: #566573; }
.rd-legend-dot.dot-person { background: var(--ground); border-color: var(--text); }

/* ── Notes: cluster hook + how-to ────────────────────────── */
.rd-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;
}
.rd-help strong { color: var(--text); }
.rd-hook { margin: 0 0 0.9rem; border-left-color: var(--amber); }
.rd-hook strong {
  font-family: var(--mono);
  font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--amber);
}

@media (max-width: 900px) {
  .rd-stage { grid-template-columns: 1fr; }
  .rd-side { position: static; }
  .rd-toolbar-label { flex-basis: 4.8rem; padding: 0.5rem 0.55rem; }
  .rd-search { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .rd-chip { transition: none; }
}
