/*
 * docs.css —— 文档站布局与组件样式（基于 new-api 主题令牌）
 */

/* ── 顶栏 ── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--app-header-height);
  background: color-mix(in oklch, var(--background) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1320px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1rem;
}
.brand { display: flex; align-items: center; gap: 0.55rem; color: var(--foreground); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-logo { border-radius: 7px; }
.brand-name { font-size: 0.95rem; letter-spacing: 0.01em; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: var(--foreground);
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { background: var(--accent); }
.icon-btn:active { transform: scale(0.96); }
.menu-btn { display: none; }
.repo-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 36px; padding: 0 0.7rem; border-radius: 9px;
  border: 1px solid var(--border); color: var(--foreground); font-size: 0.85rem;
  transition: background .15s, border-color .15s;
}
.repo-link:hover { background: var(--accent); text-decoration: none; border-color: var(--sidebar-border); }

/* 主题图标切换 */
.icon-moon { display: none; }
.dark .icon-sun { display: none; }
.dark .icon-moon { display: inline; }

/* ── 整体布局 ── */
.layout {
  max-width: 1320px; margin: 0 auto;
  display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px;
  gap: 1.5rem; padding: 0 1rem;
}
.sidebar {
  position: sticky; top: var(--app-header-height);
  align-self: start; height: calc(100svh - var(--app-header-height));
  overflow-y: auto; padding: 1.5rem 0.5rem 2rem 0;
  border-right: 1px solid var(--border);
}
.content { min-width: 0; padding: 2rem 0 4rem; }
.article { max-width: 820px; margin-right: auto; }
.toc { position: sticky; top: var(--app-header-height); align-self: start; max-height: calc(100svh - var(--app-header-height)); overflow-y: auto; padding: 2rem 0; }
.toc-inner { font-size: 0.82rem; }

/* ── 侧边导航 ── */
.nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav-home { margin-bottom: 0.35rem; }
.nav-group { margin-top: 0.45rem; }
.nav-group > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 0.3rem;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::before {
  content: ""; flex: 0 0 auto; width: 0; height: 0;
  border-left: 4px solid currentColor; border-top: 3px solid transparent; border-bottom: 3px solid transparent;
  color: var(--muted-foreground); transition: transform .15s ease;
}
.nav-group[open] > summary::before { transform: rotate(90deg); }
.nav-group-title {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted-foreground); padding: 0.3rem 0.6rem 0.3rem 0.1rem; margin: 0; flex: 1 1 auto;
}
/* 嵌套子分组：缩进 + 左边线，标题不再全大写 */
.nav-subgroup { margin-left: 0.3rem; padding-left: 0.55rem; border-left: 1px solid var(--border); }
.nav-subgroup > .nav-group-title {
  text-transform: none; letter-spacing: 0; font-size: 0.82rem; color: var(--foreground); opacity: 0.82;
}
.nav-link {
  display: block; padding: 0.4rem 0.6rem; border-radius: 8px;
  color: var(--sidebar-foreground); font-size: 0.9rem; line-height: 1.3;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--sidebar-accent); text-decoration: none; color: var(--sidebar-accent-foreground); }
.nav-link.active {
  background: var(--sidebar-primary); color: var(--sidebar-primary-foreground);
  font-weight: 600;
}

/* ── 文章头部 ── */
.article-head { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.article-title { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
.article-subtitle { margin: 0.6rem 0 0; color: var(--muted-foreground); font-size: 1rem; }
.article-foot { margin-top: 3rem; padding-top: 1.2rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted-foreground); }

/* ── Markdown 正文 ── */
.article h2 { font-size: 1.45rem; font-weight: 650; margin: 2.2rem 0 0.9rem; padding-top: 0.4rem; scroll-margin-top: calc(var(--app-header-height) + 1rem); }
.article h3 { font-size: 1.15rem; font-weight: 600; margin: 1.6rem 0 0.7rem; scroll-margin-top: calc(var(--app-header-height) + 1rem); }
.article h4 { font-size: 1rem; font-weight: 600; margin: 1.3rem 0 0.6rem; }
.article p { margin: 0.85rem 0; }
.article ul, .article ol { margin: 0.85rem 0; padding-left: 1.4rem; }
.article li { margin: 0.35rem 0; }
.article li::marker { color: var(--muted-foreground); }
.article blockquote {
  margin: 1.2rem 0; padding: 0.6rem 1rem;
  border-left: 3px solid var(--primary); background: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--foreground);
}
.article blockquote p { margin: 0.3rem 0; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.article img { border-radius: var(--radius-md); border: 1px solid var(--border); margin: 1rem 0; }
.article a { font-weight: 500; }
.article table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: 0.9rem; display: block; overflow-x: auto; }
.article th, .article td { border: 1px solid var(--border); padding: 0.55rem 0.8rem; text-align: left; }
.article thead th { background: color-mix(in oklch, var(--foreground) 4%, var(--background)); font-weight: 600; }
.article tbody tr:nth-child(even) { background: color-mix(in oklch, var(--foreground) 2%, var(--background)); }

/* 行内代码 */
.article :not(pre) > code {
  font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.86em; padding: 0.15em 0.4em; border-radius: 6px;
  background: var(--muted); color: var(--foreground);
  border: 1px solid var(--border);
}

/* 代码块 */
.article pre {
  margin: 1.2rem 0; padding: 1rem 1.1rem; overflow-x: auto;
  background: color-mix(in oklch, var(--foreground) 3%, var(--background));
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: 0.86rem; line-height: 1.6;
}
.article pre code { font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace; }

/* macOS 终端风格代码窗口 */
.code-window {
  margin: 1.2rem 0;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}
.code-header {
  display: flex; align-items: center; gap: 0.6rem;
  height: 40px; padding: 0 12px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
}
.code-dots { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.code-dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.12); }
.code-dot-red { background: #ff5f56; }
.code-dot-yellow { background: #ffbd2e; }
.code-dot-green { background: #27c93f; }
.code-lang {
  flex: 1 1 auto; text-align: center;
  font-size: 0.7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.35);
  font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace;
  user-select: none;
}
.code-copy {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px; border: none; background: transparent;
  color: rgba(255, 255, 255, 0.45); cursor: pointer; transition: background .15s, color .15s, transform .1s;
}
.code-copy:hover { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.9); }
.code-copy:active { transform: scale(0.94); }
.code-copy.copied { color: #27c93f; }
.code-window pre.hljs {
  margin: 0; padding: 1rem 1.1rem;
  background: transparent; border: none; border-radius: 0;
  font-size: 0.85rem; line-height: 1.65; overflow-x: auto;
}
.code-window pre.hljs code { font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace; }

/* ── Callout 提示框（markdown-it-container） ── */
.callout {
  display: flex; gap: 0.75rem; margin: 1.3rem 0; padding: 0.85rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--card); border-left-width: 4px;
}
.callout .callout-icon { flex: 0 0 auto; margin-top: 0.1rem; }
.callout .callout-body { min-width: 0; }
.callout .callout-body > :first-child { margin-top: 0; }
.callout .callout-body > :last-child { margin-bottom: 0; }
.callout-info { border-left-color: var(--info); background: color-mix(in oklch, var(--info) 8%, var(--background)); }
.callout-tip { border-left-color: var(--chart-1); background: color-mix(in oklch, var(--chart-1) 8%, var(--background)); }
.callout-success { border-left-color: var(--success); background: color-mix(in oklch, var(--success) 9%, var(--background)); }
.callout-warning { border-left-color: var(--warning); background: color-mix(in oklch, var(--warning) 9%, var(--background)); }
.callout-danger { border-left-color: var(--destructive); background: color-mix(in oklch, var(--destructive) 8%, var(--background)); }
.callout-note { border-left-color: var(--neutral); background: color-mix(in oklch, var(--neutral) 8%, var(--background)); }
.callout-info .callout-icon { color: var(--info); }
.callout-tip .callout-icon { color: var(--chart-1); }
.callout-success .callout-icon { color: var(--success); }
.callout-warning .callout-icon { color: var(--warning); }
.callout-danger .callout-icon { color: var(--destructive); }
.callout-note .callout-icon { color: var(--neutral); }

/* ── 右侧 TOC ── */
.toc-title { font-weight: 600; color: var(--muted-foreground); margin-bottom: 0.5rem; padding-left: 0.6rem; }
.toc-link { display: block; padding: 0.25rem 0.6rem; border-radius: 6px; color: var(--muted-foreground); font-size: 0.82rem; border-left: 2px solid transparent; }
.toc-link:hover { color: var(--foreground); text-decoration: none; background: var(--accent); }
.toc-link.h3 { padding-left: 1.3rem; font-size: 0.78rem; }
.toc-link.active { color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.toc-link.h4 { padding-left: 2rem; font-size: 0.75rem; }

/* ── 响应式 ── */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--app-header-height); left: 0; bottom: 0; width: 280px; z-index: 45;
    background: var(--background); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .22s ease; padding: 1.5rem 1rem;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none; position: fixed; inset: var(--app-header-height) 0 0 0; z-index: 44;
    background: rgb(0 0 0 / 0.45);
  }
  .sidebar-backdrop.open { display: block; }
  .repo-link span { display: none; }
  .article-title { font-size: 1.6rem; }
}
