/* =========================================================
 *  root-nav.css — 右上角根题目 / 专题导航面板
 * ========================================================= */

.root-nav {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 1000;
  width: 250px;
  max-height: calc(100% - 48px);
  display: flex;
  flex-direction: column;
  padding: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  color: var(--text);
  animation: fade-in 180ms ease-out;
}

.root-nav[hidden] {
  display: none !important;
}

.root-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.root-nav-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #c8d6e8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.root-nav-reset {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid rgba(90, 160, 255, 0.3);
  background: rgba(61, 139, 253, 0.12);
  color: #9ecbff;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease,
    box-shadow 130ms ease;
}

.root-nav-reset:hover {
  background: rgba(61, 139, 253, 0.26);
  border-color: rgba(90, 160, 255, 0.6);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(61, 139, 253, 0.3);
}

.root-nav-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #24334a transparent;
}

.root-nav-list::-webkit-scrollbar {
  width: 6px;
}

.root-nav-list::-webkit-scrollbar-thumb {
  background: #24334a;
  border-radius: 3px;
}

.root-nav-cell {
  position: relative;
  width: 100%;
}

.root-nav-item {
  appearance: none;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 38px;
  padding: 0 38px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: #cbd8ea;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease,
    box-shadow 140ms ease, transform 100ms ease;
}

.root-nav-item:hover,
.root-nav-cell:hover .root-nav-item:not(.is-active) {
  background: rgba(61, 139, 253, 0.14);
  border-color: rgba(90, 160, 255, 0.38);
}

.root-nav-item-settings {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #8ea3bd;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 140ms ease, background 140ms ease, color 140ms ease,
    border-color 140ms ease;
}

.root-nav-cell:hover .root-nav-item-settings,
.root-nav-item-settings:focus-visible {
  opacity: 1;
  color: #cfe3ff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(90, 160, 255, 0.3);
}

.root-nav-item-settings:hover {
  color: #ffffff;
  background: rgba(61, 139, 253, 0.3);
  border-color: rgba(90, 160, 255, 0.55);
}

.root-nav-item-settings svg {
  pointer-events: none;
}

.root-nav-item:focus-visible {
  outline: 2px solid rgba(125, 211, 252, 0.5);
  outline-offset: 1px;
}

.root-nav-item:active {
  transform: translateY(1px);
}

.root-nav-item.is-active {
  background: linear-gradient(
    90deg,
    rgba(61, 139, 253, 0.28),
    rgba(61, 139, 253, 0.06)
  );
  border-color: rgba(90, 160, 255, 0.65);
  box-shadow:
    inset 2px 0 0 #3d8bfd,
    0 0 14px rgba(61, 139, 253, 0.24);
}

.root-nav-item-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: #e2ecf9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.root-nav-item-sub {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: #8ea3bd;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.root-nav-empty {
  padding: 8px 4px;
  font-size: 11.5px;
  color: #6a7b93;
  text-align: center;
}

/* =========================================================
 *  悬停根题目清单气泡（固定视口层，不被面板裁剪）
 * ========================================================= */

.root-nav-popover {
  position: fixed;
  z-index: 1200;
  max-width: 260px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(90, 160, 255, 0.32);
  border-radius: 10px;
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.58),
    0 0 18px rgba(61, 139, 253, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #d7e3f5;
  pointer-events: none;
  transform: translateY(-50%);
  animation: fade-in 120ms ease-out;
}

.root-nav-popover[hidden] {
  display: none !important;
}

.root-nav-popover::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  margin-top: -6px;
  border: 6px solid transparent;
  border-left-color: rgba(15, 23, 42, 0.96);
}

.root-nav-popover-title {
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7f92ac;
}

.root-nav-popover-item {
  display: block;
  padding: 3px 0;
  font-size: 12px;
  color: #e2ecf9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.root-nav-popover-item + .root-nav-popover-item {
  border-top: 1px dashed rgba(255, 255, 255, 0.07);
}

/* =========================================================
 *  分支独占过滤：彻底隐藏非当前连通块
 * ========================================================= */

.canvas .node.is-hidden,
.canvas.is-focused .node.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translate(-50%, -50%) scale(0.92) !important;
  transition: opacity 300ms ease, transform 300ms ease,
    visibility 0s linear 300ms !important;
}

.canvas .edge-group.is-hidden,
.canvas.is-focused .edge-group.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 300ms ease, visibility 0s linear 300ms !important;
}

/* =========================================================
 *  跨连通块拉线：临时唤醒全图
 * ========================================================= */

.canvas.is-connecting .node.is-dimmed {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
}

.canvas.is-connecting .edge-group.is-dimmed {
  opacity: 1 !important;
}

