/* ========================================
   IT知识汇 - 知识库风格样式表
   配色: #7c6a46 (accent-color)
   ======================================== */

/* CSS 变量 */
:root {
  --accent-color: #7c6a46;
  --accent-light: #9a8660;
  --accent-dark: #5c4f35;
  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --bg-primary: #fff;
  --bg-secondary: #f8f6f3;
  --bg-card: #fff;
  --border-color: #e8e4de;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1200px;
  --header-height: 64px;
}

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

html {
  scroll-behavior: smooth;
}

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

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

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

ul {
  list-style: none;
}

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

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

/* ========================================
   Header 页头
   ======================================== */
.header {
  background: var(--bg-primary);
  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: var(--header-height);
}

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

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

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

.nav a {
  padding: 8px 16px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

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

.search-box {
  position: relative;
  width: 240px;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  font-size: 0.9375rem;
  background: var(--bg-secondary);
  transition: all 0.2s;
}

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

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  opacity: 0.5;
}

/* ========================================
   Hero Section
   ======================================== */
.hero {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  padding: 60px 0;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

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

.hero-desc {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.hero-search {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.hero-search input {
  width: 100%;
  padding: 16px 24px 16px 52px;
  border: 2px solid var(--border-color);
  border-radius: 32px;
  font-size: 1rem;
  background: var(--bg-primary);
  box-shadow: var(--shadow);
  transition: all 0.2s;
}

.hero-search input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: var(--shadow-hover);
}

.hero-search::before {
  content: "🔍";
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.125rem;
  opacity: 0.5;
}

/* ========================================
   Section 标题
   ======================================== */
.section {
  padding: 48px 0;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  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;
}

/* ========================================
   卡片组件
   ======================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 20px;
  transition: all 0.2s;
}

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

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

.card-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.card-meta {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ========================================
   卡片网格
   ======================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

/* ========================================
   分类标签
   ======================================== */
.category-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.category-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text-primary);
  transition: all 0.2s;
}

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

.category-tag .count {
  padding: 2px 8px;
  background: var(--bg-secondary);
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.category-tag:hover .count {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ========================================
   列表组件
   ======================================== */
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

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

.list-item-marker {
  width: 6px;
  height: 6px;
  background: var(--accent-color);
  border-radius: 50%;
  margin-top: 10px;
  flex-shrink: 0;
}

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

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

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

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

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

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

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

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

.breadcrumb span {
  margin: 0 8px;
}

/* ========================================
   分类页头部
   ======================================== */
.category-header {
  background: var(--bg-primary);
  padding: 40px 0;
  border-bottom: 1px solid var(--border-color);
}

.category-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.category-stats {
  display: flex;
  gap: 24px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ========================================
   文章页布局
   ======================================== */
.article-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
  padding: 32px 0;
}

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

.sidebar-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.toc {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
}

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

.toc a {
  display: block;
  padding: 6px 0;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  border-left: 2px solid transparent;
  padding-left: 12px;
  margin-left: -12px;
}

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

.related-pages {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

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

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

.related-pages a::before {
  content: "→";
  color: var(--accent-color);
}

/* ========================================
   文章内容
   ======================================== */
.article {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
}

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

.article-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.3;
}

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

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

.article-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 32px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.article-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 24px 0 12px;
}

.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;
}

.info-box {
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent-color);
  padding: 20px;
  margin: 24px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

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

/* ========================================
   404页面
   ======================================== */
.error-page {
  min-height: calc(100vh - var(--header-height) - 200px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 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.5rem;
  font-weight: 600;
  margin-bottom: 12px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent-color);
  color: #fff;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s;
}

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

/* ========================================
   Footer 页脚
   ======================================== */
.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 40px 0;
  margin-top: 48px;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.footer-links {
  display: flex;
  gap: 24px;
}

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

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

.copyright {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ========================================
   响应式设计
   ======================================== */
@media (max-width: 1024px) {
  .article-layout {
    grid-template-columns: 200px 1fr;
    gap: 24px;
  }
}

@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;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
  }

  .search-box {
    width: auto;
    flex: 1;
    max-width: 200px;
  }

  .hero {
    padding: 40px 0;
  }

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

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

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

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

  .sidebar {
    position: static;
    order: 2;
  }

  .toc,
  .related-pages {
    display: none;
  }

  .article {
    padding: 24px;
  }

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

  .footer-inner {
    flex-direction: column;
    gap: 20px;
    text-align: center;
  }

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

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

  .category-tags {
    justify-content: center;
  }

  .category-tag {
    padding: 10px 16px;
    font-size: 0.875rem;
  }
}
