/* ============================================================
   正文局部组件
   prose-variants.css 管「整篇的版式基调」（v0–v7），
   这个文件管「篇内的小块」：引用提示框、四级标题、小字注、
   步骤连线、卡片清单、分节线。

   只用 Markdown 原生能产出的标签（blockquote / h4 / small /
   ol / ul / hr），不新增标签、不改前台白名单。
   加载顺序：必须在 prose-variants.css 之后，才能覆盖版式的默认值。
   ============================================================ */

/* ---------- 引用块：做成提示框，左上角带引号装饰 ---------- */

:is(.prose, .ai-prose) blockquote {
  position: relative;
  margin: 0 0 20px;
  padding: 14px 18px 14px 40px;
  border-left: 3px solid var(--blue, var(--a1));
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--blue, var(--a1)) 6%, transparent);
  color: var(--ink2, var(--body, inherit));
}

:is(.prose, .ai-prose) blockquote::before {
  content: "\201C";
  position: absolute;
  left: 12px;
  top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: color-mix(in srgb, var(--blue, var(--a1)) 45%, transparent);
  pointer-events: none;
}

:is(.prose, .ai-prose) blockquote > :first-child { margin-top: 0; }
:is(.prose, .ai-prose) blockquote > :last-child { margin-bottom: 0; }
:is(.prose, .ai-prose) blockquote p { margin: 0 0 8px; font-size: 15px; line-height: 1.9; }
:is(.prose, .ai-prose) blockquote p:last-child { margin-bottom: 0; }

/* 引用块里的有序列表（步骤坑位提醒常见）不要撑出内边距 */
:is(.prose, .ai-prose) blockquote ol,
:is(.prose, .ai-prose) blockquote ul { margin-bottom: 0; padding-left: 18px; }
:is(.prose, .ai-prose) blockquote ul { list-style: disc; }
:is(.prose, .ai-prose) blockquote ul > li { list-style: disc; }
:is(.prose, .ai-prose) blockquote ul > li::before { content: none; }

/* ---------- 四级标题：小号标签，用于骨架里的子层级 ---------- */

:is(.prose, .ai-prose) h4 {
  display: block;
  margin: 22px 0 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.6;
  color: var(--blue, var(--a1));
}
:is(.prose, .ai-prose) h4::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 7px;
  border-radius: 1px;
  background: currentColor;
  vertical-align: 3px;
}

/* ---------- 小字注：来源、前提、例外 ---------- */

:is(.prose, .ai-prose) small {
  display: block;
  margin: -6px 0 18px;
  padding-left: 10px;
  border-left: 2px solid var(--line, rgba(16, 26, 45, .14));
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink3, var(--muted, #6b7787));
}

/* ---------- 有序列表：步骤之间连一条线，读起来是流程不是清单 ---------- */

/* 数字容器尺寸与行高在前后台原本不一致（前台 19px/1.9，后台 18px/1.6），
   连线的起点就没有公共基准。这里先把两者拉到同一套数值，预览才等于发布效果。 */
:is(.prose, .ai-prose) ol > li {
  margin: 0 0 8px;
  line-height: 1.9;
}
:is(.prose, .ai-prose) ol > li::before {
  top: .38em;
  width: 19px;
  height: 19px;
  line-height: 17px;
  font-size: 10.5px;
}

/* 数字容器统一后，中心恒在 9.5px，所以连线位置对所有版式通用，不用逐个微调 */
:is(.prose, .ai-prose) ol > li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 25px;
  bottom: -15px;
  width: 1px;
  /* 跟着文字色走：浅色主题是淡灰蓝，深色主题自动变浅，不用两套变量 */
  background: color-mix(in srgb, currentColor 24%, transparent);
  pointer-events: none;
}

/* ---------- 卡片清单：整段列表都是「标签：说明」时收进卡片 ---------- */

/* 触发条件：至少 3 项、且每项都以 <strong> 开头。
   模型写「- **对象A**：评价」这种对照列表时会命中；
   普通要点列表（以汉字开头）不受影响。 */
:is(.prose, .ai-prose) ul:has(> li:nth-child(3)):has(> li > strong:first-child) {
  margin: 0 0 18px;
  padding: 12px 16px 12px 34px;
  border: 1px solid var(--line, rgba(16, 26, 45, .12));
  border-radius: 8px;
  background: var(--bg2, var(--surface-2, #f7f8fa));
  list-style: none;
}

:is(.prose, .ai-prose) ul:has(> li:nth-child(3)):has(> li > strong:first-child) > li {
  position: relative;
  margin: 0 0 7px;
  padding-left: 0;
  list-style: none;
}
:is(.prose, .ai-prose) ul:has(> li:nth-child(3)):has(> li > strong:first-child) > li:last-child { margin-bottom: 0; }

/* 卡片内不用圆点/三角/破折号，改用一个小色点，避免和 v2/v3/v7 的符号打架 */
:is(.prose, .ai-prose) ul:has(> li:nth-child(3)):has(> li > strong:first-child) > li::before {
  content: "";
  position: absolute;
  left: -14px;
  top: .68em;
  width: 5px;
  height: 5px;
  margin: 0;
  border-radius: 50%;
  background: var(--blue, var(--a1));
  opacity: .55;
}

/* 卡片里的标签词统一上色，形成「左标签右说明」的读感 */
:is(.prose, .ai-prose) ul:has(> li > strong:first-child) > li > strong:first-child {
  font-weight: 700;
  color: var(--blue, var(--a1));
}

/* ---------- 分节线 ---------- */

:is(.prose, .ai-prose) hr {
  height: 1px;
  margin: 34px 0;
  border: 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--line, rgba(16, 26, 45, .16)) 18%,
    var(--line, rgba(16, 26, 45, .16)) 82%,
    transparent
  );
}

/* ---------- 强调组合：加粗 + 下划线同时出现时，作为「重点标记」 ---------- */

:is(.prose, .ai-prose) strong > u,
:is(.prose, .ai-prose) u > strong {
  text-decoration-thickness: 3px;
  text-underline-offset: 3px;
  font-weight: 800;
}

/* ---------- 版式微调：同样的小块在不同版式下换气质 ---------- */

/* v2 杂志：引用不带底色，靠粗线与大引号 */
:is(.prose, .ai-prose).v2 blockquote {
  border-left-width: 4px;
  border-radius: 0;
  background: transparent;
  padding-left: 44px;
}
:is(.prose, .ai-prose).v2 blockquote::before { font-size: 38px; left: 6px; top: 4px; }

/* v3 色块：纯描边卡片，不要左边线 */
:is(.prose, .ai-prose).v3 blockquote {
  border: 1px solid var(--line, rgba(16, 26, 45, .14));
  border-left-width: 1px;
  border-radius: 8px;
  background: transparent;
}
:is(.prose, .ai-prose).v3 blockquote::before { color: color-mix(in srgb, var(--blue, var(--a1)) 28%, transparent); }

/* v3 的 h3 原本是圆点，和列表的三角/圆点混在一起看不出层级，改回方块 */
:is(.prose, .ai-prose).v3 h3::before { border-radius: 2px; }

/* v7 终端：等宽字体，方角，虚线左边 */
:is(.prose, .ai-prose).v7 blockquote {
  border-left: 2px dashed var(--line, rgba(16, 26, 45, .3));
  border-radius: 0;
  background: transparent;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 13.5px;
}
:is(.prose, .ai-prose).v7 blockquote::before { content: "//"; left: 10px; top: 12px; font-size: 12px; font-family: var(--mono); }
:is(.prose, .ai-prose).v7 small { font-family: var(--mono, ui-monospace, Menlo, monospace); }

/* v5 时间线：引用块跟着走竖向节奏，不再加额外左线 */
:is(.prose, .ai-prose).v5 blockquote {
  border-left-style: solid;
  border-left-width: 2px;
  background: color-mix(in srgb, var(--blue, var(--a1)) 5%, transparent);
}

/* ---------- 深色主题 ---------- */

html[data-theme="dark"] :is(.prose, .ai-prose) blockquote {
  background: rgba(96, 165, 250, .09);
  color: #d5e2f5;
}
html[data-theme="dark"] :is(.prose, .ai-prose) blockquote::before { color: rgba(96, 165, 250, .5); }
html[data-theme="dark"] :is(.prose, .ai-prose) small { color: #8fa0b6; border-left-color: rgba(255, 255, 255, .14); }
html[data-theme="dark"] :is(.prose, .ai-prose) hr { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .16) 18%, rgba(255, 255, 255, .16) 82%, transparent); }
html[data-theme="dark"] :is(.prose, .ai-prose) ul:has(> li:nth-child(3)):has(> li > strong:first-child) {
  background: rgba(255, 255, 255, .035);
  border-color: rgba(255, 255, 255, .1);
}

/* 后台预览用的是 --surface-2 这套变量，不跟随 data-theme 的深色值 */
html[data-theme="dark"] .ai-prose ul:has(> li:nth-child(3)):has(> li > strong:first-child) {
  background: var(--surface-2);
  border-color: var(--line);
}
html[data-theme="dark"] .ai-prose blockquote { background: color-mix(in srgb, var(--a1) 10%, transparent); }

/* ---------- 移动端 ---------- */

@media (max-width: 560px) {
  :is(.prose, .ai-prose) blockquote { padding: 12px 14px 12px 34px; }
  :is(.prose, .ai-prose) blockquote::before { left: 9px; font-size: 26px; }
  :is(.prose, .ai-prose) blockquote p { font-size: 14.5px; }
  :is(.prose, .ai-prose) ul:has(> li:nth-child(3)):has(> li > strong:first-child) { padding: 10px 12px 10px 28px; }
  :is(.prose, .ai-prose) hr { margin: 26px 0; }
}
