/* Graph page — full-viewport layout */

/* Sidebar graph link — small icon next to 知识地图 */
.sidebar-graph-link {
  display: inline-block;
  vertical-align: middle;
  font-size: 13px;
  opacity: 0.5;
  margin-left: 4px;
  transition: opacity 0.15s;
}
.sidebar-graph-link:hover {
  opacity: 0.85;
}

.graph-container {
  position: fixed;
  top: 60px; /* below top nav */
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* Controls overlay */
.graph-controls {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: none;
}

.graph-search {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
}

.graph-search i {
  position: absolute;
  left: 14px;
  color: var(--text-dim, #889cc5);
  font-size: 14px;
}

.graph-search input {
  width: 280px;
  padding: 10px 14px 10px 38px;
  border-radius: 22px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.15));
  background: var(--bg-container, rgba(13,20,38,0.95));
  color: var(--text-body, #f0f0f0);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.graph-search input:focus {
  border-color: var(--color-accent, #3570a8);
  box-shadow: 0 0 0 3px rgba(53,112,168,0.25);
}

.graph-search input::placeholder {
  color: var(--text-dim, #889cc5);
}

.graph-info {
  pointer-events: auto;
  font-size: 13px;
  color: var(--text-dim, #889cc5);
  background: var(--bg-container, rgba(13,20,38,0.9));
  padding: 6px 14px;
  border-radius: 14px;
  white-space: nowrap;
}

/* SVG canvas */
#graph-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Links */
.graph-link {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-linecap: round;
  transition: stroke 0.2s, opacity 0.2s;
}

/* Node labels */
.node-label {
  font-size: 10px;
  fill: var(--text-body, #f0f0f0);
  pointer-events: none;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  transition: opacity 0.2s;
}

/* Tooltip */
.graph-tooltip {
  display: none;
  position: absolute;
  pointer-events: none;
  z-index: 20;
  background: var(--bg-container, rgba(13,20,38,0.96));
  color: var(--text-body, #f0f0f0);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.12));
  font-size: 13px;
  line-height: 1.5;
  max-width: 260px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.graph-tooltip strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.graph-tooltip .tip-cat {
  color: var(--color-accent, #3570a8);
  font-weight: 500;
}

.graph-tooltip small {
  display: block;
  color: var(--text-dim, #889cc5);
  margin-top: 4px;
  line-height: 1.4;
}

/* Legend */
.graph-legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 10;
  background: var(--bg-container, rgba(13,20,38,0.9));
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  max-width: 360px;
}

.legend-item {
  font-size: 12px;
  color: var(--text-dim, #889cc5);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Light theme overrides */
html[data-theme="light"] .graph-link {
  stroke: rgba(0, 0, 0, 0.1);
}

html[data-theme="light"] .node-label {
  fill: #2c2c2c;
}

html[data-theme="light"] .graph-search input {
  background: rgba(255,255,255,0.95);
  color: #2c2c2c;
  border-color: rgba(0,0,0,0.12);
}

html[data-theme="light"] .graph-tooltip {
  background: rgba(255,255,255,0.97);
  color: #2c2c2c;
  border-color: rgba(0,0,0,0.1);
}

html[data-theme="light"] .graph-info,
html[data-theme="light"] .graph-legend {
  background: rgba(255,255,255,0.92);
  color: #555;
}

/* Footer override — absolute positioned at bottom */
.graph-container + footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  padding: 8px 20px;
  font-size: 12px;
}

/* Show footer when graph controls area is hovered (near bottom) */
.graph-container:hover ~ footer,
footer:hover {
  opacity: 0.6;
  pointer-events: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .graph-controls {
    top: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    flex-direction: column;
    gap: 8px;
  }

  .graph-search input {
    width: 100%;
    max-width: 260px;
  }

  .graph-legend {
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
    flex-wrap: wrap;
    justify-content: center;
    padding: 8px 10px;
    gap: 4px 10px;
  }

  .legend-item {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .graph-container {
    top: 50px;
  }

  .graph-legend {
    bottom: 6px;
    padding: 6px 8px;
    gap: 3px 8px;
  }

  .legend-item {
    font-size: 10px;
  }

  .graph-tooltip {
    max-width: 200px;
    font-size: 12px;
  }
}
