/* ============================================================
   教程中心 · 前台样式
   两栏文档布局（左侧目录 + 正文）
   全文楷书书法字体（MaShanZheng，开源楷书），标题渐变艺术字
   ============================================================ */

/* 开源楷书字体：马善政楷书（Ma Shan Zheng，OFL 许可，工整清晰） */
@font-face {
  font-family: 'MaShanZheng';
  src: url('fonts/MaShanZheng.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fbfbfc;
  --bg-side: #f7f8fa;
  --bg-card: #ffffff;
  --ink: #1f2328;
  --ink-soft: #37414b;
  --muted: #59636e;
  --teal: #0e6b62;
  --teal-ink: #0a4f49;
  --teal-soft: #e6f0ee;
  --amber: #b7791f;
  --line: #e6e8ea;
  --line-strong: #d0d7de;
  --font-body: "MaShanZheng", "楷体", "KaiTi", "华文楷体", "STKaiti",
               -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
               "Noto Sans SC", sans-serif;
  --font-art: "MaShanZheng", "楷体", "KaiTi", "华文楷体", "STKaiti", sans-serif;
  --font-code: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-ink); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- 两栏主体布局 ---------- */

.layout {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

/* 桌面：点标题前 ☰ 可收起/展开侧边栏 */
body.sidebar-hidden .sidebar { display: none; }
body.sidebar-hidden .layout { grid-template-columns: 1fr; }

/* --- 左侧目录 --- */

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-side);
  padding: 0 16px 48px;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* 侧边栏顶部站名：居中、增大、艺术字渐变 */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 10px 18px;
  margin-bottom: 14px;
  font-size: 24px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-family: var(--font-art);
  background: linear-gradient(120deg, #0e6b62 0%, #2a9d8f 45%, #e76f51 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.cat-item { margin-bottom: 22px; }

.cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .06em;
}

.cat-head::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--teal);
  flex: none;
}

.doc-item {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.5;
  transition: all .12s;
}
.doc-item:hover { background: #eef0f2; color: var(--teal-ink); text-decoration: none; }
.doc-item.active {
  background: rgba(42, 157, 143, 0.14);
  color: var(--teal-ink);
  font-weight: 600;
}

.sidebar-empty {
  color: var(--muted);
  font-size: 14.5px;
  padding: 10px;
}

/* 手机抽屉遮罩：桌面隐藏，手机显示 */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 20, 0.45);
  z-index: 80;
}

/* --- 正文区 --- */

.content {
  padding: 44px 56px 96px;
  min-width: 0;
  background: var(--bg-card);
}

/* 正文满宽，与顶栏搜索框右缘对齐 */
#article-view { max-width: none; }

.article-head { margin-bottom: 34px; }

/* 正文标题前的 ☰ 按钮：靠左，与标题垂直对齐（青色渐变圆角按钮，明显醒目） */
.art-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2a9d8f, #0e6b62);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  flex: none;
  justify-self: start;
  padding: 0;
  box-shadow: 0 2px 10px rgba(14, 107, 98, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.art-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(14, 107, 98, 0.38);
}
.art-toggle:active { transform: translateY(0); }

/* 标题行：☰ 在左，标题居中 */
.article-title-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

/* 文章标题：居中 + 艺术字渐变 */
.article-title {
  grid-column: 2;
  margin: 0;
  font-size: 34px;
  line-height: 1.3;
  font-weight: 800;
  font-family: var(--font-art);
  background: linear-gradient(120deg, #0e6b62 0%, #2a9d8f 45%, #e76f51 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.article-summary {
  color: var(--ink-soft);
  font-size: 17.5px;
  margin: 18px 0 0;
  padding: 18px 22px;
  background: var(--bg-side);
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: 8px;
  text-align: left;
}

.article-body {
  border-top: 1px solid var(--line);
  padding-top: 34px;
  font-size: 17px;
  line-height: 1.9;
  word-break: break-word;
}
.article-body > *:first-child { margin-top: 0; }
.article-body h1 { font-size: 27px; margin: 36px 0 14px; }
.article-body h2 { font-size: 23px; margin: 32px 0 12px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.article-body h3 { font-size: 19px; margin: 24px 0 10px; }
.article-body h4 { font-size: 17px; margin: 18px 0 8px; }
.article-body p { margin: 14px 0; }
.article-body ul, .article-body ol { margin: 14px 0; padding-left: 28px; }
.article-body li { margin: 6px 0; }
.article-body code {
  font-family: var(--font-code);
  font-size: .87em;
  background: var(--teal-soft);
  color: var(--teal-ink);
  padding: 2px 7px;
  border-radius: 5px;
}
.article-body pre {
  background: #161b22;
  color: #e6edf3;
  padding: 20px 22px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.7;
  margin: 18px 0;
}
.article-body pre code { background: none; color: inherit; padding: 0; }
.article-body table { border-collapse: collapse; width: 100%; font-size: 15.5px; margin: 18px 0; }
.article-body th, .article-body td { border: 1px solid var(--line-strong); padding: 10px 14px; text-align: left; }
.article-body th { background: var(--bg-side); font-weight: 600; }
.article-body blockquote {
  margin: 18px 0;
  padding: 4px 20px;
  border-left: 5px solid var(--teal);
  background: var(--teal-soft);
  border-radius: 0 8px 8px 0;
  color: var(--ink-soft);
}
.article-body blockquote p { margin: 10px 0; }
.article-body img {
  display: block;
  max-width: 92%;
  margin: 20px auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 3px 14px rgba(31, 35, 40, 0.1);
}
/* 同一段落连续多张图：居中并排 */
.article-body p:has(> img) {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 18px 0;
}
.article-body p:has(> img) img { margin: 4px 0; max-width: 94%; }
.article-body hr { border: none; border-top: 1px solid var(--line); margin: 32px 0; }

.no-result {
  padding: 80px 0;
  text-align: center;
  color: var(--muted);
  font-size: 17px;
}

/* --- 右侧页内目录（已移除，保留样式占位） --- */

.toc { display: none; }

.toc-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .05em;
  margin-bottom: 14px;
}

.toc-list { display: flex; flex-direction: column; gap: 2px; }

.toc-link {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.5;
  border-left: 2px solid transparent;
}
.toc-link:hover { color: var(--teal-ink); text-decoration: none; background: var(--bg-side); }
.toc-link.active { color: var(--teal); border-left-color: var(--teal); font-weight: 600; background: var(--teal-soft); }
.toc-link.lv3 { padding-left: 20px; font-size: 13.5px; }

.toc-empty { color: var(--muted); font-size: 14px; }

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

/* 中等宽度：目录栏收窄，顶栏与正文边距对齐 */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .content { padding: 34px 32px 80px; }
}

/* 小屏（手机/平板竖屏）：目录收进左侧，点正文标题前 ☰ 从侧边滑出 */
@media (max-width: 992px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar-mask { display: block; }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 284px;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform .25s ease;
    border-right: 1px solid var(--line);
    border-bottom: none;
    box-shadow: 2px 0 24px rgba(31, 35, 40, 0.2);
    background: var(--bg-side);
    padding: 0 14px 40px;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-brand { padding: 20px 10px 16px; font-size: 22px; }
  .content { padding: 26px 18px 64px; }
  .article-title { font-size: 27px; }
}
