/* ============================================
   MyBlog — CSS Variables & Reset
   ============================================ */
:root {
  --color-primary: #2d8a56;
  --color-primary-light: #3cb371;
  --color-primary-dark: #1e6b3e;
  --color-accent: #e8923a;
  --color-bg: #f9fafb;
  --color-surface: #ffffff;
  --color-surface-hover: #f3f4f6;
  --color-text: #1f2937;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-border: #e5e7eb;
  --color-code-bg: #f3f4f6;
  --color-blockquote: #f0fdf4;
  --color-blockquote-border: #2d8a56;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-card-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", "Source Code Pro", Consolas,
    "Courier New", monospace;
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, "Times New Roman", serif;
  --max-width: 1100px;
  --header-height: 64px;
}

/* Dark Mode */
[data-theme="dark"] {
  --color-primary: #3cb371;
  --color-primary-light: #4ade80;
  --color-primary-dark: #2d8a56;
  --color-bg: #111827;
  --color-surface: #1f2937;
  --color-surface-hover: #374151;
  --color-text: #f3f4f6;
  --color-text-secondary: #9ca3af;
  --color-text-muted: #6b7280;
  --color-border: #374151;
  --color-code-bg: #1f2937;
  --color-blockquote: #064e3b;
  --color-blockquote-border: #3cb371;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-primary-dark);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ============================================
   Header & Navigation
   ============================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: rgba(249, 250, 251, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .site-header {
  background-color: rgba(17, 24, 39, 0.85);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.02em;
}

.site-title .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--color-primary);
  background-color: rgba(45, 138, 86, 0.08);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-left: 8px;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-left: 8px;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
  margin-top: var(--header-height);
  padding: 80px 24px 60px;
  text-align: center;
  background: linear-gradient(135deg, rgba(45, 138, 86, 0.05) 0%, rgba(60, 179, 113, 0.08) 50%, rgba(232, 146, 58, 0.03) 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 50%, rgba(45, 138, 86, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 50%, rgba(232, 146, 58, 0.03) 0%, transparent 50%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
}

.hero-tagline {
  display: inline-block;
  padding: 6px 16px;
  background: rgba(45, 138, 86, 0.1);
  color: var(--color-primary);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.03em;
  color: var(--color-text);
  margin-bottom: 16px;
}

.hero h1 .highlight {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.15rem;
  color: var(--color-text-secondary);
  max-width: 520px;
  margin: 0 auto 32px;
  line-height: 1.8;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
}

.hero-stat {
  text-align: center;
}

.hero-stat .number {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.2;
}

.hero-stat .label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ============================================
   Main Content Layout
   ============================================ */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.section-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 32px;
}

/* ============================================
   Post Cards
   ============================================ */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 768px) {
  .posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}

.post-card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--color-primary-light);
  transform: translateY(-2px);
}

.post-card-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-card-date::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--color-accent);
  border-radius: 50%;
}

.post-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
  line-height: 1.4;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

.post-card:hover h3 {
  color: var(--color-primary);
}

.post-card p {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
  flex-grow: 1;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.post-card-tags .tag {
  padding: 3px 10px;
  background: rgba(45, 138, 86, 0.08);
  color: var(--color-primary);
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.2s ease;
}

.post-card:hover .tag {
  background: rgba(45, 138, 86, 0.15);
}

.post-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.post-card-footer .read-more {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap 0.2s ease;
}

.post-card:hover .read-more {
  gap: 8px;
}

.post-card-footer .read-time {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ============================================
   Featured Post Card (wider, first post)
   ============================================ */
.post-card.featured {
  grid-column: 1 / -1;
  padding: 36px;
}

.post-card.featured h3 {
  font-size: 1.6rem;
}

.post-card.featured p {
  -webkit-line-clamp: 4;
}

/* ============================================
   Sidebar Widgets (on homepage)
   ============================================ */
.sidebar-section {
  margin-top: 64px;
}

.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 48px;
}

.tags-cloud .tag-link {
  padding: 6px 16px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
}

.tags-cloud .tag-link:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(45, 138, 86, 0.05);
}

/* ============================================
   Blog Post Page
   ============================================ */
.post-page {
  max-width: 780px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 40px) 24px 80px;
}

.post-header {
  text-align: center;
  margin-bottom: 40px;
}

.post-header .post-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.post-meta .dot {
  width: 4px;
  height: 4px;
  background: var(--color-text-muted);
  border-radius: 50%;
}

.post-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 16px;
}

.post-header .post-tags {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-header .post-tags .tag {
  padding: 4px 12px;
  background: rgba(45, 138, 86, 0.1);
  color: var(--color-primary);
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 500;
}

.post-body {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--color-text);
}

.post-body h2 {
  font-size: 1.65rem;
  font-weight: 700;
  margin: 48px 0 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-border);
  letter-spacing: -0.02em;
}

.post-body h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 36px 0 14px;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.post-body h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 28px 0 10px;
  color: var(--color-text-secondary);
}

.post-body p {
  margin-bottom: 18px;
}

.post-body strong {
  color: var(--color-primary-dark);
  font-weight: 600;
}

.post-body ul,
.post-body ol {
  margin-bottom: 18px;
  padding-left: 24px;
}

.post-body li {
  margin-bottom: 8px;
}

.post-body a {
  border-bottom: 1px solid rgba(45, 138, 86, 0.3);
  padding-bottom: 1px;
}

.post-body a:hover {
  border-bottom-color: var(--color-primary);
}

/* Code blocks */
.post-body code {
  background: var(--color-code-bg);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: #e83e8c;
  white-space: nowrap;
}

[data-theme="dark"] .post-body code {
  color: #f472b6;
}

.post-body pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 20px 24px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.7;
  border: 1px solid var(--color-border);
}

.post-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre;
}

.post-body blockquote {
  padding: 16px 24px;
  background: var(--color-blockquote);
  border-left: 4px solid var(--color-blockquote-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 24px;
  color: var(--color-text-secondary);
}

.post-body blockquote p:last-child {
  margin-bottom: 0;
}

.post-body img {
  display: block;
  margin: 24px auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-width: 100%;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.post-body th {
  background: var(--color-primary);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
}

.post-body th:first-child {
  border-radius: var(--radius-sm) 0 0 0;
}

.post-body th:last-child {
  border-radius: 0 var(--radius-sm) 0 0;
}

.post-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

.post-body tr:nth-child(even) td {
  background: rgba(45, 138, 86, 0.03);
}

[data-theme="dark"] .post-body tr:nth-child(even) td {
  background: rgba(60, 179, 113, 0.05);
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 48px 0;
}

/* Table of Contents */
.toc {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  margin-bottom: 40px;
}

.toc-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc ul li {
  margin-bottom: 6px;
  padding-left: 0;
}

.toc ul li a {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  border-bottom: none;
  transition: color 0.2s ease;
}

.toc ul li a:hover {
  color: var(--color-primary);
}

.toc ul ul {
  padding-left: 18px;
  margin-top: 4px;
}

.toc ul ul li {
  margin-bottom: 4px;
}

.toc ul ul li a {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

/* Info / Warning boxes */
.info-box {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  font-size: 0.95rem;
  line-height: 1.7;
}

.info-box.tip {
  background: rgba(45, 138, 86, 0.08);
  border: 1px solid rgba(45, 138, 86, 0.2);
  color: var(--color-primary-dark);
}

.info-box.warning {
  background: rgba(232, 146, 58, 0.08);
  border: 1px solid rgba(232, 146, 58, 0.25);
  color: #c2781a;
}

/* Back to top */
.back-to-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
  transition: all 0.2s ease;
}

.back-to-home:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(45, 138, 86, 0.05);
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 32px 24px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.site-footer .footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.site-footer p {
  margin-bottom: 6px;
}

.site-footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 8px;
}

.site-footer .footer-links a {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.site-footer .footer-links a:hover {
  color: var(--color-primary);
}

/* Filing / ICP 备案信息 */
.filing-info {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 10px;
  font-size: 0.85rem;
}

.filing-info a {
  display: inline-flex;
  align-items: center;
  color: #749ae3;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.filing-info a:hover {
  opacity: 0.8;
}

.filing-info .police-icon {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  flex-shrink: 0;
}

.filing-info .filing-sep {
  margin: 0 20px;
  color: var(--color-text-muted);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 767px) {
  .hero h1 {
    font-size: 2rem;
  }

  .hero-stats {
    gap: 32px;
  }

  .post-header h1 {
    font-size: 1.6rem;
  }

  .post-body {
    font-size: 1rem;
  }

  .post-body h2 {
    font-size: 1.35rem;
  }

  .posts-grid {
    grid-template-columns: 1fr;
  }

  .site-nav {
    display: none;
  }

  .site-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 16px;
    gap: 8px;
    box-shadow: var(--shadow-lg);
  }

  .mobile-menu-btn {
    display: flex;
  }
}

/* ============================================
   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; }

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Print styles */
@media print {
  .site-header,
  .site-footer,
  .back-to-home,
  .toc {
    display: none;
  }
  .post-page {
    padding-top: 24px;
  }
}
