/* ============================================================
   墨迹博客 · 前台样式
   ============================================================ */

:root {
  --bg: #f5f6f8;
  --bg-soft: #eceef2;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --text: #171a1f;
  --text-soft: #3d434e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --accent: #0f7b6c;
  --accent-hover: #0b6357;
  --accent-soft: #e6f4f1;
  --danger: #c0392b;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .12);
  --radius: 14px;
  --radius-sm: 9px;
  --font-sans: -apple-system, BlinkMacSystemFont, "HarmonyOS Sans SC", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Songti SC", "SimSun", "Noto Serif CJK SC", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --maxw: 1080px;
}

html[data-theme="dark"] {
  --bg: #0d1015;
  --bg-soft: #12161d;
  --surface: #161b23;
  --surface-2: #1b212b;
  --text: #e8ebf0;
  --text-soft: #c3cad6;
  --muted: #8e97a7;
  --border: #262d39;
  --border-soft: #1f252f;
  --accent: #35c3ac;
  --accent-hover: #4fd6bf;
  --accent-soft: #10312c;
  --danger: #e07a6e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

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

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

button, input, select, textarea { font: inherit; color: inherit; }

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

/* ---------------- 顶部导航 ---------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface); /* 旧浏览器降级：不透明背景 */
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 66px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .5px;
  white-space: nowrap;
}
.brand:hover { color: var(--accent); }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  font-size: 15px;
  font-family: var(--font-sans);
  font-weight: 800;
}

.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14.5px;
  transition: .18s;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.search-box { position: relative; }
.search-box input {
  width: 168px;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 999px;
  font-size: 14px;
  outline: none;
  transition: .2s;
}
.search-box input:focus {
  width: 216px;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-box::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 13px;
  height: 13px;
  margin-top: -7px;
  border: 1.8px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}
.search-box::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 50%;
  width: 6px;
  height: 1.8px;
  margin-top: 4px;
  background: var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  transition: .18s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.menu-toggle { display: none; }

/* ---------------- 通用 ---------------- */

main { min-height: 62vh; padding: 34px 0 60px; }

.page-head { margin-bottom: 26px; }
.page-head h1 {
  font-family: var(--font-serif);
  font-size: 30px;
  margin: 0 0 6px;
  letter-spacing: .3px;
}
.page-head p { margin: 0; color: var(--muted); font-size: 14.5px; }

.hero {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 42px 40px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .09);
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: 34px;
  margin: 0 0 10px;
  letter-spacing: .5px;
}
.hero p { margin: 0; opacity: .92; max-width: 640px; font-size: 15.5px; }
.hero .hero-meta { margin-top: 18px; font-size: 13.5px; opacity: .8; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 34px 0 16px;
}
.section-title h2 {
  font-size: 18px;
  margin: 0;
  letter-spacing: .3px;
}
.section-title span { color: var(--muted); font-size: 13.5px; }
.section-title .more { margin-left: auto; font-size: 13.5px; }

/* ---------------- 文章卡片 ---------------- */

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.post-card .cover {
  width: 100%;
  height: 152px;
  object-fit: cover;
  display: block;
  background: var(--bg-soft);
}
.post-card .body { padding: 20px 22px 18px; display: flex; flex-direction: column; flex: 1; }
.post-card h3 {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.45;
  margin: 0 0 9px;
}
.post-card h3 a { color: var(--text); }
.post-card h3 a:hover { color: var(--accent); }
.post-card .excerpt {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  margin: 0 0 16px;
  flex: 1;
}
.post-card .foot {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.7;
}
.chip:hover { background: var(--accent); color: #fff; }
.chip.ghost { background: var(--bg-soft); color: var(--muted); font-weight: 500; }
.chip.ghost:hover { background: var(--border); color: var(--text); }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- 分页 ---------------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 36px;
  flex-wrap: wrap;
}
.pagination button {
  min-width: 36px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 14px;
  transition: .18s;
}
.pagination button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- 文章详情 ---------------- */

.article { max-width: 780px; margin: 0 auto; }

.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.article-title {
  font-family: var(--font-serif);
  font-size: 34px;
  line-height: 1.35;
  margin: 0 0 16px;
  letter-spacing: .4px;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 13.5px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 30px;
}
.article-meta .dot { opacity: .45; }

.article-cover {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 0 0 30px;
  font-size: 14px;
}
.toc strong { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; letter-spacing: .5px; }
.toc ul { margin: 0; padding-left: 18px; }
.toc li { margin: 3px 0; }
.toc a { color: var(--text-soft); cursor: pointer; }
.toc a:hover { color: var(--accent); }
.toc .lv3 { padding-left: 14px; list-style: circle; }

/* 正文排版 */
.prose { font-size: 16.5px; line-height: 1.85; color: var(--text-soft); overflow-wrap: break-word; }
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--font-serif);
  color: var(--text);
  line-height: 1.4;
  margin: 2em 0 .7em;
  scroll-margin-top: 86px;
}
.prose h1 { font-size: 27px; }
.prose h2 {
  font-size: 23px;
  padding-bottom: .35em;
  border-bottom: 1px solid var(--border);
}
.prose h3 { font-size: 19px; }
.prose h4 { font-size: 17px; }
.prose p { margin: 0 0 1.15em; }
.prose ul, .prose ol { margin: 0 0 1.15em; padding-left: 1.5em; }
.prose li { margin: .35em 0; }
.prose li.task { list-style: none; margin-left: -1.3em; }
.prose li.task.done { color: var(--muted); text-decoration: line-through; }
.prose blockquote {
  margin: 0 0 1.15em;
  padding: 12px 20px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose img { border-radius: var(--radius-sm); margin: .4em 0; }
.prose a { border-bottom: 1px solid var(--accent-soft); }
.prose a { border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.prose code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  padding: .12em .42em;
  border-radius: 5px;
  color: var(--accent);
  word-break: break-word;
}
.prose strong { color: var(--text); }
.prose del { color: var(--muted); }

.code-block {
  position: relative;
  margin: 0 0 1.3em;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1b1f27;
}
.code-block .code-lang {
  position: absolute;
  top: 0;
  right: 0;
  padding: 3px 10px;
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #8b95a5;
  background: rgba(255, 255, 255, .05);
  border-bottom-left-radius: 8px;
  font-family: var(--font-mono);
}
.code-block pre { margin: 0; padding: 18px 20px; overflow-x: auto; }
.code-block code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: #dfe6f0;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
}

.table-wrap { overflow-x: auto; margin: 0 0 1.3em; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.prose th, .prose td { padding: 10px 14px; border-bottom: 1px solid var(--border-soft); text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 600; color: var(--text); white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: 0; }
.prose tbody tr:hover { background: var(--surface-2); }
.ta-center { text-align: center; }
.ta-right { text-align: right; }

.article-foot {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.neighbors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 24px;
}
.neighbor {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: .18s;
}
.neighbor:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.neighbor small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.neighbor span { color: var(--text); font-size: 14.5px; font-weight: 500; }
.neighbor.next { text-align: right; }
.neighbor.empty { visibility: hidden; }

/* ---------------- 列表 / 归档 ---------------- */

.list-item {
  display: flex;
  gap: 18px;
  align-items: baseline;
  padding: 16px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.list-item time {
  flex: 0 0 92px;
  color: var(--muted);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.list-item h3 { margin: 0; font-size: 16.5px; font-weight: 600; font-family: var(--font-sans); }
.list-item h3 a { color: var(--text); }
.list-item h3 a:hover { color: var(--accent); }
.list-item .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }

.year-group { margin-bottom: 26px; }
.year-group > h2 {
  font-size: 22px;
  font-family: var(--font-serif);
  color: var(--accent);
  margin: 0 0 8px;
}

.taxonomy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.taxonomy-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: .18s;
}
.taxonomy-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.taxonomy-card b { color: var(--text); font-weight: 600; font-size: 15px; }
.taxonomy-card span {
  color: var(--muted);
  font-size: 12.5px;
  background: var(--bg-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.taxonomy-card:hover b { color: var(--accent); }

/* ---------------- 空状态 / 提示 ---------------- */

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--muted);
}
.empty .big { font-size: 40px; margin-bottom: 10px; opacity: .5; }

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #fff8e6;
  border: 1px solid #f2d99a;
  color: #8a6320;
  font-size: 13.5px;
  margin-bottom: 20px;
}
html[data-theme="dark"] .notice { background: #33280f; border-color: #5c4a1d; color: #e8c88a; }

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

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 30px 0;
  color: var(--muted);
  font-size: 13.5px;
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.footer-inner .right { margin-left: auto; display: flex; gap: 16px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------------- Toast ---------------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .22s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 860px) {
  .nav {
    display: none;
    position: absolute;
    top: 66px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 14px 14px;
    gap: 2px;
    box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: 11px 12px; }
  .menu-toggle { display: grid; }
  .search-box input { width: 130px; }
  .search-box input:focus { width: 150px; }
  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 26px; }
  .article-title { font-size: 26px; }
  .prose { font-size: 16px; }
  .neighbors { grid-template-columns: 1fr; }
  .neighbor.next { text-align: left; }
  .list-item { flex-direction: column; gap: 4px; }
  .list-item time { flex: none; }
}

@media (max-width: 520px) {
  .post-grid { grid-template-columns: 1fr; }
  .brand span.name { display: none; }
  .search-box { display: none; }
}
