/* ============================================
   CSS Variables & Theme
   ============================================ */
:root {
  --bg-primary: #f0f2f5;
  --bg-card: #ffffff;
  --bg-navbar: rgba(255, 255, 255, 0.85);
  --text-primary: #2c3e50;
  --text-secondary: #7f8c8d;
  --text-muted: #bdc3c7;
  --accent: #888;
  --accent-hover: #666;
  --accent-light: rgba(0, 0, 0, 0.04);
  --border: #e8ecf1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s ease;
}

[data-theme="dark"] {
  --bg-primary: #1a1b2e;
  --bg-card: #242540;
  --bg-navbar: rgba(36, 37, 64, 0.9);
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6c6c80;
  --accent: #aaa;
  --accent-hover: #ccc;
  --accent-light: rgba(255, 255, 255, 0.06);
  --border: #35365a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"] .cat-count,
[data-theme="dark"] .archive-count {
  background: rgba(255,255,255,0.08);
  color: #888;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: var(--transition);
}

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

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

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

ul {
  list-style: none;
}

/* ============================================
   Navbar
   ============================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-navbar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  height: 60px;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.nav-logo i {
  font-size: 1.4rem;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-links a {
  padding: 6px 16px;
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
}

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

.nav-actions {
  display: flex;
  gap: 4px;
}

.nav-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: var(--transition);
}

.nav-icon:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* ============================================
   Search Overlay
   ============================================ */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.search-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-20px);
  transition: var(--transition);
}

.search-overlay.active .search-modal {
  transform: translateY(0);
}

.search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.search-header i {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.search-header input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 1rem;
  color: var(--text-primary);
}

.search-header input::placeholder {
  color: var(--text-muted);
}

.search-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 4px;
}

.search-close:hover {
  color: var(--text-primary);
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.search-result-item:hover {
  background: var(--accent-light);
}

.search-result-item h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.search-result-item p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================================
   Main Layout
   ============================================ */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 24px 40px;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 24px;
  align-items: start;
}

/* ============================================
   Cards (Common)
   ============================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ============================================
   Profile Card
   ============================================ */
.profile-card {
  text-align: center;
}

.profile-avatar {
  width: 90px;
  height: 90px;
  margin: 0 auto 12px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent-light);
  transition: var(--transition);
}

.profile-avatar:hover {
  transform: rotate(360deg);
  border-color: var(--accent);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.profile-bio {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ============================================
   Category Card
   ============================================ */
.category-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition);
}

.category-list li a:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.cat-name {
  font-size: 0.88rem;
}

.cat-count {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
}

/* ============================================
   Tags Card
   ============================================ */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 4px 0;
  transition: var(--transition);
}

.tag:hover {
  color: var(--accent);
}

/* ============================================
   Post List (Center)
   ============================================ */
.post-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
  transition: var(--transition);
}

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

.post-cover {
  width: 100%;
  height: 220px;
  overflow: hidden;
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.post-card:hover .post-cover img {
  transform: scale(1.05);
}

.post-body {
  padding: 24px;
}

.post-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-title a {
  color: var(--text-primary);
}

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

.post-excerpt {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-meta-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.post-meta-left span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-read-more {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
}

.post-read-more:hover {
  text-decoration: underline;
}

/* ============================================
   Right Sidebar - Recent & Archive
   ============================================ */
.recent-list li {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.recent-list li:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.recent-date {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.recent-title {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recent-title:hover {
  color: var(--accent);
}

.archive-list li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  transition: var(--transition);
}

.archive-list li a:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.archive-count {
  background: #f0f1f3;
  color: #999;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
}

/* ============================================
   Sidebar Sticky
   ============================================ */
.sidebar-left,
.sidebar-right {
  position: sticky;
  top: 80px;
}

/* ============================================
   Back to Top
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: var(--transition);
  z-index: 900;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--accent-hover);
  transform: translateY(-3px);
}

/* ============================================
   Footer
   ============================================ */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* ============================================
   Article Detail Page
   ============================================ */
.article-container {
  max-width: 800px;
  margin: 80px auto 40px;
  padding: 0 24px;
}

.article-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.article-hero {
  width: 100%;
  height: 320px;
  overflow: hidden;
}

.article-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-content {
  padding: 40px;
}

.article-content .post-meta {
  margin-bottom: 20px;
}

.article-content h1 {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 24px;
}

.article-text {
  font-size: 0.95rem;
  line-height: 1.9;
  color: var(--text-secondary);
}

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

.article-text h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 32px 0 16px;
}

.article-text h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 0 12px;
}

.article-text code {
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88rem;
}

.article-text pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 16px 0;
  font-size: 0.85rem;
  line-height: 1.7;
}

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

.article-text blockquote {
  border-left: 4px solid var(--accent);
  padding: 12px 20px;
  margin: 16px 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}

.article-text img {
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

.article-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.article-tag {
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: 20px;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
}

.article-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding: 12px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  max-width: 48%;
}

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

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-card {
  animation: fadeInUp 0.5s ease forwards;
}

.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.15s; }
.post-card:nth-child(4) { animation-delay: 0.2s; }
.post-card:nth-child(5) { animation-delay: 0.25s; }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1080px) {
  .main-container {
    grid-template-columns: 240px 1fr;
  }
  .sidebar-right {
    display: none;
  }
}

@media (max-width: 768px) {
  .main-container {
    grid-template-columns: 1fr;
    padding: 70px 16px 24px;
    gap: 16px;
  }

  .sidebar-left {
    position: relative;
    top: 0;
  }

  .sidebar-right {
    display: block;
    position: relative;
    top: 0;
  }

  .nav-links {
    display: none;
  }

  .post-cover {
    height: 180px;
  }

  .article-content {
    padding: 24px;
  }

  .article-content h1 {
    font-size: 1.4rem;
  }

  .article-hero {
    height: 200px;
  }
}

/* ============================================
   Loading Animation
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-primary) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}


/* ============================================
   Intro Overlay (first visit)
   ============================================ */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  touch-action: none;
}

[data-theme="dark"] .intro-overlay {
  background: rgba(0, 0, 0, 0.52);
}

.intro-overlay.active {
  display: flex;
}

.intro-overlay.closing {
  animation: introSlideUp 520ms ease forwards;
}

@keyframes introSlideUp {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-120%); opacity: 0; }
}

.intro-card {
  width: min(360px, calc(100vw - 48px));
  text-align: center;
  padding: 28px 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 20px 50px rgba(0,0,0,0.12);
}

[data-theme="dark"] .intro-card {
  background: rgba(36, 37, 64, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}

.intro-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

.intro-signature {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.intro-hint {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
