/* ============================================================
   GEO优化平台文档 - 纯HTML静态样式（替代 VitePress）
   ============================================================ */

/* ---- CSS 变量（亮色/暗色主题） ---- */
:root {
  --header-h: 64px;
  --sidebar-w: 256px;
  --toc-w: 224px;
  --content-max: 756px;

  --c-bg: #ffffff;
  --c-bg-soft: #f6f6f7;
  --c-bg-mute: #ebebec;
  --c-text: #3c3c43;
  --c-text-2: #476582;
  --c-text-3: #777e8a;
  --c-border: #e2e2e3;
  --c-brand: #409EFF;
  --c-brand-hover: #2587e8;
  --c-code-bg: #f3f4f5;
  --c-code-text: #476582;
  --c-header-bg: rgba(255,255,255,0.9);
  --c-blockquote-border: #409EFF;
  --c-blockquote-bg: rgba(64,158,255,.06);
  --c-table-border: #e2e2e3;
  --c-table-header-bg: #f6f6f7;
  --c-tip-bg: rgba(64,158,255,.08);
  --c-tip-border: #409EFF;
  --shadow-nav: 0 2px 8px rgba(0,0,0,.08);
}

[data-theme="dark"] {
  --c-bg: #1b1b1f;
  --c-bg-soft: #252529;
  --c-bg-mute: #313136;
  --c-text: #dde1e7;
  --c-text-2: #a4adc4;
  --c-text-3: #656e7f;
  --c-border: #3c3f44;
  --c-brand: #5da0f5;
  --c-brand-hover: #79b4f8;
  --c-code-bg: #292d3e;
  --c-code-text: #a8b1c8;
  --c-header-bg: rgba(27,27,31,0.92);
  --c-blockquote-border: #5da0f5;
  --c-blockquote-bg: rgba(93,160,245,.08);
  --c-table-border: #3c3f44;
  --c-table-header-bg: #252529;
  --shadow-nav: 0 2px 8px rgba(0,0,0,.3);
}
/* ---- 重置 ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Punctuation SC", "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji;
  font-size: 16px;
  line-height: 1.7;
  color: var(--c-text);
  background: var(--c-bg);
  transition: background .2s, color .2s;
}
a { color: var(--c-brand); text-decoration: none; }
a:hover { color: var(--c-brand-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---- 固定顶部导航栏 ---- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--c-header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-nav);
}
.header-inner {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 24px;
  max-width: 1440px;
  margin: 0 auto;
  gap: 12px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.site-logo {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
}
.site-logo:hover { color: var(--c-brand); text-decoration: none; }

/* 顶部导航链接 */
.top-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: flex-end;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.nav-link {
  padding: 6px 12px;
  font-size: 14px;
  color: var(--c-text-2);
  border-radius: 6px;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--c-text); background: var(--c-bg-soft); text-decoration: none; }
.nav-link.active { color: var(--c-brand); font-weight: 500; }

/* 主题切换按钮 */
.theme-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--c-text-2);
  transition: background .15s, color .15s;
}
.theme-btn:hover { background: var(--c-bg-mute); color: var(--c-text); }
.theme-icon-sun, .theme-icon-moon { line-height: 1; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="light"] .theme-icon-moon { display: none; }

/* 移动端汉堡菜单 */
.menu-btn {
  display: none;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 36px;
  height: 36px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  border-radius: 8px;
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--c-bg-mute); }
.menu-icon { display: flex; flex-direction: column; gap: 5px; }
.menu-icon span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--c-text-2);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.menu-btn.open .menu-icon span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open .menu-icon span:nth-child(2) { opacity: 0; }
.menu-btn.open .menu-icon span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- 页面布局 ---- */
.page-wrap {
  display: flex;
  min-height: calc(100vh - var(--header-h));
  padding-top: var(--header-h);
  max-width: 1440px;
  margin: 0 auto;
}

/* ---- 左侧边栏 ---- */
.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
  border-right: 1px solid var(--c-border);
  padding: 24px 12px 24px 0;
  background: var(--c-bg);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 4px; }

.sb-nav { padding-left: 16px; }
.sb-group { margin-bottom: 24px; }
.sb-group-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text);
  padding: 4px 8px;
  margin-bottom: 4px;
}
.sb-items { list-style: none; margin: 0; padding: 0; }
.sb-items li { margin: 2px 0; }
.sb-link {
  display: block;
  padding: 6px 10px;
  font-size: 14px;
  color: var(--c-text-2);
  border-radius: 6px;
  transition: color .15s, background .15s;
  line-height: 1.5;
}
.sb-link:hover { color: var(--c-text); background: var(--c-bg-soft); text-decoration: none; }
.sb-link.active {
  color: var(--c-brand);
  background: var(--c-tip-bg);
  font-weight: 500;
}

/* ---- 主内容区 ---- */
.page-main {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
}
.has-sidebar .page-main { padding-left: 40px; }

/* ---- 文档内容样式 ---- */
.doc-content { max-width: var(--content-max); }

.doc-content h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 24px;
  padding-bottom: 16px;
  color: var(--c-text);
}
.doc-content h2 {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 48px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--c-border);
  color: var(--c-text);
}
.doc-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--c-text);
}
.doc-content h4 { font-size: 1rem; font-weight: 600; margin: 20px 0 8px; }

.doc-content p { margin: 16px 0; }
.doc-content ul, .doc-content ol {
  padding-left: 24px;
  margin: 12px 0;
}
.doc-content li { margin: 6px 0; }
.doc-content li > ul, .doc-content li > ol { margin: 4px 0; }

.doc-content strong { font-weight: 600; }
.doc-content em { font-style: italic; }

/* 内联代码 */
.doc-content :not(pre) > code {
  padding: 2px 6px;
  font-size: .875em;
  font-family: 'Fira Code', 'Cascadia Code', Consolas, 'Courier New', monospace;
  background: var(--c-code-bg);
  color: var(--c-brand);
  border-radius: 4px;
  border: 1px solid var(--c-border);
}

/* 代码块 */
.code-block {
  margin: 20px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: var(--c-code-bg);
}
.code-pre, .code-block pre {
  margin: 0;
  padding: 20px 24px;
  overflow-x: auto;
  font-size: .875rem;
  font-family: 'Fira Code', 'Cascadia Code', Consolas, 'Courier New', monospace;
  line-height: 1.7;
  background: var(--c-code-bg);
  color: var(--c-code-text);
}
.code-pre code, .code-block pre code {
  background: transparent;
  color: inherit;
  border: none;
  padding: 0;
  font-size: inherit;
}
/* shiki 代码着色保留（亮色模式用 .shiki-themes github-light，暗色用 github-dark） */
[data-theme="dark"] .code-pre .shiki,
[data-theme="dark"] .code-block pre.shiki {
  background: var(--c-code-bg) !important;
}
.code-block .copy { display: none; }
.code-block .lang { display: none; }

/* blockquote */
.doc-content blockquote {
  margin: 20px 0;
  padding: 12px 20px;
  border-left: 4px solid var(--c-blockquote-border);
  background: var(--c-blockquote-bg);
  border-radius: 0 6px 6px 0;
  color: var(--c-text-2);
}
.doc-content blockquote p { margin: 4px 0; }

/* hr */
.doc-content hr {
  margin: 40px 0;
  border: none;
  border-top: 1px solid var(--c-border);
}

/* 表格 */
.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: .9rem;
  overflow-x: auto;
  display: block;
}
.doc-content table th {
  padding: 10px 16px;
  background: var(--c-table-header-bg);
  border: 1px solid var(--c-table-border);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.doc-content table td {
  padding: 10px 16px;
  border: 1px solid var(--c-table-border);
  vertical-align: top;
}
.doc-content table tr:nth-child(even) td {
  background: var(--c-bg-soft);
}

/* 标题锚点链接 */
.header-anchor {
  opacity: 0;
  margin-left: 8px;
  font-size: .85em;
  color: var(--c-text-3);
  transition: opacity .2s;
}
.doc-content h1:hover .header-anchor,
.doc-content h2:hover .header-anchor,
.doc-content h3:hover .header-anchor,
.doc-content h4:hover .header-anchor { opacity: 1; }

/* shiki 行包装 */
.doc-content .line { display: block; }

/* ---- 上一页/下一页 ---- */
.doc-prevnext {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--c-border);
  max-width: var(--content-max);
}
.prevnext-inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.prevnext-link {
  display: flex;
  flex-direction: column;
  padding: 14px 20px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  min-width: 0;
  max-width: 48%;
  flex: 1;
  transition: border-color .15s, background .15s;
  text-decoration: none;
}
.prevnext-link:hover { border-color: var(--c-brand); background: var(--c-tip-bg); text-decoration: none; }
.prevnext-link.next { align-items: flex-end; text-align: right; }
.prevnext-label { font-size: 12px; color: var(--c-text-3); margin-bottom: 4px; }
.prevnext-title { font-size: 14px; font-weight: 500; color: var(--c-brand); }

/* ---- 右侧 TOC ---- */
.toc-aside {
  flex-shrink: 0;
  width: var(--toc-w);
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}
.toc-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text);
  margin-bottom: 12px;
}
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list li { margin: 2px 0; }
.toc-list a {
  display: block;
  padding: 4px 8px;
  font-size: 14px;
  color: var(--c-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
  transition: color .15s, background .15s;
  border-left: 2px solid transparent;
}
.toc-list a:hover { color: var(--c-text); text-decoration: none; background: var(--c-bg-soft); }
.toc-list a.active { color: var(--c-brand); border-left-color: var(--c-brand); background: var(--c-tip-bg); }
.toc-h3 > a { padding-left: 20px; font-size: 14px; }

/* ---- 页脚 ---- */
.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 24px;
  text-align: center;
  color: var(--c-text-3);
  font-size: 13px;
  background: var(--c-bg-soft);
}
.footer-inner p { margin: 4px 0; }

/* ---- 移动端响应式 ---- */
@media (max-width: 1200px) {
  .toc-aside { display: none; }
}

@media (max-width: 960px) {
  /* 手机端 header：[logo] ——auto间距——  [☀] [☰]
     top-nav 隐藏，theme-btn 用 margin-left:auto 推到最右 */
  .header-left { flex: none; }
  .theme-btn   { margin-left: auto; }
  .menu-btn    { display: flex; }

  /* 顶部导航：折叠为下拉（无论有无侧边栏都一样） */
  .top-nav {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    flex-direction: column;
    padding: 8px 16px 12px;
    gap: 2px;
    z-index: 99;
    box-shadow: var(--shadow-nav);
  }
  .top-nav.open { display: flex; }
  .nav-link { font-size: 15px; padding: 10px 12px; border-radius: 8px; }

  /* ── 本地导航栏（菜单 + 页面导航）── */
  .local-nav {
    display: flex;
    align-items: center;
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    height: 40px;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    z-index: 90;
    padding: 0 8px;
    gap: 0;
  }
  /* 把正文区整体下移一个 local-nav 高度 */
  .page-wrap { padding-top: calc(var(--header-h) + 40px); }

  .local-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    height: 100%;
    font-size: 13px;
    color: var(--c-text-2);
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
  }
  .local-nav-btn:hover { color: var(--c-text); }
  .local-nav-btn .lnb-icon { font-size: 15px; }
  .local-nav-divider {
    width: 1px;
    height: 20px;
    background: var(--c-border);
    flex-shrink: 0;
  }
  .local-nav-btn.toc-btn {
    margin-left: auto;
    flex-direction: row-reverse;
  }
  .local-nav-btn.toc-btn .lnb-arrow {
    font-size: 11px;
    transition: transform .2s;
  }
  .local-nav-btn.toc-btn.open .lnb-arrow { transform: rotate(90deg); }

  /* TOC 下拉（页面导航） */
  .mobile-toc-dropdown {
    display: none;
    position: fixed;
    top: calc(var(--header-h) + 40px);
    left: 0; right: 0;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow-nav);
    padding: 8px 16px 16px;
    z-index: 89;
    max-height: 50vh;
    overflow-y: auto;
  }
  .mobile-toc-dropdown.open { display: block; }
  .mobile-toc-dropdown ul { list-style: none; margin: 0; padding: 0; }
  .mobile-toc-dropdown .toc-h2 a { display: block; padding: 8px 0; font-size: 14px; color: var(--c-text-2); border-bottom: 1px solid var(--c-border); }
  .mobile-toc-dropdown .toc-h3 a { display: block; padding: 6px 0 6px 16px; font-size: 13px; color: var(--c-text-3,var(--c-text-2)); }
  .mobile-toc-dropdown a:hover { color: var(--c-brand); text-decoration: none; }
  .mobile-toc-dropdown a.active { color: var(--c-brand); }

  /* 侧边栏变为左侧抽屉 */
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: -100%;
    width: 280px;
    height: calc(100vh - var(--header-h));
    z-index: 98;
    border-right: 1px solid var(--c-border);
    box-shadow: var(--shadow-nav);
    transition: left .25s ease;
    overflow-y: auto;
  }
  .sidebar.open { left: 0; }

  /* 遮罩层 */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 97;
  }
  .sidebar-overlay.show { display: block; }

  .page-main { padding: 32px 20px 60px; }
  .has-sidebar .page-main { padding-left: 20px; }
}

@media (max-width: 640px) {
  .site-logo { font-size: 14px; }
  .page-main { padding: 24px 16px 48px; }
  .doc-content h1 { font-size: 1.6rem; }
  .doc-content h2 { font-size: 1.2rem; }
  .prevnext-inner { flex-direction: column; }
  .prevnext-link { max-width: 100%; }
  .doc-content table { font-size: .8rem; }
  .doc-content table th,
  .doc-content table td { padding: 7px 10px; }
}

/* ---- 辅助类 ---- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
