/* =====================================================================
   正文内容兜底净化样式（文章详情 + 产品详情 .content-body）
   ---------------------------------------------------------------------
   挂载：inc/assets-functions.php → 依赖 ahlsx-l10n 之后加载（全站 CSS 的最后一层）
   作用范围：仅 body.single 下的 .content-body —— 即 single.php 路由出的
   文章页（template-parts/render-single.php:58）与产品页
   （template-parts/render-single-product.php:130）的正文容器。
   搜索页（search.php）同用 .content-body 类，但页面不带 body.single，
   天然不受本文件影响；首页/关于页/侧栏等其余区域同样不涉及。

   解决的问题：后台编辑文章/产品时，从 AI 对话（ChatGPT/文心/千问等）、
   微信公众号、Word、网页等渠道粘贴的内容自带大量行内样式与固定宽度
   （750px 定宽图片、行内字号字体、margin:0 段落挤成一片、无符号列表、
   position:absolute 悬浮块、超宽表格、浮动图片贴死文字等），
   导致正文排版混乱、图片表格撑破版心。

   设计原则（兜底 = 保排版不破，不追求完全还原）：
   1. 行内 style 优先级高于普通 CSS，关键归一化属性一律 !important；
   2. 只强制"会破坏排版/层级"的属性（宽高、间距、标题层级、字体族、
      定位、列表符号）；颜色、对齐等可能出于作者意图的样式一律不动；
   3. 正文链接沿用主题全局规则（#333、hover 主题蓝 #015cb5），不重复定义；
   4. 表格边框/横向滚动基础规则在 skin/css/style.css（.content-body 一节）
      已有，本文件只做行内宽度的兜底补充。

   纯 CSS 兜底做不到的（第十轮起由 inc/content-functions.php 过滤层接管）：
   - 段落里的 &nbsp; 假空段、Word 的 <o:p> 残留、零宽空格 —— 输出期轻过滤
     清除（见该文件头注释，表格逐字节保留）；
   - 行内样式自带 !important 的极端内容（罕见）纯 CSS 无法覆盖；
   - 缺 src 的失效图片（lazyload data-src 类）无法用 CSS 修复。
   ===================================================================== */

/* -------------------------------------------------------------------
   1. 容器基础：正文基准 16px（与 AI 粘贴文本的 15/16px 拉齐），
      长英文单词/URL 强制可断行，防止撑破版心（属性可继承，覆盖全部后代）
   ------------------------------------------------------------------- */
body.single .content-body {
	font-size: 16px;
	overflow-wrap: break-word;
	word-break: break-word;
}

/* -------------------------------------------------------------------
   2. 通用防溢出：任何后代元素不得超过版心宽度。
      粘贴内容行内写死的 width:750px 等，会被这里的 max-width:100%
      在"使用值"层面压回容器内（max-width 与 width 是两个属性，
      行内 width 再大也越不过样式表的 max-width）
   ------------------------------------------------------------------- */
body.single .content-body * {
	max-width: 100%;
	box-sizing: border-box;
}

/* 媒体类元素行内也写死宽度的，一律 !important 硬兜底 */
body.single .content-body img,
body.single .content-body video,
body.single .content-body canvas,
body.single .content-body svg,
body.single .content-body iframe,
body.single .content-body embed,
body.single .content-body object,
body.single .content-body table {
	max-width: 100% !important;
}
body.single .content-body img,
body.single .content-body video {
	height: auto !important;
}
body.single .content-body img {
	vertical-align: middle;
	border: 0;
}

/* -------------------------------------------------------------------
   3. 字体族归一：Word/微信/135 粘贴常自带 Calibri/宋体/Arial 等行内
      字体，统一继承站点字体；代码类元素随后单独恢复等宽字体
      （pre/code 选择器优先级高于上面的通配符，可正常落位）
   ------------------------------------------------------------------- */
body.single .content-body * {
	font-family: inherit !important;
}
body.single .content-body pre,
body.single .content-body code,
body.single .content-body kbd,
body.single .content-body samp {
	font-family: Consolas, Monaco, "Courier New", monospace !important;
}

/* -------------------------------------------------------------------
   4. 标题层级归一：粘贴的 h1-h6 常带巨大/细体/行内字号，统一为本站
      正文标题层级（页面主标题 .content-title h1 为 22px，正文 h1 递减
      一档避免喧宾夺主）。颜色不强制，保留作者可能的有意配色
   ------------------------------------------------------------------- */
body.single .content-body h1,
body.single .content-body h2,
body.single .content-body h3,
body.single .content-body h4,
body.single .content-body h5,
body.single .content-body h6 {
	font-weight: 700 !important;
	line-height: 1.4 !important;
	margin: 1.4em 0 0.6em !important;
}
body.single .content-body h1 { font-size: 20px !important; }
body.single .content-body h2 { font-size: 18px !important; }
body.single .content-body h3 { font-size: 16px !important; }
body.single .content-body h4 { font-size: 15px !important; }
body.single .content-body h5 { font-size: 14px !important; }
body.single .content-body h6 { font-size: 13px !important; }

/* -------------------------------------------------------------------
   5. 段落与文本块：微信/135 粘贴常 margin:0 挤成一片、行内行高字号
      各不相同，统一恢复段间距与正文基准
   ------------------------------------------------------------------- */
body.single .content-body p {
	margin: 0 0 1em !important;
	line-height: inherit !important;
	font-size: inherit !important;
}
body.single .content-body section,
body.single .content-body li {
	font-size: inherit !important;
}
body.single .content-body p:empty {
	display: none !important;
}
body.single .content-body > :first-child {
	margin-top: 0 !important;
}

/* -------------------------------------------------------------------
   5A. 行内元素与包裹层字号归一（第十轮补充）：
       上一轮只归一了 p/section/li 自身，段落里的
       <span style="font-size:22px">、AI 导出的 <div style="font-size:15px">
       包裹层依然生效——"标题大小不一、段落格式不一"的字号真空就藏在
       这两个位置。这里把行内文本元素与普通包裹层的字号/行高拉回正文
       基准；颜色/背景刻意不动（作者意图，如公众号彩色营销块）。
   表格豁免（用户明确要求：粘贴的表格原样保留，编辑器画表不容易）：
       :not(:is(table, thead, tbody, tfoot, tr, td, th) *) 精确排除
       表格后代——单元格里的任何行内字号（含 Word/Excel 粘贴的
       12px 紧凑表格）原样生效，不参与归一。主题 l10n.css 已有
       :is() 使用先例，浏览器兼容与现状一致。
   ------------------------------------------------------------------- */
body.single .content-body :is(div, section, span, a, strong, b, em, i, u, font):not(:is(table, thead, tbody, tfoot, tr, td, th) *) {
	font-size: inherit !important;
	line-height: inherit !important;
}

/* -------------------------------------------------------------------
   6. 列表归一：主题全局 ul 无 padding 无符号（style.css 182-186 行），
      正文恢复缩进与项目符号，并对抗行内 list-style-type:none
   ------------------------------------------------------------------- */
body.single .content-body ul,
body.single .content-body ol {
	margin: 1em 0 !important;
	padding-left: 2em !important;
	list-style-position: outside !important;
}
body.single .content-body ul { list-style-type: disc !important; }
body.single .content-body ol { list-style-type: decimal !important; }
body.single .content-body li > ul,
body.single .content-body li > ol {
	margin: 0.3em 0 !important;
}

/* -------------------------------------------------------------------
   7. 引用 / 代码 / 术语列表
   ------------------------------------------------------------------- */
body.single .content-body blockquote {
	margin: 1.2em 0 !important;
	padding: 10px 16px !important;
	background-color: #f7f9fb;
	border-left: 4px solid #015cb5;
	border-radius: 3px;
}
body.single .content-body blockquote > :last-child {
	margin-bottom: 0 !important;
}
body.single .content-body pre {
	margin: 1.2em 0 !important;
	padding: 12px 15px !important;
	background-color: #f6f8fa;
	border: 1px solid #e5e5e5;
	border-radius: 4px;
	overflow-x: auto;
	font-size: 13px !important;
	line-height: 1.6 !important;
	white-space: pre !important;
}
body.single .content-body code {
	padding: 2px 6px;
	background-color: #f5f5f5;
	border-radius: 3px;
	font-size: 90%;
}
body.single .content-body pre code {
	padding: 0 !important;
	background: none !important;
	font-size: inherit !important;
	border-radius: 0;
}
body.single .content-body dl { margin: 1em 0 !important; }
body.single .content-body dd { margin: 0 0 0.5em 2em !important; }
body.single .content-body dt { font-weight: 700; }

/* -------------------------------------------------------------------
   8. figure / 图注 / 分隔线
   ------------------------------------------------------------------- */
body.single .content-body figure { margin: 1em 0 !important; }
body.single .content-body figcaption {
	margin-top: 0.5em;
	text-align: center;
	color: #999;
	font-size: 13px !important;
}
body.single .content-body hr {
	height: 0 !important;
	border: 0 !important;
	border-top: 1px solid #ddd !important;
	margin: 1.5em 0 !important;
}

/* -------------------------------------------------------------------
   9. 表格兜底（边框/底色/横向滚动在 style.css 已定义，此处只兜
      行内写死的宽度与外边距，行内细字表头恢复加粗）
   ------------------------------------------------------------------- */
body.single .content-body table {
	width: 100% !important;
	margin: 1.2em 0 !important;
}
body.single .content-body th { font-weight: 700 !important; }

/* -------------------------------------------------------------------
   10. WP 编辑器对齐类与图注短代码（主题此前无对应样式，编辑器里的
       居中/浮动/图注在前台一直不生效，这里按 WP 标准行为补齐）
   ------------------------------------------------------------------- */
body.single .content-body .aligncenter {
	display: block !important;
	float: none !important;
	margin-left: auto !important;
	margin-right: auto !important;
}
body.single .content-body .alignleft {
	float: left !important;
	margin: 5px 20px 8px 0 !important;
}
body.single .content-body .alignright {
	float: right !important;
	margin: 5px 0 8px 20px !important;
}
/* 经典编辑器图注：<dl class="wp-caption" style="width:510px">，其 width
   已含两侧 padding，恢复 content-box 计宽并取消上面 dd 的缩进 */
body.single .content-body dl.wp-caption {
	box-sizing: content-box;
	padding: 5px 5px 0;
	text-align: center;
}
body.single .content-body dd.wp-caption-text {
	margin: 5px 0 0 !important;
	text-align: center;
	font-size: 13px;
	color: #999;
}

/* -------------------------------------------------------------------
   11. 粘贴垃圾修正
   ------------------------------------------------------------------- */
/* 粘贴产生的 position:fixed/absolute 悬浮块会飘出正文压住页面，
   按静态处理（兼容带/不带空格两种行内写法） */
body.single .content-body [style*="position:fixed"],
body.single .content-body [style*="position: fixed"],
body.single .content-body [style*="position:absolute"],
body.single .content-body [style*="position: absolute"] {
	position: static !important;
}
/* Word/135 编辑器粘贴的浮动图片常无外边距，文字贴死图片，补安全间距 */
body.single .content-body img[style*="float:left"],
body.single .content-body img[style*="float: left"] {
	float: left !important;
	margin: 5px 20px 8px 0 !important;
}
body.single .content-body img[style*="float:right"],
body.single .content-body img[style*="float: right"] {
	float: right !important;
	margin: 5px 0 8px 20px !important;
}
