/**
 * 知识库概括页结构图
 *
 * 根节点 24 = text-page。分组 20 / 章节 18 只用于这张图的层级（不是站内正文排版），
 * WHY：用户指定的导图字阶 24→20→18，画布标签不是页面正文。
 * 章内 H2=16（text-body）、H3=14（text-caption）。
 */

.mytheme-kb-mindmap {
  margin-top: 3rem;
}

.mytheme-kb-mindmap-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 280px;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.mytheme-kb-mm-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
  background: #ffffff;
  -webkit-user-select: none;
  user-select: none;
}

.mytheme-kb-mm-viewport.is-dragging {
  cursor: grabbing;
}

.mytheme-kb-mm-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.mytheme-kb-mm-edges {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}

.mytheme-kb-mm-node {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
  overflow: visible;
  border-radius: 10px;
  border: 1.5px solid #d1d5db;
  color: #222222;
  line-height: 1.3;
  text-align: left;
  pointer-events: none;
  background: #ffffff;
  box-shadow: none;
}

.mytheme-kb-mm-line {
  display: block;
  overflow: visible;
  white-space: nowrap;
}

.mytheme-kb-mm-node.is-book {
  align-items: center;
  justify-content: center;
  text-align: center;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: #ffffff;
  font-size: 24px; /* text-page · 导图根节点 */
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.22);
}

.mytheme-kb-mm-node.is-group {
  font-size: 20px; /* WHY: 导图分组字阶，不是正文 token */
  font-weight: 500;
}

.mytheme-kb-mm-node.is-chapter {
  font-size: 18px; /* WHY: 导图章节字阶，不是正文 token */
  font-weight: 500;
}

.mytheme-kb-mm-node.is-heading,
.mytheme-kb-mm-node.is-heading3 {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.mytheme-kb-mm-node.is-heading {
  font-size: 16px; /* text-body · 章内 H2 */
  font-weight: 400;
}

.mytheme-kb-mm-node.is-heading3 {
  font-size: 14px; /* text-caption · 章内 H3 */
  font-weight: 400;
  color: #666666;
}

.mytheme-kb-mm-node.is-branch {
  pointer-events: auto;
}

.mytheme-kb-mm-fold {
  position: absolute;
  left: 100%;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  margin: 0 0 0 -20px;
  padding: 0 22px 0 20px;
  border: 0;
  background: transparent;
  transform: translateY(-50%);
  cursor: pointer;
  pointer-events: auto;
  min-width: 48px;
  height: 100%;
  min-height: 32px;
}

.mytheme-kb-mm-viewport .mytheme-kb-mm-fold,
.mytheme-kb-mm-viewport .mytheme-kb-mm-btn {
  cursor: pointer;
}

.mytheme-kb-mm-viewport.is-dragging,
.mytheme-kb-mm-viewport.is-dragging .mytheme-kb-mm-fold {
  cursor: grabbing;
}

.mytheme-kb-mm-fold-icon,
.mytheme-kb-mm-fold-count {
  opacity: 0;
}

.mytheme-kb-mm-node.is-branch:hover .mytheme-kb-mm-fold-icon,
.mytheme-kb-mm-node.is-branch:hover .mytheme-kb-mm-fold-count,
.mytheme-kb-mm-fold:hover .mytheme-kb-mm-fold-icon,
.mytheme-kb-mm-fold:hover .mytheme-kb-mm-fold-count,
.mytheme-kb-mm-fold.is-collapsed .mytheme-kb-mm-fold-icon,
.mytheme-kb-mm-fold:focus-visible .mytheme-kb-mm-fold-icon,
.mytheme-kb-mm-fold:focus-visible .mytheme-kb-mm-fold-count {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .mytheme-kb-mm-fold-icon,
  .mytheme-kb-mm-fold-count {
    transition: opacity 0.12s ease;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mytheme-kb-mm-fold-icon,
  .mytheme-kb-mm-fold-count {
    transition: none;
  }
}

.mytheme-kb-mm-fold:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 2px;
}

.mytheme-kb-mm-fold-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  box-shadow: 0 0 0 2px #ffffff;
}

.mytheme-kb-mm-fold:not(.is-collapsed) .mytheme-kb-mm-fold-icon::before {
  content: '';
  width: 8px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.mytheme-kb-mm-fold-count {
  font-size: 13px; /* text-footnote */
  font-weight: 500;
  color: #666666;
  line-height: 1;
}

.mytheme-kb-mm-fold.is-collapsed .mytheme-kb-mm-fold-icon {
  width: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ffffff;
  color: #3b82f6;
  border: 1.5px solid #3b82f6;
  font-size: 13px; /* text-footnote */
  font-weight: 500;
}

@media (hover: none), (pointer: coarse) {
  .mytheme-kb-mm-fold-icon,
  .mytheme-kb-mm-fold-count {
    opacity: 1;
  }

  .mytheme-kb-mm-fold {
    min-width: 44px;
    min-height: 44px;
  }
}

.mytheme-kb-mm-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mytheme-kb-mm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: #333333;
  font-size: 13px; /* text-footnote */
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
}

.mytheme-kb-mm-btn-text {
  font-weight: 500;
}

.mytheme-kb-mm-zoom-label {
  min-width: 48px;
  text-align: center;
  font-size: 13px; /* text-footnote */
  color: #666666;
}

.mytheme-kb-mm-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.mytheme-kb-mm-modal-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 14px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-sizing: border-box;
}

.mytheme-kb-mm-modal-title {
  font-size: 14px; /* text-caption */
  font-weight: 600;
  color: #222222;
  margin-right: 4px;
  white-space: nowrap;
}

.mytheme-kb-mm-modal-hint {
  font-size: 13px; /* text-footnote */
  color: #999999;
  white-space: nowrap;
  margin-right: auto;
}

.mytheme-kb-mm-viewport--modal {
  flex: 1;
  position: relative;
  background: #ffffff;
}

@media (max-width: 767px) {
  .mytheme-kb-mindmap {
    margin-top: 2.25rem;
  }

  .mytheme-kb-mindmap-stage {
    aspect-ratio: 4 / 5;
    min-height: 320px;
  }

  .mytheme-kb-mm-modal-hint {
    display: none;
  }
}
