/* ==========================================
   卍法CMS - Blog Theme Stylesheet
   中文博客极简主题，纯内容优先，无图片依赖
   ========================================== */

/* ---------- CSS Variables ---------- */
:root {
  --blog-primary: #2563eb;
  --blog-primary-hover: #1d4ed8;
  --blog-primary-light: #eff6ff;
  --blog-text: #1f2937;
  --blog-text-muted: #6b7280;
  --blog-bg: #ffffff;
  --blog-bg-soft: #f9fafb;
  --blog-border: #e5e7eb;
  --blog-card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --blog-card-shadow-hover: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --blog-radius: 12px;
  --blog-radius-sm: 8px;
  --blog-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --blog-font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", "Courier New", monospace;
  --blog-max-content: 760px;
  --blog-transition: 0.2s ease;
}

/* ---------- Dark Mode ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --blog-primary: #60a5fa;
    --blog-primary-hover: #93bbfd;
    --blog-primary-light: #1e3a5f;
    --blog-text: #e5e7eb;
    --blog-text-muted: #9ca3af;
    --blog-bg: #111827;
    --blog-bg-soft: #1f2937;
    --blog-border: #374151;
    --blog-card-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --blog-card-shadow-hover: 0 10px 25px rgba(0,0,0,0.4);
  }
}

/* ---------- Base ---------- */
body {
  font-family: var(--blog-font-sans);
  color: var(--blog-text);
  background: var(--blog-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--blog-primary);
  transition: color var(--blog-transition);
}
a:hover {
  color: var(--blog-primary-hover);
}

/* ---------- Header / Navigation ---------- */
.blog-header {
  background: var(--blog-bg);
  border-bottom: 1px solid var(--blog-border);
  z-index: 1030;
}
.blog-header .navbar {
  padding: 0.75rem 0;
}
.blog-brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--blog-text);
  margin: 0;
  letter-spacing: -0.01em;
}
.blog-header .nav-link {
  color: var(--blog-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 1rem !important;
  border-radius: var(--blog-radius-sm);
  transition: all var(--blog-transition);
}
.blog-header .nav-link:hover,
.blog-header .nav-link.active {
  color: var(--blog-primary);
  background: var(--blog-primary-light);
}

/* ---------- Main Layout ---------- */
.blog-main {
  min-height: 60vh;
}

/* ---------- Hero Section ---------- */
.blog-hero {
  background: linear-gradient(135deg, var(--blog-primary-light) 0%, var(--blog-bg-soft) 100%);
  padding: 4rem 0 3rem;
  text-align: center;
}
.blog-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  color: var(--blog-text);
  line-height: 1.4;
}
.blog-hero .hero-description {
  font-size: 1.05rem;
  color: var(--blog-text-muted);
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.8;
}

/* ========== Masonry Grid (瀑布流) ========== */
.masonry-grid {
  column-count: 2;
  column-gap: 1.5rem;
}
.masonry-item {
  break-inside: avoid;
  margin-bottom: 1.5rem;
}
.masonry-card {
  background: var(--blog-bg);
  border: 1px solid var(--blog-border);
  border-radius: var(--blog-radius);
  padding: 1.5rem;
  transition: all 0.3s ease;
}
.masonry-card:hover {
  box-shadow: var(--blog-card-shadow-hover);
  border-color: var(--blog-primary);
  transform: translateY(-2px);
}
.masonry-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 0.75rem;
}
.masonry-title a {
  color: var(--blog-text);
  text-decoration: none;
}
.masonry-title a:hover {
  color: var(--blog-primary);
}
.masonry-summary {
  font-size: 0.88rem;
  color: var(--blog-text-muted);
  line-height: 1.7;
  margin: 0;
}

/* ========== News List Simple (列表页) ========== */
.news-list-simple {
  list-style: none;
}
.news-list-item {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--blog-border);
}
.news-list-item:first-child {
  padding-top: 0;
}
.news-list-item:last-child {
  border-bottom: none;
}
.news-list-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}
.news-list-title a {
  color: var(--blog-text);
  text-decoration: none;
}
.news-list-title a:hover {
  color: var(--blog-primary);
}
.news-list-summary {
  font-size: 0.9rem;
  color: var(--blog-text-muted);
  line-height: 1.7;
  margin: 0;
}

/* ========== Sidebar ========== */
.blog-sidebar {
  position: sticky;
  top: 80px;
}
.blog-sidebar-widget {
  background: var(--blog-bg);
  border: 1px solid var(--blog-border);
  border-radius: var(--blog-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.blog-sidebar-widget h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--blog-primary);
}

/* Category list with count */
.category-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.category-list li {
  margin-bottom: 0.25rem;
}
.category-list li a {
  color: var(--blog-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border-radius: var(--blog-radius-sm);
  transition: all var(--blog-transition);
}
.category-list li a:hover,
.category-list li a.current {
  color: var(--blog-primary);
  background: var(--blog-primary-light);
}
.category-list li a .cat-name {
  flex: 1;
}
.category-list li a .cat-count {
  font-size: 0.75rem;
  background: var(--blog-bg-soft);
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  color: var(--blog-text-muted);
}

/* Popular posts in sidebar */
.sidebar-popular-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--blog-border);
}
.sidebar-popular-item:last-child {
  border-bottom: none;
}
.sidebar-popular-rank {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 50%;
  background: var(--blog-primary-light);
  color: var(--blog-primary);
  flex-shrink: 0;
}
.sidebar-popular-info h5 {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  line-height: 1.4;
}
.sidebar-popular-info h5 a {
  color: var(--blog-text);
  text-decoration: none;
}
.sidebar-popular-info h5 a:hover {
  color: var(--blog-primary);
}
.sidebar-popular-info .meta {
  font-size: 0.75rem;
  color: var(--blog-text-muted);
}

/* ========== Article Detail ========== */
.article-header {
  text-align: center;
  padding: 3rem 0 2rem;
  max-width: var(--blog-max-content);
  margin: 0 auto;
}
.article-header h1 {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}
.article-header .post-meta {
  justify-content: center;
}
.article-cover {
  max-width: 900px;
  margin: 0 auto 2rem;
  border-radius: var(--blog-radius);
  overflow: hidden;
}
.article-cover img {
  width: 100%;
  height: auto;
  display: block;
}

/* ---------- Post Meta ---------- */
.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--blog-text-muted);
}
.post-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.post-meta-item i {
  font-size: 0.75rem;
}

/* ---------- Article Content ---------- */
.article-content {
  max-width: var(--blog-max-content);
  margin: 0 auto;
  font-size: 1.0625rem;
  line-height: 1.8;
  color: var(--blog-text);
}
.article-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-top: 1rem;
}
.article-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}
.article-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}
.article-content p {
  margin-bottom: 1.5rem;
}
.article-content img {
  border-radius: var(--blog-radius-sm);
  margin: 1.5rem 0;
}
.article-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article-content ul, .article-content ol {
  margin-bottom: 1.5rem;
  padding-left: 1.5rem;
}
.article-content li {
  margin-bottom: 0.5rem;
}
.article-content blockquote {
  border-left: 4px solid var(--blog-primary);
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  background: var(--blog-bg-soft);
  border-radius: 0 var(--blog-radius-sm) var(--blog-radius-sm) 0;
  color: var(--blog-text-muted);
  font-style: italic;
}
.article-content blockquote p:last-child {
  margin-bottom: 0;
}
.article-content code {
  font-family: var(--blog-font-mono);
  font-size: 0.875em;
  background: var(--blog-bg-soft);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--blog-primary);
}
.article-content pre {
  background: var(--blog-bg-soft);
  border: 1px solid var(--blog-border);
  border-radius: var(--blog-radius-sm);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}
.article-content pre code {
  background: none;
  padding: 0;
  color: var(--blog-text);
  font-size: 0.85rem;
  line-height: 1.6;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}
.article-content th, .article-content td {
  border: 1px solid var(--blog-border);
  padding: 0.75rem 1rem;
  text-align: left;
}
.article-content th {
  background: var(--blog-bg-soft);
  font-weight: 600;
}

/* ---------- TOC (Table of Contents) ---------- */
.article-toc {
  background: var(--blog-bg-soft);
  border: 1px solid var(--blog-border);
  border-radius: var(--blog-radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
  max-width: var(--blog-max-content);
  margin-left: auto;
  margin-right: auto;
}
.article-toc h4 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  color: var(--blog-text-muted);
}
.article-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.article-toc ul li {
  margin-bottom: 0.4rem;
}
.article-toc ul li a {
  color: var(--blog-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
  padding: 0.2rem 0;
  transition: all var(--blog-transition);
}
.article-toc ul li a:hover {
  color: var(--blog-primary);
}
.article-toc ul ul {
  padding-left: 1.25rem;
  margin-top: 0.25rem;
}
.article-toc ul ul li a {
  font-size: 0.85rem;
}

/* ---------- Social Share ---------- */
.article-share {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: var(--blog-max-content);
  margin: 2rem auto;
  padding: 1.5rem 0;
  border-top: 1px solid var(--blog-border);
  border-bottom: 1px solid var(--blog-border);
}
.article-share span {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--blog-text-muted);
}
.share-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all var(--blog-transition);
  border: 1px solid var(--blog-border);
  color: var(--blog-text-muted);
  background: var(--blog-bg);
}
.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--blog-card-shadow);
}
.share-btn.share-facebook:hover { background: #1877f2; color: #fff; border-color: #1877f2; }
.share-btn.share-twitter:hover { background: #1da1f2; color: #fff; border-color: #1da1f2; }
.share-btn.share-linkedin:hover { background: #0a66c2; color: #fff; border-color: #0a66c2; }
.share-btn.share-whatsapp:hover { background: #25d366; color: #fff; border-color: #25d366; }

/* ---------- Prev / Next Navigation ---------- */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  max-width: var(--blog-max-content);
  margin: 2rem auto;
}
.post-nav-item {
  display: block;
  padding: 1.25rem;
  border: 1px solid var(--blog-border);
  border-radius: var(--blog-radius);
  text-decoration: none;
  transition: all 0.3s ease;
}
.post-nav-item:hover {
  border-color: var(--blog-primary);
  box-shadow: var(--blog-card-shadow);
}
.post-nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blog-text-muted);
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.post-nav-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--blog-text);
  line-height: 1.4;
}

/* ---------- Related Posts ---------- */
.related-posts {
  max-width: 900px;
  margin: 3rem auto;
  padding: 2rem 0;
  border-top: 1px solid var(--blog-border);
}
.related-posts h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
}
.related-posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.related-post-item {
  text-decoration: none;
  color: inherit;
  border-radius: var(--blog-radius);
  overflow: hidden;
  border: 1px solid var(--blog-border);
  transition: all 0.3s ease;
}
.related-post-item:hover {
  box-shadow: var(--blog-card-shadow-hover);
  transform: translateY(-2px);
  color: inherit;
}
.related-post-info {
  padding: 1rem;
}
.related-post-info h4 {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.4rem;
}
.related-post-info .meta {
  font-size: 0.75rem;
  color: var(--blog-text-muted);
}

/* ---------- Breadcrumb ---------- */
.blog-breadcrumb {
  padding: 1rem 0;
  font-size: 0.85rem;
}
.blog-breadcrumb .breadcrumb {
  margin: 0;
  background: transparent;
}
.blog-breadcrumb .breadcrumb-item a {
  color: var(--blog-text-muted);
  text-decoration: none;
}
.blog-breadcrumb .breadcrumb-item a:hover {
  color: var(--blog-primary);
}
.blog-breadcrumb .breadcrumb-item.active {
  color: var(--blog-text);
}

/* ---------- Pagination ---------- */
.blog-pagination {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}
.blog-pagination .pagination .page-link {
  border: 1px solid var(--blog-border);
  color: var(--blog-text);
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  border-radius: var(--blog-radius-sm) !important;
  margin: 0 0.2rem;
  transition: all var(--blog-transition);
}
.blog-pagination .pagination .page-link:hover {
  background: var(--blog-primary-light);
  border-color: var(--blog-primary);
  color: var(--blog-primary);
}
.blog-pagination .pagination .page-item.active .page-link {
  background: var(--blog-primary);
  border-color: var(--blog-primary);
  color: #fff;
}
.blog-pagination .pagination .page-item.disabled .page-link {
  color: var(--blog-text-muted);
  background: transparent;
}

/* ---------- Category Filter ---------- */
.category-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.category-filter .filter-btn {
  display: inline-block;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  border-radius: 20px;
  border: 1px solid var(--blog-border);
  color: var(--blog-text-muted);
  text-decoration: none;
  transition: all var(--blog-transition);
  font-weight: 500;
}
.category-filter .filter-btn:hover,
.category-filter .filter-btn.active {
  background: var(--blog-primary);
  color: #fff;
  border-color: var(--blog-primary);
}

/* ---------- Page Title ---------- */
.page-title-section {
  padding: 3rem 0 2rem;
}
.page-title-section h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.page-title-section p {
  color: var(--blog-text-muted);
  font-size: 1.05rem;
  margin-top: 0.5rem;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--blog-text-muted);
}
.empty-state p {
  font-size: 1rem;
}

/* ---------- About Page ---------- */
.about-hero {
  text-align: center;
  padding: 4rem 0 3rem;
  background: linear-gradient(135deg, var(--blog-primary-light) 0%, var(--blog-bg-soft) 100%);
}
.about-content {
  max-width: var(--blog-max-content);
  margin: 0 auto;
  padding: 3rem 0;
  font-size: 1.0625rem;
  line-height: 1.8;
}

/* ---------- Footer ---------- */
.blog-footer {
  background: var(--blog-bg-soft);
  border-top: 1px solid var(--blog-border);
  padding: 3rem 0 1.5rem;
  margin-top: 4rem;
}
.blog-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.blog-footer-brand span {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--blog-text);
}
.blog-footer-nav {
  display: flex;
  gap: 1.5rem;
}
.blog-footer-nav a {
  color: var(--blog-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color var(--blog-transition);
}
.blog-footer-nav a:hover {
  color: var(--blog-primary);
}
.blog-footer-social {
  display: flex;
  gap: 0.75rem;
}
.blog-footer-social a {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--blog-text-muted);
  border: 1px solid var(--blog-border);
  transition: all var(--blog-transition);
  font-size: 0.85rem;
}
.blog-footer-social a:hover {
  color: var(--blog-primary);
  border-color: var(--blog-primary);
  background: var(--blog-primary-light);
}
.blog-footer-copy {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--blog-border);
}
.blog-footer-copy p {
  font-size: 0.8rem;
  color: var(--blog-text-muted);
  margin: 0;
}

/* ---------- Back to Top ---------- */
.blog-back-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--blog-primary);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 999;
  text-decoration: none;
}
.blog-back-top.visible {
  opacity: 1;
  visibility: visible;
}
.blog-back-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
  color: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
  .blog-hero h1 {
    font-size: 1.8rem;
  }
  .masonry-grid {
    column-count: 2;
  }
  .related-posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .blog-sidebar {
    position: static;
    margin-top: 2rem;
  }
}

@media (max-width: 767px) {
  .blog-hero {
    padding: 3rem 0 2rem;
  }
  .blog-hero h1 {
    font-size: 1.5rem;
  }
  .masonry-grid {
    column-count: 1;
  }
  .article-header h1 {
    font-size: 1.6rem;
  }
  .article-content {
    font-size: 1rem;
  }
  .post-nav {
    grid-template-columns: 1fr;
  }
  .related-posts-grid {
    grid-template-columns: 1fr;
  }
  .article-share {
    flex-wrap: wrap;
  }
  .blog-footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 576px) {
  .blog-hero h1 {
    font-size: 1.3rem;
  }
  .page-title-section h1 {
    font-size: 1.5rem;
  }
}

/* ---------- Print Styles ---------- */
@media print {
  .blog-header,
  .blog-footer,
  .blog-back-top,
  .blog-sidebar,
  .article-share,
  .article-toc,
  .post-nav,
  .related-posts,
  .blog-pagination,
  .category-filter {
    display: none !important;
  }
  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
  .article-content {
    max-width: 100%;
    font-size: 11pt;
    line-height: 1.6;
  }
  .article-content a {
    color: #000;
    text-decoration: underline;
  }
  .article-content a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  .article-header h1 {
    font-size: 18pt;
  }
}
