/* ==========================================================================
   拾穗集 · 个人博客样式表
   原生 CSS，无构建、无依赖；亮/暗双主题通过 html[data-theme] 切换
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root {
  color-scheme: light;
  --bg: #fcfbf9;
  --bg-blur: rgba(252, 251, 249, .84);
  --surface: #ffffff;
  --surface-2: #f5f3ef;
  --text: #1b1a18;
  --text-strong: #0d0c0b;
  --muted: #6c6862;
  --border: #e6e2da;
  --border-strong: #d5d0c5;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: rgba(194, 65, 12, .10);
  --code-bg: #f4f2ee;
  --shadow-sm: 0 1px 2px rgba(24, 20, 14, .06);
  --shadow-md: 0 2px 4px rgba(24, 20, 14, .05), 0 12px 28px rgba(24, 20, 14, .07);
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1080px;
  --readw: 46rem;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1013;
  --bg-blur: rgba(14, 16, 19, .84);
  --surface: #161a20;
  --surface-2: #1c2129;
  --text: #e9e7e4;
  --text-strong: #fbfaf8;
  --muted: #98a0aa;
  --border: #252b34;
  --border-strong: #333b46;
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --accent-soft: rgba(251, 146, 60, .14);
  --code-bg: #12161b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .4), 0 14px 32px rgba(0, 0, 0, .45);
}

/* ---------- 2. 基础排版 ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16.5px;
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .28s var(--ease), color .28s var(--ease);
}

h1, h2, h3, h4, .site-title, .hero-title, .card-title, .post-title {
  font-family: Georgia, "Noto Serif SC", "Songti SC", "Source Han Serif SC", serif;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .005em;
  color: var(--text-strong);
  margin: 0 0 .5em;
}

p { margin: 0 0 1.15em; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

img { max-width: 100%; height: auto; display: block; }

hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

::selection { background: var(--accent-soft); }

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

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem;
}
.skip-link:focus { left: 12px; top: 12px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- 3. 顶栏 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-blur);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-header .inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 64px;
}

.site-title {
  margin: 0; font-size: 1.16rem; letter-spacing: .04em;
  display: inline-flex; align-items: baseline; gap: .5rem;
}
.site-title a { color: var(--text-strong); }
.site-title a:hover { text-decoration: none; color: var(--accent); }
.site-title .dot { color: var(--accent); font-size: 1.4em; line-height: 0; }
.site-title .sub {
  font-family: system-ui, sans-serif; font-size: .68rem; font-weight: 500;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}

.site-nav { display: flex; align-items: center; gap: .35rem; }
.site-nav a {
  color: var(--muted); font-size: .94rem; padding: .4rem .7rem;
  border-radius: var(--radius-sm); transition: color .18s, background-color .18s;
}
.site-nav a:hover { color: var(--text-strong); background: var(--surface-2); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-left: .35rem;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--muted);
  font-size: 1rem; cursor: pointer; transition: all .18s var(--ease);
}
.icon-btn:hover { color: var(--accent); border-color: var(--border-strong); transform: translateY(-1px); }
.theme-toggle .moon { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .moon { display: inline; }

/* ---------- 4. 首页 Hero ---------- */
.hero { padding: 4.5rem 0 3rem; border-bottom: 1px solid var(--border); }
.hero-eyebrow {
  font-size: .74rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 1rem;
}
.hero-title { font-size: clamp(2rem, 5.2vw, 3rem); margin-bottom: 1rem; }
.hero-title em { font-style: normal; color: var(--accent); }
.hero-lead {
  max-width: 40rem; font-size: 1.08rem; color: var(--muted); margin-bottom: 1.8rem;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.6rem; font-size: .88rem; color: var(--muted); }
.hero-meta strong { color: var(--text); font-weight: 600; }

/* ---------- 5. 工具条：搜索 + 标签 ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  padding: 1.6rem 0 .4rem;
}
.search-box { position: relative; flex: 1 1 260px; max-width: 360px; }
.search-box input {
  width: 100%; padding: .62rem .9rem .62rem 2.3rem;
  font: inherit; font-size: .94rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; transition: border-color .18s, box-shadow .18s;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-box .icon {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .95rem; pointer-events: none;
}

.tag-filters { display: flex; flex-wrap: wrap; gap: .45rem; }
.tag-btn {
  font: inherit; font-size: .84rem; line-height: 1;
  padding: .46rem .8rem; cursor: pointer;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  transition: all .18s var(--ease);
}
.tag-btn:hover { color: var(--text-strong); border-color: var(--border-strong); }
.tag-btn[aria-pressed="true"] {
  color: var(--accent); background: var(--accent-soft);
  border-color: transparent; font-weight: 600;
}

/* ---------- 6. 文章卡片 ---------- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin: 2.6rem 0 1.2rem;
}
.section-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: .02em; }
.section-head .hint { font-size: .85rem; color: var(--muted); }

.card-grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  padding-bottom: 1rem;
}

.card {
  position: relative; display: flex; flex-direction: column;
  padding: 1.5rem 1.6rem 1.4rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), box-shadow .22s var(--ease),
              border-color .22s var(--ease);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.card.is-featured { grid-column: 1 / -1; }
.card.is-featured .card-title { font-size: clamp(1.3rem, 2.6vw, 1.7rem); }

.card-meta {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  font-size: .8rem; color: var(--muted); margin-bottom: .7rem;
  font-variant-numeric: tabular-nums;
}
.card-meta .sep { opacity: .45; }
.card-badge {
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 700; color: var(--accent); background: var(--accent-soft);
  padding: .2rem .55rem; border-radius: 999px;
}

.card-title { font-size: 1.16rem; margin-bottom: .55rem; }
.card-title a { color: inherit; }
.card-title a::after { content: ""; position: absolute; inset: 0; }  /* 整卡可点 */
.card:hover .card-title a { color: var(--accent); text-decoration: none; }

.card-excerpt { color: var(--muted); font-size: .95rem; margin-bottom: 1.1rem; }

.card-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  gap: .8rem; font-size: .8rem; color: var(--muted);
}
.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.tag-list li {
  font-size: .76rem; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: .18rem .6rem;
}

.empty-state {
  padding: 3rem 1rem; text-align: center; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}

/* ---------- 7. 文章正文 ---------- */
.post-header { padding: 3.2rem 0 1.6rem; border-bottom: 1px solid var(--border); }
.breadcrumb { font-size: .84rem; color: var(--muted); margin-bottom: 1.1rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.post-title { font-size: clamp(1.7rem, 4.2vw, 2.4rem); margin-bottom: .8rem; }
.post-meta {
  display: flex; flex-wrap: wrap; gap: .5rem 1.1rem;
  font-size: .87rem; color: var(--muted); font-variant-numeric: tabular-nums;
}

.post-layout {
  display: grid; gap: 3rem; padding: 2.6rem 0 3rem;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 1040px) {
  .post-layout { grid-template-columns: minmax(0, 1fr) 210px; }
}

.prose { max-width: var(--readw); font-size: 1.02rem; }
.prose > h2 {
  font-size: 1.42rem; margin: 2.6rem 0 .9rem; padding-left: .7rem;
  border-left: 3px solid var(--accent);
}
.prose > h3 { font-size: 1.14rem; margin: 2rem 0 .7rem; }
.prose > h2:first-child, .prose > h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 0 0 1.2em; }
.prose li { margin-bottom: .4rem; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--text-strong); font-weight: 600; }

.prose blockquote {
  margin: 1.6rem 0; padding: .9rem 1.2rem;
  background: var(--surface-2); border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted); font-size: .97rem;
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .88em; background: var(--code-bg);
  padding: .15em .4em; border-radius: 5px;
  border: 1px solid var(--border);
}

.code-block { position: relative; margin: 1.5rem 0; }
.code-block pre {
  margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); line-height: 1.65;
}
.code-block pre code {
  background: none; border: 0; padding: 0; font-size: .86rem;
}
.code-block .lang {
  position: absolute; top: .55rem; right: 4.4rem;
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.code-copy {
  position: absolute; top: .45rem; right: .6rem;
  font: inherit; font-size: .72rem; cursor: pointer;
  padding: .25rem .55rem; border-radius: 6px;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); opacity: 0; transition: opacity .18s, color .18s;
}
.code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--accent); }

.prose table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; font-size: .93rem; }
.prose th, .prose td { padding: .6rem .8rem; border-bottom: 1px solid var(--border); text-align: left; }
.prose th { font-weight: 600; color: var(--text-strong); background: var(--surface-2); }
.prose tbody tr:hover { background: var(--surface-2); }

.callout {
  display: flex; gap: .8rem; margin: 1.6rem 0; padding: 1rem 1.2rem;
  background: var(--accent-soft); border-radius: var(--radius-sm);
  font-size: .95rem;
}
.callout .ico { flex: none; }
.callout p:last-child { margin-bottom: 0; }

/* 目录 */
.toc { display: none; }
@media (min-width: 1040px) {
  .toc { display: block; position: sticky; top: 88px; align-self: start; font-size: .86rem; }
}
.toc h2 {
  font-family: system-ui, sans-serif; font-size: .72rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .7rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li { margin: 0; }
.toc a {
  display: block; padding: .3rem 0 .3rem .8rem; margin-left: -1px;
  color: var(--muted); border-left: 2px solid transparent; line-height: 1.5;
}
.toc a:hover { color: var(--text-strong); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc .lvl-3 a { padding-left: 1.6rem; font-size: .93em; }

/* 上/下一篇 */
.post-nav {
  display: grid; gap: 1rem; grid-template-columns: 1fr;
  padding: 2rem 0 1rem; border-top: 1px solid var(--border);
}
@media (min-width: 720px) { .post-nav { grid-template-columns: 1fr 1fr; } }
.post-nav a {
  display: block; padding: 1rem 1.2rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .18s, transform .18s var(--ease);
}
.post-nav a:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.post-nav .dir { font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.post-nav .ttl { display: block; margin-top: .3rem; color: var(--text-strong); font-weight: 600; }
.post-nav .next { text-align: right; }

/* ---------- 8. 归档页 ---------- */
.page-head { padding: 3.4rem 0 1.6rem; border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); margin-bottom: .5rem; }
.page-head p { color: var(--muted); max-width: 40rem; margin: 0; }

.year-group { margin-top: 2.4rem; }
.year-label {
  font-family: Georgia, serif; font-size: 1.5rem; color: var(--accent);
  display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem;
  font-variant-numeric: tabular-nums;
}
.year-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li {
  display: flex; align-items: baseline; gap: 1rem;
  padding: .7rem .2rem; border-bottom: 1px solid var(--border);
}
.archive-list .date {
  flex: none; width: 5.2rem; color: var(--muted); font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.archive-list .ttl { flex: 1; min-width: 0; }
.archive-list .ttl a { color: var(--text); font-weight: 500; }
.archive-list .ttl a:hover { color: var(--accent); }
.archive-list .tags { flex: none; color: var(--muted); font-size: .82rem; }
@media (max-width: 640px) {
  .archive-list li { flex-wrap: wrap; gap: .2rem .8rem; }
  .archive-list .tags { display: none; }
}

/* ---------- 9. 关于页 ---------- */
.block-title {
  font-size: 1.2rem; margin: 2.6rem 0 1.2rem;
  padding-bottom: .5rem; border-bottom: 1px solid var(--border);
}
.about-grid > div > section:first-child .block-title { margin-top: 1rem; }

.about-grid {
  display: grid; gap: 2.6rem; padding: 2.6rem 0 3rem;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) { .about-grid { grid-template-columns: 260px minmax(0, 1fr); } }

.profile-card {
  padding: 1.6rem; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); align-self: start;
}
.avatar {
  width: 96px; height: 96px; margin: 0 auto 1rem; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), #f0b27a);
  color: #fff; font-family: Georgia, serif; font-size: 2rem; font-weight: 700;
}
.profile-card .name { font-size: 1.15rem; margin-bottom: .2rem; }
.profile-card .role { font-size: .86rem; color: var(--muted); margin-bottom: 1rem; }
.profile-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem; }
.profile-links a {
  font-size: .82rem; padding: .3rem .65rem; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.profile-links a:hover { color: var(--accent); text-decoration: none; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.4rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 1.5rem; }
.timeline li::before {
  content: ""; position: absolute; left: -1.85rem; top: .55rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.timeline .when { font-size: .8rem; color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.timeline .what { color: var(--text); }
.timeline .what strong { color: var(--text-strong); }

.skill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.skill-list li {
  font-size: .85rem; padding: .35rem .75rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}

/* ---------- 10. 页脚 / 进度条 / 回到顶部 ---------- */
.reading-progress {
  position: fixed; top: 0; left: 0; z-index: 60;
  height: 3px; width: 0; background: var(--accent);
  transition: width .1s linear;
}

.site-footer {
  margin-top: 3.5rem; padding: 2.2rem 0 2.6rem;
  border-top: 1px solid var(--border); color: var(--muted); font-size: .87rem;
}
.site-footer .inner {
  display: flex; flex-wrap: wrap; gap: .8rem 1.5rem;
  align-items: center; justify-content: space-between;
}
.site-footer p { margin: 0; }
.site-footer nav { display: flex; gap: 1rem; }

.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 55;
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; font-size: 1rem;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .22s var(--ease), transform .22s var(--ease), visibility .22s;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 11. 动效降级 / 打印 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding: 3rem 0 2rem; }
  .container { padding: 0 18px; }
  .site-title .sub { display: none; }
  .site-nav a { padding: .4rem .5rem; font-size: .88rem; }
  .card { padding: 1.25rem 1.2rem; }
  .code-copy { opacity: 1; }
}

@media print {
  .site-header, .site-footer, .toc, .to-top, .reading-progress, .post-nav, .code-copy { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .prose a { color: #000; text-decoration: underline; }
}
