/**
 * 原创博客模板 - 借鉴高排名博客的布局与可读性设计
 * 要点：简约大气、内容区 65ch 可读宽度、粘性侧栏、卡片式列表、移动优先
 */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #4b5563;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-hover: 0 4px 12px rgba(0,0,0,.08);
  --max-width: 1200px;
  --content-width: 65ch;      /* 正文最佳阅读宽度 */
  --sidebar-width: 280px;
  --header-h: 60px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif SC", "Source Han Serif CN", Georgia, serif;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  background: #fafafa;
  color-scheme: light;
}
body {
  margin: 0;
  font: 16px/1.65 var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ========== 头部：简洁单行 ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  min-height: var(--header-h);
}
.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
}
.logo:hover { text-decoration: none; color: var(--accent); }
.nav-main {
  display: flex;
  align-items: center;
  gap: 28px;
  color: var(--text-secondary);
  font-size: 15px;
}
.nav-main a { color: inherit; }
.nav-main a:hover, .nav-main a.active { color: var(--accent); text-decoration: none; }
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text);
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  margin-left: auto;
}

/* ========== 主布局：内容 + 侧栏 ========== */
.layout-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 48px;
  align-items: start;
}
@media (max-width: 960px) {
  .layout-wrap { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

/* ========== 首页标题区 ========== */
.blog-intro {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.blog-intro h1 {
  font-size: clamp(1.5rem, 3vw, 1.75rem);
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}
.blog-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ========== 文章列表（卡片） ========== */
.post-list { list-style: none; padding: 0; margin: 0; }
.post-card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 24px;
  transition: box-shadow .2s, border-color .2s;
}
.post-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: rgba(37,99,235,.15);
  text-decoration: none;
}
.post-card-thumb {
  aspect-ratio: 16/9;
  background: var(--bg);
  overflow: hidden;
}
.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.post-card-body { padding: 20px 24px; }
.post-card-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.post-card-meta a,
.post-card-meta span { color: var(--muted); }
.post-card-meta a:hover { color: var(--accent); }
.post-card-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.35;
}
.post-card:hover .post-card-title { color: var(--accent); }
.post-card-excerpt {
  margin: 0;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== 侧栏（粘性） ========== */
.sidebar { position: sticky; top: calc(var(--header-h) + 24px); }
.sidebar-widget {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 24px;
}
.sidebar-widget-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 8px; }
.sidebar-list a {
  display: block;
  padding: 6px 0;
  color: var(--text-secondary);
  font-size: 15px;
}
.sidebar-list a:hover { color: var(--accent); text-decoration: none; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}
.tag-cloud a:hover { background: rgba(37,99,235,.1); color: var(--accent); text-decoration: none; }
.about-text { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin: 0; }

/* ========== 分页 ========== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ========== 单篇文章页 ========== */
.article-layout {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 48px;
  align-items: start;
}
@media (max-width: 960px) {
  .article-layout { grid-template-columns: 1fr; }
}
.article-main {
  max-width: var(--content-width);
  min-width: 0;
}
.article-breadcrumb {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
}
.article-breadcrumb a { color: var(--muted); }
.article-breadcrumb a:hover { color: var(--accent); }
.article-header { margin-bottom: 28px; }
.article-title {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 12px;
  color: var(--text);
  font-family: var(--font-serif);
}
.article-meta {
  font-size: 14px;
  color: var(--muted);
}
.article-meta a { color: var(--muted); }
.article-meta a:hover { color: var(--accent); }
.article-body {
  font-size: 17px;
  line-height: 1.75;
  color: var(--text);
}
.article-body h2 { font-size: 1.35rem; margin: 2em 0 .75em; font-weight: 600; }
.article-body h3 { font-size: 1.15rem; margin: 1.5em 0 .5em; font-weight: 600; }
.article-body p { margin: 0 0 1.25em; }
.article-body ul, .article-body ol { margin: 0 0 1.25em; padding-left: 1.5em; }
.article-body img { border-radius: var(--radius); margin: 1.25em 0; }
.article-body blockquote {
  margin: 1.5em 0;
  padding: 12px 20px;
  border-left: 4px solid var(--accent);
  background: var(--bg);
  color: var(--text-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.article-body code { font-size: .9em; background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.article-body pre { overflow-x: auto; padding: 16px; background: var(--bg); border-radius: var(--radius); margin: 1.25em 0; }
.article-body pre code { background: none; padding: 0; }

/* ========== 抽屉菜单（移动端） ========== */
.nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  visibility: hidden;
}
.nav-drawer.is-open { pointer-events: auto; visibility: visible; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity .25s;
}
.nav-drawer.is-open .drawer-backdrop { opacity: 1; }
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 85vw;
  height: 100%;
  background: var(--surface);
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
  padding: 24px;
  transform: translateX(100%);
  transition: transform .25s;
}
.nav-drawer.is-open .drawer-panel { transform: translateX(0); }
.drawer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
}
.drawer-links { display: flex; flex-direction: column; gap: 4px; padding-top: 48px; }
.drawer-links a {
  display: block;
  padding: 14px 0;
  font-size: 16px;
  color: var(--text);
}
.drawer-links a:hover { color: var(--accent); text-decoration: none; }

@media (max-width: 768px) {
  .nav-main { display: none; }
  .menu-toggle { display: flex; }
}

/* ========== 页脚 ========== */
.site-footer {
  margin-top: 48px;
  padding: 32px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-bottom: 12px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); text-decoration: none; }
.footer-copy { margin: 0; }
