/* ═══════════════════════════════════════════════════════════
   docs-theme.css — Mintlify 风三栏文档主题（阅读页 + 学习库）
   适用页面：note.html / library.html（渐进迁移，其他页暂用旧主题）
   设计基线：VoltAgent/awesome-design-md · mintlify
   动效原则：克制 — 只做阅读辅助动效，无 WebGL，尊重 reduced-motion
   ═══════════════════════════════════════════════════════════ */

:root {
  --canvas: #ffffff;
  --surface: #f7f7f7;
  --surface-soft: #fafafa;
  --surface-code: #f4f4f5;
  --hairline: #e5e5e5;
  --hairline-soft: #ededed;
  --ink: #0a0a0a;
  --charcoal: #1c1c1e;
  --slate: #3a3a3c;
  --steel: #5a5a5c;
  --stone: #888888;
  --muted: #a8a8aa;
  --accent: #00b48a;          /* mintlify green (deep, AA on white) */
  --accent-soft: rgba(0, 180, 138, 0.10);
  --accent-bright: #00d4a4;
  --warn: #c37d0d;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 264px;
  --toc-w: 224px;
  --topbar-h: 56px;
  --measure: 44rem;           /* 正文栏宽 ~704px */
}

html[data-theme="dark"] {
  --canvas: #0e0e10;
  --surface: #17171a;
  --surface-soft: #141416;
  --surface-code: #1c1c1e;
  --hairline: #26262a;
  --hairline-soft: #202024;
  --ink: #f2f2f2;
  --charcoal: #e8e8e8;
  --slate: #c8c8cc;
  --steel: #a0a0a6;
  --stone: #7c7c82;
  --muted: #5c5c62;
  --accent: #00d4a4;
  --accent-soft: rgba(0, 212, 164, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--slate);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

a { color: inherit; }

/* ── 阅读进度条 ─────────────────────────────── */
.read-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 200;
  transition: width .1s linear;
}

/* ── 顶栏 ──────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--canvas) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-brand .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.topbar-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar-nav a {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--steel);
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s ease, background-color .15s ease;
}
.topbar-nav a:hover { color: var(--ink); background: var(--surface); }
.topbar-nav a.is-active { color: var(--accent); font-weight: 600; }
.theme-toggle {
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--steel);
  border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 15px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s ease, border-color .15s ease, transform .15s ease;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--stone); transform: rotate(15deg); }

/* ── 三栏骨架 ──────────────────────────────── */
.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1440px;
  margin: 0 auto;
}

/* ── 左：侧边导航树 ─────────────────────────── */
.docs-sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 12px 48px 20px;
  border-right: 1px solid var(--hairline);
  scrollbar-width: thin;
}
.sidebar-search {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 18px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13.5px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.sidebar-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.sidebar-group { margin-bottom: 6px; }
.sidebar-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  background: none;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--stone);
  cursor: pointer;
  border-radius: 6px;
}
.sidebar-group-title:hover { color: var(--ink); }
.sidebar-group-title .chev {
  transition: transform .2s ease;
  font-size: 10px;
}
.sidebar-group.is-collapsed .chev { transform: rotate(-90deg); }
.sidebar-items {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .25s ease;
}
.sidebar-group.is-collapsed .sidebar-items { grid-template-rows: 0fr; }
.sidebar-items > ul {
  overflow: hidden;
  list-style: none;
  margin: 0;
  padding: 0 0 6px;
  min-height: 0;
}
.sidebar-items a {
  display: block;
  padding: 5px 10px 5px 14px;
  margin: 1px 0;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--steel);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.sidebar-items a:hover { color: var(--ink); background: var(--surface); }
.sidebar-items a.is-current {
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

/* ── 中：正文 ──────────────────────────────── */
.docs-main {
  min-width: 0;
  padding: 40px clamp(24px, 4vw, 64px) 96px;
}
.docs-article {
  max-width: var(--measure);
  margin: 0 auto;
  animation: article-in .45s ease both;
}
@keyframes article-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.crumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--stone);
  margin-bottom: 14px;
}
.crumbs a { color: var(--stone); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--muted); }

.doc-title {
  font-size: clamp(26px, 3vw, 34px);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 10px;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  font-size: 13px;
  color: var(--stone);
  padding-bottom: 22px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--hairline);
}
.doc-meta .tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--steel);
}
.doc-meta .type-pill {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
}

/* ── 长文排版（核心）─────────────────────────── */
.prose {
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--slate);
}
.prose > * { margin: 0 0 1.15em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}
.prose h1 { font-size: 25px; margin: 2.2em 0 0.8em; padding-top: 1.2em; border-top: 1px solid var(--hairline); }
.prose h2 { font-size: 21px; margin: 2em 0 0.7em; }
.prose h3 { font-size: 17.5px; margin: 1.7em 0 0.6em; }
.prose h1:first-child, .prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose strong { color: var(--ink); font-weight: 650; }
.prose a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1.5px;
  transition: background-size .25s ease;
}
.prose a:hover { background-size: 100% 1.5px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-bottom: 0.45em; }
.prose li::marker { color: var(--accent); }
.prose blockquote {
  margin: 1.4em 0;
  padding: 14px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--surface-soft);
  color: var(--steel);
}
.prose blockquote cite { display: block; margin-top: 8px; font-size: 13px; color: var(--stone); }
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-code);
  border: 1px solid var(--hairline-soft);
  color: var(--charcoal);
}
.prose pre {
  padding: 16px 18px;
  border-radius: 12px;
  background: #1c1c1e;
  border: 1px solid var(--hairline);
  overflow-x: auto;
  line-height: 1.6;
}
.prose pre code { background: none; border: 0; color: #e8e8e8; font-size: 13.5px; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--hairline); margin: 2.4em 0; }
.prose img { max-width: 100%; border-radius: 10px; }

/* 表格 — 词汇表这类长表的主战场 */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.7;
  margin: 1.4em 0;
  display: block;
  overflow-x: auto;
}
.prose thead th {
  position: sticky;
  top: var(--topbar-h);
  background: var(--canvas);
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--stone);
  padding: 10px 14px;
  border-bottom: 2px solid var(--hairline);
  white-space: nowrap;
}
.prose tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline-soft);
  vertical-align: top;
  min-width: 120px;
}
.prose tbody td:first-child { color: var(--ink); font-weight: 550; min-width: 150px; }
.prose tbody tr:nth-child(even) { background: var(--surface-soft); }
.prose tbody tr:hover { background: var(--accent-soft); }

/* ── 右：目录（真·从标题生成 + 滚动同步）────── */
.docs-toc {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px 20px 48px 8px;
  font-size: 13px;
  scrollbar-width: thin;
}
.toc-heading {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stone);
  margin: 0 0 10px;
}
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--hairline); }
.toc-list a {
  display: block;
  padding: 4px 0 4px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--steel);
  text-decoration: none;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.toc-list a:hover { color: var(--ink); }
.toc-list a.is-active { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.toc-list .lvl-3 a { padding-left: 28px; font-size: 12.5px; }
.toc-extra { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--hairline); color: var(--stone); font-size: 12.5px; line-height: 1.8; }
.toc-extra strong { color: var(--slate); }
.toc-pct { color: var(--accent); font-weight: 700; }

/* ── 学习库列表页 ───────────────────────────── */
.lib-head { margin-bottom: 28px; }
.lib-title { font-size: clamp(26px, 3vw, 32px); font-weight: 800; color: var(--ink); margin: 0 0 8px; letter-spacing: -0.015em; }
.lib-sub { color: var(--stone); font-size: 14.5px; margin: 0; }
.lib-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 26px;
}
.lib-filters button {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--steel);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
}
.lib-filters button:hover { border-color: var(--stone); color: var(--ink); }
.lib-filters button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--canvas);
  font-weight: 600;
}
.note-card {
  display: block;
  padding: 18px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--canvas);
  text-decoration: none;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.note-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}
.note-card .nc-top {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  color: var(--stone);
  margin-bottom: 6px;
}
.note-card .nc-type { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.note-card h3 { margin: 0 0 6px; font-size: 16.5px; font-weight: 700; color: var(--ink); line-height: 1.45; }
.note-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--steel);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-card .nc-tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.note-card .nc-tags span {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  color: var(--stone);
}
.lib-count { font-size: 13px; color: var(--stone); margin-bottom: 14px; }

/* stagger 入场（克制：仅首屏一次） */
.note-card { animation: article-in .4s ease both; }
.note-card:nth-child(2) { animation-delay: .04s; }
.note-card:nth-child(3) { animation-delay: .08s; }
.note-card:nth-child(4) { animation-delay: .12s; }
.note-card:nth-child(5) { animation-delay: .16s; }

/* ── 页脚 ──────────────────────────────────── */
.docs-footer {
  border-top: 1px solid var(--hairline);
  padding: 28px 24px;
  text-align: center;
  font-size: 12.5px;
  color: var(--stone);
}
.docs-footer a { color: var(--steel); }

/* ── 响应式 ────────────────────────────────── */
@media (max-width: 1100px) {
  .docs-shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 800px) {
  .docs-shell { grid-template-columns: 1fr; }
  .docs-sidebar { display: none; }
  .docs-main { padding: 24px 18px 72px; }
  .prose { font-size: 16px; }
}
