/* mcres/static/css/components/md-body.css
   正文排版：**.md-body 是资源详细介绍唯一的渲染容器**。

   三处共同使用：
     · 详情页 .d2-root .prose .md-body（资源介绍 / 版本介绍）
     · 编辑器预览区 .md-editor .md-body
     · 版本对比 .desc-md（可选）

   配色走 CSS 变量，容器负责定义 --md-text / --md-link / --md-accent 等；
   这里只给一套深色兜底值，任何页面单独引用也不会瞎。

   结构对应 markdown.py 的渲染输出：
     p h1-h6 hr blockquote ul ol li（含任务列表）
     table.caption  pre>code  a  img  video/audio  details/summary
     div.md-container.md-tip|.md-note|.md-warning|.md-danger|.md-details
     div.md-embed>iframe  a.md-attachment  span.katex  section[data-footnotes] */

.md-body {
  --md-fg: var(--text-primary, #dfe6ee);
  --md-fg-soft: var(--text-secondary, #cfd8e3);
  --md-fg-dim: var(--text-muted, #8b97a6);
  --md-line: var(--border-light, #2b313b);
  --md-accent: var(--color-resourcepack, #55d88b);
  --md-accent-soft: rgba(85, 216, 139, .12);
  --md-code-bg: rgba(255, 255, 255, .06);
  --md-quote-bg: rgba(255, 255, 255, .035);
  color: var(--md-fg);
  font-size: 15px;
  line-height: 1.9;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }

/* ---------- 段落与标题 ---------- */
.md-body p { margin: 11px 0; }
.md-body h1, .md-body h2, .md-body h3,
.md-body h4, .md-body h5, .md-body h6 {
  margin: 26px 0 10px;
  color: #fff;
  font-weight: 700;
  line-height: 1.45;
}
.md-body h1 { font-size: 24px; }
.md-body h2 { font-size: 21px; }
.md-body h3 { font-size: 18px; }
.md-body h4 { font-size: 16px; }
.md-body h5, .md-body h6 { font-size: 15px; color: var(--md-fg-soft); }
.md-body h2 { padding-bottom: 6px; border-bottom: 1px solid var(--md-line); }

/* ---------- 列表 ---------- */
.md-body ul, .md-body ol { margin: 11px 0 11px 24px; padding: 0; }
.md-body li { margin: 5px 0; }
.md-body ul li::marker { color: var(--md-accent); }
.md-body ol li::marker { color: var(--md-accent); font-variant-numeric: tabular-nums; }
.md-body ul ul, .md-body ul ol,
.md-body ol ul, .md-body ol ol { margin: 5px 0 5px 20px; }

/* 任务列表：勾选后整行变淡、加删除线更好读 */
.md-body li.task-list-item {
  list-style: none;
  margin-left: -20px;
  padding-left: 22px;
  position: relative;
}
.md-body li.task-list-item input[type="checkbox"] {
  position: absolute;
  left: 0;
  top: .55em;
  width: 14px;
  height: 14px;
  accent-color: var(--md-accent);
  pointer-events: none;
}
.md-body li.task-list-item:has(input[type="checkbox"]:checked) {
  color: var(--md-fg-dim);
  text-decoration: line-through;
}

/* ---------- 引用与分隔线 ---------- */
.md-body blockquote {
  margin: 15px 0;
  padding: 11px 15px;
  border-left: 3px solid var(--md-accent);
  border-radius: 0 8px 8px 0;
  background: var(--md-accent-soft);
  color: var(--md-fg-soft);
  font-size: 14px;
}
.md-body blockquote > :first-child { margin-top: 0; }
.md-body blockquote > :last-child { margin-bottom: 0; }
.md-body hr {
  margin: 24px 0;
  border: none;
  border-top: 1px solid var(--md-line);
}

/* ---------- 代码 ---------- */
.md-body code {
  font-family: "Cascadia Code", Consolas, "Sarasa Mono SC", monospace;
  font-size: .88em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--md-code-bg);
  color: var(--md-accent);
}
.md-body pre {
  margin: 15px 0;
  padding: 13px 16px;
  overflow-x: auto;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  background: rgba(0, 0, 0, .28);
  line-height: 1.65;
}
.md-body pre code {
  padding: 0;
  background: none;
  color: var(--md-fg);
  font-size: 13px;
  white-space: pre;
}
.md-body kbd {
  padding: 1px 6px;
  border: 1px solid var(--md-line);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-size: .85em;
  font-family: inherit;
}
.md-body mark { background: rgba(245, 166, 35, .25); color: inherit; }

/* ---------- 链接与图片 ---------- */
.md-body a {
  color: var(--md-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .12s;
}
.md-body a:hover { border-bottom-color: currentColor; }
.md-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  vertical-align: middle;
}
.md-body figure { margin: 16px 0; }
.md-body figcaption {
  margin-top: 6px;
  color: var(--md-fg-dim);
  font-size: 12.5px;
  text-align: center;
}

/* ---------- 表格 ---------- */
.md-body table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.md-body thead th {
  background: rgba(255, 255, 255, .05);
  font-weight: 700;
  color: #fff;
}
.md-body th, .md-body td {
  padding: 8px 12px;
  border: 1px solid var(--md-line);
  text-align: left;
  vertical-align: top;
}
.md-body tbody tr:nth-child(even) { background: rgba(255, 255, 255, .02); }
.md-body th[align="center"], .md-body td[align="center"] { text-align: center; }
.md-body th[align="right"], .md-body td[align="right"] { text-align: right; }

/* ---------- 提示框 / 折叠块 ---------- */
.md-body .md-container {
  margin: 16px 0;
  padding: 12px 16px;
  border: 1px solid var(--md-line);
  border-left: 3px solid var(--md-accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
}
.md-body .md-container > :first-child { margin-top: 0; }
.md-body .md-container > :last-child { margin-bottom: 0; }
.md-body .md-container[data-title]:not([data-title=""]) {
  padding-top: 34px;
  position: relative;
}
.md-body .md-container[data-title]:not([data-title=""])::before {
  content: attr(data-title);
  position: absolute;
  top: 8px;
  left: 16px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--md-accent);
}
.md-body .md-note { border-left-color: #6fa9e6; }
.md-body .md-note::before { color: #8dbdf0 !important; }
.md-body .md-warning, .md-body .md-danger { border-left-color: #f5a623; }
.md-body .md-warning::before, .md-body .md-danger::before { color: #f5a623 !important; }
.md-body .md-danger { border-left-color: #e5534b; }
.md-body .md-danger::before { color: #e5534b !important; }
.md-body .md-success::before { color: #55d88b !important; }

/* ---------- 对齐容器（编辑器工具栏的 居中 / 右对齐）---------- */
.md-body .md-center { text-align: center; border-left: none; padding-left: 16px; }
.md-body .md-right { text-align: right; border-left: none; padding-left: 16px; }
.md-body .md-left { text-align: left; border-left: none; }
.md-body .md-center > img,
.md-body .md-center > video,
.md-body .md-center > p > img,
.md-body .md-center > p > video,
.md-body .md-right > img,
.md-body .md-right > video,
.md-body .md-right > p > img,
.md-body .md-right > p > video { display: inline-block; margin-left: auto; margin-right: auto; }
.md-body .md-center table, .md-body .md-right table { display: inline-block; }
.md-body .md-center ul, .md-body .md-center ol { display: inline-block; text-align: left; }

.md-body details {
  margin: 16px 0;
  padding: 10px 14px;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
}
.md-body summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--md-fg);
}
.md-body summary::marker { color: var(--md-accent); }

/* ---------- 富媒体 ---------- */
.md-body video.md-video,
.md-body audio.md-audio {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 16px 0;
  border-radius: 8px;
  background: #000;
}
.md-body audio.md-audio { background: transparent; }
.md-body .md-embed {
  position: relative;
  margin: 16px 0;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.md-body .md-embed iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.md-body a.md-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 10px 14px;
  border: 1px solid var(--md-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
  color: var(--md-fg);
  border-bottom: 1px solid var(--md-line);
}
.md-body a.md-attachment:hover { border-color: var(--md-accent); }
.md-body .md-attachment-icon { color: var(--md-accent); font-size: 16px; }
.md-body .md-attachment-name { font-weight: 600; }
.md-body .md-attachment-meta {
  margin-left: auto;
  color: var(--md-fg-dim);
  font-size: 12px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 公式 ---------- */
.md-body .katex { font-size: 1.05em; }
.md-body .katex-display {
  margin: 18px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}
.md-body .md-math-inline { white-space: nowrap; }
.md-body .md-math-error {
  color: #e5534b;
  font-family: "Cascadia Code", Consolas, monospace;
}

/* ---------- 脚注 ---------- */
.md-body section[data-footnotes] {
  margin-top: 26px;
  padding-top: 12px;
  border-top: 1px solid var(--md-line);
  font-size: 13px;
  color: var(--md-fg-dim);
}
.md-body sup {
  font-size: .72em;
  line-height: 0;
}

/* ---------- 空状态 ---------- */
.md-body .md-empty {
  color: var(--md-fg-dim);
  font-style: italic;
}
