/* FreeWorld Mod API 站点样式。颜色统一走 :root 变量，深色模式只改变量。 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1c2330;
  --muted: #5b6678;
  --border: #d9dee6;
  --accent: #c27c00;
  --accent-soft: #fff4dc;
  --link: #1f5fbf;
  --code-bg: #f1f3f6;
  --ok: #1b7f4b;
  --warn: #a15c00;
  --bad: #b3261e;
  --pin: #f5a400;
  --pin-text: #1c1300;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .06);
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131a;
    --surface: #161b24;
    --surface-2: #1d2430;
    --text: #e3e8f0;
    --muted: #9aa6b8;
    --border: #2a3342;
    --accent: #f5b335;
    --accent-soft: #33280f;
    --link: #79a8ff;
    --code-bg: #1b212c;
    --ok: #5cc98c;
    --warn: #f0b04a;
    --bad: #ff8a80;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f131a;
  --surface: #161b24;
  --surface-2: #1d2430;
  --text: #e3e8f0;
  --muted: #9aa6b8;
  --border: #2a3342;
  --accent: #f5b335;
  --accent-soft: #33280f;
  --link: #79a8ff;
  --code-bg: #1b212c;
  --ok: #5cc98c;
  --warn: #f0b04a;
  --bad: #ff8a80;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 var(--sans);
}

/* 双语：同一段落的中英文写在相邻元素上，按 html[data-lang] 显示其一。 */
html[data-lang="zh"] body [lang="en"],
html[data-lang="en"] body [lang="zh-CN"] { display: none !important; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.topbar .spacer { flex: 1; }
.version-chip {
  font: 12px/1.4 var(--mono); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw;
}
.btn {
  font: inherit; font-size: 13px; cursor: pointer;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px;
}
.btn:hover { border-color: var(--accent); }
.menu-btn { display: none; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); max-width: 1280px; margin: 0 auto; }
.sidenav {
  position: sticky; top: 53px; align-self: start;
  height: calc(100vh - 53px); overflow-y: auto;
  padding: 20px 12px 40px 20px; border-right: 1px solid var(--border);
}
.sidenav a {
  display: block; padding: 6px 10px; margin: 1px 0; border-radius: 6px;
  color: var(--muted); font-size: 14px;
}
.sidenav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidenav a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.sidenav .group { margin: 16px 10px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

main { padding: 28px 40px 80px; min-width: 0; }
.content { max-width: 880px; }
.content-wide { max-width: none; }

h1 { font-size: 28px; line-height: 1.3; margin: 0 0 8px; }
h2 { font-size: 21px; margin: 40px 0 10px; padding-top: 8px; border-top: 1px solid var(--border); }
h3 { font-size: 17px; margin: 28px 0 8px; }
.lead { font-size: 16px; color: var(--muted); margin: 0 0 24px; }
p, li { max-width: 78ch; }

code, pre, kbd { font-family: var(--mono); font-size: 13px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; word-break: break-word; }
pre {
  position: relative; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; overflow-x: auto; line-height: 1.55;
}
pre code { background: none; padding: 0; word-break: normal; }
pre .copy {
  position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s;
}
pre:hover .copy, pre .copy:focus { opacity: 1; }
.code-title {
  font: 12px var(--mono); color: var(--muted);
  margin: 16px 0 -6px; padding-left: 2px;
}

table { border-collapse: collapse; width: 100%; margin: 12px 0 20px; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.callout {
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 16px 0;
}
.callout.warn { border-color: var(--warn); }
.callout.bad { border-color: var(--bad); }
.callout.ok { border-color: var(--ok); background: var(--surface-2); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 16px 0 24px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--shadow); color: var(--text);
}
a.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }

.badge {
  display: inline-block; font: 11px/1.6 var(--mono); padding: 0 6px; border-radius: 4px;
  border: 1px solid var(--border); color: var(--muted); vertical-align: middle; white-space: nowrap;
}
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.bad { color: var(--bad); border-color: currentColor; }

/* ---------- 截图标注：标记点用百分比坐标，换图后只需调坐标 ---------- */
figure.shot { margin: 20px 0 28px; }
.shot-frame { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #000; }
.shot-frame img { display: block; width: 100%; height: auto; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--pin); color: var(--pin-text); font: 700 13px/26px var(--sans); text-align: center;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .55);
}
.box { position: absolute; border: 2px solid var(--pin); border-radius: 6px; box-shadow: 0 0 0 2px rgba(0, 0, 0, .45); }
figure.shot figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }
figure.shot ol.legend { margin: 10px 0 0; padding-left: 0; list-style: none; counter-reset: pin; }
figure.shot ol.legend > li { counter-increment: pin; position: relative; padding-left: 34px; margin: 6px 0; color: var(--text); }
figure.shot ol.legend > li::before {
  content: counter(pin); position: absolute; left: 0; top: 1px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--pin); color: var(--pin-text);
  font: 700 12px/22px var(--sans); text-align: center;
}

/* ---------- 流程图 ---------- */
.flow { list-style: none; padding: 0; margin: 16px 0; counter-reset: step; }
.flow > li {
  position: relative; counter-increment: step; margin: 0 0 10px; padding: 10px 14px 10px 52px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
.flow > li::before {
  content: counter(step); position: absolute; left: 14px; top: 10px;
  width: 26px; height: 26px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border);
  font: 600 13px/24px var(--mono); text-align: center; color: var(--muted);
}
.flow > li.hook { border-color: var(--accent); }
.flow > li.hook::before { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.flow .where { display: block; font: 12px var(--mono); color: var(--muted); }

/* ---------- API 参考 ---------- */
.ref-toolbar { position: sticky; top: 53px; z-index: 5; background: var(--bg); padding: 10px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ref-toolbar input[type="search"] {
  flex: 1; min-width: 200px; font: inherit; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.ref-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.ref-tabs button[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.ref-count { font-size: 13px; color: var(--muted); }
details.ref-item { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; scroll-margin-top: 130px; }
h2[id], h3[id], tr[id], li[id] { scroll-margin-top: 70px; }
details.ref-item > summary {
  cursor: pointer; padding: 10px 14px; list-style: none; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline;
}
details.ref-item > summary::-webkit-details-marker { display: none; }
details.ref-item > summary::before { content: "▸"; color: var(--muted); width: 1em; }
details.ref-item[open] > summary::before { content: "▾"; }
details.ref-item > summary .name { font: 600 14px var(--mono); }
details.ref-item > summary .meta { font-size: 13px; color: var(--muted); }
details.ref-item .body { padding: 0 14px 14px; border-top: 1px solid var(--border); }
.member { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.member:last-child { border-bottom: 0; }
.member .sig { font: 13px var(--mono); overflow-wrap: anywhere; }
.member .note { margin: 4px 0 0; font-size: 14px; }
.member .note.missing { color: var(--muted); font-style: italic; }
.member .note.src { color: var(--muted); font-size: 13px; }
.member .ids { margin: 2px 0 0; }
.member[id] { scroll-margin-top: 130px; }
.fields td:first-child, .fields td:nth-child(2) { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.fields td.val { font-family: var(--mono); font-size: 12px; color: var(--muted); max-width: 320px; overflow-wrap: anywhere; }
.fields tr.inherited td { opacity: .75; }
.xml-tree { font: 13px/1.7 var(--mono); background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; overflow-x: auto; }
.xml-tree ul { list-style: none; margin: 0; padding-left: 20px; }
.xml-tree > ul { padding-left: 0; }
.xml-tree .el { color: var(--link); }
.xml-tree .attr { color: var(--warn); }
.xml-tree .ty { color: var(--muted); }
.ids { font: 12px var(--mono); color: var(--muted); overflow-wrap: anywhere; }

/* ---------- AI Agent 指引页 ---------- */
.agent-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
.agent-actions .btn { padding: 6px 14px; font-size: 14px; }
a.btn { display: inline-block; }
a.btn:hover { text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--pin-text); font-weight: 600; }
.md-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.md-toc a { font-size: 13px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); }
.md-toc a:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.md-doc { margin-top: 16px; padding: 4px 24px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.md-doc h1 { font-size: 22px; margin-top: 20px; }
.md-doc h2 { font-size: 18px; margin-top: 30px; }
.md-doc h2[id] { scroll-margin-top: 70px; }
.md-doc .md-task { color: var(--muted); }
.md-source { margin-top: 16px; max-height: 80vh; white-space: pre-wrap; overflow-wrap: anywhere; }

footer.site-footer { margin-top: 60px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* ---------- 窄屏 ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidenav {
    display: none; position: fixed; top: 53px; left: 0; right: 0; bottom: 0; z-index: 15;
    height: auto; background: var(--surface); border-right: 0; padding: 16px;
  }
  body.nav-open .sidenav { display: block; }
  .menu-btn { display: inline-block; }
  main { padding: 20px 16px 60px; }
  .topbar { padding: 10px 16px; }
  .version-chip { display: none; }
  .brand small { display: none; }
  h1 { font-size: 24px; }
  .pin { width: 20px; height: 20px; font-size: 11px; line-height: 20px; }
  .md-doc { padding: 4px 14px 16px; }
}

/* Website integration keeps the return link usable on narrow screens. */
.home-link { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 860px) {
  .topbar { gap: 8px; }
  .topbar .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topbar .spacer { display: none; }
  .topbar .btn { flex-shrink: 0; }
}

