/* ============================================================
   自动化老汪 · 站点样式覆盖（PaperMod 之上）
   1) 修复 feather SVG 无默认尺寸问题（返回顶部箭头过大）
   2) 中文排版 + 整体精致化
   ============================================================ */

:root {
  --main-font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono-font: "Cascadia Code", "JetBrains Mono", Consolas, "Sarasa Mono SC", monospace;

  /* 站点视觉基调：工业蓝灰 + 琥珀强调 */
  --brand: #1f6feb;
  --brand-soft: rgba(31, 111, 235, 0.08);
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --line: #e4e7ec;
  --ink: #1f2328;
  --ink-soft: #5b6570;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 22, 28, 0.04), 0 8px 24px rgba(16, 22, 28, 0.06);
}

html[data-theme="dark"] {
  --brand: #6ea8ff;
  --brand-soft: rgba(110, 168, 255, 0.12);
  --surface: #16181c;
  --surface-soft: #1d2025;
  --line: #2b2f36;
  --ink: #e6e8eb;
  --ink-soft: #9aa4af;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* ---------- 1. SVG 尺寸兜底（核心修复） ---------- */
/* PaperMod 主题未给 .feather 定尺寸，SVG 会退回 300×150 的替换元素默认值，
   导致「返回顶部」箭头巨大、撑满按钮容器。这里统一锁死。 */
.feather,
svg.feather,
.feather-chevrons-up,
.feather-chevron-right,
.feather-chevron-left,
.feather-facebook,
.feather-twitter,
.feather-instagram,
.feather-linkedin,
.feather-github,
.feather-moon,
.feather-sun {
  width: 1em;
  height: 1em;
  max-width: 100%;
  max-height: 100%;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ---------- 2. 返回顶部按钮 ----------
   尺寸：44px 圆形按钮 + 22px 单向上箭头（stroke 2.2，粗到远看也认得出）。
   不再做 JS 裁切双箭头 —— 双箭头裁单箭头的 trick 在实测里 SVG 高度
   吃不到 !important 规则，14px 的箭头塞在 32px 按钮里就是一个灰点点。
   现在直接把 SVG 换成单箭头 + 尺寸放足，最简单直接。 */
.top-link {
  bottom: 1.25rem;
  right: 1.25rem;
  width: 2.75rem;  /* 44px */
  height: 2.75rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(16, 22, 28, .12);
  opacity: 1;
  z-index: 99;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .18s, border-color .18s, background .18s, transform .18s;
}

.top-link:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-soft);
  transform: translateY(-2px);
}

.top-link:focus,
.top-link:focus-visible {
  color: var(--brand);
  border-color: var(--brand);
}

/* SVG 尺寸锁死：PaperMod 主题没给 .feather 定尺寸，会退回 300x150。
   22px 箭头在 44px 按钮里留出四周 11px 呼吸空间。 */
.top-link svg {
  width: 22px !important;
  height: 22px !important;
  stroke-width: 2.2;
  color: inherit;
  display: block;
}

/* 🔴 始终可见：主题 <noscript> 里的 `.top-link{display:none}`、
   主题 .hidden 类的 visibility/opacity:0、以及 window.onscroll 动态加回
   hidden 类 —— 全部用 !important 压过去，用户明确要求常驻可见。 */
.top-link,
.top-link.hidden {
  visibility: visible !important;
  opacity: 1 !important;
  display: inline-flex !important;
}

/* ---------- 3. 整体基底 ---------- */
body {
  font-family: var(--main-font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 顶栏：细底边 + 毛玻璃，不再是 PaperMod 默认的重边框 */
header.header {
  backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
}

.header .logo img,
.header .logo svg {
  max-height: 28px;
}

.header .nav-links .active {
  color: var(--brand);
  font-weight: 600;
}

/* 首页标题区：收敛留白，别太空 */
.main-header {
  margin: 2rem 0 1rem;
}

.main-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 .3rem;
}

.main-header .description {
  color: var(--ink-soft);
  font-size: .95rem;
  margin: 0;
}

/* ---------- 4. 文章列表卡片 ---------- */
.post-entry {
  position: relative;
  margin-bottom: .75rem;
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.post-entry:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(16, 22, 28, .06), 0 14px 32px rgba(16, 22, 28, .08);
}

/* 首页列表标题：首篇（.first-entry）与常规卡片（.post-entry）同字号。
   主题默认 .first-entry .entry-header h2 = 40px、.entry-header h2 = 24px，
   首篇明显偏大。这里强制两者对齐到 24px（1.5rem）。
   ⚠️ 首页标题元素是 <h2 class="entry-hint-parent">，没有 .post-title 类，
      .post-title 只存在于文章正文页，所以必须用 .entry-header h2 这个真实选择器。 */
.first-entry .entry-header h2,
.post-entry .entry-header h2 {
  font-family: var(--main-font);
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.45;
  color: var(--ink);
  margin: 0 0 .45rem;
}

.first-entry:hover .entry-header h2,
.post-entry:hover .entry-header h2 {
  color: var(--brand);
}

.post-entry .post-meta {
  font-size: .78rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .9rem;
}

.post-entry .summary {
  margin-top: .55rem;
  font-size: .92rem;
  line-height: 1.75;
  color: var(--ink-soft);
}

/* 摘要放宽到 3 行，避免中文段落刚开头就被省略号截断 */
.post-entry .entry-content {
  -webkit-line-clamp: 3;
  line-clamp: 3;
  font-size: .92rem;
  line-height: 1.75;
  color: var(--ink-soft);
  margin: .5rem 0;
}

/* PaperMod 用一个绝对定位的透明 <a class="entry-link"> 覆盖整张卡片。
   必须显式保证它有尺寸、有层级、能接收点击，否则「点卡片任意处进全文」会失效。
   ⚠️ 首页第一张卡片是 .first-entry，不是 .post-entry —— 两个类都得写。
   之前漏了 first-entry，它的 entry-link z-index 是 auto，被 SVG 箭头/polyline
   等块级子元素盖住，用户点「阅读全文 →」实际点在 polyline 上，不触发跳转。 */
.post-entry .entry-link,
.first-entry .entry-link {
  position: absolute;
  inset: 0;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  z-index: 5;         /* 比之前的 2 再抬一档，稳稳压在 SVG/img 之上 */
  border-radius: var(--radius);
  cursor: pointer;
}

/* 卡片内可交互元素（图片链接等）提到链接层之上，避免被 entry-link 吞掉点击 */
.post-entry .entry-cover a,
.post-entry .entry-cover img,
.first-entry .entry-cover a,
.first-entry .entry-cover img {
  position: relative;
  z-index: 6;
}

/* 底部「阅读全文 →」常驻显示，让用户一眼知道整卡可点。
   不用 hover 才浮现——用户反馈过「右下角没有按钮」就是被这个 opacity:0 坑过。
   ⚠️ PaperMod 的首页第一张是 .first-entry，普通卡片是 .post-entry，两个不同类名。
   之前只写 .post-entry 就漏掉了 first-entry，现在两个都覆盖。 */
.post-entry .entry-footer::after,
.first-entry .entry-footer::after {
  content: "阅读全文 →";
  margin-left: auto;
  color: var(--brand);
  font-weight: 600;
  font-size: .82rem;
  white-space: nowrap;
}

.post-entry .entry-footer,
.first-entry .entry-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* hover 时颜色加深，保留一点交互反馈 */
.post-entry:hover .entry-footer::after,
.first-entry:hover .entry-footer::after {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-entry .tags a,
.tags a {
  font-size: .74rem;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: .1rem .6rem;
  margin-right: .3rem;
  text-decoration: none;
}

/* ---------- 5. 文章正文页 ---------- */
.post-header {
  margin-bottom: 1.5rem;
}

.post-title {
  font-family: var(--main-font);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
  margin-bottom: .6rem;
}

.post-meta {
  font-size: .82rem;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: .3rem 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.post-content,
.post-single .post-content {
  font-family: var(--main-font);
  font-size: 1.06rem;
  line-height: 1.9;
  color: var(--ink);
  letter-spacing: .01em;
  word-wrap: break-word;
}

.post-content p {
  margin-bottom: 1.15em;
  text-indent: 0;
}

/* 首段做引言块，视觉上有个起手 */
.post-content > p:first-of-type {
  font-size: 1.1rem;
  color: var(--ink);
  padding-left: .9rem;
  border-left: 3px solid var(--brand);
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  font-family: var(--main-font);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.45;
  scroll-margin-top: 90px;
}

.post-content h2 {
  margin-top: 2.2em;
  margin-bottom: .9em;
  padding-bottom: .35em;
  border-bottom: 1px solid var(--line);
  font-size: 1.32rem;
}

.post-content h3 {
  margin-top: 1.8em;
  margin-bottom: .7em;
  font-size: 1.14rem;
}

.post-content h4 {
  margin-top: 1.5em;
  font-size: 1.03rem;
  color: var(--ink-soft);
}

.post-content code {
  font-family: var(--mono-font);
  font-size: .87em;
  padding: .16em .4em;
  border-radius: 4px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.post-content pre {
  font-family: var(--mono-font);
  font-size: .85rem;
  line-height: 1.65;
  overflow-x: auto;
  padding: 1rem 1.1rem;
  margin: 1.4em 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.post-content pre code {
  padding: 0;
  background: transparent;
  border: none;
  white-space: pre;
}

.post-content table {
  display: table;
  width: 100%;
  margin: 1.6em 0;
  font-size: .9rem;
  border-collapse: collapse;
}

.post-content table th,
.post-content table td {
  padding: .6em .85em;
  border: 1px solid var(--line);
  text-align: left;
}

.post-content table th {
  background: var(--surface-soft);
  font-weight: 650;
}

.post-content table tbody tr:nth-child(even) {
  background: var(--surface-soft);
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.4em 0;
  box-shadow: var(--shadow);
}

.post-content blockquote {
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  padding: .75rem 1rem;
  margin: 1.4em 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-soft);
  font-style: normal;
}

.post-content ul,
.post-content ol {
  line-height: 1.9;
  margin-bottom: 1.15em;
  padding-left: 1.3em;
}

.post-content li {
  margin-bottom: .35em;
}

.post-content li::marker {
  color: var(--brand);
}

.post-content hr {
  margin: 2.4em 0;
  border: none;
  border-top: 1px solid var(--line);
}

/* 锚点图标：平时藏起来，hover 才出现 */
.heading-link {
  opacity: 0;
  margin-left: .35rem;
  color: var(--brand);
  transition: opacity .2s;
}

.heading-link:hover,
h1:hover > .heading-link,
h2:hover > .heading-link,
h3:hover > .heading-link,
h4:hover > .heading-link {
  opacity: 1;
}

/* ---------- 6. TOC 目录 ---------- */
#TableOfContents {
  font-size: .84rem;
  line-height: 1.7;
}

#TableOfContents ul {
  margin: 0;
  padding-left: 1em;
}

#TableOfContents a {
  color: var(--ink-soft);
  text-decoration: none;
}

#TableOfContents a:hover,
#TableOfContents .active > a {
  color: var(--brand);
}

/* ---------- 7. 文章底部导航 ---------- */
.post-nav {
  border-top: 1px solid var(--line);
  margin-top: 2.5rem;
  padding-top: 1.25rem;
}

.post-nav .post-nav-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .8rem 1rem;
}

.post-nav .post-nav-item:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.post-nav .post-nav-item .nav-title {
  font-size: .8rem;
  color: var(--ink-soft);
}

.post-nav .post-nav-item .nav-subtitle {
  font-size: .95rem;
  color: var(--ink);
}

/* ---------- 8. 页脚 ---------- */
.footer {
  font-size: 13px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  margin-top: 3rem;
}

.footer a {
  color: var(--ink-soft);
  text-decoration: none;
}

.footer a:hover {
  color: var(--brand);
}

/* 页脚 RSS 明入口 */
.footer-rss {
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: .75rem;
}

.footer-rss a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

.footer-rss a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 9. 归档 / 分类页 ---------- */
.post-list-item .post-title {
  font-family: var(--main-font);
  font-size: 1.05rem;
  font-weight: 600;
}

.post-list .post-list-item .post-title a {
  color: var(--ink);
}

.post-list .post-list-item:hover .post-title a {
  color: var(--brand);
}

.archive-month {
  font-weight: 650;
  margin-top: 1.6rem;
}

/* ---------- 9.5 右侧「订阅」浮动按钮 ----------
   固定右侧垂直居中，点击跳 RSS（/index.xml）。无邮件订阅后端，订阅即 RSS。
   常驻可见，不被主题 hidden 类吃掉。 */
.subscribe-link {
  position: fixed;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .55rem .45rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand);
  box-shadow: var(--shadow);
  font-size: .72rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  z-index: 98;
  transition: color .18s, border-color .18s, background .18s, transform .18s;
}

.subscribe-link:hover {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  transform: translateY(-50%) scale(1.05);
}

.subscribe-link svg {
  width: 18px;
  height: 18px;
  display: block;
}

.subscribe-link,
.subscribe-link.hidden {
  visibility: visible !important;
  opacity: 1 !important;
}

/* ---------- 10. 移动端 ---------- */
@media (max-width: 768px) {
  .post-entry {
    padding: 1rem;
  }

  .post-title {
    font-size: 1.5rem;
  }

  .post-content,
  .post-single .post-content {
    font-size: 1.03rem;
    line-height: 1.85;
  }

  .post-content h2 {
    font-size: 1.2rem;
  }

  .top-link {
    width: 2.25rem;  /* 移动端也保 36px，别再小到像灰点点 */
    height: 2.25rem;
    bottom: .875rem;
    right: .875rem;
  }

  .top-link svg {
    width: 18px !important;
    height: 18px !important;
  }

  #TableOfContents {
    display: none;
  }
}

/* ---------- 11. 首页合集导览（页面下部，紧凑不展开） ---------- */
.home-collections {
  margin: 2.25rem 0 0;
}

.coll-section-heading {
  margin-bottom: .9rem;
}

.coll-stack {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.coll-card {
  --coll: var(--brand);
  --coll-soft: var(--brand-soft);
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .8rem .95rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--coll);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.coll-card:hover {
  transform: translateX(2px);
  border-color: color-mix(in srgb, var(--coll) 45%, var(--line));
  box-shadow: 0 4px 12px rgba(16, 22, 28, .06), 0 12px 28px rgba(16, 22, 28, .07);
}

.coll-card.accent-blue {
  --coll: #1f6feb;
  --coll-soft: rgba(31, 111, 235, .10);
}

.coll-card.accent-amber {
  --coll: #e8932e;
  --coll-soft: rgba(232, 147, 46, .12);
}

.coll-card.accent-purple {
  --coll: #7c3aed;
  --coll-soft: rgba(124, 58, 237, .10);
}

html[data-theme="dark"] .coll-card.accent-blue {
  --coll: #6ea8ff;
  --coll-soft: rgba(110, 168, 255, .16);
}

html[data-theme="dark"] .coll-card.accent-amber {
  --coll: #f0b256;
  --coll-soft: rgba(240, 178, 86, .16);
}

html[data-theme="dark"] .coll-card.accent-purple {
  --coll: #b794f6;
  --coll-soft: rgba(183, 148, 246, .16);
}

.coll-icon {
  flex-shrink: 0;
  width: 2.15rem;
  height: 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 8px;
  background: var(--coll-soft);
  border: 1px solid color-mix(in srgb, var(--coll) 22%, transparent);
}

.coll-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.coll-title {
  font-family: var(--main-font);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: break-word;
  transition: color .15s ease;
}

.coll-card:hover .coll-title {
  color: var(--coll);
}

.coll-desc {
  font-size: .82rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.coll-arrow {
  flex-shrink: 0;
  width: 1.85rem;
  height: 1.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--coll);
  background: transparent;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.coll-card:hover .coll-arrow {
  transform: translateX(3px);
  background: var(--coll-soft);
  border-color: color-mix(in srgb, var(--coll) 40%, transparent);
}

/* 首页分区标题（最新文章 / 专题合集共用） */
.home-list-heading {
  font-family: var(--main-font);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 1rem;
  padding-left: .6rem;
  border-left: 3px solid var(--brand);
}

@media (max-width: 640px) {
  .coll-card {
    padding: .7rem .8rem;
    gap: .7rem;
  }

  .coll-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* 分类/文章列表页抬头「全部文章」字号，主题默认 40px，缩小一号 */
.page-header h1 {
  font-size: 28px;
  line-height: 1.3;
}
