/* ========================================
   发电设备 - 电子书风格样式表
   www.fadianshebeijia.cn
   ======================================== */

/* 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: #fafafa;
  --bg-warm: #f5f3f0;
  --border-color: #e0e0e0;
  --border-light: #f0f0f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --max-width: 1200px;
  --header-height: 64px;
}

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

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

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
}

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

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

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

ul, ol {
  list-style: none;
}

/* ========================================
   布局组件
   ======================================== */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

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

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

.search-box {
  position: relative;
}

.search-input {
  width: 240px;
  padding: 8px 36px 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.9rem;
  background: var(--bg-secondary);
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: var(--bg-primary);
}

.search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

/* 页脚 */
.footer {
  background: var(--bg-warm);
  border-top: 1px solid var(--border-light);
  padding: 48px 0 24px;
  margin-top: 64px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 32px;
}

.footer-brand p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 12px;
  line-height: 1.7;
}

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

.footer-links li {
  margin-bottom: 10px;
}

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

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

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ========================================
   首页组件
   ======================================== */

/* Hero 区域 */
.hero {
  background: linear-gradient(135deg, var(--bg-warm) 0%, var(--bg-secondary) 100%);
  padding: 80px 0 60px;
  text-align: center;
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  font-family: var(--font-serif);
}

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

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 40px;
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-color);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 区块标题 */
.section {
  padding: 60px 0;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--accent-color);
  border-radius: 2px;
}

.view-all {
  font-size: 0.9rem;
  color: var(--accent-color);
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.book-card {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

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

.book-cover {
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-color) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  font-size: 3rem;
  position: relative;
}

.book-cover::after {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: rgba(255,255,255,0.2);
}

.book-info {
  padding: 16px;
}

.book-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

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

.category-card:hover {
  border-color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.category-icon {
  width: 48px;
  height: 48px;
  background: var(--bg-warm);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.5rem;
}

.category-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

/* 书籍列表 */
.book-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.book-list-item {
  display: flex;
  gap: 20px;
  padding: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.book-list-item:hover {
  border-color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.book-list-cover {
  width: 80px;
  height: 110px;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-color) 100%);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  font-size: 1.5rem;
}

.book-list-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.book-list-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.book-list-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 三栏文章列表 */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.article-column {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
}

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

.article-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

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

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

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

/* ========================================
   分类页组件
   ======================================== */

/* 面包屑 */
.breadcrumb {
  padding: 20px 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

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

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

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

.breadcrumb-current {
  color: var(--text-primary);
}

/* 分类头部 */
.category-header {
  background: var(--bg-warm);
  padding: 40px 0;
  margin-bottom: 32px;
}

.category-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.category-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.category-stats {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* 筛选排序 */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.filter-options {
  display: flex;
  gap: 24px;
}

.filter-option {
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.filter-option:hover,
.filter-option.active {
  color: var(--accent-color);
  font-weight: 500;
}

.sort-select {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: var(--bg-primary);
  cursor: pointer;
}

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

.page-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.page-btn.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #fff;
}

.page-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========================================
   文章页组件
   ======================================== */

/* 两栏布局 */
.two-column {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 40px;
  padding: 32px 0;
}

/* 主内容区 */
.main-content {
  min-width: 0;
}

/* 侧边栏 */
.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 32px);
  height: fit-content;
}

.sidebar-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

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

/* 目录 */
.toc-list {
  font-size: 0.9rem;
}

.toc-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.toc-item:last-child {
  border-bottom: none;
}

.toc-item a {
  color: var(--text-secondary);
  display: block;
}

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

.toc-item.level-1 {
  font-weight: 500;
  color: var(--text-primary);
}

.toc-item.level-2 {
  padding-left: 16px;
}

/* 文章头部 */
.article-header {
  margin-bottom: 32px;
}

.article-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 16px;
  font-family: var(--font-serif);
}

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

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

/* 文章内容 */
.article-content {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.article-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 40px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

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

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

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

.article-content ul {
  list-style: disc;
}

.article-content ol {
  list-style: decimal;
}

.article-content li {
  margin-bottom: 8px;
}

.article-content blockquote {
  border-left: 4px solid var(--accent-color);
  padding-left: 20px;
  margin: 24px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.article-content code {
  background: var(--bg-warm);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: "SF Mono", Monaco, monospace;
  font-size: 0.9em;
}

.article-content pre {
  background: var(--bg-warm);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 20px 0;
}

.article-content pre code {
  background: none;
  padding: 0;
}

/* 书籍详情卡片 */
.book-detail-card {
  background: var(--bg-warm);
  border-radius: var(--radius-lg);
  padding: 32px;
  display: flex;
  gap: 32px;
  margin-bottom: 32px;
}

.book-detail-cover {
  width: 200px;
  height: 280px;
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent-color) 100%);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  font-size: 4rem;
  box-shadow: var(--shadow-md);
  position: relative;
}

.book-detail-cover::after {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: rgba(255,255,255,0.2);
}

.book-detail-info {
  flex: 1;
}

.book-detail-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.book-detail-meta {
  display: flex;
  gap: 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.book-detail-desc {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
}

.book-detail-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.book-detail-item {
  display: flex;
  gap: 8px;
  font-size: 0.9rem;
}

.book-detail-label {
  color: var(--text-muted);
}

.book-detail-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* 相关文章 */
.related-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-light);
}

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

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.related-item {
  padding: 16px;
  background: var(--bg-warm);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.related-item:hover {
  background: var(--bg-secondary);
}

.related-item-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* ========================================
   404页面
   ======================================== */

.error-page {
  min-height: calc(100vh - var(--header-height) - 300px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
}

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

.error-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.error-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 400px;
}

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

.btn {
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

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

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

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

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

/* ========================================
   响应式设计
   ======================================== */

@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-column {
    grid-template-columns: 1fr;
  }

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

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

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

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

  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 0;
    gap: 12px;
  }

  .nav {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 20px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
  }

  .search-box {
    flex: 1;
    display: flex;
    justify-content: flex-end;
  }

  .search-input {
    width: 100%;
    max-width: 200px;
  }

  .hero {
    padding: 48px 0 40px;
  }

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

  .hero-subtitle {
    font-size: 1rem;
  }

  .hero-stats {
    gap: 24px;
  }

  .stat-number {
    font-size: 1.5rem;
  }

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

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

  .book-list-item {
    flex-direction: column;
    gap: 16px;
  }

  .book-list-cover {
    width: 100%;
    height: 160px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .category-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .filter-bar {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .book-detail-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .book-detail-cover {
    width: 160px;
    height: 220px;
  }

  .book-detail-list {
    grid-template-columns: 1fr;
    text-align: left;
  }

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

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

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

  .error-actions {
    flex-direction: column;
    width: 100%;
    max-width: 280px;
  }

  .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .book-info {
    padding: 12px;
  }

  .book-title {
    font-size: 0.9rem;
  }

  .section {
    padding: 40px 0;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
