/* ===== CSS Variables & Theme ===== */
:root {
  --bg: #faf9f7;
  --bg-elevated: #ffffff;
  --bg-muted: #f3f1ed;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-subtle: #9ca3af;
  --border: #e5e2dc;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --tag-bg: #eef2ff;
  --tag-text: #4338ca;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Lora", "Noto Serif SC", Georgia, serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --max-width: 1120px;
  --content-width: 720px;
  --header-height: 64px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-elevated: #181b24;
  --bg-muted: #1e2230;
  --text: #e8eaed;
  --text-muted: #9ca3af;
  --text-subtle: #6b7280;
  --border: #2d3348;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.12);
  --tag-bg: rgba(99, 102, 241, 0.15);
  --tag-text: #a5b4fc;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  display: block;
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
  font-weight: 800;
}

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

.nav-links a {
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.menu-toggle {
  display: none;
}

/* ===== Hero ===== */
.hero {
  padding: 80px 0 64px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 16px;
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 32px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 40px;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* ===== Section ===== */
.section {
  padding: 48px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ===== Featured Post ===== */
.featured-post {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  color: inherit;
}

.featured-post:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.featured-image {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}

.featured-content {
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.featured-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 12px;
}

.featured-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.featured-content p {
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.7;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  flex-wrap: wrap;
}

/* ===== Post Grid ===== */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.post-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

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

.post-card-image {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

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

.post-card-body h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.post-card-body p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 16px;
}

.post-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

/* ===== Tags ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== Sidebar Layout (Article list page) ===== */
.layout-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 48px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 24px);
}

.sidebar-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.sidebar-card h3 {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 16px;
}

.sidebar-links {
  list-style: none;
}

.sidebar-links li {
  margin-bottom: 12px;
}

.sidebar-links a {
  color: var(--text-muted);
  font-size: 0.9375rem;
  text-decoration: none;
  transition: color var(--transition);
}

.sidebar-links a:hover {
  color: var(--accent);
}

.sidebar-links .date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* ===== Article Page ===== */
.article-header {
  padding: 64px 0 40px;
  max-width: var(--content-width);
  margin: 0 auto;
}

.article-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--text-muted);
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.author-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
  font-weight: 700;
}

.article-content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 40px 24px 80px;
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.85;
  color: var(--text);
}

.article-content h2 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 48px 0 16px;
  letter-spacing: -0.01em;
}

.article-content h3 {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 32px 0 12px;
}

.article-content p {
  margin-bottom: 1.5em;
}

.article-content ul,
.article-content ol {
  margin: 0 0 1.5em 1.5em;
}

.article-content li {
  margin-bottom: 0.5em;
}

.article-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 16px 24px;
  margin: 2em 0;
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--text-muted);
}

.article-content pre {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  overflow-x: auto;
  margin: 1.5em 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.article-content pre code {
  background: none;
  padding: 0;
}

.article-content img {
  border-radius: var(--radius);
  margin: 2em 0;
}

.article-nav {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  border-top: 1px solid var(--border);
}

.article-nav a {
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.article-nav a:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.article-nav .nav-label {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.article-nav .nav-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.article-nav .next {
  text-align: right;
}

/* ===== About Page ===== */
.about-hero {
  padding: 64px 0;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 48px;
  align-items: center;
}

.about-avatar {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: white;
  box-shadow: var(--shadow-lg);
}

.about-intro h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.about-intro .subtitle {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 16px;
}

.about-intro p {
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 24px;
}

.social-links {
  display: flex;
  gap: 12px;
}

.social-links a {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: all var(--transition);
}

.social-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 48px;
}

.skill-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.skill-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.skill-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 48px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-copy {
  font-size: 0.875rem;
  color: var(--text-subtle);
}

.footer-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.footer-links a {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-beian {
  margin-top: 16px;
  text-align: center;
}

.footer-beian a {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  text-decoration: none;
}

.footer-beian a:hover {
  color: var(--text-muted);
}

/* ===== Gradient backgrounds for cards ===== */
.gradient-1 { background: linear-gradient(135deg, #667eea, #764ba2); }
.gradient-2 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.gradient-3 { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.gradient-4 { background: linear-gradient(135deg, #43e97b, #38f9d7); }
.gradient-5 { background: linear-gradient(135deg, #fa709a, #fee140); }
.gradient-6 { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.gradient-7 { background: linear-gradient(135deg, #ff9a9e, #fecfef); }
.gradient-8 { background: linear-gradient(135deg, #ffecd2, #fcb69f); }

/* ===== Mobile Nav ===== */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  padding: 24px;
  flex-direction: column;
}

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

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.mobile-nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mobile-nav-links a {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

/* ===== Responsive ===== */
@media (max-width: 960px) {
  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .layout-with-sidebar {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .featured-post {
    grid-template-columns: 1fr;
  }

  .featured-image {
    min-height: 200px;
  }

  .skills-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }

  .post-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    gap: 24px;
  }

  .about-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .about-avatar {
    margin: 0 auto;
    width: 120px;
    height: 120px;
    font-size: 2.5rem;
  }

  .social-links {
    justify-content: center;
  }

  .skills-grid {
    grid-template-columns: 1fr;
  }

  .article-nav {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}
