/* doc2site 基础样式。
 *
 * 两条约束决定了这里的每一个选择：
 *   1. 产物是陌生人用**手机**打开的；
 *   2. 内容是中文，而中文没有空格可以断行。
 */

:root {
  --d2s-fg: #1a1a1a;
  --d2s-bg: #ffffff;
  --d2s-muted: #666;
  --d2s-border: #e2e2e2;
  --d2s-accent: #2563eb;
  --d2s-warn-bg: #fff8e6;
  --d2s-warn-border: #e0a800;
  --d2s-surface: #f7f7f8;
  --d2s-measure: 42em;
}

@media (prefers-color-scheme: dark) {
  :root {
    --d2s-fg: #e6e6e6;
    --d2s-bg: #16171a;
    --d2s-muted: #9aa0a6;
    --d2s-border: #33363b;
    --d2s-accent: #7aa2f7;
    --d2s-warn-bg: #2b2410;
    --d2s-warn-border: #a17d1a;
    --d2s-surface: #1e2024;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--d2s-bg);
  color: var(--d2s-fg);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "d2s-sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  margin: 0;
  /* 中文没有空格，长串标点/英文混排时必须显式允许断行，
     否则一行能把整个视口撑破。 */
  line-break: strict;
  overflow-wrap: break-word;
  line-height: 1.75;
  font-size: 16px;
}

.d2s-page {
  max-width: var(--d2s-measure);
  margin: 0 auto;
  padding: 2rem 1.1rem 6rem;
}

.d2s-page.d2s-wide { max-width: 72em; }

/* 顶栏 */
.d2s-bar {
  border-bottom: 1px solid var(--d2s-border);
  padding: .7rem 1.1rem;
  display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap;
  font-size: .85rem; color: var(--d2s-muted);
}
.d2s-bar a { color: var(--d2s-accent); text-decoration: none; }
.d2s-bar a:hover { text-decoration: underline; }
.d2s-bar strong { color: var(--d2s-fg); font-weight: 600; }

/* 内容丢失横幅：读者本人也有权知道缺了什么，
   而不是只有那个跑构建的人知道。 */
.d2s-notice {
  background: var(--d2s-warn-bg);
  border: 1px solid var(--d2s-warn-border);
  border-radius: 8px;
  padding: .8rem 1rem;
  margin: 0 0 1.6rem;
  font-size: .92rem;
}
.d2s-notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.d2s-notice a { color: var(--d2s-accent); font-weight: 600; }

h1, h2, h3, h4 { line-height: 1.35; margin: 2em 0 .6em; }
h1 { font-size: 1.9rem; margin-top: 0; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.18rem; }
p { margin: 0 0 1em; }

a { color: var(--d2s-accent); }

img, svg, video { max-width: 100%; height: auto; }

/* 宽内容自己滚，页面本身永远不许横向滚 */
.d2s-scroll, table, pre { max-width: 100%; overflow-x: auto; }

table {
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: .95em;
  display: block;          /* 让 overflow-x 生效 */
  width: max-content;
  max-width: 100%;
}
th, td { border: 1px solid var(--d2s-border); padding: .4em .7em; text-align: left; }
th { background: var(--d2s-surface); font-weight: 600; }

pre.d2s-code {
  background: var(--d2s-surface);
  border: 1px solid var(--d2s-border);
  border-radius: 6px;
  padding: .8em 1em;
  font-size: .88em;
  line-height: 1.6;
}
code { font-size: .92em; }
:not(pre) > code {
  background: var(--d2s-surface);
  border: 1px solid var(--d2s-border);
  border-radius: 4px;
  padding: .1em .35em;
}

blockquote {
  margin: 1.2em 0;
  padding: .2em 0 .2em 1em;
  border-left: 3px solid var(--d2s-border);
  color: var(--d2s-muted);
}

hr { border: 0; border-top: 1px solid var(--d2s-border); margin: 2.4em 0; }

.footnotes { font-size: .9em; color: var(--d2s-muted);
             border-top: 1px solid var(--d2s-border); margin-top: 3em; }

.task-list-item { list-style: none; }
.task-list-item input { margin-right: .5em; }

/* ---------- docx ---------- */
/* docx-preview 输出的是 A4 页盒：section 上带着内联的
   `padding: 72pt; width: 595.3pt`，外面套一个灰底带投影的 wrapper。
   在 1280px 桌面上像一份文档；在 390px 手机上，那 595.3pt 会把正文挤成
   每行三四个字的一条细缝，而页面本身还不横向溢出——所以自动化的
   溢出闸门抓不到它，只有真的看一眼才看得见。

   内联样式必须用 !important 才压得住。 */
.d2s-docx .docx-wrapper {
  background: transparent !important;
  padding: 0 !important;
  display: block !important;
}
.d2s-docx section.docx {
  width: auto !important;
  max-width: 100% !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 0 !important;
  margin: 0 0 1.5em !important;
  box-shadow: none !important;
  background: transparent !important;
  overflow: visible !important;
  display: block !important;
}
.d2s-docx section.docx > article { margin-bottom: 0 !important; }
.d2s-docx img, .d2s-docx svg { max-width: 100% !important; height: auto !important; }

/* 被丢弃的图表/SmartArt 会留下一个按原尺寸撑开的空盒子——
   一大片什么都没有的留白，比缺失本身更让人困惑。
   收掉它，让顶部的横幅去说明缺了什么。 */
.d2s-docx .d2s-empty-box {
  display: block !important;
  width: auto !important;
  height: auto !important;
}

@media (max-width: 820px) {
  .d2s-docx [style*="width"] { max-width: 100% !important; }
  .d2s-docx table { display: block; overflow-x: auto; }
}

/* 无法转换的 EMF/WMF 的可见占位符。
   不伪造缺失的内容，也不留一个静默的空洞。 */
.d2s-missing {
  display: inline-block;
  border: 1px dashed var(--d2s-warn-border);
  background: var(--d2s-warn-bg);
  color: var(--d2s-muted);
  padding: .5em .8em;
  border-radius: 6px;
  font-size: .85em;
}

/* ---------- pptx ---------- */
/* 每页锁定原始宽高比，用 CSS 变量驱动缩放，
   这样不需要 JavaScript 就能在手机上正确缩放。 */
.d2s-slides { max-width: 72em; margin: 0 auto; padding: 1.5rem 1rem 5rem; }

.d2s-slide {
  position: relative;
  width: 100%;
  aspect-ratio: var(--d2s-slide-ratio, 16 / 9);
  margin: 0 0 1.6rem;
  border: 1px solid var(--d2s-border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

/* 内层保持渲染时的像素尺寸，靠 scale 适配容器宽度。
   容器宽度用 cqw（容器查询单位），无 JS。 */
.d2s-slide-inner {
  position: absolute;
  top: 0; left: 0;
  width: var(--d2s-slide-w, 1280px);
  height: var(--d2s-slide-h, 720px);
  transform-origin: 0 0;
  transform: scale(calc(100cqw / var(--d2s-slide-w-num, 1280)));
}
.d2s-slide { container-type: inline-size; }

.d2s-slide-label {
  font-size: .8rem; color: var(--d2s-muted);
  margin: 0 0 .35rem;
}

.d2s-notes {
  margin: -1rem 0 2rem;
  font-size: .9rem;
  border: 1px solid var(--d2s-border);
  border-radius: 6px;
  background: var(--d2s-surface);
}
.d2s-notes summary { cursor: pointer; padding: .5em .8em; color: var(--d2s-muted); }
.d2s-notes .d2s-notes-body { padding: 0 .8em .8em; white-space: pre-wrap; }

/* ---------- 索引页 ---------- */
.d2s-index-list { list-style: none; padding: 0; margin: 1.5em 0 0; }
.d2s-index-list li {
  border-bottom: 1px solid var(--d2s-border);
  padding: .85em 0;
}
.d2s-index-list a { font-size: 1.06rem; text-decoration: none; font-weight: 600; }
.d2s-index-list a:hover { text-decoration: underline; }
.d2s-index-meta { color: var(--d2s-muted); font-size: .84rem; margin-top: .25em; }
.d2s-tag {
  display: inline-block; font-size: .74rem; padding: .1em .5em;
  border: 1px solid var(--d2s-border); border-radius: 999px; margin-left: .4em;
  color: var(--d2s-muted);
}

@media print {
  .d2s-bar, .d2s-notice { display: none; }
  .d2s-page { max-width: none; padding: 0; }
}
