/* ==========================================================================
   OpClaw 文档站 · 专用样式
   --------------------------------------------------------------------------
   加载顺序：主站 /assets/style.css（提供设计令牌、顶栏、页脚、按钮）
             → 本文件（文档布局、侧栏、正文排版、代码高亮配色）
   约束：只新增文档专属类（doc- / side- / home- / tbl / tip / hljs-），
         不覆盖主站既有类名语义。
   ========================================================================== */

/* ---------- 两栏布局 ---------- */
.doc-wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 46px;
  align-items: start;
}
.doc-sidebar {
  position: sticky;
  top: 86px;
  padding: 36px 0 60px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.doc-main { padding: 36px 0 72px; min-width: 0; }
.doc-body { max-width: 780px; }

/* ---------- 侧栏 ---------- */
.side-nav { font-size: 14.5px; }
.side-group { display: none; }
.side-t {
  margin: 20px 0 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .5px;
}
.side-group > .side-t:first-child { margin-top: 0; }
.side-nav a {
  display: block;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  transition: background .16s, color .16s;
}
.side-nav a:hover { background: var(--bg-soft); color: var(--primary); }
.side-nav a.on { background: var(--bg-soft); color: var(--primary); font-weight: 600; }

/* 分组显示：由 docs.js 写入 body[data-sec] */
body[data-sec="guide"]     .side-group[data-sec="guide"],
body[data-sec="aimate"]    .side-group[data-sec="aimate"],
body[data-sec="reference"] .side-group[data-sec="reference"],
body[data-sec="pricing"]   .side-group[data-sec="pricing"] { display: block; }

/* 首页无侧栏 */
body[data-sec="home"] .doc-sidebar { display: none; }
body[data-sec="home"] .doc-wrap { grid-template-columns: minmax(0, 1fr); }

/* 顶栏当前栏目高亮 */
.nav-links a.on { background: var(--bg-soft); color: var(--primary); }

/* ---------- 正文排版 ---------- */
.doc-body h1 {
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -.4px;
  margin: 0 0 20px;
  line-height: 1.24;
}
.doc-body h2 {
  font-size: 1.42rem;
  font-weight: 700;
  margin: 44px 0 15px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 86px;
}
.doc-body h3 {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 30px 0 10px;
  scroll-margin-top: 86px;
}
.doc-body h4 { font-size: 1rem; font-weight: 700; margin: 24px 0 8px; }
.doc-body p { margin: 0 0 16px; color: var(--ink-2); }
.doc-body ul, .doc-body ol { margin: 0 0 16px; padding-left: 1.35em; color: var(--ink-2); }
.doc-body li { margin: 6px 0; }
.doc-body li > ul, .doc-body li > ol { margin: 6px 0 2px; }
.doc-body a { color: var(--primary); }
.doc-body a:hover { text-decoration: underline; }
.doc-body strong { color: var(--ink); font-weight: 700; }
.doc-body hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.doc-body blockquote {
  margin: 0 0 18px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.doc-body blockquote p:last-child { margin-bottom: 0; }

/* 行内代码 */
.doc-body code {
  background: var(--bg-soft);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

/* ---------- 表格 ---------- */
.tbl { overflow-x: auto; margin: 0 0 20px; border-radius: 12px; }
.doc-body table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.doc-body th, .doc-body td {
  border: 1px solid var(--line);
  padding: 10px 13px;
  text-align: left;
  vertical-align: top;
}
.doc-body th { background: var(--bg-soft); font-weight: 700; color: var(--ink); white-space: nowrap; }
.doc-body td { color: var(--ink-2); }
/* 首列多为短标签（场景/维度/角色…），不折行，避免被压窄后拆字 */
.doc-body td:first-child { white-space: nowrap; }
.doc-body tbody tr:hover { background: #fbfaff; }

/* ---------- 代码块 ---------- */
.doc-body pre {
  background: #f4f1fd;
  border: 1px solid var(--line);
  color: #2c2740;
  border-radius: 14px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 20px;
  font-size: 13.5px;
  line-height: 1.75;
}
.doc-body pre code {
  background: none;
  color: inherit;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

/* ---------- 提示块（对应 md 的 ::: tip / ::: warning / ::: info） ---------- */
.tip, .warn, .info {
  background: var(--bg-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 12px 12px 0;
  padding: 14px 18px;
  margin: 0 0 20px;
}
.tip-t { font-weight: 700; color: var(--primary); margin: 0 0 6px; font-size: 14.5px; }
.tip p, .warn p, .info p { margin: 0 0 8px; }
.tip p:last-child, .warn p:last-child, .info p:last-child { margin-bottom: 0; }
.tip ul, .warn ul, .info ul, .tip ol, .warn ol, .info ol { margin: 6px 0 8px; }
.tip > *:last-child, .warn > *:last-child, .info > *:last-child { margin-bottom: 0; }

/* 注意（warning）：橙 */
.warn { background: #fef6ec; border-left-color: var(--accent); }
.warn .tip-t { color: #b8730f; }

/* 提示（info）：中性 */
.info { background: #f2f4f8; border-left-color: #8e8ba6; }
.info .tip-t { color: #5b5a70; }

/* ---------- 首页 ---------- */
.doc-home { max-width: var(--max); }
.home-hero { padding: 56px 0 8px; }
.home-hero h1 { font-size: clamp(1.95rem, 4vw, 2.8rem); font-weight: 800; margin: 0 0 14px; letter-spacing: -.5px; }
.home-hero p { font-size: 17px; color: var(--muted); max-width: 42em; margin: 0 0 22px; }
.home-hero .hero-actions { margin-bottom: 0; }
.home-sec { margin-top: 44px; }
.home-sec > h2 { font-size: 1.22rem; font-weight: 700; margin: 0 0 16px; }
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.home-grid .card { padding: 22px; }
.home-grid .card h3 { font-size: 16.5px; margin: 0 0 8px; }
.home-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.home-links a {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s;
}
.home-links a:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(106, 79, 222, .14); }
.home-links b { display: block; font-size: 15.5px; color: var(--ink); margin-bottom: 4px; }
.home-links span { font-size: 13.5px; color: var(--muted); }

/* ---------- 代码高亮配色（浅底，扁平，与站点紫统一） ---------- */
.hljs-comment, .hljs-quote { color: #8e8ba6; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-section, .hljs-doctag, .hljs-name { color: #7c3aed; font-weight: 600; }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-meta .hljs-string { color: #0f766e; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: #b45309; }
.hljs-title, .hljs-title.class_, .hljs-title.function_, .hljs-built_in, .hljs-type { color: #1d4ed8; }
.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-selector-attr, .hljs-selector-pseudo { color: #9d174d; }
.hljs-meta, .hljs-selector-id, .hljs-selector-class { color: #6b6a80; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .doc-wrap { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .doc-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 20px 0 18px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
  }
  .doc-main { padding: 22px 0 60px; }
  .doc-body h1 { font-size: 1.68rem; }
  .home-grid, .home-links { grid-template-columns: 1fr; }
  .home-hero { padding: 34px 0 4px; }
}
@media (max-width: 620px) {
  .doc-body h2 { font-size: 1.25rem; margin-top: 34px; }
  .doc-body pre { font-size: 12.5px; padding: 14px 15px; }
  .doc-body table { font-size: 13.5px; }
}
