/* Datenquellen-Graph · Habitué tokens (defined in styles.css :root).
   Categories use palette colours only: sources = Anthrazit weich, memory = Bordeaux,
   use at work = Salbei (recorded, «belegt»), tools = Ocker. */

.connections-section {
  --cg-data: var(--ink-soft);
  --cg-data-bg: var(--surface-2);
  --cg-memory: var(--bordeaux);
  --cg-memory-bg: var(--bordeaux-light);
  --cg-work: var(--sage-text);
  --cg-work-bg: var(--sage-bg);
  --cg-tool: var(--ochre);
  --cg-tool-bg: var(--ochre-bg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 26px;
  margin-bottom: 24px;
  container-type: inline-size;
}

.cg-heading h2 { font-size: 24px; letter-spacing: -0.025em; }
.cg-heading p { font-size: 14px; color: var(--ink-soft); margin-top: 8px; max-width: 720px; }

.cg-legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin: 17px 0;
  font-size: 12px;
  color: var(--ink-soft);
}
.cg-legend > span { display: inline-flex; align-items: center; gap: 7px; }
.cg-dot { height: 9px; width: 9px; border-radius: 50%; }
.cg-data { background: var(--cg-data); }
.cg-memory { background: var(--cg-memory); }
.cg-work { background: var(--cg-work); }

.cg-selection {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
  font-size: 14px;
}
.cg-selection-copy { min-width: 0; overflow-wrap: anywhere; }
.cg-selection strong { font-weight: 600; }
.cg-selection p { margin-top: 5px; color: var(--ink-soft); }
.cg-selection .cg-process { font-size: 13px; color: var(--ink-soft); }
.cg-selection .cg-related { font-size: 13px; color: var(--ink-soft); }
.cg-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex-shrink: 0;
  max-width: 170px;
  justify-content: end;
}

.cg-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) minmax(0, 1.16fr);
  gap: 36px;
  align-items: start;
}
.cg-column { min-width: 0; position: relative; z-index: 1; }
.cg-column-label { margin-bottom: 14px; min-height: 43px; font-size: 14px; }
.cg-column-label b { font-weight: 600; }
.cg-column-label small { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.cg-node-list { display: grid; gap: 10px; }
.cg-stage-list { display: grid; padding-top: 84px; gap: 72px; }
.cg-node-wrap { min-width: 0; --cg-color: var(--cg-data); --cg-bg: var(--cg-data-bg); }
.cg-stages { --cg-color: var(--cg-memory); --cg-bg: var(--cg-memory-bg); }
.cg-uses { --cg-color: var(--cg-work); --cg-bg: var(--cg-work-bg); }

.cg-node {
  display: flex;
  gap: 9px;
  align-items: start;
  width: 100%;
  min-height: 72px;
  padding: 12px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: left;
  background: var(--cg-bg);
  color: var(--ink);
  transition: background-color 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.cg-node:hover { border-color: color-mix(in srgb, var(--cg-color) 45%, transparent); }
.cg-node[aria-pressed="true"] {
  border-color: var(--cg-color);
  box-shadow: 0 0 0 1px var(--cg-color);
  background: color-mix(in srgb, var(--cg-color) 12%, var(--surface));
}
.cg-node:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.cg-unrelated .cg-node { background: color-mix(in srgb, var(--cg-bg) 40%, var(--surface)); }

.cg-emblem {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--cg-color);
  background: color-mix(in srgb, var(--cg-color) 12%, transparent);
}
.cg-emblem svg { height: 21px; width: 21px; stroke-width: 1.8; }
.cg-node-text { display: flex; flex-direction: column; gap: 7px; min-width: 0; flex: 1; }
.cg-node-label { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.cg-caption { font-size: 12px; color: var(--ink-soft); overflow-wrap: anywhere; line-height: 1.45; }

.cg-stages .cg-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 10px;
  border-radius: 16px;
  min-height: 137px;
}
.cg-stages .cg-emblem { height: 46px; width: 46px; flex-basis: 46px; margin-bottom: 5px; }
.cg-stages .cg-emblem svg { width: 27px; height: 27px; }
.cg-stages .cg-node-text { width: 100%; }

.cg-lines {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}
.cg-reference { margin-top: 20px; color: var(--ink-soft); font-size: 13px; max-width: 850px; }
.source-inventory-heading { margin: 26px 0 16px; }

@container (max-width: 669px) {
  .cg-layout { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 0 17px; }
  .cg-stage-list { padding-top: 0; gap: 26px; margin: 0 24px; }
  .cg-column-label { min-height: auto; }
  .cg-selection { flex-direction: column; }
  .cg-selection-actions { max-width: none; justify-content: start; }
  .cg-heading h2 { font-size: 21px; }
  .cg-node { min-height: 70px; }
  .cg-stages .cg-node { min-height: 125px; }
}

@media (max-width: 600px) {
  .connections-section { padding: 16px; }
  .cg-legend { gap: 10px 14px; }
  .cg-selection { padding: 12px; }
}

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

/* Mode switch (Gedächtnis / Werkzeuge) */
.cg-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.cg-mode-switch button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}
.cg-mode-switch button:hover { background: var(--surface-2); color: var(--ink); }
.cg-mode-switch button svg { width: 17px; height: 17px; }
.cg-mode-switch button[aria-pressed="true"] {
  background: var(--bordeaux);
  color: #FFFFFF;
  border-color: var(--bordeaux);
}
.cg-mode-switch button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* Tools graph */
.cg-tool { background: var(--cg-tool); }
.cg-tools { --cg-color: var(--cg-tool); --cg-bg: var(--cg-tool-bg); }
.tg-layout {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.07fr) minmax(0, 1fr);
  gap: 34px;
}
.tg-evidence-key {
  display: flex;
  gap: 9px 22px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-soft);
  margin: -2px 0 18px;
}
.tg-evidence-key > span { display: flex; align-items: center; gap: 8px; }
.tg-line { width: 25px; height: 0; border-top: 2px solid var(--cg-work); }
.tg-dashed { border-top-style: dashed; border-color: var(--cg-data); }
.tg-selection { background: var(--cream-tint); }
.tg-layout .cg-node { min-height: 78px; }
.tg-layout .cg-unrelated .cg-node { opacity: 0.57; }
.tg-missing { --cg-color: var(--ink-soft); --cg-bg: var(--bg); }
.tg-missing .cg-node { border: 1px dashed var(--line-strong); }
.tg-missing .cg-caption { color: var(--ink-soft); }
.tg-source-note {
  margin-top: 22px;
  padding: 15px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--ink-soft);
}
.tg-source-note p { margin-top: 6px; overflow-wrap: anywhere; }
.tg-source-note strong { color: var(--ink); }

@container (max-width: 669px) {
  .tg-layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .cg-mode-switch button { flex: 1; justify-content: center; padding: 8px 10px; font-size: 13px; }
  .tg-evidence-key { font-size: 11px; }
}
