/* ==========================================================================
   觉醒 —— 书籍主题
   暖纸底色 · 墨色文字 · 朱砂点缀 · 中英混排的书卷气
   大陆优化版:无外部字体加载,微信浏览器兼容
   ========================================================================== */

/* 1. 设计变量 */
:root {
  /* —— 色板 —— */
  --paper: #f6f1e8;        /* 页面底色:暖纸 */
  --ink: #2e2922;          /* 正文:暖墨 */
  --ink-soft: #5b5345;     /* 次级文字 */
  --ink-faint: #93887a;    /* 弱化文字:注释 / 页码 */
  --accent: #9e4f27;       /* 朱砂红:强调与链接 */
  --accent-soft: #b46a3f;  /* 强调悬停 */
  --gold: #b3954f;         /* 点缀金:装饰线 */
  --line: #e2d8c6;         /* 分隔线 */
  --quote-bg: #f4ecdd;     /* 引用底色 */
  --code-bg: #f3ecdf;      /* 代码底色 */
  --th-bg: #efe6d5;        /* 表头底色 */

  /* —— 字体栈(纯系统字体,不加载外部字体) —— */
  --font-serif: 'Source Han Serif SC','Noto Serif SC','Songti SC','STSong','SimSun',serif;
  --font-ui: 'Source Han Serif SC','PingFang SC','Microsoft YaHei','Hiragino Sans GB',sans-serif;
  --font-mono: 'SF Mono','Menlo','Consolas','Courier New',monospace;

  /* —— 覆盖 united 主题的默认值 —— */
  --bs-body-bg: var(--paper);
  --bs-body-color: var(--ink);
  --bs-body-font-family: var(--font-serif);
  --bs-body-line-height: 1.9;
  --bs-link-color: var(--accent);
  --bs-link-hover-color: var(--accent-soft);
  --bs-link-decoration: none;
  --bs-primary: var(--accent);
  --bs-primary-rgb: 158,79,39;
}

/* 2. 基础排版 */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--bs-body-font-family);
  font-size: 17px;
  line-height: 1.9;
  color: var(--ink);
  background-color: var(--paper);
  letter-spacing: .015em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (max-width: 768px) { body { font-size: 16px; } }
@media (max-width: 480px) { body { font-size: 15px; } }

::selection { background: rgba(158,79,39,.18); }

/* 阅读栏宽:正文不铺满整屏 */
main.content {
  max-width: 46em;
  margin-left: auto;
  margin-right: auto;
}

/* 3. 正文 —— 中文书式:段首缩进两字 */
main.content section > p { text-indent: 2em; }
main.content section li p,
main.content section blockquote p,
main.content section .callout p { text-indent: 0; }

/* 4. 标题 */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.45;
}

/* 4.1 章标题(页首标题块) */
.quarto-title h1.title {
  text-align: center;
  font-size: 2em;
  letter-spacing: .08em;
  margin-bottom: .3em;
}
.quarto-title h1.title .chapter-number {
  color: var(--accent);
  font-weight: 400;
  font-size: .72em;
  margin-right: .2em;
  letter-spacing: 0;
}
.quarto-title p.subtitle {
  text-align: center;
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-weight: 400;
  letter-spacing: .08em;
}
/* 标题下方的金色饰线 */
.quarto-title-block::after {
  content: "";
  display: block;
  width: 4em;
  height: 2px;
  margin: 1.1em auto 1.5em;
  background: -webkit-gradient(linear, left top, right top, from(transparent), color-stop(20%, var(--gold)), color-stop(80%, var(--gold)), to(transparent));
  background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent);
}

/* 4.2 小节标题 */
main.content h2 {
  margin: 2.4em 0 .9em;
  padding-left: .6em;
  border-left: 3px solid var(--accent);
  font-size: 1.28em;
}
main.content h2 .header-section-number {
  color: var(--accent);
  font-size: .78em;
  font-weight: 400;
  margin-right: .5em;
}
main.content h3 {
  margin: 2em 0 .7em;
  font-size: 1.12em;
  color: var(--ink-soft);
}
main.content h3 .header-section-number {
  color: var(--accent);
  font-size: .8em;
  font-weight: 400;
  margin-right: .5em;
}
main.content h4, main.content h5, main.content h6 {
  margin: 1.6em 0 .6em;
  font-size: 1.02em;
  color: var(--ink-soft);
}

/* 5. 段落与强调 */
main.content p { margin: .9em 0; }
strong { font-weight: 700; color: var(--ink); }

/* 6. 链接 */
a {
  color: var(--bs-link-color);
  text-decoration: none;
  -webkit-transition: color .15s ease;
  transition: color .15s ease;
}
a:hover {
  color: var(--bs-link-hover-color);
  text-decoration: underline;
  text-underline-offset: .2em;
}

/* 7. 引用 */
blockquote {
  margin: 1.6em 0;
  padding: .9em 1.3em;
  background: var(--quote-bg);
  border-left: 3px solid var(--gold);
  color: var(--ink-soft);
  border-radius: 0 8px 8px 0;
}
blockquote p { margin: .4em 0; }

/* 8. 列表 */
main.content ul, main.content ol { padding-left: 1.6em; margin: 1em 0; }
main.content li { margin: .45em 0; }
main.content ul > li::marker { color: var(--accent); }

/* 9. 表格 */
main.content table {
  font-size: .95em;
  width: auto;
  max-width: 100%;
  margin: 1.6em auto;
  border-collapse: collapse;
}
main.content thead th {
  background: var(--th-bg);
  color: var(--ink);
  font-weight: 600;
  padding: .55em .95em;
  border-bottom: 1.5px solid var(--gold);
}
main.content td { padding: .5em .95em; border-bottom: 1px solid var(--line); }
main.content tbody tr:nth-child(even) { background: rgba(239,230,213,.45); }

/* 10. 代码 */
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1em 1.2em;
  font-size: .9em;
  line-height: 1.65;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
}
pre code {
  background: none;
  padding: 0;
  color: var(--ink);
  font-family: var(--font-mono);
}
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: .86em;
  background: var(--code-bg);
  color: var(--accent);
  padding: .15em .45em;
  border-radius: 4px;
  word-break: break-word;
  white-space: normal;
}

/* 11. 图片与图注 */
img {
  max-width: 100%;
  height: auto;
  -ms-interpolation-mode: bicubic;
}
.figure-caption {
  text-align: center;
  font-size: .88em;
  font-weight: 600;
  color: var(--ink-faint);
  margin-top: .6em;
}

/* 12. 左侧边栏(全书目录) */
#quarto-sidebar {
  background: var(--paper);
  border-right: 1px solid var(--line);
  font-family: var(--font-ui);
}
#quarto-sidebar .sidebar-title {
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink);
}
#quarto-sidebar #toc-title {
  font-family: var(--font-ui);
  font-size: .9em;
  letter-spacing: .2em;
  color: var(--ink-faint);
}
#quarto-sidebar a.nav-link { color: var(--ink-soft); }
#quarto-sidebar a.nav-link:hover { color: var(--accent); }
#quarto-sidebar a.nav-link.active { color: var(--accent); font-weight: 600; }
#quarto-sidebar .toc-active { background: rgba(158,79,39,.07); border-left: 2px solid var(--accent); }
#quarto-sidebar .header-section-number {
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: .8em;
  margin-right: .35em;
}

/* 13. 右侧 TOC:覆盖 united 主题把 #TOC 和 .margin-sidebar 隐藏的规则 */
#TOC { display: block !important; }
#quarto-margin-sidebar { display: block !important; }

/* 14. 顶部导航(移动端)与面包屑 */
header#quarto-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
header#quarto-header .quarto-page-breadcrumbs a { color: var(--ink-soft); }
header#quarto-header .quarto-page-breadcrumbs a:hover { color: var(--accent); }
.quarto-title-breadcrumbs .breadcrumb-item a { color: var(--ink-faint); }
.quarto-title-breadcrumbs .breadcrumb-item:last-child a { color: var(--accent); }

/* 标题信息区(作者 / 日期) */
.quarto-title-meta-heading {
  font-family: var(--font-ui);
  font-size: .78em;
  letter-spacing: .15em;
  color: var(--ink-faint);
}
.quarto-title-meta-contents { color: var(--ink-soft); font-size: .95em; }

/* 15. 页脚上一页 / 下一页 */
.nav-page { border-top: 1px solid var(--line); }
.nav-page .nav-page-text { color: var(--ink-faint); }
.nav-page a { color: var(--accent); }

/* ===================================================================
   16. 前言页(index.qmd)
   不使用 :has() 以保证微信 X5 内核兼容。
   index.qmd 中通过 JS 给 body 添加了 .cover-mode 类。
   =================================================================== */

/* 封面模式:大标题居中 */
.cover-mode .quarto-title h1.title {
  font-size: 2.6em;
  letter-spacing: .16em;
  text-indent: .16em;
  margin-top: .4em;
}
.cover-mode .quarto-title p.subtitle { letter-spacing: .22em; }
.cover-mode .quarto-title-meta { -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; }

.cover {
  max-width: 40em;
  margin: 1.8em auto 4em;
  text-align: center;
}

/* "前言"小标题 */
.cover h1 {
  font-size: 1.35em;
  font-weight: 600;
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--ink);
  margin: 0 0 .6em;
}
.cover h1::before {
  content: "";
  display: block;
  width: 2.6em;
  height: 1px;
  background: -webkit-gradient(linear, left top, right top, from(transparent), color-stop(var(--gold)), to(transparent));
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 0 auto .9em;
}

/* 封面图 */
.cover-img {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 1.6em auto 2.2em;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(46,41,34,.12);
}

.cover .tagline {
  font-size: 1.22em;
  line-height: 1.9;
  color: var(--accent);
  font-weight: 600;
  margin: 1.2em auto 1.6em;
  max-width: 30em;
}
.cover .tagline p,
.cover .closing p { margin: 0; text-align: center; text-indent: 0; }

/* 正文段落 */
.cover section > p {
  text-align: justify;
  text-justify: inter-ideograph;
  max-width: 32em;
  margin: 1.1em auto;
}

/* 四部分目录 */
.cover ul {
  list-style: none;
  margin: 2.2em auto;
  padding: 0;
  max-width: 33em;
  text-align: left;
}
.cover ul li {
  padding: .75em .2em .75em 1.1em;
  border-bottom: 1px dashed var(--line);
  font-size: 1em;
  line-height: 1.8;
}
.cover ul li:last-child { border-bottom: none; }
.cover ul li strong { color: var(--ink); }

.cover .closing {
  color: var(--ink-soft);
  margin-top: 2.4em;
  font-size: .98em;
  letter-spacing: .03em;
}

@media (max-width: 768px) {
  .cover-mode .quarto-title h1.title { font-size: 2em; letter-spacing: .12em; text-indent: .12em; }
  .cover h1 { font-size: 1.2em; letter-spacing: .24em; text-indent: .24em; }
}

/* ===================================================================
   17. 移动端适配(微信浏览器特别优化)
   =================================================================== */

/* 微信内置浏览器:禁用通过长按菜单选择文字时弹出的菜单项 */
* {
  -webkit-touch-callout: none;
  -webkit-user-select: text;
  user-select: text;
}

/* 移动端:加大触控目标 */
@media (max-width: 768px) {
  /* 左侧栏链接加大点击区域 */
  #quarto-sidebar a.nav-link {
    padding: .4em 0;
    display: block;
  }

  /* 页脚导航按钮 */
  .nav-page a {
    padding: .6em 0;
  }

  /* TOC 链接 */
  #TOC a.nav-link {
    padding: .3em 0;
    display: block;
  }

  /* 正文内链接 */
  main.content a {
    padding: .15em 0;
  }

  /* 减少左侧栏宽度以腾出阅读空间 */
  #quarto-sidebar {
    width: 260px !important;
  }
}

/* 小屏手机:进一步调整 */
@media (max-width: 480px) {
  main.content h2 {
    font-size: 1.15em;
    margin: 1.8em 0 .7em;
  }
  main.content h3 {
    font-size: 1.05em;
    margin: 1.5em 0 .6em;
  }
}

/* 18. 工具类 */
.chapquote {
  text-align: right;
  color: var(--ink-soft);
  width: 80%;
  margin: 1em 0 2em auto;
}
.clipped { clip-path: circle(); }
.centre-it { margin-left: auto; margin-right: auto; }
img.rounded {
  object-fit: cover;
  border-radius: 10%;
  height: 240px;
  width: 250px;
  margin-top: 18px;
}
.small-table { font-size: 14px; line-height: 1.2; }
.small-table tr:nth-child(even) { background-color: var(--paper); }
.small-table th {
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.output-scroll {
  max-height: 500px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
}
.output-scroll::-webkit-scrollbar { width: 8px; }
.output-scroll::-webkit-scrollbar-thumb { background-color: var(--line); border-radius: 4px; }
.sidebar-logo { max-width: 100% !important; }

@media (max-width: 952px) {
  img.rounded {
    height: auto;
    width: 80%;
    display: block;
    margin: 18px auto 0;
  }
}

/* 19. Callout 卡片(练习 / 注意 / 提示) */
.callout.callout-style-default {
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: #faf5ea;
  box-shadow: none;
  margin: 1.8em 0;
}
.callout .callout-header {
  padding: .55em 1.25em .5em;
  background: rgba(179,149,79,.12);
  border-bottom: 1px solid var(--line);
  border-radius: 0 10px 0 0;
}
.callout .callout-title-container {
  font-family: var(--font-ui);
  font-size: .92em;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink);
}
.callout .callout-icon { display: none; }
.callout .callout-body {
  padding: .9em 1.35em 1.05em;
  font-size: 1em;
}
.callout .callout-body > p { margin: .55em 0; }
.callout .callout-body > p:first-child { margin-top: 0; }
.callout .callout-body > p:last-child { margin-bottom: 0; }
.callout .callout-body ul,
.callout .callout-body ol { margin: .4em 0; padding-left: 1.5em; }

/* 类型色 */
div.callout.callout-tip { border-left-color: var(--accent); }
div.callout.callout-tip .callout-header { background: rgba(158,79,39,.08); }
div.callout.callout-note { border-left-color: var(--gold); }
div.callout.callout-note .callout-header { background: rgba(179,149,79,.12); }
div.callout.callout-warning { border-left-color: #b3543a; }
div.callout.callout-warning .callout-header { background: rgba(179,84,58,.09); }
div.callout.callout-important { border-left-color: var(--accent); }
div.callout.callout-important .callout-header { background: rgba(158,79,39,.12); }