/* =============================================================
   iCard 文章正文排版 (Markdown rendering enhancement)
   Scope: .caption-post  (文章渲染容器)
   设计目标: 精致、易读、留白充足、深浅色皆宜
   ============================================================= */

:root {
  --post-accent: #3086ff;          /* 主题蓝，与全局按钮/品牌一致 */
  --post-accent-soft: rgba(48, 134, 255, .12);
  --post-text: #3b4b5e;            /* 正文主色 */
  --post-strong: #1f2d3d;          /* 强调文字 */
  --post-muted: #5e6e80;           /* 弱化文字/说明 */
  --post-bg-soft: #f4f7fb;         /* 引用/表头浅底 */
  --post-border: #e6ecf2;          /* 分隔/边框 */
  --post-code-bg: #1b2230;         /* 代码块深色底 */
  --post-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- 基础排版 ---------- */
.caption-post {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  font-size: 1.05rem;
  line-height: 1.9;
  font-weight: 400;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--post-text);
  letter-spacing: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.caption-post p {
  margin: 1.1rem 0;
}

.caption-post strong,
.caption-post b {
  font-weight: 700;
  color: #15232e;
  font-synthesis: weight;
}

.caption-post em {
  font-style: italic;
}

.caption-post del {
  color: var(--post-muted);
}

/* ---------- 标题层级（覆盖全局 1.5px 字距，修复中文排版） ---------- */
.caption-post h1,
.caption-post h2,
.caption-post h3,
.caption-post h4,
.caption-post h5,
.caption-post h6 {
  letter-spacing: normal;
  line-height: 1.4;
  font-weight: 700;
  font-family: inherit;
  scroll-margin-top: 90px;
  position: relative;
}

.caption-post h2 {
  font-size: 1.6rem;
  margin: 2.4rem 0 1.1rem;
  padding-left: .9rem;
  border-left: 4px solid var(--post-accent);
  color: var(--post-strong);
}

.caption-post h3 {
  font-size: 1.3rem;
  margin: 2rem 0 1rem;
  padding-left: .8rem;
  border-left: 3px solid var(--post-accent);
  color: var(--post-strong);
}

.caption-post h4 {
  font-size: 1.12rem;
  margin: 1.7rem 0 .9rem;
  color: var(--post-accent);
}

.caption-post h5,
.caption-post h6 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.4rem 0 .8rem;
  color: var(--post-text);
}

/* 标题悬停锚点 */
.heading-anchor {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  margin-left: .5rem;
  font-size: .85em;
  font-weight: 400;
  color: var(--post-accent);
  text-decoration: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.caption-post h2:hover .heading-anchor,
.caption-post h3:hover .heading-anchor,
.caption-post h4:hover .heading-anchor {
  opacity: .8;
}
.heading-anchor:hover {
  opacity: 1 !important;
}

/* 锚点跳转高亮 */
.caption-post h2:target,
.caption-post h3:target,
.caption-post h4:target {
  animation: anchorFlash .9s ease;
}
@keyframes anchorFlash {
  0% {
    background: var(--post-accent-soft);
    border-radius: 4px;
  }
  100% {
    background: transparent;
  }
}

/* ---------- 链接（动画下划线，排除图片/锚点） ---------- */
.caption-post a:not([data-fancybox]):not(.heading-anchor) {
  color: var(--post-accent);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size .25s ease, color .2s ease;
}
.caption-post a:not([data-fancybox]):not(.heading-anchor):hover {
  background-size: 100% 1px;
}

/* ---------- 引用块 ---------- */
.caption-post blockquote {
  margin: 1.6rem 0;
  padding: .85rem 1.1rem .85rem 1.25rem;
  background: rgba(48, 134, 255, .07);
  border-left: 3px solid var(--post-accent);
  border-radius: 0 .6rem .6rem 0;
  color: var(--post-muted);
  position: relative;
}
.caption-post blockquote p {
  margin: .5em 0;
}
.caption-post blockquote blockquote {
  background: rgba(48, 134, 255, .04);
  border-left-color: var(--post-accent);
}

/* ---------- 行内代码 ---------- */
.caption-post code {
  font-family: var(--post-mono);
  font-size: .9em;
  background: rgba(48, 134, 255, .10);
  color: #1f6fe0;
  padding: .15em .45em;
  border-radius: 6px;
  word-break: break-word;
}

/* ---------- 代码块（深色 + Mac 风格圆点 + 复制按钮） ---------- */
.caption-post pre {
  position: relative;
  background: var(--post-code-bg);
  color: #e6edf3;
  border-radius: 12px;
  padding: 2.8rem 1.2rem 1.2rem;
  margin: 1.8rem 0;
  overflow-x: auto;
  box-shadow: 0 10px 30px rgba(20, 30, 50, .18);
  font-family: var(--post-mono);
  font-size: .9rem;
  line-height: 1.7;
}
.caption-post pre::before {
  content: "";
  position: absolute;
  top: 1.1rem;
  left: 1.2rem;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff5f56;
  box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
}
.caption-post pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
  word-break: normal;
}

.code-copy {
  position: absolute;
  top: .7rem;
  right: .8rem;
  z-index: 2;
  font-family: inherit;
  font-size: .72rem;
  color: #c9d4e3;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 6px;
  padding: .25rem .6rem;
  cursor: pointer;
  transition: all .2s ease;
}
.code-copy:hover {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}
.code-copy.copied {
  color: #7ee2a8;
  border-color: rgba(126, 226, 168, .4);
}

/* ---------- 表格（圆角 + 斑马纹 + 移动端滚动） ---------- */
.table-wrap {
  overflow-x: auto;
  margin: 1.8rem 0;
  border-radius: 10px;
  border: 1px solid var(--post-border);
}
.caption-post table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  margin: 0;
}
.caption-post th,
.caption-post td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--post-border);
  text-align: left;
}
.caption-post thead th {
  background: var(--post-bg-soft);
  font-weight: 600;
  color: var(--post-strong);
}
.caption-post tbody tr:hover {
  background: #fafbfc;
}
.caption-post tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- 列表 ---------- */
.caption-post ul,
.caption-post ol {
  margin: 1.1rem 0;
  padding-left: 1.6rem;
}
.caption-post li {
  margin: .45rem 0;
  line-height: 1.85;
}
.caption-post ul {
  list-style: none;
  padding-left: 1.2rem;
}
.caption-post ul li {
  position: relative;
  padding-left: .6rem;
}
.caption-post ul li::before {
  content: "";
  position: absolute;
  left: -.9rem;
  top: .82em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--post-accent);
}
.caption-post ol {
  list-style: decimal;
}

/* ---------- 分隔线 ---------- */
.caption-post hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--post-border), transparent);
  margin: 2.4rem 0;
}

/* ---------- 图片（灯箱容器 + 阴影） ---------- */
.caption-post a[data-fancybox] {
  display: block;
  margin: 1.8rem 0;
  text-align: center;
}
.caption-post img {
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(20, 30, 50, .12);
  max-width: 100%;
  height: auto;
}

/* ---------- 嵌入视频等 ---------- */
.caption-post iframe {
  max-width: 100%;
  border-radius: 12px;
  margin: 1.6rem 0;
}

/* ---------- 选中色 ---------- */
.caption-post ::selection {
  background: var(--post-accent-soft);
}

/* ---------- 响应式 ---------- */
@media (max-width: 580px) {
  .caption-post {
    font-size: 1rem;
  }
  .caption-post h2 {
    font-size: 1.35rem;
  }
  .caption-post h3 {
    font-size: 1.15rem;
  }
  .caption-post pre {
    font-size: .82rem;
    padding-top: 2.6rem;
  }
}
