/* ==========================================================================
   Reverse – Evidenzanalyse, Befunde, Graph, Vergleich, Artefakte, Connector
   Nutzt ausschließlich die Tokens aus variables.css (blaue statt roter Akzente).
   ========================================================================== */

:root {
    /* Status der Befunde */
    --ev-observed: var(--color-accent);
    --ev-observed-soft: var(--color-accent-soft);
    --ev-derived: #9a8fd6;
    --ev-derived-soft: rgba(154, 143, 214, 0.14);
    --ev-unknown: var(--color-text-muted);
    --ev-unknown-soft: var(--color-inset);

    /* Knotentypen im Graphen (gedämpft, gut unterscheidbar) */
    --gt-page: #5b8fd9;
    --gt-subpage: #7aa7e6;
    --gt-script: #e0b072;
    --gt-stylesheet: #82c4e0;
    --gt-file: #8389a8;
    --gt-module: #c7a96b;
    --gt-function: #b8a3e8;
    --gt-external: #6f7591;
    --gt-host: #d98b6b;
    --gt-endpoint: #48a878;
    --gt-request: #6cc4a0;
    --gt-library: #c792ea;
    --gt-package: #a58fd0;
    --gt-binary: #d7a34b;
    --gt-form: #e6c27a;
    --graph-edge: #3a3f4c;
    --graph-edge-active: var(--color-accent);
}
:root[data-theme="light"] {
    --ev-derived: #6a5bb5;
    --ev-derived-soft: rgba(106, 91, 181, 0.12);
    --graph-edge: #c3c8d3;
    --gt-file: #596079;
    --gt-external: #8a90a6;
}

/* ---------- Badges ---------- */
.badge.ev-observed { background: var(--ev-observed-soft); color: var(--ev-observed); }
.badge.ev-derived { background: var(--ev-derived-soft); color: var(--ev-derived); border: 1px dashed currentColor; padding: 3px 6px; }
.badge.ev-unknown { background: var(--ev-unknown-soft); color: var(--ev-unknown); border: 1px dotted currentColor; padding: 3px 6px; }
.badge.ev-conf-high { background: var(--color-success-soft); color: var(--color-success); }
.badge.ev-conf-medium { background: var(--color-warning-soft); color: var(--color-warning); }
.badge.ev-conf-low { background: var(--color-inset); color: var(--color-text-muted); }
.badge.ev-rel-high { background: var(--color-accent-soft); color: var(--color-accent); }
.badge.ev-rel-medium { background: var(--color-inset); color: var(--color-text-body); }
.badge.ev-rel-low { background: var(--color-inset); color: var(--color-text-faint); }

/* ---------- Layout ---------- */
.ev-tabs { max-width: 100%; overflow-x: auto; }
.ev-tabs .nav-count { margin-left: 6px; }
.ev-content { min-width: 0; container-type: inline-size; }
.ev-split {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
    gap: var(--space-6);
    align-items: start;
}
.ev-split > .panel { max-height: calc(100vh - var(--topbar-height) - var(--footer-height) - 150px); min-height: 320px; display: flex; flex-direction: column; }
.ev-split .col-scroll { flex: 1; overflow: auto; }
.ev-detail { overflow: auto; }
.ev-filters { gap: var(--space-2); }
.ev-filters .input { width: 220px; max-width: 100%; }
.ev-table td { vertical-align: top; }
.ev-title { color: var(--color-text); font-weight: 600; display: block; }
.ev-explain + .ev-explain { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-border-subtle); }
.ev-explain h3 { font-size: var(--text-md); margin: 0 0 var(--space-2); display: flex; align-items: center; gap: var(--space-2); }
.ev-steps { margin: 0; padding: 0; }
.ev-progress { height: 6px; background: var(--color-inset); border-radius: var(--radius-pill); overflow: hidden; }
.ev-progress > span { display: block; height: 100%; background: var(--color-accent); transition: width var(--transition); }
.ev-legend { padding: 0; }
.ev-legend > summary { padding: var(--space-4) var(--space-5); }
.ev-compare-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.ev-diff-list { max-height: 320px; overflow: auto; padding-left: 1.2em; }
.ev-diff-list li { margin-bottom: 4px; }
.ev-support li { margin-bottom: 6px; }
.ev-facts { max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.stat-card-btn { border: 0; cursor: pointer; font: inherit; color: inherit; text-align: left; width: 100%; }
.stat-card-btn:hover { background: var(--color-surface-elevated); }
.stat-card-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.link-btn {
    background: none; border: 0; padding: 0; font: inherit; color: var(--color-accent); cursor: pointer; text-align: left;
    display: inline-flex; align-items: center; gap: 4px;
}
.link-btn:hover { color: var(--color-accent-hover); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 2px; }

/* ---------- Graph ---------- */
.graph-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: var(--space-6);
    align-items: stretch;
}
.graph-main { display: flex; flex-direction: column; min-height: 520px; }
.graph-main .panel-toolbar .input { width: 220px; max-width: 100%; }
.graph-stage { position: relative; flex: 1; min-height: 440px; background: var(--color-inset); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.graph-svg { width: 100%; height: 100%; min-height: 440px; display: block; cursor: grab; touch-action: none; }
.graph-svg:active { cursor: grabbing; }
.graph-zoom { position: absolute; right: var(--space-3); top: var(--space-3); display: flex; gap: 4px; }
.graph-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); padding: var(--space-2) var(--space-4); }
.legend-line { display: inline-block; width: 26px; height: 0; border-top: 2px solid var(--color-text-muted); vertical-align: middle; }
.legend-line.derived { border-top-style: dashed; }
.graph-edge { stroke: var(--graph-edge); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.graph-edge.derived { stroke-dasharray: 5 4; }
.graph-edge.active { stroke: var(--graph-edge-active); stroke-width: 2; }
.graph-edge.dim { opacity: 0.25; }
.graph-arrow { fill: var(--graph-edge); }
.graph-node { cursor: pointer; }
.graph-node circle { fill: var(--node-color, var(--gt-file)); stroke: var(--color-surface); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.graph-node.derived circle { stroke-dasharray: 3 2; stroke: var(--node-color); fill-opacity: 0.45; }
.graph-node.selected circle { stroke: var(--color-text); stroke-width: 3; }
.graph-node.dim { opacity: 0.3; }
.graph-node:hover circle, .graph-node:focus circle { stroke: var(--color-text); }
.graph-label { fill: var(--color-text-body); font-family: var(--font-sans); pointer-events: none; paint-order: stroke; stroke: var(--color-inset); stroke-width: 3px; vector-effect: non-scaling-stroke; }
.graph-label.hidden-label { display: none; }
.graph-node.selected .graph-label { fill: var(--color-text); font-weight: 700; }

.graph-side { display: flex; flex-direction: column; max-height: 760px; overflow: hidden; }
.graph-side > details { flex: none; }
.graph-side-section { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); min-height: 0; }
.graph-side-section:last-child { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.graph-filter-group { display: flex; flex-direction: column; gap: 6px; }
.graph-type-check { align-items: center; }
.graph-detail { overflow: auto; max-height: 340px; margin-top: var(--space-2); }
.graph-edge-list { list-style: none; margin: 4px 0 0; padding: 0; font-size: var(--text-sm); }
.graph-edge-list li { margin-bottom: 4px; }
.graph-list { overflow: auto; flex: 1; margin-top: var(--space-2); display: flex; flex-direction: column; gap: 2px; }
.graph-list-item {
    display: flex; align-items: center; gap: var(--space-2); width: 100%;
    background: none; border: 0; border-radius: var(--radius-sm); padding: 5px 8px;
    color: var(--color-text-body); font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer;
}
.graph-list-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.graph-list-item:hover { background: var(--color-accent-softer); }
.graph-list-item[aria-selected="true"] { background: var(--color-accent-soft); color: var(--color-text); }
.graph-list-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; }
.graph-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--node-color, var(--gt-file)); flex: none; }

.gt-page { --node-color: var(--gt-page); }
.gt-subpage { --node-color: var(--gt-subpage); }
.gt-script { --node-color: var(--gt-script); }
.gt-stylesheet { --node-color: var(--gt-stylesheet); }
.gt-file { --node-color: var(--gt-file); }
.gt-module { --node-color: var(--gt-module); }
.gt-function { --node-color: var(--gt-function); }
.gt-external { --node-color: var(--gt-external); }
.gt-host { --node-color: var(--gt-host); }
.gt-endpoint { --node-color: var(--gt-endpoint); }
.gt-request { --node-color: var(--gt-request); }
.gt-library { --node-color: var(--gt-library); }
.gt-package { --node-color: var(--gt-package); }
.gt-binary { --node-color: var(--gt-binary); }
.gt-form { --node-color: var(--gt-form); }

/* ---------- Connector ---------- */
.connector-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr) auto; gap: var(--space-3); align-items: end; }

/* ---------- Responsive ---------- */
/* Breite des Arbeitsbereichs (nicht des Fensters) entscheidet – Sidebar und Inspector belegen Platz. */
@container (max-width: 1000px) {
    .ev-split { grid-template-columns: minmax(0, 1fr); }
    .ev-split > .panel { max-height: none; }
    .ev-split .col-scroll { max-height: 60vh; }
    .ev-detail { max-height: none; }
    .graph-layout { grid-template-columns: minmax(0, 1fr); }
    .graph-side { max-height: none; }
    .graph-list { max-height: 280px; }
}
@media (max-width: 1280px) {
    .ev-split { grid-template-columns: minmax(0, 1fr); }
    .ev-split > .panel { max-height: none; }
    .ev-detail { max-height: 70vh; }
    .graph-layout { grid-template-columns: minmax(0, 1fr); }
    .graph-side { max-height: none; }
    .graph-list { max-height: 280px; }
}
@media (max-width: 860px) {
    .ev-compare-pick, .connector-form { grid-template-columns: minmax(0, 1fr); }
    .ev-filters .input, .graph-main .panel-toolbar .input { width: 100%; }
    .graph-stage, .graph-svg { min-height: 340px; }
}
