/*
  正文区贴近 GitHub 仓库 README / GFM 浅色呈现（ scoped 到 main#content article）。
  说明：Obsidian [[wikilink]] 不是 GFM，Hugo 不会转成链接，需在文内改为 [text](url)。
*/

/* 版心：对标 GitHub 文章正文区宽度（约 800px 内容 + 两侧内边距）。
   width: 100% 覆盖 Etch min770px.css 里 width: 600px 的硬限制。 */
body {
  width: 100% !important;
  max-width: 860px;
  padding: 0 32px;
}

/*
  注意：Etch 主题设置了 html { font-size: 62.5% }，导致 1rem = 10px 而非 16px。
  本文件统一使用 px 避免换算陷阱。
*/

/* ===== 文章正文样式（对标 GitHub Primer / GFM） ===== */

main#content article {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.5;
  color: #1f2328;
  word-wrap: break-word;
}

/* 首尾元素消除多余边距 */
main#content article > :first-child { margin-top: 0 !important; }
main#content article > :last-child  { margin-bottom: 0 !important; }

/* 标题基础 */
main#content article h1,
main#content article h2,
main#content article h3,
main#content article h4,
main#content article h5,
main#content article h6 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
  color: #1f2328;
}

main#content article h1 {
  font-size: 2em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid rgba(209, 217, 224, 0.7);
}

main#content article h2 {
  font-size: 1.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid rgba(209, 217, 224, 0.7);
}

main#content article h3 { font-size: 1.25em; }
main#content article h4 { font-size: 1em; }
main#content article h5 { font-size: 0.875em; }
main#content article h6 { font-size: 0.85em; color: #59636e; }

/* 标题内行内代码不缩小字号，覆盖 Etch 主题的 0.96em / 0 5px */
main#content article h1 code, main#content article h2 code,
main#content article h3 code, main#content article h4 code,
main#content article h5 code, main#content article h6 code {
  padding: 0 0.2em;
  font-size: inherit;
  background-color: rgba(129, 139, 152, 0.12);
  border-radius: 4px;
}

/* 页头标题（front matter title，不在 article 内） */
main#content header#post-header h1 {
  margin: 0 0 16px;
  padding-bottom: 0.3em;
  font-size: 2em;
  font-weight: 600;
  line-height: 1.25;
  color: #1f2328;
  border-bottom: 1px solid rgba(209, 217, 224, 0.7);
}

/* 链接 */
main#content article a { color: #0969da; text-decoration: none; }
main#content article a:hover { text-decoration: underline; }

/* 块级元素统一底部间距 */
main#content article p,
main#content article blockquote,
main#content article details,
main#content article dl,
main#content article ol,
main#content article pre,
main#content article table,
main#content article ul {
  margin-top: 0;
  margin-bottom: 16px;
}

/* 文字修饰 */
main#content article b,
main#content article strong { font-weight: 600; }
main#content article em      { font-style: italic; }
main#content article del     { color: #636c76; text-decoration: line-through; }
main#content article mark    { background-color: #fff8c5; color: #1f2328; }

/* 列表 */
main#content article ul,
main#content article ol { padding-left: 2em; }

/* 嵌套列表不再加底部间距 */
main#content article ol ol, main#content article ol ul,
main#content article ul ol, main#content article ul ul {
  margin-top: 0;
  margin-bottom: 0;
}

main#content article li + li   { margin-top: 0.25em; }
main#content article li > p    { margin-top: 16px; }

/* Task-list（- [ ] / - [x]） */
main#content article .task-list-item { list-style-type: none; }
main#content article .task-list-item-checkbox {
  margin: 0 0.2em 0.25em -1.4em;
  vertical-align: middle;
}

/* 引用块：覆盖 Etch 主题的 margin-left:50px 和 font-style:italic */
main#content article blockquote {
  margin: 0 0 16px 0;
  padding: 0 1em;
  color: #59636e;
  border-left: 0.25em solid #d1d9e0;
  font-style: italic;
}
main#content article blockquote > :first-child { margin-top: 0; }
main#content article blockquote > :last-child  { margin-bottom: 0; }
/* blockquote 内的 strong/b 同时保持 italic */
main#content article blockquote strong,
main#content article blockquote b { font-weight: 600; }

/* 分隔线 */
main#content article hr {
  height: 0.25em;
  padding: 0;
  margin: 24px 0;
  background-color: #d1d9e0;
  border: 0;
}

/* 表格 */
main#content article table {
  border-spacing: 0;
  border-collapse: collapse;
  display: block;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  font-variant: tabular-nums;
}

main#content article table th { font-weight: 600; }

main#content article table td,
main#content article table th {
  padding: 6px 13px;
  border: 1px solid #d1d9e0;
}

main#content article table tr {
  background-color: #fff;
  border-top: 1px solid rgba(209, 217, 224, 0.7);
}
main#content article table tr:nth-child(2n) { background-color: #f6f8fa; }

/* 行内代码 */
main#content article :not(pre) > code,
main#content article :not(pre) > tt {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 85%;
  padding: 0.2em 0.4em;
  margin: 0;
  white-space: break-spaces;
  background-color: rgba(129, 139, 152, 0.12);
  border-radius: 6px;
}

/* 键盘按键 */
main#content article kbd {
  display: inline-block;
  padding: 4px;
  font: 11px ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  line-height: 10px;
  color: #1f2328;
  vertical-align: middle;
  background-color: #f6f8fa;
  border: 1px solid rgba(209, 217, 224, 0.7);
  border-radius: 6px;
  box-shadow: inset 0 -1px 0 rgba(209, 217, 224, 0.7);
}

/* 代码块 */
main#content article pre,
main#content article .highlight pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 85%;
  line-height: 1.45;
  color: #1f2328;
  background-color: #f6f8fa !important;
  border-radius: 6px;
  overflow: auto;
  padding: 16px;
  margin-bottom: 0;
  border: 0;
}

main#content article .highlight {
  margin-bottom: 16px;
  background: transparent !important;
}

main#content article pre code,
main#content article .highlight pre code {
  display: inline;
  padding: 0;
  margin: 0;
  overflow: visible;
  line-height: inherit;
  word-wrap: normal;
  background-color: transparent !important;
  border: 0;
  font-size: inherit;
  white-space: pre;
}

/* details / summary */
main#content article details { display: block; }
main#content article summary { display: list-item; cursor: pointer; }

/* Mermaid 图表 */
main#content article .mermaid {
  margin: 0 0 16px;
  text-align: center;
  background: #f6f8fa;
  border-radius: 6px;
  padding: 16px;
}

/* 图片：覆盖 Etch 主题的 margin:0 auto（居中），GitHub 默认左对齐 */
main#content article img {
  max-width: 100%;
  box-sizing: content-box;
  display: inline-block;
  margin: 0;
}

/* 覆盖 Etch min770px.css 里 width:108% / margin-left:-3.8% 的出血规则 */
main#content hr {
  width: 100% !important;
  margin-left: 0 !important;
}

main#content pre {
  width: 100% !important;
  margin-left: 0 !important;
}

main#content img {
  max-width: 100% !important;
  margin-left: 0 !important;
}

main#content figure {
  margin-left: 0 !important;
}

/* 首页 _index：导语与「笔记列表」之间留出固定间距（Markdown 多空行常被折叠） */
main#content p.home-index-intro {
  margin: 0 0 16px;
  color: #394548;
  line-height: 1.6;
}
main#content p.home-index-posts-label {
  margin: 32px 0 12px;
  color: #394548;
  line-height: 1.6;
}

/* ===== UI 优化覆盖层 ===== */

/* --- 顶部导航 --- */
header#banner {
  margin: 32px 0 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eaeef2;
}

header#banner h2 {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

header#banner a {
  color: #111827;
}

/* 覆盖主题的 text-transform: lowercase */
header#banner nav ul {
  text-transform: none;
}

header#banner nav ul li a {
  color: #4b5563;
  font-size: 15px;
  transition: color 0.15s ease;
}

header#banner nav ul li a:hover {
  color: #111827;
  text-decoration: none;
}

/* --- 文章列表 --- */
main#content ul#posts {
  margin-top: 0;
  /* 首条有顶部边框，形成完整围合 */
  border-top: 1px solid #f0f4f8;
}

main#content ul#posts li {
  margin: 0;
  padding: 0;
}

main#content ul#posts li a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid #f0f4f8;
  color: #1a202c;
  font-size: 15px;
  text-decoration: none;
  transition: color 0.15s ease, padding-left 0.15s ease;
}

main#content ul#posts li a:hover {
  color: #0969da;
  padding-left: 5px;
  text-decoration: none;
}

main#content ul#posts small {
  flex-shrink: 0;
  font-size: 13px;
  color: #9ca3af;
  margin-left: 0;
  letter-spacing: 0.01em;
}

main#content ul#posts li a:hover small {
  color: #9ca3af;
}

/* --- 首页导语区 --- */
main#content p.home-index-intro {
  margin: 0 0 24px;
  padding: 12px 16px;
  color: #4b5563;
  line-height: 1.75;
  border-left: 3px solid #e5e7eb;
  background: #fafbfc;
  border-radius: 0 4px 4px 0;
}

main#content p.home-index-posts-label {
  margin: 36px 0 8px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  line-height: 1;
}

/* 隐藏 posts-label 内的 strong 的默认加粗（已通过 letter-spacing + uppercase 表达强调） */
main#content p.home-index-posts-label strong {
  font-weight: 600;
}

/* --- 页脚 --- */
footer#footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid #eaeef2;
  font-size: 13px;
  color: #9ca3af;
}
