/* =========================================================
 * style.css - 前台样式
 * 深灰 + 柔和蓝 · 深浅双主题 · 完全响应式
 * ========================================================= */

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --text: #1f2328;
  --text-2: #59636e;
  --text-3: #8b949e;
  --border: #e6e8eb;
  --accent: #3e63dd;
  --accent-hover: #3355c7;
  --accent-weak: rgba(62, 99, 221, 0.09);
  --code-bg: #f4f6f8;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.04), 0 8px 24px rgba(20, 24, 33, 0.06);
  --shadow-lg: 0 4px 12px rgba(20, 24, 33, 0.08), 0 16px 48px rgba(20, 24, 33, 0.1);
  --radius: 14px;
  --radius-sm: 9px;
  --nav-h: 64px;
}
[data-theme="dark"] {
  --bg: #101114;
  --surface: #17181c;
  --surface-2: #1e2025;
  --text: #e8eaed;
  --text-2: #a2a9b3;
  --text-3: #6e7681;
  --border: #26282e;
  --accent: #7c93ff;
  --accent-hover: #93a6ff;
  --accent-weak: rgba(124, 147, 255, 0.12);
  --code-bg: #1d1f24;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.4), 0 16px 48px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: Inter, "Segoe UI", system-ui, -apple-system, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--accent-weak); }

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.page-main { min-height: calc(100vh - var(--nav-h) - 220px); padding-top: 40px; padding-bottom: 64px; }
.muted { color: var(--text-2); font-size: 14px; }

/* ---------- 顶部导航 ---------- */
.nav-wrap {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav { height: var(--nav-h); }
.nav-inner { display: flex; align-items: center; gap: 28px; height: 100%; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; color: var(--text); }
.brand::after { content: "."; color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-links > a {
  padding: 7px 14px; border-radius: 999px; font-size: 15px; color: var(--text-2);
  transition: all 0.18s ease;
}
.nav-links > a:hover { color: var(--text); background: var(--surface-2); }
.nav-links > a.active { color: var(--accent); background: var(--accent-weak); font-weight: 600; }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text-2); transition: all 0.18s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
[data-theme="light"] .i-moon { display: none; }
[data-theme="dark"] .i-sun { display: none; }
.nav-burger { display: none; }

/* 导航搜索 */
.nav-search { position: relative; margin-left: 12px; }
.nav-search input {
  width: 200px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 14px;
  outline: none; transition: all 0.2s ease;
}
.nav-search input:focus { width: 250px; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.search-drop {
  position: absolute; top: calc(100% + 10px); right: 0; width: 340px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 120;
}
.search-drop.open { display: block; animation: pop 0.16s ease; }
.search-item { display: block; padding: 10px 12px; border-radius: var(--radius-sm); }
.search-item:hover { background: var(--surface-2); }
.si-title { display: block; font-weight: 600; font-size: 14px; color: var(--text); }
.si-sum { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-all { display: block; text-align: center; padding: 9px; font-size: 13px; color: var(--accent); }
.search-empty { padding: 16px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 40px; text-align: center; }
.hero-hi { color: var(--accent); font-weight: 600; font-size: 15px; letter-spacing: 1px; }
.hero-title { font-size: clamp(34px, 5vw, 52px); font-weight: 800; letter-spacing: 1px; margin: 10px 0 14px; }
.hero-desc { color: var(--text-2); max-width: 560px; margin: 0 auto; font-size: 17px; }

/* ---------- 区块 ---------- */
.section { margin-top: 48px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.section-head h2 { font-size: 22px; font-weight: 700; }
.section-head .more { color: var(--accent); font-size: 14px; font-weight: 500; }
.page-title { font-size: 28px; font-weight: 800; }
.filter-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.filter-desc { margin-bottom: 20px; }

/* ---------- 精选 ---------- */
.featured-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.feat-main, .feat-item, .rel-card {
  position: relative; display: block; border-radius: var(--radius); overflow: hidden;
  min-height: 320px; background-size: cover; background-position: center;
  box-shadow: var(--shadow); transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.feat-item { min-height: 151px; }
.feat-item + .feat-item { margin-top: 18px; }
.feat-main:hover, .feat-item:hover, .rel-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.cover-char {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 88px; font-weight: 800; color: rgba(255, 255, 255, 0.28);
  user-select: none; pointer-events: none; line-height: 1;
}
.feat-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 22px; gap: 8px;
  background: linear-gradient(180deg, rgba(10, 12, 18, 0) 30%, rgba(10, 12, 18, 0.72) 100%);
}
.feat-title { color: #fff; font-size: 24px; font-weight: 700; line-height: 1.35; }
.feat-title-sm { color: #fff; font-size: 17px; font-weight: 700; line-height: 1.4; }
.feat-sum { color: rgba(255, 255, 255, 0.82); font-size: 13.5px; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-cat {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.18); color: #fff; font-size: 12.5px;
  backdrop-filter: blur(4px); width: fit-content;
}
.feat-overlay .card-cat { width: fit-content; }

/* ---------- 文章行 ---------- */
.post-rows { display: flex; flex-direction: column; gap: 18px; }
.post-row {
  display: flex; gap: 24px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.post-row:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 19px; font-weight: 700; line-height: 1.4; }
.row-title a:hover { color: var(--accent); }
.row-sum { color: var(--text-2); font-size: 14.5px; margin: 8px 0 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-cover {
  width: 168px; min-width: 168px; height: 124px; border-radius: var(--radius-sm);
  background-size: cover; background-position: center; position: relative; overflow: hidden;
}
.row-cover .cover-char { font-size: 40px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-3); font-size: 13px; }
.meta-cat { color: var(--accent); font-weight: 600; }
.meta-cat:hover { text-decoration: underline; }

/* ---------- 分类 / 标签 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.cat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 6px;
  transition: all 0.2s ease;
}
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.cat-card strong { font-size: 16px; }
.cat-desc { color: var(--text-3); font-size: 12.5px; min-height: 20px; }
.cat-count { color: var(--accent); font-size: 12.5px; font-weight: 600; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-chip {
  padding: 6px 16px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); font-size: 13.5px; color: var(--text-2);
  transition: all 0.18s ease;
}
.tag-chip:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--text-3); padding: 56px 0; font-size: 15px; }
.empty-big { padding: 110px 0; }
.empty-big h1 { font-size: 72px; color: var(--text-3); margin-bottom: 10px; }
.empty-big p { margin-bottom: 26px; }

/* ---------- 文章详情 ---------- */
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 40px; }
.post-page { max-width: 760px; }
.post-head { margin-bottom: 28px; }
.post-head .meta-cat { display: inline-block; margin-bottom: 14px; }
.post-title { font-size: clamp(28px, 4vw, 40px); font-weight: 800; line-height: 1.3; letter-spacing: 0.3px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 16px; color: var(--text-3); font-size: 13.5px; margin-top: 16px; }
.post-cover { height: 340px; border-radius: var(--radius); background-size: cover; background-position: center;
  margin: 10px 0 30px; position: relative; overflow: hidden; }
.post-cover .cover-char { font-size: 110px; }

/* 正文排版 */
.prose { font-size: 17px; line-height: 1.85; color: var(--text); }
.prose > * + * { margin-top: 1.1em; }
.prose h2, .prose h3, .prose h4 { font-weight: 700; line-height: 1.4; margin-top: 1.9em; scroll-margin-top: 84px; }
.prose h2 { font-size: 25px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 20px; }
.prose h4 { font-size: 17px; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose a:hover { color: var(--accent-hover); }
.prose strong { font-weight: 700; }
.prose blockquote {
  border-left: 3px solid var(--accent); background: var(--accent-weak);
  padding: 14px 20px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-2);
}
.prose blockquote p { margin: 0; }
.prose ul, .prose ol { padding-left: 1.6em; }
.prose li + li { margin-top: 0.4em; }
.prose ul.sub { margin-top: 0.4em; }
.prose code {
  font-family: ui-monospace, "Cascadia Code", Consolas, "JetBrains Mono", monospace;
  font-size: 0.86em; background: var(--code-bg); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 6px; color: var(--accent);
}
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.prose img { border-radius: var(--radius-sm); }
.code-block { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--code-bg); }
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 14px; border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-3); font-family: ui-monospace, Consolas, monospace;
}
.code-copy {
  border: none; background: transparent; color: var(--text-3); font-size: 12px; padding: 2px 8px;
  border-radius: 6px; transition: all 0.15s ease;
}
.code-copy:hover { color: var(--accent); background: var(--accent-weak); }
.code-block pre { padding: 16px 18px; overflow-x: auto; }
.code-block code { background: transparent; border: none; padding: 0; color: var(--text);
  font-size: 13.5px; line-height: 1.7; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.prose th { background: var(--surface-2); text-align: left; font-weight: 700; }
.prose th, .prose td { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.prose tbody tr:last-child td { border-bottom: none; }
.prose tbody tr:hover { background: var(--surface-2); }

/* 目录 */
.toc-wrap { position: sticky; top: calc(var(--nav-h) + 24px); align-self: start; max-height: calc(100vh - 120px); overflow-y: auto; }
.toc { border-left: 1px solid var(--border); padding-left: 4px; }
.toc-h { font-size: 13px; font-weight: 700; color: var(--text-2); padding-left: 16px; margin-bottom: 8px; }
.toc-item {
  display: block; padding: 5px 16px; font-size: 13px; color: var(--text-3);
  border-left: 2px solid transparent; margin-left: -3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: all 0.15s ease;
}
.toc-item:hover { color: var(--text); }
.toc-item.lv3 { padding-left: 30px; }
.toc-item.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* 上一篇 / 下一篇 */
.post-neighbor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; }
.neighbor {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 5px; transition: all 0.2s ease; background: var(--surface);
}
.neighbor:hover { border-color: var(--accent); }
.neighbor.next { text-align: right; }
.neighbor span { font-size: 12px; color: var(--text-3); }
.neighbor strong { font-size: 14.5px; line-height: 1.45; }
.neighbor.disabled { opacity: 0.45; pointer-events: none; }

/* 相关推荐 */
.related { margin-top: 44px; }
.related h3 { font-size: 18px; margin-bottom: 16px; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.rel-card { min-height: 150px; }

/* ---------- 归档 ---------- */
.year-block { margin-top: 34px; }
.year-h { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.year-h::after { content: ""; display: block; width: 34px; height: 3px; background: var(--accent); border-radius: 2px; margin-top: 8px; }
.month-h { color: var(--text-3); font-size: 14px; font-weight: 600; margin: 20px 0 8px; }
.archive-list { display: flex; flex-direction: column; }
.archive-item {
  display: flex; align-items: baseline; gap: 16px; padding: 11px 12px; border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.archive-item:hover { background: var(--surface-2); }
.ai-date { color: var(--text-3); font-size: 13px; font-family: ui-monospace, Consolas, monospace; }
.ai-title { flex: 1; font-weight: 500; }
.archive-item:hover .ai-title { color: var(--accent); }
.ai-cat { color: var(--text-3); font-size: 12.5px; }

/* ---------- 关于 ---------- */
.about-wrap { display: flex; justify-content: center; }
.about-wrap .post-page { width: 100%; max-width: 760px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 44px 48px; box-shadow: var(--shadow); }
.about-social { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }
.page-btn, .page-num {
  min-width: 38px; height: 38px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-size: 14px; color: var(--text-2); transition: all 0.18s ease;
}
.page-btn:hover, .page-num:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.disabled { opacity: 0.4; pointer-events: none; }
.page-num.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.page-ellipsis { color: var(--text-3); }

/* ---------- 页脚 ---------- */
footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; }
.footer-inner {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; padding-top: 44px; padding-bottom: 32px;
}
.footer-logo { font-size: 18px; font-weight: 800; }
.footer-desc { color: var(--text-3); font-size: 13.5px; margin: 10px 0 14px; }
.footer-h { font-size: 13.5px; font-weight: 700; margin-bottom: 12px; }
.footer-col { display: flex; flex-direction: column; gap: 8px; }
.footer-col a { color: var(--text-2); font-size: 13.5px; transition: color 0.15s ease; width: fit-content; }
.footer-col a:hover { color: var(--accent); }
.footer-links-row { display: flex; flex-wrap: wrap; gap: 14px; }
.footer-links-row a { color: var(--text-2); font-size: 13.5px; }
.footer-links-row a:hover { color: var(--accent); }
.footer-bottom { padding: 18px 24px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12.5px; text-align: center; }
.footer-bottom a { color: var(--text-3); }
.footer-bottom a:hover { color: var(--accent); }

/* ---------- Toast / 弹窗（前台与后台共用） ---------- */
#toast-box { position: fixed; bottom: 28px; right: 28px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px; color: #fff;
  background: #1f2328; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px); transition: all 0.3s ease; max-width: 340px;
}
[data-theme="dark"] .toast { background: #2c2f36; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left: 3px solid #34c98e; }
.toast-error { border-left: 3px solid #f0616d; }
.toast-info { border-left: 3px solid var(--accent); }
.modal-mask {
  position: fixed; inset: 0; z-index: 1000; background: rgba(12, 14, 20, 0.5);
  display: grid; place-items: center; backdrop-filter: blur(3px); animation: fadeIn 0.15s ease;
}
.modal {
  width: min(420px, calc(100vw - 48px)); background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 26px; animation: pop 0.18s ease;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal-msg { color: var(--text-2); font-size: 14px; line-height: 1.7; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 22px; border-radius: var(--radius-sm); font-size: 14.5px;
  font-weight: 600; border: 1px solid transparent; transition: all 0.18s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-3); }
.btn-danger { background: #e5484d; color: #fff; }
.btn-danger:hover { background: #d03d42; }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }

/* ---------- 动画 ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.section, .hero { animation: rise 0.45s ease both; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .featured-grid { grid-template-columns: 1fr; }
  .feat-main { min-height: 260px; }
  .post-layout { grid-template-columns: 1fr; }
  .toc-wrap { display: none; }
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .container { padding: 0 18px; }
  .nav-burger { display: grid; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    flex-direction: column; align-items: stretch; padding: 12px 18px 18px; gap: 4px;
    display: none; box-shadow: var(--shadow-lg);
  }
  .nav-links.open { display: flex; animation: pop 0.18s ease; }
  .nav-links > a { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 15.5px; }
  .nav-search { margin: 8px 0 0; }
  .nav-search input { width: 100%; }
  .nav-search input:focus { width: 100%; }
  .search-drop { width: 100%; left: 0; }
  .post-row { flex-direction: column-reverse; padding: 18px; }
  .row-cover { width: 100%; height: 150px; }
  .post-neighbor, .related-grid { grid-template-columns: 1fr; }
  .about-wrap .post-page { padding: 28px 22px; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .hero { padding: 36px 0 24px; }
}
