@import 'normalize.css';
@import url("https://fontsapi.zeoseven.com/442/main/result.css");
@import url("https://fontsapi.zeoseven.com/292/main/result.css");

/* =========================
   字体
   ========================= */
@font-face {
  font-family: 'David Libre';
  font-style: normal;
  font-display: fallback;
  font-weight: 400;
  src: url(https://cdn.jsdelivr.net/fontsource/fonts/david-libre@latest/latin-400-normal.woff2) format('woff2'),
       url(https://cdn.jsdelivr.net/fontsource/fonts/david-libre@latest/latin-400-normal.woff) format('woff');
}
@font-face {
  font-family: 'David Libre';
  font-style: normal;
  font-display: fallback;
  font-weight: 500;
  src: url(https://cdn.jsdelivr.net/fontsource/fonts/david-libre@latest/latin-500-normal.woff2) format('woff2'),
       url(https://cdn.jsdelivr.net/fontsource/fonts/david-libre@latest/latin-500-normal.woff) format('woff');
}
@font-face {
  font-family: 'David Libre';
  font-style: normal;
  font-display: fallback;
  font-weight: 700;
  src: url(https://cdn.jsdelivr.net/fontsource/fonts/david-libre@latest/latin-700-normal.woff2) format('woff2'),
       url(https://cdn.jsdelivr.net/fontsource/fonts/david-libre@latest/latin-700-normal.woff) format('woff');
}

/* =========================
   页面基础
   ========================= */
html,
body {
  font-family: 'David Libre', 'LXGW WenKai', Georgia, 'Times New Roman', Times, serif;
  font-size: 17px;
  line-height: 1.9;
  color: #222;
  background-color: #fff;
  height: 100%;
}

/* =========================
   内联代码
   ========================= */
:root {
  --code-bg-color-light: #f6f8fa;
  --code-bg-color-dark: #333;
}

code {
  border: 1px solid #ddd;
  border-radius: 0.2rem;
  padding: 0.15rem 0.35rem;
  background-color: var(--code-bg-color-light);
  font-family: "Maple Mono NF CN", Consolas, monospace !important;
  font-size: 0.95em;
}

.astro-code code {
  border: none !important;
  background: none !important;
}

@media (prefers-color-scheme: dark) {
  body {
    color: #ddd;
    background-color: #1e1e1e;
  }
  code {
    background-color: var(--code-bg-color-dark);
    border-color: #444;
  }
}

/* =========================
   正文样式
   ========================= */
.post-content {
  line-height: 1.9;
  font-size: 1.05rem;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ✅ 普通段落首行缩进 */
.post-content p:not(.no-indent) {
  text-indent: 2em;
  margin: 0 0 1.2em 0;
}

/* ✅ 不缩进类（支持 <p> 和 <div>） */
.post-content .no-indent {
  text-indent: 0 !important;
  margin-left: 0 !important;
  text-align: left !important;
}
.post-content .no-indent p,
.post-content .no-indent strong,
.post-content .no-indent em,
.post-content .no-indent code {
  text-indent: 0 !important;
}

/* 🚫 标题、列表、代码块等不缩进 */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6,
.post-content ul,
.post-content ol,
.post-content li,
.post-content pre,
.post-content code,
.post-content blockquote,
.post-content table,
.post-content p:has(img) {
  text-indent: 0 !important;
}

/* 图片样式 */
.post-content img {
  display: block;
  margin: 1.5em auto;
  max-width: 100%;
  border-radius: 0.6rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.post-content figure {
  text-align: center;
  margin: 1.5em auto;
}
.post-content figcaption {
  font-size: 0.9rem;
  color: #666;
  margin-top: 0.5em;
}

/* =========================
   目录样式
   ========================= */
.toc .toc-item {
  display: block;
  padding-left: calc((var(--depth) - 1) * 1rem);
  text-indent: 0;
  line-height: 1.5;
  font-weight: 600;
}

/* =========================
   数学公式（KaTeX + MathJax）
   ========================= */

/* ✅ KaTeX 块级公式 */
.katex-display {
  display: block;
  text-align: center;
  margin: 1.2em 0;
}
.post-content p:has(.katex-display) {
  text-align: center !important;
  text-indent: 0 !important;
}

/* ✅ MathJax v2 兼容 */
.MathJax,
.MathJax_SVG_Display {
  max-width: 80vw;
  display: block !important;
  text-align: center !important;
  margin: 1.2em auto !important;
  font-size: 1rem;
}

/* ✅ MathJax v3 CHTML 或 SVG 模式（块级） */
.post-content mjx-container[display="true"],
.post-content .MathJax[display="true"] {
  display: block !important;
  text-align: center !important;
  margin: 1.2em auto !important;
  line-height: normal !important;
}

/* ✅ 让块级公式内部 SVG 居中 */
.post-content mjx-container[display="true"] > svg {
  display: inline-block !important;
  text-align: center !important;
  margin: 0 auto !important;
}

/* ✅ MathJax v3 行内公式（兼容 jax="SVG"） */
.post-content mjx-container:not([display]),
.post-content mjx-container[display="false"],
.post-content mjx-container[jax="SVG"][display="false"] {
  display: inline-block !important;
  vertical-align: middle !important;
  margin: 0 0.25em;
  text-align: inherit !important;
  line-height: normal !important;
}

/* ✅ 块级公式所在段落去掉缩进并居中 */
.post-content p:has(mjx-container[display="true"]),
.post-content p:has(.MathJax[display="true"]) {
  text-align: center !important;
  text-indent: 0 !important;
}

/* =========================
   ✅ Astro / Shiki 代码块
   ========================= */
.astro-code {
  position: relative;
  border-radius: 0.6rem;
  padding: 2.2em 1.4em 1.2em;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 1.5em 0;
  overflow-x: auto;
}

.astro-code::before {
  content: attr(data-language);
  position: absolute;
  top: 6px;
  left: 12px;
  font-size: 0.7rem;
  font-family: "Maple Mono NF CN", monospace;
  color: #aaa;
  text-transform: lowercase;
}

/* Copy 按钮（全局通用） */
.astro-code .copy-code {
  position: absolute;
  top: 6px;
  right: 12px;
  font-size: 0.7rem;
  font-family: "Maple Mono NF CN", monospace;
  color: #bbb;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
.astro-code .copy-code:hover {
  color: #fff;
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
}

/* 亮色模式下 Copy 按钮 */
@media (prefers-color-scheme: light) {
  .astro-code::before {
    color: #666;
  }
  .astro-code .copy-code {
    color: #555;
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.1);
  }
  .astro-code .copy-code:hover {
    background: rgba(0,0,0,0.15);
  }
}

/* =========================
   标题层级样式
   ========================= */
.post-content h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 2em 0 1em;
}
.post-content h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 1.8em 0 0.9em;
}
.post-content h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 1.6em 0 0.8em;
}
.post-content h4 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.4em 0 0.7em;
}
.post-content h5 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.2em 0 0.6em;
}
.post-content h6 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1em 0 0.5em;
}
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  line-height: 1.4;
}

/* ============================================
   📘 学习巩固/拓展卡片（Study Box）
   ============================================ */
.study-box {
  margin-top: 2.5rem;
  padding: 1.6rem 1.2rem;
  border-radius: 18px;
  background: linear-gradient(135deg, #fafafa 0%, #e8e8e8 100%);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.7),
    0 4px 10px rgba(0,0,0,0.08);
  text-align: center;
  transition: all 0.25s ease;
}

html.dark .study-box {
  background: linear-gradient(135deg, #2a2a2a, #1c1c1c);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.1),
    0 4px 10px rgba(0,0,0,0.4);
}

.study-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 1.1rem;
  color: #333;
}

html.dark .study-title {
  color: #ddd;
}

/* ============================================
   📘 按钮容器（自适应换行 + 居中）
   ============================================ */
.study-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

/* ============================================
   📘 学习按钮样式
   ============================================ */
.study-btn {
  padding: 0.8rem 1.6rem;
  background: #ffffff;
  color: #222;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
  transition: all 0.22s ease;
  display: inline-block;
  min-width: 115px; /* 防止文字换行挤压 */
  text-align: center;
}

.study-btn:hover {
  background: #f0f0f0;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

/* 暗色按钮模式 */
html.dark .study-btn {
  background: #2d2d2d;
  color: #eaeaea;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}

html.dark .study-btn:hover {
  background: #3a3a3a;
  box-shadow: 0 6px 16px rgba(0,0,0,0.55);
  transform: translateY(-2px);
}