/* Sidebar hover-expand + active 保持 */
/*
 * 原理：
 *   1. 默认子菜单收起（max-height:0 + opacity:0）
 *   2. hover 时展开（方便浏览未选中的项）
 *   3. JS 在渲染后给 .active 的所有祖先 li 加 .keep-open 类
 *   4. .keep-open 下的子菜单始终展开，不受 hover 影响
 *   5. .active 链接有高亮视觉反馈
 */

/* ── 默认隐藏所有子菜单 ── */
.sidebar-nav ul ul {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.15s ease, opacity 0.15s ease;
}

/* ── hover 展开子菜单 ── */
.sidebar-nav ul li:hover > ul {
  max-height: 2000px;
  opacity: 1;
}

/* ── 核心：JS 标记了 .keep-open 的菜单，始终展开，优先级最高 ── */
.sidebar-nav ul li.keep-open > ul {
  max-height: 2000px !important;
  opacity: 1 !important;
}

/* ── 当前页面链接高亮 ── */
/* docsify 的 .active 加在 li 上，需要向下选中 a */
.sidebar-nav li.active > a {
  font-weight: 700;
  color: var(--theme-color, #42b983) !important;
  background: rgba(66, 185, 131, 0.12);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: -6px;
}

/* ── hover 缓冲区：防止鼠标移动时菜单回缩 ── */
.sidebar-nav ul li {
  padding-bottom: 4px;
}
.sidebar-nav ul li:has(> ul) {
  padding-bottom: 6px;
}

/* ── 紧凑间距 ── */
.sidebar-nav ul {
  margin: 0;
  padding-left: 16px;
}

/* ── 分组分隔线：更醒目的 hr ── */
.sidebar-nav hr {
  border: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--theme-color, #42b983), rgba(66, 185, 131, 0.15));
  margin: 20px 12px 20px 0;
  border-radius: 1px;
  opacity: 0.85;
}

/* 大分组标题高亮（hr 后的第一个顶层 li） */
.sidebar-nav > hr + ul > li:first-child > a,
.sidebar-nav > hr + ul > li:first-child > strong,
.sidebar-nav > hr + ul > li:first-child > p,
.sidebar-nav > ul:first-child > li:first-child > a {
  display: block;
  font-weight: 700;
  color: var(--theme-color, #42b983) !important;
  background: rgba(66, 185, 131, 0.08);
  border-left: 3px solid var(--theme-color, #42b983);
  padding: 6px 10px 6px 12px;
  margin: 6px 0 10px -4px;
  border-radius: 0 6px 6px 0;
  text-transform: none !important;
}

/* 顶层项之间的间距，让分组呼吸感更强 */
.sidebar-nav > ul > li {
  margin: 5px 0;
}

/* 子分组左侧加虚线，强化层级边界 */
.sidebar-nav ul li > ul {
  padding-left: 18px;
  border-left: 1px dashed rgba(66, 185, 131, 0.25);
  margin-left: 2px;
}
