/* Topology graph (ClusterGraph): toolbar, canvas and cards. Shared by the
   Plower cluster workspace and the admin console's Graph tab. */
.topo-graph {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.topo-graph-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
}

.topo-graph-toolbar {
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.topo-graph-toolbar__actions {
  display: flex;
  gap: var(--space-1);
  margin-left: auto;
}

.topo-graph-stage {
  position: relative;
  height: clamp(30rem, calc(100dvh - 18rem), 42rem);
}

/* GraphCanvas positions itself (relative) and hides its outline inline. */
.topo-graph-canvas {
  height: 100%;
  background: var(--bg);
}

.topo-graph-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* World coordinates: wide enough for any layout; overflow stays visible. */
.topo-graph-edges {
  position: absolute;
  inset: 0;
  width: 2400px;
  height: 1800px;
  overflow: visible;
  pointer-events: none;
}

.topo-graph-edge {
  stroke: var(--line-strong);
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* Card geometry mirrors NODE_HEIGHT and TOPOLOGY_* in the Rust layout. */
.topo-graph-canvas .sv-graph-node {
  min-height: 172px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  color: var(--text);
  box-shadow: none;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.topo-graph-canvas .sv-graph-node:hover {
  border-color: var(--line-strong);
}

.topo-graph-canvas .sv-graph-node:focus {
  outline: none;
}

.topo-graph-canvas .sv-graph-node:focus-visible,
.topo-graph-canvas .sv-graph-node-selected {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.topo-graph-canvas .sv-graph-node-title {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-10) 0 var(--space-3);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
}

.topo-graph-canvas .sv-graph-node-icon,
.topo-graph-canvas .sv-graph-node-status {
  display: none;
}

.topo-graph-canvas .sv-graph-node-identity {
  min-width: 0;
}

.topo-graph-canvas .sv-graph-node-identity strong {
  display: block;
  overflow: hidden;
  font-weight: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topo-graph-canvas .sv-graph-node-body {
  padding: 0;
}

.topo-topology-node {
  position: relative;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3);
}

.topo-node-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-12);
}

.topo-node-primary {
  overflow: hidden;
  color: var(--text-dim);
  font-size: var(--text-12);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topo-node-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.topo-node-facts > div {
  min-width: 0;
}

.topo-node-facts dt {
  color: var(--text-dim);
  font-size: var(--text-11);
}

.topo-node-facts dd {
  overflow: hidden;
  font-size: var(--text-12);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Where edges attach; top matches TOPOLOGY_PORT_Y (42px title + 64px). */
.topo-readonly-handle {
  position: absolute;
  top: 64px;
  width: 10px;
  height: 10px;
  transform: translateY(-50%);
  border: 2px solid var(--bg-raised);
  border-radius: var(--radius-full);
  background: var(--line-strong);
}

.topo-readonly-handle--input {
  left: -6px;
}

.topo-readonly-handle--output {
  right: -6px;
}

/* Sits in the GraphNode title bar, above the card body. */
.topo-node-inspect {
  position: absolute;
  top: calc(-1 * (42px - var(--space-1)));
  right: var(--space-1);
}

.topo-graph-inspector {
  position: absolute;
  z-index: 4;
  top: var(--space-3);
  right: var(--space-3);
  width: min(20rem, calc(100% - 2 * var(--space-3)));
  padding: var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-popover);
}

.topo-graph-inspector__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.topo-graph-inspector__heading {
  min-width: 0;
}

.topo-graph-inspector__kind {
  color: var(--text-dim);
  font-size: var(--text-12);
}

.topo-graph-inspector__title {
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: var(--text-13);
  font-weight: var(--weight-medium);
}

.topo-graph-inspector__details > div {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--text-12);
}

.topo-graph-inspector__details > div:last-child {
  border-bottom: 0;
}

.topo-graph-inspector__details dt {
  color: var(--text-dim);
}

.topo-graph-inspector__details dd {
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.topo-graph-empty {
  position: absolute;
  left: 50%;
  bottom: var(--space-12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  width: max-content;
  max-width: calc(100% - 2 * var(--space-6));
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: var(--text-13);
  text-align: center;
  pointer-events: none;
}

.topo-graph-empty strong {
  color: var(--text);
  font-weight: var(--weight-medium);
}

.topo-graph-hint {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: var(--text-12);
}
