/* ── knowledge_graph_update.css ──────────────────────────────────
   Knowledge Graph page - aligned with global style.css design language
   ──────────────────────────────────────────────────────────────── */

/* ── Icon helper ─────────────────────────────────────────────────── */

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  stroke-width: 0;
  stroke: currentColor;
  fill: currentColor;
}
.icon-lucide {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Override base content width */
.kg-content {
  max-width: 960px !important;
}

/* ── Header Actions ─────────────────────────────────────────────── */

.header-actions {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  right: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

/* Match .hero-badge pill style from index.html */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-accent);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.back-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-subtle);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.back-btn .icon { width: 0.8rem; height: 0.8rem; flex-shrink: 0; }

/* ── Page Header ─────────────────────────────────────────────────── */

.kg-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-top: 4rem;  /* space for absolute-positioned header bar */
}

.kg-header__title {
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  margin: 0 0 0.75rem;
}

.kg-header__title span { color: var(--accent); }

.kg-header__sub {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.65;
  font-weight: 300;
  max-width: 560px;
  margin: 0 auto 1.5rem;
}

/* ── Stats ───────────────────────────────────────────────────────── */

.kg-stats {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.625rem 0;
  box-shadow: var(--shadow-card);
}

.kg-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.1rem;
}

.kg-stat__val {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.kg-stat__lbl {
  font-size: 0.68rem;
  color: var(--text-3);
  font-weight: 400;
  white-space: nowrap;
}

.kg-stat__sep {
  width: 1px;
  height: 2rem;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Graph Section ───────────────────────────────────────────────── */

.kg-graph-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
  transition: box-shadow 0.3s;
}

.kg-graph-wrap:hover {
  box-shadow: var(--shadow-hover);
}

/* Controls bar */
.kg-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.kg-filters {
  display: flex;
  gap: 0.2rem;
}

.kg-filter {
  font-family: var(--font-accent);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.kg-filter:hover {
  color: var(--text);
  background: var(--bg-subtle);
  border-color: var(--border);
}

.kg-filter.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.kg-reset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 7px;
  border: 1px solid var(--border-mid);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.kg-reset-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.kg-reset-btn .icon { width: 0.8rem; height: 0.8rem; }

/* Canvas */
.kg-canvas {
  position: relative;
  height: 480px;
  background: var(--bg);
  overflow: hidden;
}

.kg-canvas svg { width: 100%; height: 100%; display: block; }

/* Subtle dot-grid texture on canvas background */
.kg-canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--border-mid) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  opacity: 0.5;
}

.graph-hint {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-accent);
  font-size: 0.68rem;
  color: var(--text-3);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  pointer-events: none;
  transition: opacity 0.5s;
  white-space: nowrap;
  z-index: 2;
}

.graph-hint.hidden { opacity: 0; }

/* Tooltip */
.graph-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  padding: 0.625rem 0.875rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  max-width: 230px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 10;
}

.graph-tooltip.visible { opacity: 1; }

.graph-tooltip__type {
  font-family: var(--font-accent);
  font-size: 0.63rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.2rem;
}

.graph-tooltip__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.graph-tooltip__desc {
  font-size: 0.74rem;
  color: var(--text-2);
  line-height: 1.5;
}

/* Legend - edge types */
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.4rem;
  padding: 0.5rem 0.875rem;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  user-select: none;
}

.legend-item:hover {
  color: var(--text-2);
  background: var(--bg-card);
  border-color: var(--border);
}

.legend-item.active-edge {
  color: var(--accent);
  background: rgba(37,99,235,0.07);
  border-color: rgba(37,99,235,0.2);
}

.dark .legend-item.active-edge {
  background: rgba(91,156,246,0.1);
  border-color: rgba(91,156,246,0.25);
}

.legend-edge-line {
  display: inline-block;
  width: 12px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  flex-shrink: 0;
  opacity: 0.55;
}

.legend-item.active-edge .legend-edge-line {
  opacity: 1;
}

/* ── Feature Cards ───────────────────────────────────────────────── */

.kg-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .kg-features { grid-template-columns: 1fr; }
}

.kg-feat {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.125rem 1.25rem;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.25s, border-color 0.25s;
}

.kg-feat:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-mid);
}

/* Icon + title on same row */
.kg-feat__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.kg-feat__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  flex-shrink: 0;
}

.kg-feat__icon .icon { width: 1rem; height: 1rem; }

.kg-feat__title {
  font-family: var(--font-accent);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.kg-feat__text {
  font-size: 0.795rem;
  color: var(--text-2);
  line-height: 1.65;
  font-weight: 300;
}

/* Node types compact list */
.node-types-compact {
  display: flex;
  flex-direction: column;
  gap: 0.275rem;
}

.ntc-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  color: var(--text-2);
}

.ntc-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ntc-name { flex: 1; }

.ntc-count {
  font-size: 0.65rem;
  color: var(--text-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* Edge types */
.edge-type-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.edge-type-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.edge-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.edge-code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.635rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  opacity: 0.85;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.edge-desc {
  font-size: 0.755rem;
  color: var(--text-2);
  line-height: 1.5;
  font-weight: 300;
}

.edge-count {
  flex-shrink: 0;
  font-size: 0.63rem;
  font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.04rem 0.35rem;
  border-radius: 100px;
}

/* Module list */
.module-list {
  display: flex;
  flex-direction: column;
  gap: 0.225rem;
}

.module-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.775rem;
  color: var(--text-2);
  font-weight: 300;
}

.module-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0.7;
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 580px) {
  .header-actions {
    top: 1rem;
    left: 1rem;
    right: 1rem;
  }

  .kg-header {
    padding-top: 3.5rem;
  }

  .kg-stats {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
  }

  .kg-stat__sep { display: none; }
  .kg-stat { padding: 0 0.875rem; }

  .kg-filters {
    flex-wrap: wrap;
    gap: 0.15rem;
  }

  .kg-filter {
    font-size: 0.68rem;
    padding: 0.22rem 0.5rem;
  }

  .kg-canvas {
    height: 340px;
  }

  .kg-features {
    grid-template-columns: 1fr;
  }
}
