/* Copyright (c) 2025-now SuInk.
   Licensed under the Limited Redistribution License in the repository root. */

/* 文档站样式。配色与首屏落地页共用一套 token，两边看着是同一个产品；
   暗色是默认，明色留给长时间阅读，由 app.js 的主题开关在 data-theme 上切换。 */

:root {
  --bg: #100d13;
  --bg-soft: #16121a;
  --bg-card: #1b161f;
  --bg-inset: #120f16;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #ece7ee;
  --text-dim: #9d92a5;
  --text-faint: #6f6379;
  --accent: #d9578d;
  --accent-soft: rgba(217, 87, 141, 0.12);
  --warn: #e0a33f;
  --warn-soft: rgba(224, 163, 63, 0.12);
  --radius: 10px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --topbar-h: 58px;
  --sidebar-w: 236px;
  --shell-max: 1180px;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #faf8fb;
  --bg-card: #ffffff;
  --bg-inset: #f5f2f6;
  --line: rgba(24, 16, 28, 0.1);
  --line-strong: rgba(24, 16, 28, 0.18);
  --text: #1d1622;
  --text-dim: #6b6274;
  --text-faint: #948b9d;
  --accent: #c83f76;
  --accent-soft: rgba(200, 63, 118, 0.09);
  --warn: #9a6512;
  --warn-soft: rgba(200, 140, 40, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff;
  padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.brand strong { font-size: 16px; font-weight: 700; }
.brand small {
  display: block; margin-top: -6px;
  font-size: 11px; color: var(--text-dim); font-weight: 400;
}

.page-tabs { display: flex; gap: 4px; margin-left: 10px; }
.page-tabs a {
  padding: 5px 12px; border-radius: 7px;
  font-size: 14px; color: var(--text-dim);
}
.page-tabs a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.page-tabs a[aria-current="page"] { color: var(--text); background: var(--accent-soft); }

.top-links { display: flex; align-items: center; gap: 6px; margin-left: auto; }
/* 固定高度：带文字的项受行高影响会长到 35px，和 32px 的按钮排在一起顶不齐。 */
.top-links a {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px; border-radius: 7px;
  border: 1px solid transparent;
  font-size: 14px; color: var(--text-dim);
}
/* 选择器要覆盖 button，不能只写 a：主题按钮是 button，它的图标拿不到这条
   规则就会掉回基线对齐，比同排其他图标高出约 1.7px。 */
/* 18px 而不是 16：这些描边图标的墨迹只占 viewBox 的 3/4，按 16px 画出来的
   实际高度约 12px，配 14px 的汉字（满格）会显得矮一截、像没对齐。 */
.top-links svg { display: block; flex-shrink: 0; width: 18px; height: 18px; }
.top-links [data-theme-icon] { display: inline-flex; align-items: center; }
.top-links a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }

/* 语言切换跟同排其他项一样不带常驻边框：一排无边框的项里只有它有框，
   看起来就像没对齐。 */
.lang-switch { gap: 6px; }

/* 主题项文字会在三种模式间变，给个下限免得每次点完整排都往左右跳。 */
.icon-button.theme-item {
  width: auto; min-width: 100px; gap: 7px;
  padding: 0 10px;
  font-size: 13.5px;
}

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-dim);
  cursor: pointer; font-size: 15px; font-family: var(--font);
}
.icon-button:hover { color: var(--text); background: var(--bg-soft); }
.menu-button { display: none; }

/* ---------- 布局 ---------- */

.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 40px;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 20px;
}

.sidebar {
  position: sticky; top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 26px 0 40px;
}

.sidebar-search { margin-bottom: 20px; }
.sidebar-search label {
  display: block; margin-bottom: 7px;
  font-size: 12px; color: var(--text-dim); letter-spacing: 0.02em;
}
.sidebar-search input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--bg-card); color: var(--text);
  font-family: var(--font); font-size: 13.5px;
}
.sidebar-search input::placeholder { color: var(--text-faint); }
.search-status { margin-top: 6px; font-size: 12px; color: var(--text-dim); min-height: 1em; }

.sidebar-nav p {
  margin: 18px 0 6px;
  font-size: 12px; font-weight: 700;
  color: var(--text-faint); letter-spacing: 0.08em;
}
.sidebar-nav p:first-child { margin-top: 0; }
.sidebar-nav a {
  display: block;
  padding: 5px 10px; border-radius: 7px;
  font-size: 13.5px; color: var(--text-dim);
  border-left: 2px solid transparent;
}
.sidebar-nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.sidebar-nav a.active {
  color: var(--accent); background: var(--accent-soft);
  border-left-color: var(--accent);
}

.sidebar-backdrop { display: none; }

.content { padding: 34px 0 72px; min-width: 0; }

/* ---------- 正文排版 ---------- */

.page-intro { margin-bottom: 40px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.eyebrow {
  font-size: 12.5px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.06em;
  margin-bottom: 8px;
}
h1 { font-size: clamp(26px, 4vw, 34px); font-weight: 700; line-height: 1.35; }
h2 { font-size: clamp(19px, 2.6vw, 23px); font-weight: 700; line-height: 1.45; }
h3 { font-size: 15.5px; font-weight: 700; line-height: 1.55; }
.lead { margin-top: 12px; font-size: 16px; color: var(--text-dim); }

.section { margin-bottom: 52px; }
.section-heading { margin-bottom: 18px; }
.section-heading .eyebrow { margin-bottom: 4px; }

.content p { margin-bottom: 14px; color: var(--text-dim); }
.content h2 + p, .content h3 + p { margin-top: 8px; }
.content h3 { margin: 22px 0 6px; color: var(--text); }

.content ul, .content ol { margin: 0 0 16px 20px; color: var(--text-dim); }
.content li { margin-bottom: 7px; }
.content li::marker { color: var(--text-faint); }

code {
  font-family: var(--mono); font-size: 0.9em;
  padding: 1px 5px; border-radius: 4px;
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line);
  /* 行内 code 常是 URL 或路径这类长串，默认不换行会把窄容器（比如对照卡片
     里的 dd）撑破并被裁掉。pre 里的代码另有横向滚动，下面单独排除。 */
  overflow-wrap: anywhere;
}

pre {
  position: relative;
  margin: 0 0 16px;
  padding: 15px 17px;
  overflow-x: auto;
  background: var(--bg-inset);
  border: 1px solid var(--line); border-radius: var(--radius);
}
pre code {
  padding: 0; border: none; background: none;
  font-size: 13px; line-height: 1.75; color: var(--text);
  white-space: pre;
  overflow-wrap: normal;
}

.copy-button {
  position: absolute; top: 9px; right: 9px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--bg-card); color: var(--text-dim);
  font-family: var(--font); font-size: 12px; cursor: pointer;
  opacity: 0; transition: opacity .15s ease, color .15s ease;
}
pre:hover .copy-button, .copy-button:focus-visible { opacity: 1; }
.copy-button:hover { color: var(--accent); }

/* ---------- 表格 ---------- */

.table-wrap {
  margin-bottom: 18px;
  overflow-x: auto;
  border: 1px solid var(--line); border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--bg-soft); color: var(--text); font-weight: 700; white-space: nowrap; }
td { color: var(--text-dim); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- 提示块 ---------- */

.callout {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.callout strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 14.5px; }
.callout p { margin: 0; font-size: 13.5px; }
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); }

/* ---------- 步骤 ---------- */

.steps { list-style: none; margin: 0 0 18px; }
.steps li { display: flex; gap: 14px; margin-bottom: 16px; }
.steps li > span {
  flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700; font-family: var(--mono);
}
.steps h3 { margin: 0 0 3px; }
.steps p { margin: 0; font-size: 13.5px; }
.steps.compact li { margin-bottom: 12px; }

/* ---------- 标签页 ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button {
  padding: 6px 14px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--text-dim);
  font-family: var(--font); font-size: 13.5px; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] {
  color: var(--text); background: var(--bg-card);
  border-color: var(--line-strong);
}

/* ---------- 卡片网格 ---------- */

.tool-grid, .ops-grid, .memory-layers, .comparison, .foundations, .services, .update-paths, .requirements {
  display: grid; gap: 14px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.tool-grid article, .ops-grid > div, .memory-layers article,
.comparison article, .foundations > *, .services > *,
.update-paths > *, .requirements > * {
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.tool-grid h3, .memory-layers h3, .comparison h3 { margin: 0 0 6px; }
.tool-grid p, .memory-layers p { margin: 0; font-size: 13.5px; }

.ops-grid > div { display: flex; flex-direction: column; gap: 6px; }
.ops-grid strong { font-size: 14.5px; }
.ops-grid code { align-self: flex-start; font-size: 12.5px; }
.ops-grid span { font-size: 13px; color: var(--text-dim); }

.memory-layers article > span {
  display: block; margin-bottom: 8px;
  font-family: var(--mono); font-size: 12px;
  color: var(--accent); font-weight: 600;
}

.comparison dl { margin: 0; font-size: 13.5px; }
.comparison dl > div {
  display: grid; grid-template-columns: 84px 1fr; gap: 10px;
  padding: 6px 0; border-top: 1px solid var(--line);
}
.comparison dt { color: var(--text-faint); }
.comparison dd { margin: 0; color: var(--text-dim); }

/* ---------- 列表变体 ---------- */

.check-list, .policy-list { list-style: none; margin: 0 0 18px; }
.check-list li, .policy-list li {
  position: relative;
  padding-left: 24px; margin-bottom: 9px;
  font-size: 14px; color: var(--text-dim);
}
.check-list li::before, .policy-list li::before {
  content: ""; position: absolute; left: 6px; top: 0.7em;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

/* ---------- 时间线 ---------- */

.timeline { list-style: none; margin: 0 0 18px; padding-left: 22px; border-left: 1px solid var(--line); }
.timeline li { position: relative; margin-bottom: 18px; }
.timeline li::before {
  content: ""; position: absolute; left: -27px; top: 0.6em;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.timeline strong { display: block; margin-bottom: 3px; color: var(--text); font-size: 14.5px; }
.timeline p { margin: 0; font-size: 13.5px; }

/* ---------- 架构图 ---------- */

.architecture { margin-bottom: 18px; text-align: center; }
.arch-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.arch-row > div, .arch-core {
  padding: 13px;
  background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.arch-row strong, .arch-core strong { display: block; font-size: 14px; }
.arch-row span, .arch-core span {
  display: block; margin-top: 3px;
  font-size: 12.5px; color: var(--text-dim);
}
.arch-core { border-color: var(--accent); background: var(--accent-soft); }
.arch-arrow { padding: 7px 0; color: var(--text-faint); font-size: 15px; }

/* ---------- 流程条 ---------- */

.flow-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 18px; padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.flow-strip span {
  padding: 4px 10px; border-radius: 6px;
  background: var(--bg-inset); border: 1px solid var(--line);
  font-size: 13px;
}
.flow-strip b { color: var(--text-faint); font-weight: 400; }

/* ---------- FAQ ---------- */

.faq > * {
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.faq h3 { margin: 0 0 5px; }
.faq p { margin: 0; font-size: 13.5px; }

.recommended { border-color: var(--accent) !important; }

/* ---------- 页内导航 ---------- */

.page-nav {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  margin-top: 44px; padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

/* ---------- 页脚 ---------- */

.footer {
  display: flex; flex-wrap: wrap; gap: 20px; align-items: center;
  max-width: var(--shell-max); margin: 0 auto;
  padding: 26px 20px;
  border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--text-dim);
}
.footer strong { color: var(--text); font-size: 15px; }
.footer p { margin: 0; font-size: 13px; }
.footer > div:last-child { display: flex; flex-wrap: wrap; gap: 16px; margin-left: auto; }
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--text); }

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  .menu-button { display: grid; }
  .page-tabs { display: none; }
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }

  /* 侧栏在窄屏收成抽屉，由顶栏的目录按钮唤出。 */
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    width: 280px; height: 100vh;
    padding: 20px;
    background: var(--bg-soft);
    border-right: 1px solid var(--line-strong);
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 50;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
}

@media (max-width: 600px) {
  /* 之前这里是 .top-links a:not(.icon-link) { display:none }，给纯图标时代写的。
     后来每项都加了文字、去掉了 icon-link，这条就把首页/演示/语言切换/GitHub
     全隐藏了——移动端连语言都切不了。改成只藏文字、留下图标。 */
  .nav-label { display: none; }
  .top-links { gap: 2px; }
  .top-links a,
  .top-links .icon-button,
  .top-links .icon-button.theme-item,
  .top-links .lang-switch {
    width: 40px; min-width: 40px; height: 40px; padding: 0;
    justify-content: center;
  }
  .brand { min-height: 40px; }
  .brand small { display: none; }
  .content { padding: 24px 0 56px; }
  .topbar { gap: 10px; padding: 0 14px; }
  /* 页脚与页内导航的链接在窄屏也要够大。 */
  .footer > div:last-child { gap: 4px; }
  .footer a, .page-nav a {
    display: inline-flex; align-items: center;
    min-height: 40px; padding: 0 8px;
  }
  .sidebar-nav a { min-height: 40px; display: flex; align-items: center; }
  .tabs button { min-height: 40px; }
  /* 代码块的复制按钮在触屏上没有 hover，常驻显示才点得到。 */
  pre .copy-button { min-height: 40px; padding: 0 12px; opacity: 1; }
  .menu-button { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
