/* ============================================================
   MassBattle Docs — shared stylesheet
   MassBattle 文档站 — 共享样式表
   ============================================================ */

:root {
  --sidebar-bg: #1b222c;
  --sidebar-bg-hover: #232c38;
  --sidebar-text: #9aa7b5;
  --sidebar-text-active: #ffffff;
  --accent: #3d8bfd;
  --accent-soft: #e8f1ff;
  --content-bg: #ffffff;
  --text-main: #24292f;
  --text-soft: #57606a;
  --border: #d8dee4;
  --code-bg: #f2f4f7;
  --code-text: #0550ae;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  --sans: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --topbar-h: 56px;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--text-main);
  background: var(--content-bg);
  font-size: 15px;
  line-height: 1.75;
}

/* ---------- language switching | 语言切换 ---------- */
/* Default: English. html[data-lang="zh"] switches to Chinese.
   Both rules are (0,2,1): they must be the ONLY display rules touching
   .zh/.en so hidden content never leaks through a block-layout rule. */
html:not([data-lang="zh"]):not([data-lang="zh-TW"]) .zh { display: none; }
html[data-lang="zh"] .en, html[data-lang="zh-TW"] .en { display: none; }
/* zh-TW shows the Chinese spans (dictionary pass converts them to traditional) */
html[data-lang="zh-TW"] p.zh { display: block; }
html[data-lang="zh-TW"] span.zh { display: inline; }
html[data-lang="zh-TW"] div.zh { display: block; }
/* bilingual headings: "中文 <span class="en-sub">English</span>" -> one language */
html:not([data-lang="zh"]):not([data-lang="zh-TW"]) .h-zh { display: none; }
html[data-lang="zh"] .en-sub, html[data-lang="zh-TW"] .en-sub { display: none; }
html[data-lang="zh-TW"] .h-zh { display: inline; }
html:not([data-lang="zh"]):not([data-lang="zh-TW"]) #content h2 .en-sub { margin-left: 0; }

/* ---------- top bar | 顶栏 ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: #10151c; color: #e6edf3; z-index: 100;
  display: flex; align-items: center; padding: 0 16px; gap: 14px;
}
#topbar .brand {
  color: #fff; text-decoration: none; font-weight: 700; font-size: 16px;
  letter-spacing: .3px; white-space: nowrap;
}
#topbar .brand .accent { color: var(--accent); }
#topbar .crumb {
  color: #8b98a5; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
#topbar .crumb a { color: #b7c3cf; text-decoration: none; }
#topbar .crumb a:hover { color: #fff; }
#topbar .crumb .sep { margin: 0 6px; color: #4b5866; }
#topbar-right { display: flex; align-items: center; gap: 10px; }

#search {
  width: 210px; height: 34px; border-radius: 17px; border: 1px solid #2d3947;
  background: #1d2733; color: #e6edf3; padding: 0 14px; font-size: 13px; outline: none;
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: #5d6b7a; }

#lang-toggle {
  height: 34px; padding: 0 16px; border-radius: 17px; cursor: pointer;
  border: 1px solid #2d3947; background: #1d2733; color: #c9d6e2;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
#lang-toggle:hover { border-color: var(--accent); color: #fff; }

/* ---------- language menu | 12 语言下拉菜单 ---------- */
.lang-wrap { position: relative; }
.lang-btn {
  height: 34px; padding: 0 14px; border-radius: 17px; cursor: pointer;
  border: 1px solid #2d3947; background: #1d2733; color: #c9d6e2;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.lang-btn:hover { border-color: var(--accent); color: #fff; }
.lang-menu {
  display: none; position: absolute; right: 0; top: 40px; z-index: 200;
  min-width: 170px; max-height: 60vh; overflow-y: auto;
  background: #1d2733; border: 1px solid #2d3947; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45); padding: 4px;
}
.lang-menu.open { display: block; }
.lang-menu button {
  display: block; width: 100%; text-align: left; padding: 7px 12px;
  background: none; border: none; border-radius: 5px; cursor: pointer;
  color: #c9d6e2; font-size: 13px; white-space: nowrap;
}
.lang-menu button:hover { background: #273445; color: #fff; }
.lang-menu button.active { color: var(--accent); font-weight: 700; }
html[dir="rtl"] .lang-menu { right: auto; left: 0; }

#menu-btn {
  display: none; height: 34px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid #2d3947; background: #1d2733; color: #c9d6e2; font-size: 14px;
}

/* ---------- sidebar | 侧栏目录 ---------- */
#sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); overflow-y: auto; z-index: 90;
  padding: 10px 0 40px;
  scrollbar-width: thin; scrollbar-color: #39465a transparent;
}
.sidebar-module { margin-bottom: 2px; }
.sidebar-module-head {
  display: flex; align-items: center; gap: 6px; padding: 7px 16px;
  color: #dbe4ee; font-weight: 700; font-size: 13.5px; cursor: pointer; user-select: none;
}
.sidebar-module-head:hover { background: var(--sidebar-bg-hover); }
.sidebar-module-head .arrow {
  font-size: 10px; color: #5d6b7a; transition: transform .15s; flex-shrink: 0;
}
.sidebar-module.collapsed .arrow { transform: rotate(-90deg); }
.sidebar-module-head .count { margin-left: auto; color: #5d6b7a; font-size: 11px; font-weight: 400; }

.sidebar-group { margin: 2px 0; }
.sidebar-group-head {
  padding: 5px 16px 5px 28px; color: #7d8b9a; font-size: 12px; font-weight: 600;
  cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px;
}
.sidebar-group-head:hover { color: #b7c3cf; }
.sidebar-group-head .arrow { font-size: 9px; transition: transform .15s; }
.sidebar-group.collapsed .arrow { transform: rotate(-90deg); }
.sidebar-group.collapsed + .sidebar-items, .sidebar-group.collapsed ~ .sidebar-items { display: none; }

.sidebar-items { list-style: none; margin: 0; padding: 0; }
.sidebar-items li { margin: 0; }
.sidebar-items a {
  display: block; padding: 4px 16px 4px 40px; color: var(--sidebar-text);
  text-decoration: none; font-size: 13px; line-height: 1.5;
  border-left: 2px solid transparent;
}
.sidebar-items a:hover { background: var(--sidebar-bg-hover); color: #dfe8f2; }
.sidebar-items a.active {
  background: var(--sidebar-bg-hover); color: var(--sidebar-text-active);
  border-left-color: var(--accent); font-weight: 600;
}
.sidebar-items a .pending { color: #f0883e; font-size: 10px; margin-left: 4px; }

/* ---------- main content | 主内容 ---------- */
#content {
  margin-left: var(--sidebar-w); margin-top: var(--topbar-h);
  padding: 28px 40px 80px; max-width: 940px;
}
h1.page-title {
  font-size: 30px; margin: 6px 0 2px; line-height: 1.3; letter-spacing: .2px;
}
.type-badges { margin: 10px 0 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-block; padding: 1px 10px; border-radius: 11px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .4px; line-height: 1.7;
}
.badge-class      { background: #f3e8ff; color: #7c3aed; }
.badge-struct     { background: var(--accent-soft); color: #0b5ed7; }
.badge-enum       { background: #e6f4ea; color: #1a7f37; }
.badge-interface  { background: #e0f7fa; color: #00838f; }
.badge-processor  { background: #fff3e0; color: #b45309; }
.badge-subsystem  { background: #fce4ec; color: #c2185b; }
.badge-task       { background: #f9fbe7; color: #827717; }
.badge-deprecated { background: #f1f3f4; color: #6b7280; text-decoration: line-through; }
.badge-file       { background: #f1f3f4; color: #6b7280; font-weight: 500; }

.file-path { color: var(--text-soft); font-size: 13px; margin: 4px 0 18px; font-family: var(--mono); }

/* section structure */
#content section { margin: 34px 0; }
#content h2 {
  font-size: 21px; margin: 0 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border); scroll-margin-top: 70px;
}
#content h2 .en-sub { font-size: 14px; color: var(--text-soft); font-weight: 400; margin-left: 10px; }
#content h3 {
  font-size: 17px; margin: 26px 0 8px; color: #1f2937; scroll-margin-top: 70px;
}
#content h4 {
  font-size: 15px; margin: 20px 0 8px; font-family: var(--mono);
  background: var(--code-bg); padding: 3px 10px; border-radius: 5px;
  display: inline-block; scroll-margin-top: 70px;
}
#content h5 { font-size: 13px; margin: 14px 0 6px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .6px; }

/* member / method cards */
.member, .method {
  border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px;
  margin: 14px 0; background: #fcfdfe;
}
.member .member-name, .method .method-name {
  font-family: var(--mono); font-weight: 700; font-size: 14.5px; color: #1f2937;
}
.member .member-type, .method .method-type {
  font-family: var(--mono); font-size: 12.5px; color: var(--code-text);
  margin-left: 8px; background: var(--code-bg); padding: 1px 8px; border-radius: 4px;
}
.member .desc, .method .desc { margin: 8px 0 0; }

/* tables */
table {
  border-collapse: collapse; width: 100%; margin: 10px 0 18px;
  font-size: 13.5px;
}
table th {
  background: #f3f6f9; text-align: left; padding: 8px 12px; font-weight: 600;
  border: 1px solid var(--border); white-space: nowrap;
}
table td {
  padding: 7px 12px; border: 1px solid var(--border); vertical-align: top;
}
table tbody tr:nth-child(even) { background: #fafbfc; }
table td code, p code, li code, .desc code {
  font-family: var(--mono); font-size: 12.5px; background: var(--code-bg);
  color: var(--code-text); padding: 1px 6px; border-radius: 4px;
}

/* inheritance tree */
.inherit-tree {
  font-family: var(--mono); font-size: 13.5px; background: var(--code-bg);
  padding: 10px 16px; border-radius: 6px; overflow-x: auto; white-space: nowrap;
}
.inherit-tree .arrow { color: var(--text-soft); margin: 0 8px; }

/* callout boxes */
.callout {
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: 10px 16px; border-radius: 0 6px 6px 0; margin: 14px 0;
}
.callout.warn { border-left-color: #d97706; background: #fef3e2; }
.callout.info { border-left-color: #0e9f6e; background: #e6f6ef; }

/* ---------- page TOC (right side, wide screens) | 页内目录 ---------- */
#page-toc {
  position: fixed; top: calc(var(--topbar-h) + 24px); right: 20px;
  width: 230px; max-height: calc(100vh - 120px); overflow-y: auto;
  font-size: 12.5px; line-height: 1.9; z-index: 50;
  border-left: 1px solid var(--border); padding-left: 14px;
}
@media (max-width: 1420px) { #page-toc { display: none; } }
#page-toc .toc-title { font-weight: 700; color: var(--text-soft); font-size: 11px; letter-spacing: .8px; text-transform: uppercase; margin-bottom: 4px; }
#page-toc a { color: var(--text-soft); text-decoration: none; display: block; }
#page-toc a:hover { color: var(--accent); }
#page-toc a.lv3 { padding-left: 14px; font-size: 11.5px; }
#page-toc a.active { color: var(--accent); font-weight: 600; }

/* ---------- mobile | 移动端 ---------- */
@media (max-width: 1100px) {
  #sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open #sidebar { transform: translateX(0); }
  #content { margin-left: 0; padding: 20px 16px 60px; }
  #menu-btn { display: inline-block; }
  #search { width: 120px; }
}

/* ---------- index / architecture pages | 首页与架构图页 ---------- */
.hero {
  padding: 30px 0 8px;
}
.hero h1 { font-size: 34px; margin: 0 0 10px; }
.hero .sub { color: var(--text-soft); font-size: 16px; max-width: 720px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 20px 0; }
.card {
  border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px;
  text-decoration: none; color: var(--text-main); transition: box-shadow .15s, border-color .15s;
  background: #fff;
}
.card:hover { box-shadow: 0 4px 16px rgba(20,40,80,.10); border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 16px; color: #1f2937; }
.card p { margin: 0; font-size: 13px; color: var(--text-soft); }
.card .card-count { float: right; color: var(--accent); font-weight: 700; font-size: 13px; }

/* architecture svg */
.diagram-wrap {
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: #fbfcfe; margin: 16px 0;
}
.diagram-toolbar {
  display: flex; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: #f6f8fa; align-items: center; flex-wrap: wrap;
}
.diagram-toolbar button {
  border: 1px solid var(--border); background: #fff; border-radius: 5px;
  padding: 3px 12px; cursor: pointer; font-size: 12.5px; color: #1f2937;
}
.diagram-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.diagram-toolbar .hint { color: var(--text-soft); font-size: 12px; }
.diagram-svg-wrap { overflow: auto; max-height: 82vh; }
.diagram-svg-wrap svg { display: block; }

.dg-node { cursor: pointer; }
.dg-node rect.node-body {
  fill: #ffffff; stroke: #94a3b8; stroke-width: 1.2; rx: 8;
  transition: stroke .12s, stroke-width .12s;
}
.dg-node:hover rect.node-body { stroke: var(--accent); stroke-width: 2; }
.dg-node text.node-title { font-family: var(--mono); font-size: 12.5px; font-weight: 700; fill: #1f2937; pointer-events: none; }
.dg-node text.node-sub { font-size: 10.5px; fill: #64748b; pointer-events: none; }
.dg-edge { stroke: #cbd5e1; stroke-width: 1.4; fill: none; }
.dg-edge.arrow { marker-end: url(#arrowhead); }
.dg-edge-label { font-size: 10px; fill: #94a3b8; pointer-events: none; }
.dg-lane { fill: #f8fafc; stroke: #e2e8f0; rx: 10; }
.dg-lane-label { font-size: 12px; font-weight: 700; fill: #475569; letter-spacing: .5px; }

/* principle cards (index page) | 理念卡片 */
.src-line { font-size: 12px; color: var(--text-soft); margin-top: 8px; }
.src-line code { font-size: 11.5px; background: var(--code-bg); padding: 1px 6px; border-radius: 4px; }
.principle-facts { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
.principle-facts summary { cursor: pointer; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.principle-facts ul { margin: 8px 0 0; padding-left: 20px; font-size: 13px; }
.principle-facts li { margin: 3px 0; }

/* utility */
.hidden { display: none !important; }
@media print {
  #topbar, #sidebar, #page-toc { display: none; }
  #content { margin: 0; }
}
