/* ============================================================
   馒头的知识库 · 静态站点样式
   A clean, modern, responsive documentation theme.
   ============================================================ */

:root {
  --brand: #6f9f24;
  --brand-2: #9cc43d;
  --brand-soft: #f1f8e0;
  --page: #f9fcef;
  --bg: #ffffff;
  --bg-subtle: #eef4db;
  --text: #1f2418;
  --text-soft: #55603f;
  --text-muted: #8a9273;
  --border: #e6edcf;
  --border-strong: #d4e0ad;
  --code-bg: #f1f6e0;
  --shadow-sm: 0 1px 2px rgba(55, 70, 20, .07), 0 1px 3px rgba(55, 70, 20, .04);
  --shadow-md: 0 6px 20px rgba(55, 70, 20, .08);
  --shadow-lg: 0 18px 48px rgba(55, 70, 20, .12);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 268px;
  --header-h: 60px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #a8cd52;
    --brand-2: #c6e07c;
    --brand-soft: #262f18;
    --page: #101208;
    --bg: #101208;
    --bg-subtle: #191d0f;
    --text: #edf0e3;
    --text-soft: #b3baa1;
    --text-muted: #7f8770;
    --border: #282e1b;
    --border-strong: #3a4227;
    --code-bg: #191d0f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
}
.topbar .brand:hover { text-decoration: none; }
.logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow-sm);
  flex: none;
}
.topbar .spacer { flex: 1; }
.topbar .tag {
  font-size: 12.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
}
.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 9px;
  width: 38px;
  height: 38px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

/* ---------- Home hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 74px 24px 60px;
  text-align: center;
  background:
    radial-gradient(1100px 420px at 50% -140px, color-mix(in srgb, var(--brand) 16%, transparent), transparent 70%),
    var(--page);
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.2;
  letter-spacing: -.5px;
}
.hero h1 .grad {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero p {
  margin: 0 auto;
  max-width: 620px;
  color: var(--text-soft);
  font-size: 17px;
}
.hero .meta {
  margin-top: 22px;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.pill {
  font-size: 13px;
  color: var(--text-soft);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px;
}

/* ---------- Document grid ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 46px 0 20px;
}
.section-head h2 { margin: 0; font-size: 21px; letter-spacing: -.2px; }
.section-head .count { font-size: 13.5px; color: var(--text-muted); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
  padding-bottom: 70px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  color: inherit;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  text-decoration: none;
}
.card .icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: var(--brand-soft);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
}
.card h3 { margin: 0; font-size: 17px; }
.card p { margin: 0; font-size: 14px; color: var(--text-soft); }
.card .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.card .tags span {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}

/* ---------- Doc layout ---------- */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: var(--header-h);
  width: var(--sidebar-w);
  flex: none;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 26px 18px 60px 24px;
  border-right: 1px solid var(--border);
  background: var(--page);
}
.sidebar .sb-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 12px 8px;
}
.sidebar nav a {
  display: block;
  padding: 7px 12px;
  margin: 2px 0;
  border-radius: 8px;
  font-size: 14.2px;
  color: var(--text-soft);
  border-left: 2px solid transparent;
}
.sidebar nav a:hover { background: var(--bg-subtle); color: var(--text); text-decoration: none; }
.sidebar nav a.active {
  color: var(--brand);
  background: var(--brand-soft);
  border-left-color: var(--brand);
  font-weight: 600;
}
.sidebar nav a.sub { padding-left: 22px; font-size: 13.4px; }
.sidebar hr { border: 0; border-top: 1px solid var(--border); margin: 18px 8px; }

.doc { flex: 1; min-width: 0; }
.doc-inner { max-width: 820px; margin: 0 auto; padding: 40px 40px 100px; }

.breadcrumb { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand); }
.doc-meta { font-size: 13px; color: var(--text-muted); margin: -8px 0 18px; }
.doc-meta .dot { margin: 0 6px; opacity: .6; }

.doc h1.title {
  font-size: clamp(27px, 4vw, 36px);
  line-height: 1.25;
  letter-spacing: -.5px;
  margin: 0 0 16px;
}
.doc .lead { font-size: 17.5px; color: var(--text-soft); margin: 0 0 34px; }

.doc h2 {
  font-size: 23px;
  margin: 46px 0 14px;
  padding-top: 8px;
  letter-spacing: -.3px;
  scroll-margin-top: 80px;
}
.doc h2 .h2-badge {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  vertical-align: 2px;
}
.doc h3 { font-size: 17.5px; margin: 28px 0 10px; color: var(--text); }
.doc p { margin: 0 0 16px; color: var(--text); }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 24px; color: var(--text); }
.doc li { margin: 6px 0; }

.doc code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}
.doc pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 18px;
}
.doc pre code { background: none; border: 0; padding: 0; font-size: 13.5px; }

.callout {
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 0 0 20px;
  color: var(--text-soft);
  font-size: 14.5px;
}
.callout strong { color: var(--text); }

.doc blockquote {
  margin: 0 0 18px;
  padding: 12px 18px;
  border-left: 3px solid var(--border-strong);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
  font-size: 14.5px;
}
.doc blockquote p { margin: 0 0 8px; }
.doc blockquote p:last-child { margin-bottom: 0; }
.doc blockquote a { word-break: break-all; }

.doc .src {
  margin: 0 0 22px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.doc .src a { color: var(--text-muted); text-decoration: underline; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 22px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.doc thead th {
  background: var(--bg-subtle);
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.doc tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc tbody tr:last-child td { border-bottom: 0; }
.doc tbody tr:hover { background: var(--bg-subtle); }
/* 首列（名称列）不换行，避免被其他内容多的列挤压 */
.doc tbody td:first-child { white-space: nowrap; }
.kbd-syntax { font-family: var(--mono); font-size: .86em; color: var(--brand); }

/* 窄屏：保持表格形态，按列数给足宽度并横向滚动，避免列被挤压 */
.table-hint {
  display: none;
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 2px 8px;
}
.table-hint.show { display: block; }

@media (max-width: 760px) {
  .doc .table-wrap table { font-size: 13.5px; }
  .doc thead th, .doc tbody td { padding: 10px 13px; }
  .doc .table-wrap table[data-cols="4"] { min-width: 780px; }
  .doc .table-wrap table[data-cols="5"] { min-width: 880px; }
  .doc .table-wrap table[data-cols="6"] { min-width: 1020px; }
}

/* ---------- Steps ---------- */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 20px; }
.steps li {
  position: relative;
  padding: 4px 0 20px 52px;
  border-left: 2px solid var(--border);
  margin-left: 15px;
}
.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -16px;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
/* 步骤「小标题」：仅带 .step-title 的元素独占一行；普通 <strong> 保持行内，避免打断句子 */
.steps .step-title { display: block; margin-bottom: 2px; }

/* ---------- Figures / screenshots ---------- */
figure.fig { margin: 0 0 22px; }
figure.fig img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--bg-subtle);
}
figure.fig figcaption {
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}
figure.fig.cover { margin: 0 0 34px; }
figure.fig.cover img { border: 0; box-shadow: none; border-radius: 10px; }

/* 电脑端 + 移动端 并排 */
.shot-pair {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  align-items: center;
  margin: 0 0 22px;
}
.shot-pair figure { margin: 0; }
.shot-pair.two-narrow {
  grid-template-columns: 1fr 1fr;
  align-items: start;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}
.steps li .shot-pair { margin: 12px 0 4px; }
.steps li figure.fig { margin: 12px 0 4px; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 34px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}
.site-footer a { color: var(--text-soft); }

/* ---------- Prev / Next ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 54px; }
.pager a {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.pager a:hover { border-color: var(--brand); text-decoration: none; }
.pager .dir { font-size: 12.5px; color: var(--text-muted); display: block; }
.pager .next { text-align: right; }

/* ---------- 404 ---------- */
.center-page {
  min-height: calc(100vh - var(--header-h));
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
}
.center-page .code { font-size: 76px; font-weight: 800; line-height: 1;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.btn {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 22px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.btn:hover { text-decoration: none; opacity: .93; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; place-items: center; }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    z-index: 40;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop {
    position: fixed; inset: var(--header-h) 0 0 0;
    background: rgba(10, 14, 22, .42);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .backdrop.show { opacity: 1; pointer-events: auto; }
  .doc-inner { padding: 28px 20px 80px; }
  .topbar .tag { display: none; }
}

@media (max-width: 640px) {
  .shot-pair, .shot-pair.two-narrow { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
/* ---------- Pagefind 搜索（官方 Component UI · Modal） ----------
   组件通过 --pf-* 变量表着色。该表定义在 pagefind-component-ui.css 的 :root 中，
   因此该样式表必须排在 styles.css 之前（见各页面 <head>）；
   这里再用 html:root（特异性 0,1,1）兜底，确保站点配色一定覆盖官方默认灰白。 */
html:root {
  --pf-font: var(--font);
  --pf-text: var(--text);
  --pf-text-secondary: var(--text-soft);
  --pf-text-muted: var(--text-muted);
  --pf-background: var(--bg);
  --pf-border: var(--border);
  --pf-border-focus: var(--border-strong);
  --pf-hover: var(--bg-subtle);
  --pf-mark: var(--brand);
  --pf-outline-focus: var(--brand);
  --pf-outline-offset: 2px;
  --pf-skeleton: var(--bg-subtle);
  --pf-skeleton-shine: var(--bg);
  --pf-modal-backdrop: rgba(18, 24, 10, .45);
  --pf-modal-max-width: 680px;
  --pf-modal-top: 9vh;
  --pf-border-radius: 10px;
  --pf-input-height: 38px;
  --pf-shadow-lg: var(--shadow-lg);
  --pf-shadow-md: var(--shadow-md);
  --pf-shadow-sm: var(--shadow-sm);
  --pf-icon-search: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2355603f' stroke-width='2' stroke-linecap='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20.5 20.5l-4-4'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  html:root {
    --pf-modal-backdrop: rgba(0, 0, 0, .62);
    --pf-icon-search: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23b3baa1' stroke-width='2' stroke-linecap='round' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20.5 20.5l-4-4'/%3E%3C/svg%3E");
  }
}

/* 顶栏里的官方触发按钮：与站点其它控件对齐 */
.topbar pagefind-modal-trigger {
  flex: none;
  margin-left: 8px;
  vertical-align: middle;
}
