/* The graph pane (graph-pane.js): the Graph view, its header, legend,
   search and stage, for any host that shows one. A host links it after
   style.css, whose tokens (--graph-*, --bg, --border, ...) it uses: the Web
   Shell (index.html), the console (web/console/) and the e2e test's pane
   host. A host lays the pane out itself; these rules give it the shell's
   look, beside what it sits by, and under it on a phone. */

/* Beside the terminal, half the width; under it on a phone. ursa-viz draws
   in the --graph-* colours, ink on white by day and starlight on the sky by
   night: switching the theme recolours an open view (graph.js). */
.graph-pane {
  flex: 1 1 50%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg);
}
.graph-pane[hidden] { display: none; }
.graph-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 6px 0 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.graph-status {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
/* The legend: what sizes the nodes, and each colour named, in text. */
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  padding: 6px 14px 7px;
  border-bottom: 1px solid var(--border);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
}
.graph-legend[hidden] { display: none; }
.graph-legend .key { color: var(--fg); }
.graph-legend ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.graph-legend li { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.graph-legend .swatch {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--graph-other);
}
.graph-legend .count { color: var(--muted); }
.graph-legend .size-key { display: inline-flex; align-items: center; gap: 4px; }
.graph-legend .dot { display: inline-block; border-radius: 50%; background: var(--graph-node); }
.graph-legend .dot.small { width: 4px; height: 4px; }
.graph-legend .dot.large { width: 11px; height: 11px; }
.swatch.c0 { background: var(--graph-c0); }
.swatch.c1 { background: var(--graph-c1); }
.swatch.c2 { background: var(--graph-c2); }
.swatch.c3 { background: var(--graph-c3); }
.swatch.c4 { background: var(--graph-c4); }
.swatch.c5 { background: var(--graph-c5); }
.swatch.c6 { background: var(--graph-c6); }
.swatch.c7 { background: var(--graph-c7); }
.graph-close {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 6px;
  color: var(--fg);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.graph-close svg { width: 18px; height: 18px; display: block; }
.graph-close:hover { color: var(--prompt); }
.graph-close:focus-visible, .graph-stage canvas:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Search (/): the box takes the status line's place while it is open
   (graph-search.js); under the header, the matches that are not shown. */
.graph-search { flex: 1; min-width: 0; display: flex; }
.graph-search[hidden] { display: none; }
.graph-search input {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.graph-search input:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.graph-found {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 6px 6px 7px 14px;
  border-bottom: 1px solid var(--border);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
}
.graph-found[hidden] { display: none; }
.graph-found ul { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; padding: 0; list-style: none; flex: 1; min-width: 0; }
.graph-found li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.graph-found .key { color: var(--fg); }
.graph-found button {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: none;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.graph-found button:hover { color: var(--prompt); }
.graph-found button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.graph-found .dismiss { border: 0; font-size: 15px; line-height: 1; padding: 2px 6px; }
.graph-stage { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.graph-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
.graph-stage canvas.over-node { cursor: pointer; }
.graph-stage canvas:active { cursor: grabbing; }
/* The hovered node's tooltip: beside it, and never in the pointer's way. */
.graph-tip {
  position: absolute;
  z-index: 1;
  max-width: min(280px, 80%);
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.18);
}
.graph-tip[hidden] { display: none; }
.graph-tip div { overflow: hidden; text-overflow: ellipsis; }
.graph-tip .key { color: var(--muted); }
.graph-tip .id { font-weight: 600; }
/* A group's label in the aggregated view: how many nodes its disc stands for. */
.graph-group {
  position: absolute;
  z-index: 1;
  transform: translate(-50%, -50%);
  padding: 0 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  color: var(--fg);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
}
.graph-group[hidden] { display: none; }
/* The busy ring: over a node whose command (.expand) is running or queued. */
.graph-busy {
  position: absolute;
  z-index: 1;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  box-sizing: border-box;
  border: 2px dashed var(--graph-selection);
  border-radius: 50%;
  pointer-events: none;
  animation: graph-busy 1.2s linear infinite;
}
.graph-busy[hidden] { display: none; }
@keyframes graph-busy { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .graph-busy { animation: none; }
}

/* A phone: the pane under what it sits beside. */
@media (max-width: 640px) {
  .graph-pane { border-left: 0; border-top: 1px solid var(--border); }
}
