/* 现代学术风格 - Modern Academic Style */
/* 学术蓝主题配色 + 进度条 + 增强侧边栏 */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&family=Noto+Sans+SC:wght@400;500;700&family=Fira+Code:wght@400;500&display=swap');

:root {
  /* 学术蓝主色调 */
  --primary-color: #1a365d;      /* 深学术蓝 */
  --accent-color: #3182ce;        /* 鲜明蓝 */
  --accent-hover: #2c5282;        /* 悬停深蓝 */
  --accent-light: #ebf8ff;        /* 浅蓝背景 */

  /* 文本颜色 */
  --text-color: #2d3748;
  --text-light: #718096;
  --text-muted: #a0aec0;

  /* 背景色 */
  --bg-color: #ffffff;
  --code-bg: #f7fafc;
  --border-color: #e2e8f0;
  --sidebar-bg: #f8fafc;

  /* 进度条颜色 */
  --progress-bg: #e2e8f0;
  --progress-fill: #3182ce;
  --success-color: #38a169;

  /* 导航栏 */
  --navbar-bg: #ffffff;
}

/* 进度条容器 */
.progress-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--progress-bg);
  z-index: 9999;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), var(--success-color));
  width: 0%;
  transition: width 0.3s ease;
}

/* 章节进度指示器 */
.chapter-progress {
  position: sticky;
  top: 60px;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
}

.chapter-progress-label {
  color: var(--text-light);
  font-weight: 500;
}

.chapter-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--progress-bg);
  border-radius: 3px;
  overflow: hidden;
  max-width: 200px;
}

.chapter-progress-fill {
  height: 100%;
  background: var(--accent-color);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.chapter-progress-text {
  color: var(--primary-color);
  font-weight: 600;
  min-width: 80px;
  text-align: right;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Source Sans Pro", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-color);
  background-color: var(--bg-color);
}

/* 标题样式 */
h1, h2, h3, h4, h5, h6 {
  color: var(--primary-color);
  font-weight: 600;
  line-height: 1.3;
}

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  border-bottom: 3px solid var(--accent-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.6rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3rem;
}

h3 {
  font-size: 1.3rem;
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  color: var(--primary-color);
}

h4 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  color: var(--text-light);
}

/* 段落和列表 */
p {
  margin-bottom: 1rem;
}

ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* 代码样式 */
code {
  font-family: "Fira Code", "SF Mono", Consolas, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  color: #e53e3e;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

pre code {
  background: none;
  padding: 0;
  color: var(--text-color);
}

/* 表格样式 */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

th, td {
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  text-align: left;
}

th {
  background: var(--code-bg);
  font-weight: 600;
  color: var(--primary-color);
  border-bottom: 2px solid var(--accent-color);
}

tr:nth-child(even) {
  background: var(--sidebar-bg);
}

tr:hover {
  background: var(--accent-light);
}

/* 引用块 */
blockquote {
  border-left: 4px solid var(--accent-color);
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  background: var(--sidebar-bg);
  border-radius: 0 6px 6px 0;
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* 链接 */
a {
  color: var(--accent-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

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

/* 导航栏 */
.navbar {
  box-shadow: 0 2px 8px rgba(26, 54, 93, 0.08);
  background: var(--navbar-bg) !important;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
  color: var(--primary-color) !important;
  font-weight: 700;
  font-size: 1.2rem;
}

.nav-link {
  color: var(--text-color) !important;
  font-weight: 500;
  padding: 0.5rem 1rem !important;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--accent-color) !important;
  background: var(--accent-light);
}

/* 侧边目录 - 增强版 */
.toc-sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  min-height: calc(100vh - 60px);
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

#TOC {
  font-size: 0.9rem;
}

#TOC ul {
  padding-left: 0;
  list-style: none;
  margin: 0;
}

#TOC > ul > li {
  margin-bottom: 0;
}

#TOC li {
  margin-bottom: 0;
}

#TOC li a {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text-color);
  border-radius: 6px;
  border-bottom: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

#TOC li a:hover {
  background: var(--accent-light);
  color: var(--accent-color);
}

#TOC li a.active {
  background: var(--accent-light);
  color: var(--accent-color);
  font-weight: 600;
  border-left: 3px solid var(--accent-color);
  margin-left: -3px;
}

/* 章节编号徽章 */
.chapter-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent-color);
  color: white;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.5rem;
}

/* 卷和部分标题 */
.part-title {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-top: 1.5rem;
}

.part-title:first-child {
  margin-top: 0;
}

/* 页面布局 - 900px 舒适宽度 */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 3rem;
}

/* 封面特殊样式 */
.title-block {
  text-align: center;
  padding: 4rem 2rem;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--bg-color) 100%);
  border-radius: 12px;
  margin-bottom: 3rem;
  border: 1px solid var(--border-color);
}

.title-block h1 {
  border: none;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.title-block .subtitle {
  font-size: 1.3rem;
  color: var(--text-light);
  font-weight: 400;
  margin-bottom: 1rem;
}

.title-block .author {
  font-size: 1rem;
  color: var(--text-muted);
}

/* 摘要样式 */
.abstract {
  background: var(--accent-light);
  padding: 1.5rem;
  border-radius: 8px;
  margin: 2rem 0;
  border-left: 4px solid var(--accent-color);
}

.abstract h2 {
  font-size: 1.1rem;
  margin-top: 0;
  border: none;
  color: var(--primary-color);
}

/* 脚注 */
.footnote-ref {
  font-size: 0.75rem;
  vertical-align: super;
  color: var(--accent-color);
}

/* 分隔线 */
hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2.5rem 0;
}

/* Callout 样式优化 */
.callout {
  border-radius: 8px;
  border-left: 4px solid var(--accent-color);
  background: var(--sidebar-bg);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.callout-note {
  border-left-color: #3182ce;
  background: #ebf8ff;
}

.callout-tip {
  border-left-color: #38a169;
  background: #f0fff4;
}

.callout-warning {
  border-left-color: #dd6b20;
  background: #fffaf0;
}

.callout-important {
  border-left-color: #e53e3e;
  background: #fff5f5;
}

/* 示例框样式 */
.example {
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.example-title {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

/* 定理样式 */
.theorem {
  background: var(--accent-light);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
  border-left: 4px solid var(--accent-color);
}

.theorem-title {
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

/* 定义样式 */
.definition {
  background: #f0fff4;
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
  border-left: 4px solid #38a169;
}

/* 响应式调整 */
@media (max-width: 1200px) {
  main {
    max-width: 100%;
    padding: 1.5rem 2rem;
  }
}

@media (max-width: 768px) {
  main {
    padding: 1rem;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  .title-block h1 {
    font-size: 2rem;
  }

  .chapter-progress {
    display: none;
  }

  .toc-sidebar {
    display: none;
  }
}

/* 打印样式 */
@media print {
  .navbar, .toc-sidebar, .sidebar, .progress-container, .chapter-progress {
    display: none !important;
  }

  main {
    max-width: 100%;
    padding: 0;
  }

  body {
    font-size: 12pt;
    line-height: 1.6;
  }

  h1, h2, h3 {
    page-break-after: avoid;
  }
}
