/* Program-graph viewer (issue #2). Layers on top of styles.css tokens. */

.graph-loading,
.graph-empty,
.graph-error {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--color-muted);
  font-family: "DM Mono", monospace;
}
.graph-empty {
  height: 100%;
  display: grid;
  place-items: center;
}
.graph-error { color: var(--color-danger); }

/* ---- example (high / low) selector ---- */
.example-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (max-width: 640px) { .example-tabs { grid-template-columns: 1fr; } }

.example-card {
  text-align: left;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.example-card:hover { border-color: var(--color-border-strong); background: var(--color-surface-2); }
.example-card.active {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-subtle);
}
.example-card .ex-tier {
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.example-card .ex-name {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0.15rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.example-card .ex-path {
  font-family: "DM Mono", monospace;
  font-size: 0.78rem;
  color: var(--color-muted);
  word-break: break-all;
}

/* ---- graph-type toggle ---- */
.type-toggle {
  display: inline-flex;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.type-btn {
  border: none;
  background: transparent;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.type-btn:hover { color: var(--color-foreground); }
.type-btn.active {
  background: var(--color-surface);
  color: var(--color-foreground);
}
.type-btn .type-sub {
  display: block;
  font-weight: 400;
  font-size: 0.66rem;
  color: var(--color-muted);
  letter-spacing: 0.02em;
}

/* ---- main split layout ---- */
.graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: stretch;
}
@media (max-width: 900px) { .graph-layout { grid-template-columns: 1fr; } }

.graph-stage {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  height: 620px;
  overflow: hidden;
}
#cy { width: 100%; height: 100%; }

.graph-desc {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-size: 0.82rem;
  color: var(--color-foreground);
  pointer-events: none;
  max-width: 60ch;
}
.graph-desc strong { font-family: "Plus Jakarta Sans", sans-serif; }

.graph-hint {
  position: absolute;
  bottom: 10px; right: 12px;
  font-size: 0.72rem;
  color: var(--color-muted);
  font-family: "DM Mono", monospace;
  background: rgba(255,255,255,0.8);
  padding: 2px 8px;
  border-radius: 6px;
  pointer-events: none;
}
.graph-toolbar {
  position: absolute;
  bottom: 10px; left: 12px;
  display: flex; gap: 6px;
}
.graph-toolbar button {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 7px;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-foreground);
  box-shadow: var(--shadow-sm);
}
.graph-toolbar button:hover { border-color: var(--color-border-strong); }

/* ---- side panel ---- */
.graph-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.side-card {
  border-top: 1px solid var(--color-border);
  padding: 0.9rem 0 0;
}
.side-card h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 0.6rem;
}
.score-row { display: flex; justify-content: space-between; font-size: 0.9rem; padding: 0.15rem 0; }
.score-row span:last-child { font-family: "DM Mono", monospace; font-weight: 500; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; }

.legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; padding: 0.12rem 0; }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 1px solid rgba(0,0,0,0.15); }
.legend-swatch.edge { height: 0; width: 20px; border-radius: 0; border: none; border-top: 3px solid; }
.legend-swatch.dashed { border-top-style: dashed; }

/* ---- source panel (full-width, below the graph + sidebar) ---- */
.source-card { padding: 0; overflow: hidden; margin-top: 1rem; }
.source-card h3 { padding: 0.9rem 0 0; }
.source-scroll { max-height: 70vh; overflow: auto; margin-top: 0.5rem; }
.source-line {
  display: flex;
  font-family: "DM Mono", monospace;
  font-size: 0.76rem;
  line-height: 1.5;
  white-space: pre;
}
.source-line .ln {
  width: 3ch; text-align: right; padding: 0 0.7rem;
  color: var(--color-muted); user-select: none; flex: none;
  border-right: 1px solid var(--color-border);
}
.source-line .code { padding: 0 0.7rem; }
.source-line.hl { background: var(--color-accent-subtle); }
.source-line.hl .ln { color: var(--color-accent-hover); font-weight: 600; }

/* Size context on example cards (apples-to-apples comparisons) */
.ex-size {
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-muted);
}
