/**
 * 包装机械网 - 样式表
 * 知识库风格 (Wiki Style)
 * 主色调: #7c6a46
 */

/* ========== 基础重置 ========== */
*, *::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.6;
  color: #333;
  background-color: #f8f9fa;
}

a {
  text-decoration: none;
  color: #7c6a46;
  transition: color 0.2s ease;
}

a:hover {
  color: #5a4d35;
}

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

ul, ol {
  list-style: none;
}

/* ========== 变量定义 ========== */
:root {
  --accent-color: #7c6a46;
  --accent-light: #9a8660;
  --accent-dark: #5a4d35;
  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --bg-white: #fff;
  --bg-light: #f8f9fa;
  --bg-gray: #e9ecef;
  --border-color: #dee2e6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* ========== 布局容器 ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

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

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

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

.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: 1rem;
}

.main-nav {
  display: flex;
  gap: 30px;
}

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

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

/* ========== 搜索框 ========== */
.search-box {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.search-box input {
  width: 100%;
  padding: 14px 50px 14px 20px;
  border: 2px solid var(--border-color);
  border-radius: 50px;
  font-size: 1rem;
  background: var(--bg-white);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(124, 106, 70, 0.1);
}

.search-box button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent-color);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.search-box button:hover {
  background: var(--accent-dark);
}

/* ========== Hero 区域 ========== */
.hero {
  background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-dark) 100%);
  color: #fff;
  padding: 60px 0;
  text-align: center;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 30px;
}

/* ========== 面包屑 ========== */
.breadcrumb {
  background: var(--bg-light);
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.breadcrumb ol {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

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

.breadcrumb li:not(:last-child)::after {
  content: ">";
  margin-left: 8px;
  color: var(--text-muted);
}

/* ========== 卡片组件 ========== */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

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

.card-body {
  padding: 20px;
}

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

.card-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== 分类卡片 ========== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

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

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

.category-card-icon {
  width: 48px;
  height: 48px;
  background: rgba(124, 106, 70, 0.1);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: var(--accent-color);
  font-size: 1.5rem;
}

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

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

/* ========== 内容区块 ========== */
.section {
  padding: 40px 0;
}

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

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

/* ========== 文章列表 ========== */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.article-item {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  gap: 16px;
  transition: all 0.2s ease;
}

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

.article-item-icon {
  width: 48px;
  height: 48px;
  background: rgba(124, 106, 70, 0.1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
  flex-shrink: 0;
}

.article-item-content {
  flex: 1;
  min-width: 0;
}

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

.article-item-title a {
  color: inherit;
}

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

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

.article-item-meta {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== 标签云 ========== */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(124, 106, 70, 0.1);
  color: var(--accent-color);
  border-radius: 20px;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.tag:hover {
  background: var(--accent-color);
  color: #fff;
}

/* ========== 侧边栏目录 ========== */
.toc {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  position: sticky;
  top: 84px;
}

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

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toc-list a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 4px 0;
  display: block;
}

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

.toc-list a.active {
  color: var(--accent-color);
  font-weight: 500;
}

/* ========== 文章正文 ========== */
.article-content {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 40px;
}

.article-header {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.article-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.3;
}

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

.article-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.article-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 30px 0 16px;
  color: var(--text-primary);
}

.article-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 24px 0 12px;
  color: var(--text-primary);
}

.article-body p {
  margin-bottom: 16px;
}

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

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

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

.article-body strong {
  font-weight: 600;
  color: var(--accent-dark);
}

/* ========== 信息框 ========== */
.info-box {
  background: rgba(124, 106, 70, 0.05);
  border-left: 4px solid var(--accent-color);
  padding: 20px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 20px 0;
}

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

.info-box ul {
  margin: 0;
  padding-left: 20px;
}

.info-box li {
  margin-bottom: 6px;
  color: var(--text-secondary);
}

/* ========== 三栏布局 ========== */
.three-column {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.column-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent-color);
}

.column-section ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.column-section a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.column-section a::before {
  content: "•";
  color: var(--accent-color);
}

/* ========== 页脚 ========== */
.footer {
  background: var(--text-primary);
  color: #fff;
  padding: 40px 0 20px;
  margin-top: 60px;
}

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

.footer-brand {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--accent-light);
}

.footer-desc {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  line-height: 1.6;
}

.footer-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: #fff;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links a {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
}

.footer-links a:hover {
  color: #fff;
}

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 20px;
  text-align: center;
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
}

/* ========== 404 页面 ========== */
.error-page {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.error-content {
  max-width: 500px;
}

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

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

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

.btn {
  display: inline-block;
  padding: 12px 30px;
  background: var(--accent-color);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background 0.2s ease;
}

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

/* ========== 两栏布局 (文章页) ========== */
.two-column-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 30px;
  padding: 30px 0;
}

.sidebar {
  width: 260px;
}

.main-content {
  min-width: 0;
}

/* ========== 响应式设计 ========== */
@media (max-width: 992px) {
  .three-column {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

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

  .toc {
    position: static;
    margin-bottom: 20px;
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 0;
    gap: 12px;
  }

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

  .hero {
    padding: 40px 0;
  }

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

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

  .category-card {
    padding: 16px;
  }

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

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

  .article-content {
    padding: 24px;
  }

  .article-header h1 {
    font-size: 1.5rem;
  }

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

@media (max-width: 480px) {
  .container,
  .container-narrow {
    padding: 0 16px;
  }

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

  .article-item {
    flex-direction: column;
    gap: 12px;
  }

  .article-item-icon {
    width: 40px;
    height: 40px;
  }
}
