/**
 * 文章详情页样式 - 侧边栏直接展示分类（最新3篇）
 */

:root {
  --primary: #1e88e5;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #424245;
  --bg-page: #fff;
  --bg-card: #f5f5f7;
  --bg-light: #fbfbfd;
  --border-color: #e8e8ed;
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

figure {
  margin: 0;
}

.site-main {
  padding: 60px 0 100px;
  max-width: 1200px;
  margin: 0 auto;
}

/* 主容器：左侧文章 + 右侧侧边栏 */
.single-post-article {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 40px;
  padding: 0 24px;
}

.post-main-content {
  flex: 1;
  min-width: 0;
}

/* ========== 侧边栏（直接展示版本） ========== */
.post-sidebar {
  width: 320px;
  flex-shrink: 0;
  align-self: flex-start;
}

.sidebar-sticky {
  position: sticky;
  top: 40px;
}

.sidebar-nav {
  background: var(--bg-light);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.sidebar-nav h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-list li {
  margin-bottom: 16px;
}

.nav-list a {
  font-weight: 500;
  font-size: 15px;
}

.nav-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 16px;
  display: block;
}

/* 单个分类块 */
.sidebar-cat-block {
  margin-bottom: 20px;
}

.sidebar-cat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  display: block;
  text-decoration: none;
}

.sidebar-cat-title:hover {
  color: var(--primary);
}

.sidebar-cat-posts {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-cat-posts li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.sidebar-cat-posts a {
  font-size: 13px;
  color: var(--text-tertiary);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 0;
  transition: var(--transition);
}

.sidebar-cat-posts a:hover {
  color: var(--primary);
}

/* ========== 文章主体样式 ========== */
.single-post-header {
  margin-bottom: 48px;
}

.single-post-featured-image {
  margin-bottom: 32px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.featured-img {
  width: 100%;
  height: auto;
  display: block;
}

.single-post-title {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 20px;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.single-post-meta {
  color: var(--text-secondary);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.single-post-content {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-tertiary);
}

.single-post-content p {
  margin-bottom: 24px;
}

.single-post-content h2 {
  font-size: 28px;
  font-weight: 600;
  margin: 48px 0 20px;
  color: var(--text-primary);
  line-height: 1.3;
}

.single-post-content h3 {
  font-size: 24px;
  font-weight: 600;
  margin: 36px 0 16px;
  color: var(--text-primary);
}

.single-post-content h4 {
  font-size: 20px;
  font-weight: 600;
  margin: 28px 0 12px;
}

.single-post-content ul,
.single-post-content ol {
  margin: 0 0 24px 24px;
  padding-left: 12px;
  line-height: 1.8;
}

.single-post-content li {
  margin-bottom: 8px;
  list-style-position: outside;
}

.single-post-content ul {
  list-style-type: disc;
}

.single-post-content ul ul {
  margin: 8px 0 0 20px;
}

.single-post-content ol {
  list-style-type: decimal;
}

.single-post-content ol ol {
  margin: 8px 0 0 20px;
}

.single-post-content blockquote {
  margin: 32px 0;
  padding: 20px 24px;
  background: var(--bg-card);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: normal;
}

.single-post-content code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: #e11d48;
}

.single-post-content pre {
  background: #1e1e1e;
  color: #fff;
  padding: 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 24px 0;
}

.single-post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.single-post-content th,
.single-post-content td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.single-post-content th {
  background: var(--bg-card);
  font-weight: 600;
}

.page-links {
  margin: 40px 0;
  padding: 16px 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-links span {
  padding: 6px 12px;
  background: var(--bg-page);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* 上下篇导航 */
.single-post-footer {
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border-color);
}

.nav-links {
  display: flex;
  justify-content: space-between;
  gap: 32px;
}

.nav-prev,
.nav-next {
  flex: 1;
  padding: 20px;
  background: var(--bg-light);
  border-radius: var(--radius);
  transition: var(--transition);
}

.nav-prev:hover,
.nav-next:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

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

.nav-links span:first-child {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
  display: block;
}

.nav-links .post-title {
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
}

/* 相关推荐 */
.related-posts {
  margin-top: 60px;
}

.related-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

.related-item {
  transition: var(--transition);
}

.related-item:hover {
  transform: translateY(-4px);
}

.related-item a {
  color: var(--text-primary);
  display: block;
}

.related-img {
  height: 140px;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.related-item h4 {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
}

/* ========== 响应式 ========== */
@media (max-width: 992px) {
  .single-post-article {
    flex-direction: column;
    gap: 48px;
  }

  .post-sidebar {
    width: 100%;
    position: static;
  }

  .nav-links {
    flex-direction: column;
    gap: 16px;
  }

  .nav-next {
    text-align: left;
  }
}

@media (max-width: 768px) {
  .site-main {
    padding: 40px 0 60px;
  }

  .single-post-title {
    font-size: 32px;
  }

  .single-post-content {
    font-size: 16px;
  }

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

@media (max-width: 480px) {
  .single-post-title {
    font-size: 28px;
  }

  .single-post-article {
    padding: 0 16px;
  }
}