/* 帽子 - 电子书风格样式表 */
/* CSS 变量定义 */
:root {
  --accent-color: #795548;
  --accent-light: #8d6e63;
  --accent-dark: #5d4037;
  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --bg-primary: #fff;
  --bg-secondary: #faf8f5;
  --bg-card: #fff;
  --border-color: #e8e4e0;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
  --header-height: 64px;
  --toc-width: 280px;
}

/* 重置样式 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

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

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

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

ul, ol {
  list-style: none;
}

/* 头部样式 */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
}

.logo a {
  color: inherit;
}

.nav {
  display: flex;
  gap: 32px;
}

.nav a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
}

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

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  width: 240px;
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  font-size: 0.9rem;
  color: var(--text-primary);
}

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

/* 主容器 */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px;
}

/* Hero 区域 */
.hero {
  text-align: center;
  padding: 60px 20px;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 48px;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent-dark);
  margin-bottom: 16px;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* 区块标题 */
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent-color);
  display: inline-block;
}

/* 卡片网格 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border-color);
}

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

.card-cover {
  aspect-ratio: 4/3;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--accent-light);
}

.card-body {
  padding: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 分类网格 */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

.category-item {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.category-item:hover {
  border-color: var(--accent-color);
  background: var(--bg-secondary);
}

.category-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.category-name {
  font-weight: 500;
  color: var(--text-primary);
}

/* 列表样式 */
.list-section {
  margin-bottom: 48px;
}

.list-item {
  background: var(--bg-card);
  padding: 20px 24px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

.list-item:hover {
  border-color: var(--accent-color);
  background: var(--bg-secondary);
}

.list-item-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
}

.list-item-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.list-item-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 三栏文章推荐 */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 48px;
}

.articles-col {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.articles-col-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.articles-list li {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-color);
}

.articles-list li:last-child {
  border-bottom: none;
}

.articles-list a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.articles-list a::before {
  content: "•";
  color: var(--accent-color);
  margin-right: 8px;
}

/* 面包屑 */
.breadcrumb {
  padding: 16px 24px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-secondary);
}

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

.breadcrumb span {
  margin: 0 8px;
  color: var(--text-muted);
}

.breadcrumb strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* 分类头部 */
.category-header {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.category-header h1 {
  font-size: 2rem;
  color: var(--accent-dark);
  margin-bottom: 8px;
}

.category-count {
  color: var(--text-muted);
}

/* 筛选栏 */
.filter-bar {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.filter-item {
  color: var(--text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.filter-item:hover,
.filter-item.active {
  color: var(--accent-color);
  background: var(--bg-secondary);
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 40px 0;
}

.pagination a,
.pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

.pagination .current {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
}

/* 文章详情页布局 */
.article-layout {
  display: grid;
  grid-template-columns: 1fr var(--toc-width);
  gap: 40px;
}

.article-main {
  background: var(--bg-card);
  padding: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.article-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 40px);
  height: fit-content;
}

/* 目录组件 */
.toc {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.toc-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent-color);
}

.toc-section {
  margin-bottom: 20px;
}

.toc-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.toc-list {
  font-size: 0.9rem;
}

.toc-list li {
  padding: 6px 0;
  padding-left: 12px;
  border-left: 2px solid transparent;
}

.toc-list li:hover,
.toc-list li.active {
  border-left-color: var(--accent-color);
}

.toc-list a {
  color: var(--text-secondary);
}

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

/* 文章内容 */
.article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.article-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-dark);
  margin-bottom: 16px;
  line-height: 1.4;
}

.article-meta {
  display: flex;
  gap: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.article-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.article-cover {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 4/3;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin: 0 auto 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  color: var(--accent-light);
}

.article-content {
  font-size: 1.05rem;
  line-height: 1.9;
  color: var(--text-primary);
}

.article-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent-dark);
  margin: 40px 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.article-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 28px 0 16px;
}

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

.article-content ul,
.article-content ol {
  margin-bottom: 20px;
  padding-left: 24px;
}

.article-content ul li {
  list-style: disc;
  margin-bottom: 8px;
}

.article-content ol li {
  list-style: decimal;
  margin-bottom: 8px;
}

/* 文章信息 */
.article-info {
  margin-top: 40px;
  padding: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.article-info-title {
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 12px;
}

.article-info-list {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.article-info-list li {
  padding: 6px 0;
  display: flex;
}

.article-info-list li strong {
  min-width: 100px;
  color: var(--text-primary);
}

/* 相关推荐 */
.related-section {
  margin-top: 40px;
  padding-top: 40px;
  border-top: 1px solid var(--border-color);
}

.related-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent-color);
  margin-bottom: 20px;
}

.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.related-list a {
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.related-list a:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: var(--bg-card);
}

/* 404页面 */
.error-page {
  text-align: center;
  padding: 100px 20px;
}

.error-code {
  font-size: 8rem;
  font-weight: 700;
  color: var(--accent-light);
  line-height: 1;
  margin-bottom: 20px;
}

.error-title {
  font-size: 1.8rem;
  color: var(--accent-dark);
  margin-bottom: 16px;
}

.error-desc {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-color);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

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

/* 页脚 */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 40px 24px;
  margin-top: 60px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 20px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

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

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

/* 响应式设计 */
@media (max-width: 1024px) {
  .articles-grid {
    grid-template-columns: 1fr;
  }

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

  .article-sidebar {
    position: static;
    order: -1;
  }

  .toc {
    margin-bottom: 24px;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .header-inner {
    padding: 0 16px;
  }

  .nav {
    display: none;
  }

  .search-box {
    width: 160px;
    padding: 6px 12px;
  }

  .main {
    padding: 24px 16px;
  }

  .hero {
    padding: 40px 16px;
  }

  .hero-title {
    font-size: 1.8rem;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .article-main {
    padding: 24px;
  }

  .article-title {
    font-size: 1.4rem;
  }

  .filter-bar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .error-code {
    font-size: 5rem;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 16px;
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

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

  .list-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination a,
  .pagination span {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }
}
