/* ============================================================
   本地静态博客 · site.css
   一个强调排版节奏与阅读舒适的编辑风主题（无外部依赖、无网络字体）
   ============================================================ */

:root {
  --font-sans: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui,
    -apple-system, "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;

  --paper: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f4f2ed;
  --ink: #1b1a18;
  --ink-soft: #4a4640;
  --muted: #7c766c;
  --border: #e5e0d8;
  --border-strong: #d5cec3;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.09);

  --measure: 43rem;
  --wide: 68rem;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 8px 24px -18px rgba(28, 25, 23, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131417;
    --surface: #191b1f;
    --surface-2: #202329;
    --ink: #e9e7e4;
    --ink-soft: #c3c0bb;
    --muted: #8f8b85;
    --border: #2a2d33;
    --border-strong: #3a3e46;
    --accent: #56c8bb;
    --accent-soft: rgba(86, 200, 187, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -20px rgba(0, 0, 0, 0.7);
  }
}

[data-theme="dark"] {
  --paper: #131417;
  --surface: #191b1f;
  --surface-2: #202329;
  --ink: #e9e7e4;
  --ink-soft: #c3c0bb;
  --muted: #8f8b85;
  --border: #2a2d33;
  --border-strong: #3a3e46;
  --accent: #56c8bb;
  --accent-soft: rgba(86, 200, 187, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 1.75rem; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--surface);
  padding: 0.6rem 1rem; border: 1px solid var(--border);
}
.skip:focus { left: 1rem; top: 0.5rem; z-index: 50; }

.muted { color: var(--muted); }

/* ---------------------------------------------- 页头 */

.site-head {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(6px);
  border-bottom: 1px solid var(--border);
}

.head-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; min-height: 4.25rem;
}

.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark { color: var(--accent); font-size: 1.15rem; line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 1.02rem; font-weight: 650; letter-spacing: -0.01em; }
.brand-text i { font-style: normal; font-size: 0.74rem; color: var(--muted); }

.site-nav { display: flex; align-items: center; gap: 1.15rem; font-size: 0.88rem; }
.site-nav a { color: var(--ink-soft); position: relative; padding: 0.2rem 0; }
.site-nav a::after {
  content: ""; position: absolute; left: 0; right: 100%; bottom: -2px;
  height: 1px; background: var(--accent); transition: right 0.22s ease;
}
.site-nav a:hover::after { right: 0; }

.theme-btn {
  font: inherit; font-size: 0.95rem; line-height: 1;
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 1.9rem; height: 1.9rem; border-radius: 50%; cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------------------------------------------- 首页 · 最新一篇 */

.latest { margin: 3.25rem 0 2.5rem; max-width: var(--measure); }
.latest-label {
  margin: 0 0 0.9rem; font-family: var(--font-mono); font-size: 0.72rem;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
  display: flex; align-items: center; gap: 0.6rem;
}
.latest-label::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.latest-title {
  margin: 0 0 0.7rem; font-size: clamp(1.7rem, 3.4vw, 2.35rem);
  line-height: 1.28; letter-spacing: -0.02em; font-weight: 660;
}
.latest-summary { margin: 0 0 0.8rem; color: var(--ink-soft); font-size: 1.02rem; }
.latest-meta { margin: 0; font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }

/* ---------------------------------------------- 工具条（搜索 + 标签筛选） */

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem;
  padding: 1.1rem 0 1.35rem; border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border); margin-bottom: 0.4rem;
}
#search {
  font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.5rem 0.8rem; min-width: 15rem; flex: 1 1 15rem;
  max-width: 22rem;
}
#search::placeholder { color: var(--muted); }
#search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.tagbar { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tagbar button {
  font: inherit; font-size: 0.8rem; cursor: pointer;
  background: none; color: var(--muted);
  border: 1px solid var(--border); border-radius: 100px; padding: 0.16rem 0.7rem;
  transition: all 0.16s ease;
}
.tagbar button:hover { color: var(--ink); border-color: var(--border-strong); }
.tagbar button[aria-pressed="true"] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.tagbar span.all-label { font-size: 0.78rem; color: var(--muted); align-self: center; }

/* ---------------------------------------------- 文章列表 */

.entries { display: flex; flex-direction: column; }

.entry {
  display: grid; grid-template-columns: 6.5rem 1fr; gap: 1.5rem;
  padding: 1.6rem 0; border-bottom: 1px solid var(--border);
}
.entry-side time { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.entry-main { min-width: 0; max-width: var(--measure); }
.entry-title { margin: 0 0 0.35rem; font-size: 1.24rem; line-height: 1.4; font-weight: 640; letter-spacing: -0.012em; }
.entry-title .badge {
  margin-left: 0.55rem; vertical-align: 0.12em;
  font-size: 0.66rem; font-family: var(--font-sans); font-weight: 500;
  color: #a15c00; border: 1px solid #e0b070; background: #fdf3e2;
  padding: 0.05rem 0.4rem; border-radius: 3px;
}
.entry-summary { margin: 0 0 0.6rem; color: var(--ink-soft); font-size: 0.95rem; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; font-size: 0.78rem; }
.entry-meta .rt { font-family: var(--font-mono); color: var(--muted); margin-right: 0.35rem; }

.tag {
  color: var(--muted); border: 1px solid var(--border); border-radius: 100px;
  padding: 0.1rem 0.6rem; font-size: 0.76rem; transition: all 0.16s ease;
}
.tag:hover { color: var(--accent); border-color: var(--accent); }

.empty { padding: 4rem 0; max-width: var(--measure); }
.empty h2 { margin: 0 0 0.6rem; font-size: 1.3rem; }
.empty p { margin: 0; color: var(--muted); }
.empty code { font-family: var(--font-mono); font-size: 0.85rem; background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 3px; }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.6rem 0 2rem; font-size: 0.86rem;
}
.pager-info { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.pager-empty { width: 4rem; }

/* ---------------------------------------------- 页面标题 */

.page-title { margin: 3.25rem 0 0.5rem; font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -0.02em; font-weight: 660; }
.page-note { margin: 0 0 2.25rem; color: var(--muted); font-size: 0.86rem; font-family: var(--font-mono); }

/* ---------------------------------------------- 归档 */

.arc-year { margin: 0 0 2.25rem; max-width: var(--measure); }
.arc-year h2 {
  font-size: 1.05rem; margin: 0 0 0.75rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: baseline;
}
.arc-year h2 .count { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); font-weight: 400; }
.arc-year ul { list-style: none; margin: 0; padding: 0; }
.arc-year li { display: grid; grid-template-columns: 3.6rem 1fr auto; gap: 1rem; padding: 0.42rem 0; align-items: baseline; }
.arc-year li time { font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted); }
.arc-year li a { font-size: 0.98rem; }
.arc-tags { font-size: 0.74rem; color: var(--muted); }

/* ---------------------------------------------- 标签云 */

.cloud { display: flex; flex-wrap: wrap; gap: 0.6rem; max-width: var(--measure); }
.cloud-item {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.42rem 0.8rem; font-size: 0.92rem; transition: all 0.16s ease;
}
.cloud-item i { font-style: normal; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.cloud-item:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------- 文章正文 */

.post { padding: 3rem 0 2rem; }
.post-head { max-width: var(--measure); margin-bottom: 2rem; }
.post-head h1 { margin: 0 0 0.9rem; font-size: clamp(1.75rem, 3.6vw, 2.4rem); line-height: 1.3; letter-spacing: -0.022em; font-weight: 660; }
.post-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0 0 0.85rem; font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); }
.post-meta .dot { color: var(--border-strong); }

.toc {
  max-width: var(--measure); margin: 0 0 2rem; padding: 0.9rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.88rem;
}
.toc summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.toc ul { list-style: none; margin: 0.7rem 0 0; padding: 0; }
.toc li { padding: 0.14rem 0; }
.toc-l3 { padding-left: 1.2rem !important; font-size: 0.84rem; }
.toc a { color: var(--ink-soft); }
.toc a:hover { color: var(--accent); }

.prose { max-width: var(--measure); font-size: 1.03rem; line-height: 1.88; }
.prose > *:first-child { margin-top: 0; }
.prose p { margin: 0 0 1.25rem; }
.prose h2 {
  margin: 2.5rem 0 1rem; font-size: 1.4rem; line-height: 1.4; letter-spacing: -0.015em;
  padding-top: 0.4rem; border-top: 1px solid var(--border);
}
.prose h3 { margin: 2rem 0 0.8rem; font-size: 1.14rem; }
.prose h4, .prose h5, .prose h6 { margin: 1.6rem 0 0.6rem; font-size: 1rem; }
.prose ul, .prose ol { margin: 0 0 1.25rem; padding-left: 1.4rem; }
.prose li { margin: 0.35rem 0; }
.prose li > ul, .prose li > ol { margin: 0.35rem 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose strong { font-weight: 660; }
.prose hr { margin: 2.4rem 0; border: 0; border-top: 1px solid var(--border); }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); }

.prose blockquote {
  margin: 1.6rem 0; padding: 0.2rem 0 0.2rem 1.15rem;
  border-left: 2px solid var(--accent); color: var(--ink-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font-family: var(--font-mono); font-size: 0.87em;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 0.08rem 0.34rem; border-radius: 3px;
}
.prose pre {
  margin: 0; overflow-x: auto; padding: 1rem 1.1rem;
  background: var(--surface); font-size: 0.86rem; line-height: 1.65;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: 1em; }
.code-block {
  position: relative; margin: 1.5rem 0; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.code-lang {
  position: absolute; top: 0; right: 0; padding: 0.18rem 0.55rem;
  font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted);
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  border-bottom-left-radius: var(--radius); background: var(--surface-2);
}
.prose .code-block > pre { padding-top: 1.8rem; }

.table-wrap { margin: 1.5rem 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.prose th, .prose td { padding: 0.55rem 0.85rem; border-bottom: 1px solid var(--border); text-align: left; }
.prose thead th { background: var(--surface-2); font-weight: 620; white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }

.post-foot { max-width: var(--measure); margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.back { font-size: 0.88rem; color: var(--muted); }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.4rem; font-size: 0.92rem; }
.pn-next { text-align: right; }
.back-row { margin: 2.25rem 0 0; }

/* ---------------------------------------------- 页脚 */

.site-foot {
  margin-top: 4rem; border-top: 1px solid var(--border);
  padding: 1.75rem 0 2.75rem; font-size: 0.8rem; color: var(--muted);
}
.site-foot p { margin: 0; }

/* ---------------------------------------------- 窄屏 */

@media (max-width: 720px) {
  body { font-size: 16px; }
  .wrap { padding: 0 1.15rem; }
  .entry { grid-template-columns: 1fr; gap: 0.3rem; padding: 1.35rem 0; }
  .entry-side time { font-size: 0.72rem; }
  .head-inner { min-height: 3.8rem; }
  .brand-text i { display: none; }
  .site-nav { gap: 0.85rem; font-size: 0.84rem; }
  .latest { margin-top: 2.25rem; }
  .arc-year li { grid-template-columns: 3.2rem 1fr; }
  .arc-tags { display: none; }
  .post-nav { grid-template-columns: 1fr; }
  .pn-next { text-align: left; }
  .toolbar { padding: 0.9rem 0 1.1rem; }
}

@media print {
  .site-head, .site-foot, .toolbar, .pager, .post-nav, .toc { display: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .prose a { color: #000; text-decoration: none; }
}
