/* ============================================
   王灏新视野工作室 - 博客主题 CSS
   简约大气，支持暗色模式，响应式
   ============================================ */

/* --- CSS 变量 --- */
:root {
  --primary:      #2563eb;
  --primary-light:#3b82f6;
  --primary-dark: #1d4ed8;
  --accent:       #06b6d4;
  --success:      #10b981;
  --text-primary: #1e293b;
  --text-secondary:#475569;
  --text-muted:   #94a3b8;
  --bg:           #ffffff;
  --bg-alt:       #f8fafc;
  --bg-card:      #ffffff;
  --border:       #e2e8f0;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:       0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:    0 10px 40px rgba(0,0,0,.12);
  --radius:       10px;
  --radius-sm:    6px;
  --transition:   0.2s ease;
  --font-sans:    'PingFang SC','Helvetica Neue',Arial,'Microsoft YaHei',sans-serif;
  --font-mono:    'JetBrains Mono','Fira Code',Consolas,monospace;
  --header-h:     64px;
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #f1f5f9;
    --text-secondary:#cbd5e1;
    --text-muted:   #64748b;
    --bg:           #0f172a;
    --bg-alt:       #1e293b;
    --bg-card:      #1e293b;
    --border:       #334155;
  }
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: box-shadow var(--transition);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(15,23,42,.92); }
}
.site-header.scrolled { box-shadow: var(--shadow); }
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.site-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .9rem;
  font-weight: 800;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--primary); }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--transition);
}
.site-nav a:hover, .site-nav a.active {
  color: var(--primary);
  background: rgba(37,99,235,.07);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-primary);
}

/* --- 搜索框 --- */
.header-search { position: relative; }
.header-search input {
  width: 200px;
  padding: 7px 14px 7px 36px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .85rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
}
.header-search input:focus {
  border-color: var(--primary);
  width: 240px;
  background: var(--bg);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.header-search .search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

/* --- 主容器 --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.page-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 40px;
  padding: 40px 0 60px;
}
main { min-width: 0; flex: 1; }
footer { margin-top: auto; }

/* --- Hero 区域 --- */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: 60px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z' fill='%23fff' fill-opacity='.05' fill-rule='evenodd'/%3E%3C/svg%3E") repeat;
}
.hero-inner { position: relative; z-index: 1; }
.hero h1 { font-size: 2.4rem; font-weight: 800; margin-bottom: 12px; line-height: 1.2; }
.hero p { font-size: 1.1rem; opacity: .88; margin-bottom: 28px; }
.hero-tags { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-tags span {
  background: rgba(255,255,255,.2);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 500;
}

/* --- 文章卡片 --- */
.article-list { display: flex; flex-direction: column; gap: 24px; }

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}
.article-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.article-card.has-cover { flex-direction: row; }
.article-card.has-cover .article-cover {
  width: 240px;
  flex-shrink: 0;
  overflow: hidden;
}
.article-card.has-cover .article-cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform var(--transition);
}
.article-card.has-cover:hover .article-cover img { transform: scale(1.05); }

.article-body { padding: 24px; flex: 1; min-width: 0; }

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.article-meta .category-badge {
  background: rgba(37,99,235,.1);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
  font-size: .78rem;
}
.article-meta .meta-item { display: flex; align-items: center; gap: 4px; }

.article-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-title a { color: var(--text-primary); }
.article-title a:hover { color: var(--primary); }

.article-summary {
  font-size: .9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.article-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-badge {
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.tag-badge:hover { background: rgba(37,99,235,.08); color: var(--primary); border-color: var(--primary-light); }

.read-more {
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.read-more:hover { gap: 8px; }

/* 置顶标记 */
.article-card.is-top .article-title::before {
  content: '置顶';
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  font-size: .65rem;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 8px;
  font-weight: 700;
}

/* --- 文章详情页 --- */
.article-detail-header { margin-bottom: 32px; }
.article-detail-header h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 16px;
}
.article-cover-full {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
  max-height: 400px;
}
.article-cover-full img { width: 100%; height: 400px; object-fit: cover; }

/* --- Markdown 正文 --- */
.markdown-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
}
.markdown-body h1,.markdown-body h2,.markdown-body h3,
.markdown-body h4,.markdown-body h5,.markdown-body h6 {
  font-weight: 700;
  line-height: 1.3;
  margin: 1.8em 0 .8em;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.markdown-body h1 { font-size: 1.8em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 2px solid var(--border); padding-bottom: .4em; }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body p { margin: 0 0 1.2em; }
.markdown-body ul,.markdown-body ol { padding-left: 1.8em; margin: 0 0 1.2em; }
.markdown-body li { margin: .4em 0; }
.markdown-body blockquote {
  margin: 1.5em 0;
  padding: 12px 20px;
  border-left: 4px solid var(--primary);
  background: rgba(37,99,235,.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}
.markdown-body code {
  font-family: var(--font-mono);
  font-size: .875em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}
.markdown-body pre {
  background: #1e293b;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 1.5em 0;
  overflow-x: auto;
  position: relative;
}
.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: .875rem;
  line-height: 1.6;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: .9rem;
  overflow-x: auto;
  display: block;
}
.markdown-body th { background: var(--bg-alt); font-weight: 600; }
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.markdown-body tr:hover td { background: rgba(37,99,235,.03); }
.markdown-body img { border-radius: var(--radius-sm); margin: 1em auto; box-shadow: var(--shadow-sm); }
.markdown-body a { border-bottom: 1px dotted var(--primary); }
.markdown-body a:hover { border-bottom-style: solid; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

/* 文章目录 */
.toc-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
}
.toc-box .toc-title { font-weight: 700; margin-bottom: 12px; font-size: .9rem; color: var(--text-muted); letter-spacing: .05em; }
.toc-list { list-style: none; padding: 0; }
.toc-list li { margin: 4px 0; }
.toc-list li a { font-size: .88rem; color: var(--text-secondary); }
.toc-list li a:hover { color: var(--primary); }
.toc-list .toc-h3 { padding-left: 16px; }
.toc-list .toc-h4 { padding-left: 32px; }

/* --- 侧栏 --- */
.sidebar { display: flex; flex-direction: column; gap: 24px; }
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.widget-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* 标签云 */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud a {
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.tag-cloud a:hover {
  background: rgba(37,99,235,.1);
  color: var(--primary);
  border-color: var(--primary-light);
}
.tag-cloud .tag-count { color: var(--text-muted); font-size: .72rem; margin-left: 2px; }

/* 最新文章 */
.recent-list { list-style: none; }
.recent-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.recent-list li:last-child { border-bottom: none; padding-bottom: 0; }
.recent-list a { font-size: .88rem; color: var(--text-primary); line-height: 1.4; display: block; margin-bottom: 4px; }
.recent-list a:hover { color: var(--primary); }
.recent-list .recent-date { font-size: .75rem; color: var(--text-muted); }

/* 分类列表 */
.category-list { list-style: none; }
.category-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: .88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.category-list li:last-child a { border-bottom: none; }
.category-list li a:hover { color: var(--primary); }
.category-list .cat-count {
  background: var(--bg-alt);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: .75rem;
  color: var(--text-muted);
}

/* --- 分页 --- */
.pagination { margin: 40px 0; }
.pagination-list {
  display: flex;
  list-style: none;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  transition: all var(--transition);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); background: rgba(37,99,235,.06); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-ellipsis { display: inline-flex; align-items: center; padding: 0 8px; color: var(--text-muted); }

/* --- 标签页/分类页 Banner --- */
.page-banner {
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 40px 0;
  margin-bottom: 0;
}
.page-banner h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 6px; }
.page-banner p { color: var(--text-secondary); font-size: .9rem; }
.page-banner .tag-count-label {
  display: inline-flex;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 2px 12px;
  border-radius: 20px;
  font-size: .8rem;
  margin-top: 8px;
}

/* --- 关于页 --- */
.about-layout { max-width: 800px; margin: 0 auto; padding: 60px 24px; }
.about-header { text-align: center; margin-bottom: 48px; }
.about-avatar {
  width: 100px; height: 100px;
  border-radius: 50%;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 2.4rem;
  font-weight: 800;
}
.about-header h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; }
.about-header p { color: var(--text-secondary); }
.skill-tags { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.skill-tag {
  padding: 6px 16px;
  background: rgba(37,99,235,.1);
  color: var(--primary);
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 500;
}

/* --- Footer --- */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 40px 0 24px;
  margin-top: 60px;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}
.footer-brand p { color: var(--text-secondary); font-size: .88rem; margin-top: 10px; line-height: 1.6; }
.footer-col h4 { font-size: .85rem; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.footer-col ul { list-style: none; }
.footer-col ul li { margin: 6px 0; }
.footer-col ul li a { font-size: .85rem; color: var(--text-secondary); }
.footer-col ul li a:hover { color: var(--primary); }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .8rem;
  color: var(--text-muted);
}
.footer-bottom a { color: var(--text-muted); }
.footer-bottom a:hover { color: var(--primary); }

/* --- 返回顶部 --- */
#back-to-top {
  position: fixed;
  right: 24px;
  bottom: 80px;
  width: 44px; height: 44px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition);
  z-index: 99;
}
#back-to-top.visible { opacity: 1; transform: translateY(0); }
#back-to-top:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* --- 加载进度条 --- */
#nprogress .bar { background: var(--primary); height: 3px; }
#nprogress .peg { box-shadow: 0 0 10px var(--primary), 0 0 5px var(--primary); }

/* --- 搜索结果高亮 --- */
.search-highlight { background: rgba(245,158,11,.25); border-radius: 2px; padding: 0 2px; }

/* --- 响应式 --- */
@media (max-width: 1024px) {
  .page-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; } /* 移动端侧栏折叠 */
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  :root { --header-h: 56px; }
  .hero h1 { font-size: 1.6rem; }
  .article-detail-header h1 { font-size: 1.5rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .site-nav { display: none; flex-direction: column; position: absolute; top: var(--header-h); left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 16px 24px; gap: 4px; }
  .site-nav.open { display: flex; }
  .nav-toggle { display: flex; }
  .header-search { display: none; }
  .article-card.has-cover { flex-direction: column; }
  .article-card.has-cover .article-cover { width: 100%; height: 200px; }
}
@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .article-body { padding: 16px; }
  .page-layout { padding: 24px 0 40px; }
}

/* --- 工具类 --- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: rgba(37,99,235,.07); }

/* --- 空状态 --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 1rem; }

/* --- 搜索关键词高亮 --- */
mark.search-highlight {
  background: rgba(37, 99, 235, .15);
  color: var(--primary-dark);
  border-radius: 2px;
  padding: 0 2px;
  font-style: normal;
}
@media (prefers-color-scheme: dark) {
  mark.search-highlight {
    background: rgba(96, 165, 250, .25);
    color: #93c5fd;
  }
}
