/* =========================================================
   李明的个人博客 — 样式表
   纯静态 · 响应式 · 支持深色模式
   ========================================================= */

/* ---------- 设计变量（浅色） ---------- */
:root {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --bg-elev: #ffffff;
  --text: #1f2430;
  --text-soft: #5b6472;
  --text-faint: #8a93a3;
  --border: #e7e9f0;
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --accent-2: #0ea5e9;
  --code-bg: #f3f4f8;
  --code-text: #c7254e;
  --pre-bg: #1e2330;
  --pre-text: #e6e9f0;
  --shadow: 0 6px 24px rgba(20, 25, 40, 0.08);
  --shadow-sm: 0 2px 8px rgba(20, 25, 40, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1080px;
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* ---------- 深色模式 ---------- */
[data-theme="dark"] {
  --bg: #0f1218;
  --bg-soft: #161b24;
  --bg-elev: #1a202b;
  --text: #e7ebf2;
  --text-soft: #aab3c2;
  --text-faint: #7b8494;
  --border: #272e3a;
  --accent: #818cf8;
  --accent-soft: #232a3d;
  --accent-2: #38bdf8;
  --code-bg: #11151d;
  --code-text: #ff9bb3;
  --pre-bg: #0b0e14;
  --pre-text: #e6e9f0;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.accent { color: var(--accent); }

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg-soft) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 100%; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-avatar { width: 34px; height: 34px; border-radius: 9px; }
.nav-links { display: flex; gap: 26px; list-style: none; margin: 0; padding: 0; }
.nav-links a { color: var(--text-soft); font-weight: 500; transition: color .2s; }
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.nav-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle, .hamburger {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
  transition: transform .15s, background .2s, border-color .2s;
}
.theme-toggle:hover, .hamburger:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-icon { font-size: 16px; line-height: 1; }
.hamburger { display: none; flex-direction: column; gap: 4px; }
.hamburger span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: .25s; }
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero { padding: 56px 20px 40px; }
.hero-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 24px; box-shadow: var(--shadow);
  padding: 48px 40px; text-align: center;
  background-image: radial-gradient(120% 140% at 0% 0%, var(--accent-soft) 0%, transparent 45%);
}
.hero-avatar { width: 104px; height: 104px; border-radius: 26px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.hero-name { font-size: clamp(28px, 5vw, 40px); margin: 0 0 8px; letter-spacing: -0.5px; }
.hero-role { font-size: 17px; color: var(--accent); font-weight: 600; margin: 0 0 14px; }
.hero-tagline { color: var(--text-soft); max-width: 620px; margin: 0 auto 26px; }
.hero-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-socials { margin-top: 26px; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.hero-socials a {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text-soft); font-weight: 500; font-size: 14px;
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-soft);
}
.hero-socials a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.ic { width: 16px; height: 16px; fill: currentColor; flex: none; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; border-radius: 11px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: transform .15s, box-shadow .2s, background .2s;
  font-size: 15px;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: var(--bg-elev); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; background: var(--bg-elev); color: var(--text-soft); border: 1px solid var(--border); }
.btn-sm:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 区块通用 ---------- */
.section { padding: 56px 0; }
.section-title { font-size: clamp(22px, 3.5vw, 30px); margin: 0 0 6px; letter-spacing: -0.4px; }
.section-sub { color: var(--text-soft); margin: 0 0 28px; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 26px; }

/* ---------- 关于 ---------- */
.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
.side-card h3 { margin: 0 0 12px; font-size: 16px; }
.side-card h3:not(:first-child) { margin-top: 22px; }
.facts { list-style: none; margin: 0; padding: 0; }
.facts li { padding: 7px 0; border-bottom: 1px dashed var(--border); color: var(--text-soft); font-size: 14px; }
.facts li:last-child { border-bottom: none; }
.facts strong { color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- 文章卡片 ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.post-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; cursor: pointer; transition: transform .18s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column; gap: 10px;
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.post-card h3 { margin: 0; font-size: 18px; line-height: 1.4; }
.post-card .excerpt { color: var(--text-soft); font-size: 14px; margin: 0; flex: 1; }
.post-meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-faint); flex-wrap: wrap; }
.post-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-faint); }
.post-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.post-tags .tag { font-size: 11px; padding: 3px 9px; }

/* ---------- 编辑器 ---------- */
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.editor-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-hint { font-size: 13px; color: var(--text-faint); }
.editor-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.editor-pane { display: flex; flex-direction: column; min-width: 0; }
.pane-label { font-size: 13px; font-weight: 600; color: var(--text-soft); margin-bottom: 8px; }
#mdInput {
  flex: 1; min-height: 420px; resize: vertical;
  padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text); font-family: var(--mono); font-size: 13.5px; line-height: 1.6;
}
#mdInput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.editor-preview { min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); padding: 18px 22px; overflow: auto; }

/* ---------- 阅读弹层 ---------- */
.reader { position: fixed; inset: 0; z-index: 100; display: none; }
.reader.open { display: block; }
.reader-backdrop { position: absolute; inset: 0; background: rgba(10, 13, 20, 0.55); backdrop-filter: blur(3px); }
.reader-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(820px, 92vw); max-height: 88vh; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 18px;
  padding: 40px 44px; box-shadow: var(--shadow);
}
.reader-close {
  position: sticky; top: -28px; float: right; margin: -20px -20px 0 0;
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text); cursor: pointer; font-size: 15px;
}
.reader-close:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 页脚 / 返回顶部 ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 28px 0; margin-top: 30px; }
.footer-inner { text-align: center; color: var(--text-faint); font-size: 13.5px; }
.footer-inner a { color: var(--text-soft); }
.footer-sub { margin: 6px 0 0; }
.back-to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--accent); cursor: pointer; font-size: 18px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .25s, transform .2s;
}
.back-to-top.show { opacity: 1; pointer-events: auto; }
.back-to-top:hover { transform: translateY(-2px); }

/* ---------- 滚动揭示动画 ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}

/* =========================================================
   Markdown 内容样式（.markdown-body）
   ========================================================= */
.markdown-body { color: var(--text); font-size: 15.5px; line-height: 1.8; word-wrap: break-word; }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  line-height: 1.35; margin: 1.6em 0 .6em; font-weight: 700; letter-spacing: -0.2px;
}
.markdown-body h1 { font-size: 1.9em; border-bottom: 2px solid var(--border); padding-bottom: .3em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: .25em; }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1.05em; }
.markdown-body p { margin: 0 0 1em; }
.markdown-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.markdown-body strong { color: var(--text); font-weight: 700; }
.markdown-body ul, .markdown-body ol { margin: 0 0 1em; padding-left: 1.5em; }
.markdown-body li { margin: .3em 0; }
.markdown-body blockquote {
  margin: 0 0 1em; padding: .6em 1.1em; border-left: 4px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-soft);
}
.markdown-body blockquote p:last-child { margin-bottom: 0; }
.markdown-body code {
  font-family: var(--mono); font-size: .9em; padding: .15em .4em; border-radius: 5px;
  background: var(--code-bg); color: var(--code-text);
}
.markdown-body pre {
  background: var(--pre-bg); color: var(--pre-text); padding: 16px 18px; border-radius: var(--radius-sm);
  overflow: auto; margin: 0 0 1em; font-size: 13.5px; line-height: 1.6;
}
.markdown-body pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.8em 0; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); display: block; margin: 1em 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 0 0 1em; font-size: 14px; display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.markdown-body th { background: var(--bg-soft); font-weight: 700; }
.markdown-body tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-soft) 60%, transparent); }

/* =========================================================
   响应式
   ========================================================= */
@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .nav-links {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; gap: 0; background: var(--bg-soft);
    border-bottom: 1px solid var(--border); padding: 8px 20px 14px;
    transform: translateY(-12px); opacity: 0; pointer-events: none; transition: .2s;
  }
  .nav-links.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav-links li { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .nav-links li:last-child { border-bottom: none; }
  .hamburger { display: flex; }
  .editor-panes { grid-template-columns: 1fr; }
  .hero-card { padding: 36px 22px; }
  .reader-panel { padding: 30px 22px; }
}
