/* ==========================================================================
   jzwo.cn · 阅读体验优化层
   只覆盖排版与间距，不改主题结构；本文件加载在 main.css 之后
   ========================================================================== */

:root {
  --read-width: 40rem;        /* 正文行宽 ≈ 40 个汉字 */
  --line: #e6e4e0;
  --ink: #1f2328;
  --ink-2: #5a6169;
  --accent: #2563eb;
  --pill-bg: #f1f0ee;
}

/* ---------- 1. 正文：行高与行长 ---------- */
#post-content p,
article p,
.post-content p {
  font-size: 17px !important;
  line-height: 1.78 !important;
  margin-bottom: 1.15em;
  color: var(--ink);
  text-wrap: pretty;
}

article p,
article ul,
article ol,
article blockquote,
article > h2,
article > h3 {
  max-width: var(--read-width);
}

article ul,
article ol {
  font-size: 17px;
  line-height: 1.78;
  margin-bottom: 1.15em;
  padding-left: 1.35em;
}

article li { margin-bottom: .45em; }

article li::marker { color: var(--ink-2); }

/* ---------- 2. 标题层级（主题用 #post-content + !important，这里必须同级覆盖） ---------- */
#post-content h2,
article h2,
.post-content h2 {
  display: block;
  box-shadow: none;
  padding: 0;
  font-size: 26px !important;
  font-weight: 650;
  line-height: 1.36;
  margin: 2.1em 0 .65em;
  letter-spacing: 0;
  text-wrap: balance;
}

#post-content h3,
article h3,
.post-content h3 {
  display: block;
  box-shadow: none;
  padding: 0;
  font-size: 19px !important;
  font-weight: 620;
  line-height: 1.45;
  margin: 1.7em 0 .5em;
  text-wrap: balance;
}

#post-content > h2:first-child,
#post-content > h3:first-child,
article h2:first-child,
article h3:first-child { margin-top: 0; }

/* ---------- 3. 引用与分隔 ---------- */
article blockquote {
  margin: 1.6em 0;
  padding: .2em 0 .2em 1.1em;
  border-left: 3px solid var(--accent);
  color: var(--ink-2);
  font-size: 16.5px;
}

article blockquote p { margin-bottom: .5em; font-size: inherit; }
article blockquote p:last-child { margin-bottom: 0; }

article hr {
  margin: 2.6em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* ---------- 4. 代码 ---------- */
article pre,
.post-content pre {
  margin: 1.5em 0;
  padding: 16px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.72;
  tab-size: 2;
}

article pre code { font-size: inherit; line-height: inherit; }

article :not(pre) > code {
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .92em;
  background: var(--pill-bg);
  color: #b4322f;
}

/* ---------- 5. 图片 ---------- */
article img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 1.4em 0;
}

/* ---------- 6. 表格 ---------- */
article table {
  width: 100%;
  margin: 1.6em 0;
  font-size: 15px;
  border-collapse: collapse;
}

article th,
article td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

article th {
  font-weight: 600;
  background: var(--pill-bg);
  white-space: nowrap;
}

/* ---------- 7. 列表页条目 ---------- */
article.card .card-title {
  font-size: 20px;
  font-weight: 550 !important;
  line-height: 1.45;
  text-wrap: pretty;
}

article.card .card-title a {
  color: inherit;
  text-decoration: none;
  transition: color .15s ease-out;
}

article.card .card-title a:hover,
article.card .card-title a:focus-visible {
  color: var(--accent);
}

article.card .card-text.more {
  font-size: 15px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

article.card + article.card { border-top: 1px solid var(--line); }

/* ---------- 8. 侧栏标签做成 pill ---------- */
.list-group-horizontal li a {
  display: inline-block;
  padding: 3px 11px !important;
  border-radius: 999px;
  background: var(--pill-bg);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
  text-decoration: none;
  transition: color .15s ease-out, background-color .15s ease-out;
}

.list-group-horizontal li a:hover,
.list-group-horizontal li a:focus-visible {
  background: var(--accent);
  color: #fff;
}

/* ---------- 9. 目录 ---------- */
#toc .accordion-button {
  font-size: 14px;
  font-weight: 600;
}

#toc-content ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
  border-left: 2px solid var(--line);
}

#toc-content li a {
  display: block;
  padding: 4px 0 4px 12px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
  text-decoration: none;
}

#toc-content li a:hover {
  border-left-color: var(--accent);
  color: var(--accent);
}

/* ---------- 10. 导航当前项：改为下划线指示，而不是整块蓝底 ---------- */
.navbar .nav-link.active {
  background: none !important;
  color: var(--accent) !important;
  box-shadow: inset 0 -2px 0 0 currentColor;
  border-radius: 0;
}

#mobile-navbar .list-group-item.active {
  background: var(--pill-bg) !important;
  color: var(--accent) !important;
}

/* ---------- 11. 左侧图标栏：加大点击区 + hover 反馈 ---------- */
#left .nav-link {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 19px;
  color: var(--ink-2);
  transition: background-color .15s ease-out, color .15s ease-out;
}

#left .nav-link:hover,
#left .nav-link:focus-visible {
  background: var(--pill-bg);
  color: var(--accent);
}

/* 左栏当前页：底色 + 主色图标，和顶部导航的指示条呼应 */
#left .nav-link.active {
  background: var(--pill-bg);
  color: var(--accent);
}

/* 列表条目分隔加强 */
article.card {
  padding-top: 22px;
  padding-bottom: 22px;
}

/* 热门标签容器：给一点边界，提升可点击感 */
#right .list-group-horizontal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 8px;
  margin-top: 4px;
}

/* ---------- 12. 阅读时长 ---------- */
.read-time {
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 14. 深色模式令牌（对比度已按 WCAG 实算，全部 ≥4.5:1） ---------- */
body[data-bs-theme="dark"] {
  --ink: #dee2e6;        /* 14.94:1 on #0A0C19 */
  --ink-2: #a8b0bd;      /*  8.90:1 */
  --line: #262c3a;
  --accent: #7fb0ff;     /*  8.85:1 */
  --pill-bg: #1e2430;
  --code-bg: #22272e;
}

body[data-bs-theme="dark"] #post-content p,
body[data-bs-theme="dark"] article p,
body[data-bs-theme="dark"] article ul,
body[data-bs-theme="dark"] article ol {
  color: #dee2e6 !important;
}

body[data-bs-theme="dark"] #post-content h2,
body[data-bs-theme="dark"] #post-content h3 {
  color: #e6edf3;
}

/* 链接：Bootstrap 默认 #0d6efd 在深底上只有 2.9:1 */
body[data-bs-theme="dark"] #post-content a,
body[data-bs-theme="dark"] article a {
  color: #7fb0ff;
}

body[data-bs-theme="dark"] #post-content a:hover,
body[data-bs-theme="dark"] article a:hover {
  color: #a9c9ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

body[data-bs-theme="dark"] .list-group-horizontal li a {
  background: #1e2430;
  color: #c3cbd8;        /* 9.52:1 */
}

body[data-bs-theme="dark"] .list-group-horizontal li a:hover {
  background: #3b82f6;
  color: #fff;
}

body[data-bs-theme="dark"] article blockquote {
  color: #a8b0bd;
  border-left-color: #7fb0ff;
}

body[data-bs-theme="dark"] article :not(pre) > code {
  background: #1e2430;
  color: #ff9c9c;
}

body[data-bs-theme="dark"] article th {
  background: #1e2430;
  color: #dee2e6;
}

body[data-bs-theme="dark"] article th,
body[data-bs-theme="dark"] article td {
  border-bottom-color: #262c3a;
}

body[data-bs-theme="dark"] #left .nav-link:hover,
body[data-bs-theme="dark"] #left .nav-link:focus-visible {
  background: #1e2430;
}

/* ---------- 15. 手机端 ---------- */
@media (max-width: 900px) {
  article p,
  article ul,
  article ol { font-size: 16.5px; line-height: 1.8; }

  article h2 { font-size: 22px; margin-top: 1.8em; }
  article h3 { font-size: 18px; }

  article pre { padding: 14px; font-size: 13px; }
}
