/* ── Archive knowledge graph (/search) ──────────────────────────────────────
   Drawn by js/search-graph.js. Dots take their vertical's --vertical hue
   (tokens.css) through a data-vertical attribute, so the nine taxonomy colours
   stay in one place. Those hues are labels; house cyan (--accent) is kept for
   the one interactive state, the traced links of the dot under focus. */
.kgraph { margin: var(--space-6) 0 var(--space-7); }
.kgraph__title { font: var(--type-h2); color: var(--color-text-high); margin: 0 0 var(--space-2); }
.kgraph__dek { font: var(--type-caption); color: var(--color-text-muted); margin: 0; max-width: 46rem; }

.kgraph__legend { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-4) 0 var(--space-3); }
.kgraph__chip {
  display: inline-flex; align-items: center; gap: .45em; cursor: pointer;
  font: var(--type-meta); letter-spacing: .05em; text-transform: uppercase;
  color: var(--vertical-ink); background: none;
  border: 1px solid var(--color-hairline); border-radius: 999px; padding: .35em .8em;
}
.kgraph__chip::before { content: ""; width: .6em; height: .6em; border-radius: 50%; background: var(--vertical); }
.kgraph__chip:hover { border-color: var(--vertical); }
.kgraph__chip[aria-pressed="true"] { border-color: var(--vertical); box-shadow: inset 0 0 0 1px var(--vertical); }
.kgraph__chip:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.kgraph__stage {
  position: relative; height: clamp(420px, 72vh, 720px);
  background: var(--color-panel); border: 1px solid var(--color-hairline); border-radius: 6px;
  overflow: hidden;
}
/* Wider than the text column on big screens: a map wants room. */
@media (min-width: 900px) {
  .kgraph__stage {
    width: min(1180px, calc(100vw - 48px));
    margin-left: calc(50% - min(590px, 50vw - 24px));
    height: clamp(520px, 76vh, 760px);
  }
}
@media (max-width: 599px) { .kgraph__stage { height: clamp(420px, 120vw, 560px); } }
.kgraph__stage { background: radial-gradient(ellipse at 50% 45%, var(--color-panel), var(--color-ground)); }
/* Sideways drags turn the scene; vertical swipes still scroll the page. */
.kgraph__svg { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; user-select: none; }
.kgraph__svg.is-turning { cursor: grabbing; }

.kgraph__edge { stroke: var(--color-text-muted); stroke-opacity: .22; stroke-width: 1; transition: stroke-opacity .15s; }
.kgraph__edge.is-mutual { stroke-opacity: .38; stroke-width: 1.5; }

.kgraph__node { cursor: pointer; outline: none; }
.kgraph__node circle {
  fill: var(--vertical); stroke: var(--color-ground); stroke-width: 1.5;
  transition: opacity .15s, filter .15s;
}
.kgraph__node text {
  font: var(--type-meta); font-size: 11px; fill: var(--color-text-high);
  paint-order: stroke; stroke: var(--color-panel); stroke-width: 3px; stroke-linejoin: round;
  pointer-events: none; opacity: 0; transition: opacity .15s;
}
.kgraph__node.is-label text { opacity: .85; }

/* Vertical names, floating over their clusters on the overview. */
.kgraph__cat {
  font: var(--type-meta); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  fill: var(--vertical-ink); cursor: pointer;
  paint-order: stroke; stroke: var(--color-ground); stroke-width: 4px; stroke-linejoin: round;
}
.kgraph__cat:hover { text-decoration: underline; }
.kgraph__svg.is-drilled .kgraph__cat { font-size: 10px; fill-opacity: .45; }
.kgraph__svg.is-drilled .kgraph__cat.is-current { display: none; }

/* Something is focused, filtered or searched: everything else steps back. */
.kgraph__svg.is-dim .kgraph__node circle { opacity: .14; }
.kgraph__svg.is-dim .kgraph__node text { opacity: 0; }
.kgraph__svg.is-dim .kgraph__edge { stroke-opacity: .05; }
.kgraph__svg.is-dim .kgraph__node.is-lit circle { opacity: 1; }
.kgraph__svg.is-dim .kgraph__node.is-label text { opacity: .9; }
.kgraph__svg.is-dim .kgraph__edge.is-lit { stroke-opacity: .5; }
/* Inside a vertical: its own links read clearly; the ones that leave it stay
   drawn, quieter, out to the dots they land on. */
.kgraph__svg.is-dim .kgraph__node.is-out circle { opacity: .55; }
.kgraph__svg.is-dim .kgraph__edge.is-inner { stroke-opacity: .6; }
.kgraph__svg.is-dim .kgraph__edge.is-leaving { stroke-opacity: .28; stroke-dasharray: 3 3; }
.kgraph__svg .kgraph__edge.is-traced { stroke: var(--accent); stroke-opacity: .9; stroke-width: 1.5; }
.kgraph__node.is-focus circle { filter: drop-shadow(0 0 6px var(--vertical)); stroke: var(--color-text-high); }
.kgraph__node.is-focus text { opacity: 1 !important; }
.kgraph__node:focus-visible circle { stroke: var(--focus-ring); stroke-width: 2.5; }

.kgraph__tip {
  position: absolute; left: 0; top: 0; z-index: 2; max-width: 280px; pointer-events: none;
  background: var(--scrim); border: 1px solid var(--color-hairline); border-radius: 4px;
  padding: .55em .75em; opacity: 0; transition: opacity .12s;
}
.kgraph__tip.is-on { opacity: 1; }
.kgraph__tip-k { display: block; font: var(--type-meta); letter-spacing: .05em; text-transform: uppercase; color: var(--vertical-ink); }
.kgraph__tip-t { display: block; font: var(--type-ui); color: var(--color-text-high); margin: .2em 0; }
.kgraph__tip-m { display: block; font: var(--type-meta); color: var(--color-text-muted); }

.kgraph__crumb {
  position: absolute; left: var(--space-3); top: var(--space-3); z-index: 2;
  display: flex; align-items: center; gap: var(--space-3);
  font: var(--type-meta); letter-spacing: .05em; text-transform: uppercase;
}
.kgraph__crumb[hidden] { display: none; }
.kgraph__crumb-up {
  font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer;
  color: var(--color-text-high); background: var(--color-ground);
  border: 1px solid var(--color-hairline); border-radius: 4px; padding: .5em .8em;
}
.kgraph__crumb-up:hover { border-color: var(--accent); }
.kgraph__crumb-up:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.kgraph__crumb-here { color: var(--vertical-ink); }

.kgraph__zoom { position: absolute; right: var(--space-3); bottom: var(--space-3); display: flex; gap: var(--space-1); }
.kgraph__zoom button {
  min-width: 36px; height: 36px; padding: 0 .6em; cursor: pointer;
  font: var(--type-meta); font-size: .9rem; color: var(--color-text-high);
  background: var(--color-ground); border: 1px solid var(--color-hairline); border-radius: 4px;
}
.kgraph__zoom button:hover { border-color: var(--accent); }
.kgraph__zoom button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.kgraph__hint { font: var(--type-meta); color: var(--color-text-muted); margin: var(--space-2) 0 0; }

@media (prefers-reduced-motion: reduce) {
  .kgraph__edge, .kgraph__node circle, .kgraph__node text, .kgraph__tip { transition: none; }
}
