/* ==========================================================================
   正文排版 — 前台文章详情页 与 后台内容编辑器 共用（单一数据源）
   目的：「编辑即所见」——后台编辑区与前台详情页使用完全相同的排版规则，
        字号、行距、首行缩进、标题、图片对齐与缩放、引用、表格、列表全部一致。
   注意：本文件不依赖任何主题变量，颜色/字体使用字面量，保证前后台通用。
   ========================================================================== */

.article-content,
.rich-text {
  font-size: 16.5px;
  line-height: 2.05;
  color: #26303f;
  word-break: break-word;
}

/* 段落：段间距 + 中文首行缩进两字

   段间距取值依据（不要随意放大）：
     正文行高 2.05 → 16.5px 字号的行盒高约 33.8px，
     行与行之间的视觉空隙 = 33.8 − 16.5 ≈ 17.3px；
     段落额外留 6px 外边距，加上上下两行的半行距，段与段的视觉间距约 23px，
     约为行间距的 1.3 倍 —— 段落层次清楚，又不会出现「空一行」的松散感。
     需要整体再紧或再松，只改这里的 6px（含下方 div 一条），前后台同步生效。 */
.article-content p,
.rich-text p { margin: 0 0 6px; text-indent: 2em; }

/* 兼容早期用 <div> 分段的内容 */
.article-content > div,
.rich-text > div { margin: 0 0 6px; text-indent: 2em; }

/* 真正的空段落（<p></p>，多为编辑时残留）不占任何高度与间距 */
.article-content p:empty,
.rich-text p:empty { margin: 0; height: 0; }

/* 段内 <br> 换行的续行缩进：空标记只用左内边距撑出 2 字符，
   行内元素的内边距不参与行高计算 → 行距与之前完全一致。
   标记由 /js/richtext-indent.js 按「该块首行缩进 > 0」的规则自动插入，不写入数据库。 */
.article-content span.br-indent,
.rich-text span.br-indent { padding-left: 2em; }

/* 小标题 */
.article-content h2,
.rich-text h2 {
  font-size: 20px; margin: 26px 0 14px; color: #0b3c74;
  font-family: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", serif;
}
.article-content h3,
.rich-text h3 { font-size: 18px; margin: 22px 0 12px; color: #0b3c74; }

/* 图片：以行内块参与排版，使段落 text-align（左/中/右）真实生效；
   等比缩放完整显示（不裁切），与后台编辑区表现一致。 */
.article-content img,
.rich-text img {
  max-width: 100%; height: auto; display: inline-block;
  margin: 8px 0; border-radius: 6px; vertical-align: top;
}
/* 图片独占一段：默认居中，并抵消首行缩进（对齐方式由段落内联 text-align 覆盖） */
.article-content p:has(> img:only-child),
.rich-text p:has(> img:only-child),
.article-content p:has(> a:only-child > img),
.rich-text p:has(> a:only-child > img) { text-indent: 0; text-align: center; }
/* 直接位于正文根级的裸图片（旧内容）：块级居中 */
.article-content > img,
.rich-text > img { display: block; margin: 8px auto; }

/* 列表 */
.article-content ul, .article-content ol,
.rich-text ul, .rich-text ol { margin: 0 0 18px; padding-left: 2em; }
.article-content ul, .rich-text ul { list-style: disc; }
.article-content ol, .rich-text ol { list-style: decimal; }
.article-content li, .rich-text li { margin-bottom: 7px; }

/* 表格：
   1) 总宽度不超过正文容器——源站常带 width:1099px 之类固定像素宽，一律覆盖为自适应；
   2) 列宽按内容分配（覆盖 colgroup/col 的固定列宽），行高随内容自适应；
   3) 单元格文字不缩进（单元格内段落不再继承正文的首行缩进 2 字），
      过长文字自动换行，不撑破表格。 */
.article-content table,
.rich-text table {
  width: auto !important;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 15px;
  line-height: 1.75;
}
/* 覆盖源站 colgroup 的固定列宽，列宽改为随文字内容分配
   （后台拖动列线调整过列宽的表格带 .rt-fixed，见下方规则，不在此列） */
.article-content table:not(.rt-fixed) col,
.rich-text table:not(.rt-fixed) col { width: auto !important; }
.article-content th, .article-content td,
.rich-text th, .rich-text td {
  border: 1px solid #e4e9f2; padding: 9px 13px;
  vertical-align: middle;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  width: auto !important;    /* 覆盖单元格的固定宽度，列宽随内容 */
  height: auto !important;   /* 覆盖固定行高，行高随内容 */
  max-width: 100%;
}
.article-content th, .rich-text th { background: #eaf0f8; }
/* 手动调过列宽的表格（后台拖动列线后带 .rt-fixed）：
   按 colgroup 里的百分比分配列宽，总宽固定为正文宽度；
   单元格仍允许换行，内容多时向下长高而不会撑破页面。
   该类名在保存时由白名单保留，前台与编辑区共用，所见即所得。 */
.article-content table.rt-fixed,
.rich-text table.rt-fixed {
  width: 100% !important;
  table-layout: fixed !important;
}
.article-content table.rt-fixed col,
.rich-text table.rt-fixed col { width: auto; }
.article-content table.rt-fixed td,
.rich-text table.rt-fixed td,
.article-content table.rt-fixed th,
.rich-text table.rt-fixed th { min-width: 0; }
/* 单元格内文字：不缩进、不留段间距，行高紧凑、随内容自适应 */
.article-content table p, .article-content table div, .article-content table li,
.rich-text table p, .rich-text table div, .rich-text table li {
  margin: 0 !important;
  text-indent: 0 !important;
}

/* 引用 */
.article-content blockquote, .rich-text blockquote {
  margin: 18px 0; padding: 12px 20px; background: #f3f5f9;
  border-left: 3px solid #0b3c74; color: #57647a;
}

/* 链接 */
.article-content a, .rich-text a { color: #16579f; text-decoration: underline; }

/* 窄屏同步缩放，保持前后台一致 */
@media (max-width: 820px) {
  .article-content, .rich-text { font-size: 16px; }
}
