/* ==========================================
   Custom CSS — 修复代码块和正文字体颜色对比度
   ========================================== */

/* ---------- Light Mode: 覆盖 Butterfly 默认低对比度配色 ---------- */

/* 字体大小：正文 15px，代码 14px（Butterfly 默认正文 14px） */
:root {
  --global-font-size: 15px;
  --font-color: #1e293b;
}

/* 文章正文区域字体 */
.container .post-content {
  font-size: 15px;
}

/* 代码块字体略小于正文 */
.container pre,
.container code,
figure.highlight .highlight-tools {
  font-size: 14px;
}

/* 代码块整体：纯白背景 + 深色文字，替代 Butterfly 的 #F6F8FA / #90A4AE */
:root {
  --hl-bg: #f6f8fa;
  --hl-color: #1e293b;
  --hltools-bg: #e8eaed;
  --hltools-color: #57606a;
  --hlnumber-bg: #f0f1f3;
  --hlnumber-color: #8b949e;
  --hlscrollbar-bg: #d0d7de;
}

/* 行内代码：加深背景使其可见 */
.container code:not(pre code):not(figure.highlight code) {
  background: #e8eaed !important;
  color: #cf222e !important;
  padding: 2px 6px !important;
  border-radius: 4px;
}

/* 代码块内 code 不做行内样式 */
figure.highlight code,
pre code {
  background: none !important;
  color: inherit !important;
}

/* 代码块阴影和圆角 */
figure.highlight {
  border-radius: 6px;
  border: 1px solid #d0d7de;
  box-shadow: none;
}

figure.highlight .highlight-tools {
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid #d0d7de;
}

/* Gutter 行号区域 */
figure.highlight .gutter pre {
  background-color: var(--hlnumber-bg) !important;
  color: var(--hlnumber-color) !important;
}

/* ---------- Dark Mode: 提高对比度 ---------- */

[data-theme='dark'] {
  /* 正文：从 70% 透明度提升到 90% */
  --font-color: rgba(255, 255, 255, 0.9);

  /* 代码块 */
  --hl-bg: #1a1a1a;
  --hl-color: rgba(255, 255, 255, 0.88);
  --hltools-bg: #212121;
  --hltools-color: #8b949e;
  --hlnumber-bg: #1a1a1a;
  --hlnumber-color: rgba(255, 255, 255, 0.35);
  --hlscrollbar-bg: #303030;
}

/* 暗色模式行内代码 */
[data-theme='dark'] .container code:not(pre code):not(figure.highlight code) {
  background: #303030 !important;
  color: #ff8b7b !important;
}

/* 暗色模式代码块边框 */
[data-theme='dark'] figure.highlight {
  border-color: #303030;
}

[data-theme='dark'] figure.highlight .highlight-tools {
  border-bottom-color: #303030;
}

/* 暗色模式覆盖 Butterfly 的 brightness 滤镜（避免图片过暗） */
[data-theme='dark'] img:not(.cover) {
  filter: brightness(0.9);
}

/* ---------- 通用：链接可读性 ---------- */

a {
  color: #0969da;
}

[data-theme='dark'] a {
  color: #58a6ff;
}

/* ---------- 通用：引用块 ---------- */

blockquote {
  color: #57606a;
  border-left-color: #0969da;
}

[data-theme='dark'] blockquote {
  color: rgba(255, 255, 255, 0.8);
}
