/* ===== book.wiki 全局样式 ===== */
/* 配色：极简、东方、科技、学术 */

:root {
  --bg-primary: #FAFAFA;
  --bg-secondary: #F5F5F0;
  --bg-card: #FFFFFF;
  --bg-panel: #F8F8F5;
  
  --text-primary: #1A1A1A;
  --text-secondary: #666666;
  --text-muted: #999999;
  --text-accent: #C41E3A;
  
  --border-light: #E5E5E0;
  --border-medium: #D0D0C8;
  
  --accent-red: #C41E3A;
  --accent-red-light: rgba(196, 30, 58, 0.08);
  
  /* 知识图谱节点色 (from ontology) */
  --color-person: #4A90E2;
  --color-concept: #F5A623;
  --color-event: #7ED321;
  --color-place: #BD10E0;
  --color-work: #9013FE;
  --color-theory: #50E3C2;
  --color-invention: #B8E986;
  --color-organization: #417505;
  --color-time: #D0021B;
  
  /* 字号层级 */
  --font-xs: 12px;
  --font-sm: 14px;
  --font-md: 16px;
  --font-lg: 20px;
  --font-xl: 28px;
  --font-2xl: 36px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  --nav-height: 56px;
  --panel-width: 320px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
}

/* 英文正文用 Georgia */
.en-text {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.8;
}

/* UI元素用 Inter */
.ui-text {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== 导航栏 ===== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(250, 250, 250, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  z-index: 1000;
  transition: background 0.3s, box-shadow 0.3s;
}

.navbar.scrolled {
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-sm);
}

.navbar-brand {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.navbar-brand span {
  color: var(--text-accent);
}

.navbar-links {
  display: flex;
  gap: 28px;
  align-items: center;
}

.navbar-links a {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
  font-weight: 500;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--text-accent);
}

/* ===== 通用容器 ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-content {
  padding-top: calc(var(--nav-height) + 24px);
  min-height: 100vh;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-red);
  color: white;
}

.btn-primary:hover {
  background: #A31830;
  transform: translateY(-1px);
}

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

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

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s, transform 0.3s;
  overflow: hidden;
}

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

/* ===== 徽章 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: var(--font-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-green {
  background: #E8F5E9;
  color: #2E7D32;
}

.badge-gray {
  background: #F5F5F5;
  color: #757575;
}

.badge-accent {
  background: var(--accent-red-light);
  color: var(--accent-red);
}

/* ===== 实体类型色标 ===== */
.entity-type-person { color: var(--color-person); }
.entity-type-concept { color: var(--color-concept); }
.entity-type-event { color: var(--color-event); }
.entity-type-place { color: var(--color-place); }
.entity-type-work { color: var(--color-work); }
.entity-type-theory { color: var(--color-theory); }
.entity-type-invention { color: var(--color-invention); }
.entity-type-organization { color: var(--color-organization); }
.entity-type-time { color: var(--color-time); }

/* 实体高亮样式 */
.entity-highlight {
  cursor: pointer;
  border-bottom: 1px dashed;
  transition: background 0.2s;
  padding: 0 2px;
  border-radius: 2px;
}

.entity-highlight:hover {
  background: var(--accent-red-light);
}

.entity-highlight.person { border-color: var(--color-person); color: var(--color-person); }
.entity-highlight.concept { border-color: var(--color-concept); color: var(--color-concept); }
.entity-highlight.event { border-color: var(--color-event); background: rgba(126,211,33,0.08); }
.entity-highlight.place { border-color: var(--color-place); color: var(--color-place); }
.entity-highlight.work { border-color: var(--color-work); color: var(--color-work); }
.entity-highlight.theory { border-color: var(--color-theory); color: var(--color-theory); }

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

.search-box input {
  width: 100%;
  padding: 14px 48px 14px 20px;
  border: 1.5px solid var(--border-medium);
  border-radius: 100px;
  font-size: var(--font-md);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: var(--accent-red);
  box-shadow: 0 0 0 3px var(--accent-red-light);
}

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

.search-icon {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* 搜索下拉 */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-dropdown.active {
  display: block;
}

.search-dropdown-item {
  padding: 12px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

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

.search-dropdown-item:hover {
  background: var(--bg-panel);
}

.search-dropdown-item .item-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: var(--font-sm);
}

.search-dropdown-item .item-type {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== 知识面板 (阅读页右侧) ===== */
.knowledge-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--bg-panel);
  border-left: 1px solid var(--border-light);
  height: calc(100vh - var(--nav-height));
  position: sticky;
  top: var(--nav-height);
  overflow-y: auto;
  padding: 20px;
}

.panel-section {
  margin-bottom: 24px;
}

.panel-section-title {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

/* ===== 实体卡片 (面板内) ===== */
.entity-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}

.entity-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.entity-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xs);
  color: white;
  flex-shrink: 0;
}

.entity-card-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
}

.entity-card-subtitle {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

.entity-card-definition {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 8px;
}

/* ===== 关系列表 ===== */
.relation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.relation-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-sm);
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.relation-item .relation-type {
  font-size: var(--font-xs);
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 100px;
  white-space: nowrap;
}

.relation-item a {
  color: var(--color-person);
  text-decoration: none;
  font-weight: 500;
}

.relation-item a:hover {
  text-decoration: underline;
}

/* ===== 时间轴 ===== */
.timeline {
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-medium);
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--accent-red);
}

.timeline-item .time-year {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--accent-red);
  margin-bottom: 2px;
}

.timeline-item .time-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
}

/* ===== 加载态 ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: var(--font-sm);
}

.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-medium);
  border-top-color: var(--accent-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 底部 Powered by ===== */
.powered-by {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: var(--font-xs);
  color: var(--text-muted);
  z-index: 999;
  box-shadow: var(--shadow-sm);
}

.powered-by a {
  color: var(--text-accent);
  text-decoration: none;
  font-weight: 500;
}

/* ===== 页脚 ===== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
  padding: 40px 0;
  margin-top: 60px;
}

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

.footer-brand {
  font-size: var(--font-lg);
  font-weight: 600;
}

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

.footer-links a {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  text-decoration: none;
}

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

/* ===== 响应式：移动端 ===== */
@media (max-width: 768px) {
  :root {
    --panel-width: 100%;
  }
  
  .navbar {
    padding: 0 16px;
  }
  
  .navbar-links {
    gap: 16px;
  }
  
  .navbar-links a span {
    display: none;
  }
  
  .container {
    padding: 0 16px;
  }
  
  .knowledge-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: 60vh;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-light);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 900;
  }
  
  .knowledge-panel.open {
    transform: translateY(0);
  }
  
  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* ===== 粒子画布背景 ===== */
#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ===== 统计条 ===== */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 20px 0;
}

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

.stats-number {
  font-size: var(--font-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stats-label {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== 章节标题 ===== */
.chapter-title {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-light);
}

.chapter-title-en {
  font-size: var(--font-md);
  color: var(--text-secondary);
  font-style: italic;
  font-family: Georgia, serif;
}

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.filter-chip {
  padding: 8px 16px;
  border-radius: 100px;
  font-size: var(--font-sm);
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.filter-chip:hover,
.filter-chip.active {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: var(--accent-red-light);
}

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

.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: box-shadow 0.3s, transform 0.3s;
  cursor: pointer;
  position: relative;
}

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

.book-card-structured .structured-badge {
  position: absolute;
  top: 16px;
  right: 16px;
}

.book-card-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.4;
}

.book-card-title-en {
  font-size: var(--font-sm);
  color: var(--text-muted);
  font-style: italic;
  font-family: Georgia, serif;
  margin-bottom: 12px;
}

.book-card-meta {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.book-card-anchor {
  display: inline-block;
  font-size: var(--font-xs);
  color: var(--accent-red);
  background: var(--accent-red-light);
  padding: 4px 10px;
  border-radius: 100px;
  margin-top: 8px;
}

.book-card-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: var(--font-xs);
  color: var(--text-muted);
}

/* ===== 阅读页布局 ===== */
.read-layout {
  display: flex;
  height: calc(100vh - var(--nav-height));
  overflow: hidden;
}

.read-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.read-column {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  scroll-behavior: smooth;
}

.read-column:first-child {
  border-right: 1px solid var(--border-light);
}

.read-paragraph {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}

.read-paragraph:last-child {
  border-bottom: none;
}

.read-paragraph .para-en {
  font-family: Georgia, serif;
  font-size: var(--font-md);
  line-height: 1.8;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.read-paragraph .para-zh {
  font-size: var(--font-md);
  line-height: 1.8;
  color: var(--text-secondary);
}

.read-paragraph .para-num {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: "Inter", sans-serif;
}

/* ===== 实体页布局 ===== */
.entity-hero {
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  border-bottom: 1px solid var(--border-light);
  padding: 48px 0 32px;
}

.entity-hero-content {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.entity-hero-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xl);
  color: white;
  flex-shrink: 0;
}

.entity-hero-text h1 {
  font-size: var(--font-2xl);
  font-weight: 700;
  margin-bottom: 4px;
}

.entity-hero-text .entity-subtitle {
  font-size: var(--font-md);
  color: var(--text-secondary);
  font-style: italic;
  font-family: Georgia, serif;
  margin-bottom: 8px;
}

.entity-hero-text .entity-meta {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

.entity-hero-text .entity-definition {
  font-size: var(--font-md);
  color: var(--text-secondary);
  margin-top: 16px;
  max-width: 700px;
  line-height: 1.7;
}

/* ===== 图谱页 ===== */
.graph-container {
  width: 100%;
  height: calc(100vh - var(--nav-height));
  background: var(--bg-primary);
  position: relative;
}

.graph-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.graph-control-btn {
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: var(--font-xs);
  cursor: pointer;
  transition: all 0.2s;
}

.graph-control-btn:hover,
.graph-control-btn.active {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
}

.graph-legend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: var(--font-xs);
  z-index: 10;
}

.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.graph-legend-item:last-child {
  margin-bottom: 0;
}

.graph-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ===== 探索页 ===== */
.explore-hero {
  padding: 60px 0 40px;
  text-align: center;
}

.explore-hero h1 {
  font-size: var(--font-2xl);
  font-weight: 700;
  margin-bottom: 16px;
}

.explore-hero p {
  font-size: var(--font-md);
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 32px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 40px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

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

.category-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: var(--font-xl);
  color: white;
}

.category-card h3 {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: 4px;
}

.category-card p {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

/* ===== 响应式工具 ===== */
@media (max-width: 768px) {
  .read-layout {
    flex-direction: column;
  }
  
  .read-main {
    flex-direction: column;
  }
  
  .read-column:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }
  
  .entity-hero-content {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
  
  .book-grid {
    grid-template-columns: 1fr;
  }
  
  .category-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .stats-bar {
    flex-direction: column;
    gap: 20px;
  }
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== 工具类 ===== */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: var(--font-sm); }
.text-muted { color: var(--text-muted); }
.w-full { width: 100%; }
.max-w-2xl { max-width: 672px; }
.mx-auto { margin-left: auto; margin-right: auto; }
