/* ============================================================
   SciTools Lab · 左侧目录树框架（sidebar.css）
   与 style.css 配合使用：style.css 保留原有暗色主题与全部
   工具页样式（.tool-card / .row / .out-area / .btn …），
   本文件只负责「顶栏 + 左侧栏 + 主区 + 右侧目录」四栏骨架。
   ============================================================ */

:root {
  --sidebar-w: 264px;
  --toc-w: 216px;
  --header-h: 58px;
  --shell-max: 1560px;
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  padding: 0 20px;
  flex-wrap: nowrap;
  background: rgba(15, 20, 27, .92);
  backdrop-filter: blur(8px);
}
.site-header .brand { gap: 9px; flex: 0 0 auto; }
.site-header .logo svg { width: 23px; height: 23px; }
.site-header h1 { font-size: 17px; }
.site-header-spacer { flex: 1 1 auto; }
.hamburger {
  display: none;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  flex: 0 0 auto;
}
.site-search {
  position: relative;
  flex: 0 1 300px;
  min-width: 120px;
}
.site-search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
.site-search input::placeholder { color: var(--muted); }
.site-search input:focus { outline: none; border-color: var(--accent); }
.site-search svg {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  pointer-events: none;
}
.site-search .no-hit {
  display: none;
  padding: 6px 4px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 四栏骨架 ---------- */
.shell {
  display: flex;
  align-items: flex-start;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0;
}
.main-col {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---------- 左侧目录树（matplotlib 文档站风格：无图标、caret 居右、当前页淡色高亮） ---------- */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 8px 40px 14px;
  border-right: 1px solid var(--border);
}
/* 侧栏滚动条：完全隐藏（保留滚动能力） */
.sidebar, .toc {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar,
.toc::-webkit-scrollbar { display: none; }

/* 一级板块标题链接：点它跳转板块页，点 caret 才折叠 */
.side-title-a {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.side-title-a:hover { color: inherit; text-decoration: none; }
/* 纯单页板块：标题即入口（无折叠），视觉与 summary 行保持一致 */
.side-group-a {
  display: flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 1px;
}
.side-group-a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.side-group > summary {
  display: flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-size: 13px;
  user-select: none;
}
.side-group > summary::-webkit-details-marker { display: none; }
.side-group > summary:hover { background: var(--card); }
.side-group[open] > summary { font-weight: 600; }
/* caret：SVG chevron，行尾对齐，默认朝下、展开朝上（matplotlib 语义） */
.side-caret {
  order: 2;
  margin-left: auto;
  color: var(--muted);
  flex: 0 0 auto;
  display: block;
  transition: transform .15s ease;
}
.side-group[open] > summary .side-caret { transform: rotate(180deg); }
.side-label { flex: 1 1 auto; min-width: 0; }
.side-label .en { color: var(--muted); font-size: 11px; margin-left: 5px; font-weight: 400; }
/* 二级 / 三级条目的英文小字 */
.side-sub .en,
.side-list .en { color: var(--muted); font-size: 10.5px; margin-left: 5px; font-weight: 400; }
/* 三级叶子高亮时英文跟随主题色 */
.side-list a.active .en { color: var(--accent); opacity: .82; }

/* 当前页 / 当前板块：左侧竖条 + 主题色粗体（matplotlib 风格，无背景块） */
.side-group-a.active,
.side-title-a.active,
.side-list a.active {
  position: relative;
  color: var(--accent);
  font-weight: 600;
  background: transparent;
}
.side-group-a.active::before,
.side-title-a.active::before,
.side-list a.active::before {
  content: '';
  position: absolute;
  left: -8px; top: 3px; bottom: 3px;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
}
/* 高亮行的英文小字跟随主题色（略淡保持层级） */
.side-group-a.active .en,
.side-title-a.active .en { color: var(--accent); opacity: .82; }

/* 二级子项 */
.side-list { list-style: none; margin: 1px 0 4px; padding: 0 0 0 14px; }
.side-list a {
  display: block;
  padding: 4px 9px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
}
.side-list a:hover { background: var(--card); color: var(--text); text-decoration: none; }

/* 二级（软件）分组 */
.side-sub { margin: 1px 0; }
.side-sub > summary {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-size: 12.5px;
  user-select: none;
}
.side-sub > summary::-webkit-details-marker { display: none; }
.side-sub > summary:hover { color: var(--text); background: var(--card); }
.side-sub[open] > summary { color: var(--text); }
.side-sub .side-caret { width: 11px; height: 11px; }
.side-sub[open] > summary .side-caret { transform: rotate(180deg); }

/* ---------- 右侧本页目录（matplotlib "On this page" 风格：无卡片） ---------- */
.toc {
  flex: 0 0 var(--toc-w);
  width: var(--toc-w);
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 22px 14px 40px 12px;
}
.toc-card {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
}
.toc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.toc-nav a {
  display: block;
  padding: 3px 8px;
  border-left: 2px solid transparent;
  border-radius: 0 5px 5px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.toc-nav a:hover { color: var(--text); text-decoration: none; }
.toc-nav a.lvl-3 { padding-left: 18px; font-size: 11.6px; }
.toc-nav a.active { color: var(--accent); border-left-color: var(--accent); background: transparent; }

/* ---------- 移动端 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 38;
  display: none;
}
.overlay.show { display: block; }

@media (max-width: 1180px) {
  .toc { display: none; }
}
@media (max-width: 880px) {
  .hamburger { display: inline-flex; }
  .site-search { display: none; }
  .shell { padding: 0; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    z-index: 40;
    width: var(--sidebar-w);
    height: calc(100vh - var(--header-h));
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 18px rgba(0, 0, 0, .35);
  }
  .sidebar.open { transform: translateX(0); }
  main { padding: 10px 16px 40px; }
  .site-header { padding: 0 14px; }
}