/* ============================================================
   全局变量与基础样式
   ============================================================ */
:root {
  --grad-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --grad-js: linear-gradient(135deg, #f7df1e 0%, #f0a500 100%);
  --grad-vue: linear-gradient(135deg, #41b883 0%, #2e7d5b 100%);
  --grad-java: linear-gradient(135deg, #f0932b 0%, #e0560c 100%);
  --grad-hero: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f0932b 100%);

  --text-main: #1f2430;
  --text-sub: #6b7280;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 8px 24px rgba(31, 36, 48, 0.08);
  --shadow-hover: 0 16px 40px rgba(31, 36, 48, 0.16);

  --radius: 14px;
  --max-width: 1080px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background: var(--bg);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   导航栏
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--grad-primary);
  color: #fff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.85rem;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.nav-link {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 0.95rem;
  color: var(--text-sub);
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(102, 126, 234, 0.1);
}

.nav-link.active {
  color: #fff;
  background: var(--grad-primary);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: all 0.3s ease;
}

/* ============================================================
   主体容器
   ============================================================ */
.site-main {
  flex: 1;
  width: 100%;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   首页 Hero
   ============================================================ */
.hero {
  background: var(--grad-hero);
  color: #fff;
  padding: 72px 0;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.hero::before {
  content: "";
  position: absolute;
  left: -60px;
  bottom: -100px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.hero p {
  margin-top: 12px;
  font-size: 1.05rem;
  opacity: 0.92;
  max-width: 640px;
}

.hero-tags {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-tag {
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hero-tag:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* ============================================================
   分类筛选栏
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 32px 0 8px;
}

.filter-btn {
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-sub);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.filter-btn.active {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
}

/* ============================================================
   文章卡片列表
   ============================================================ */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding: 16px 0 48px;
}

.post-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.post-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}

.post-card-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-category {
  align-self: flex-start;
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.cat-js { background: var(--grad-js); }
.cat-vue { background: var(--grad-vue); }
.cat-java { background: var(--grad-java); }

.post-card h2 {
  margin: 14px 0 10px;
  font-size: 1.25rem;
  line-height: 1.4;
}

.post-card h2 a {
  transition: color 0.2s ease;
}

.post-card h2 a:hover {
  color: #667eea;
}

.post-summary {
  color: var(--text-sub);
  font-size: 0.92rem;
  flex: 1;
}

.post-meta {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-sub);
}

.post-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.post-tag {
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-sub);
}

/* ============================================================
   详情页
   ============================================================ */
.detail {
  padding: 48px 0 64px;
}

.detail-header {
  margin-bottom: 32px;
}

.detail-header .post-category {
  margin-bottom: 16px;
}

.detail-header h1 {
  font-size: 2rem;
  line-height: 1.35;
}

.detail-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  color: var(--text-sub);
  font-size: 0.9rem;
}

.detail-meta .post-tags {
  margin-left: auto;
}

.article {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  font-size: 1rem;
}

.article h2 {
  margin: 32px 0 14px;
  font-size: 1.4rem;
}

.article h2:first-child {
  margin-top: 0;
}

.article p {
  margin-bottom: 16px;
}

.article ul,
.article ol {
  margin: 0 0 16px 24px;
}

.article code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  background: rgba(102, 126, 234, 0.1);
  color: #5b52c9;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.88em;
}

.article pre {
  background: #1f2430;
  color: #e6e6e6;
  padding: 20px;
  border-radius: 10px;
  overflow-x: auto;
  margin: 0 0 20px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.article pre code {
  background: none;
  color: inherit;
  padding: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
  color: #667eea;
  font-size: 0.95rem;
}

.back-link:hover {
  text-decoration: underline;
}

/* ============================================================
   页脚
   ============================================================ */
.site-footer {
  background: #1f2430;
  color: #b8bcc7;
  padding: 40px 24px 32px;
  margin-top: 40px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-slogan {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 18px;
  letter-spacing: 2px;
}

.footer-beian {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.85rem;
}

.footer-beian a {
  color: #b8bcc7;
}

.footer-beian a:hover {
  color: #fff;
  text-decoration: underline;
}

.beian-divider {
  color: #4b5563;
}

.beian-ga {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.beian-icon {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

.footer-copy {
  margin-top: 16px;
  font-size: 0.8rem;
  color: #6b7280;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: none;
  }

  .nav-menu.open {
    display: flex;
  }

  .nav-link {
    display: block;
    text-align: center;
  }

  .hero {
    padding: 48px 0;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .article {
    padding: 24px;
  }

  .detail-header h1 {
    font-size: 1.5rem;
  }
}
