/* ============================================================
   D&D 3.5e 中文Wiki - 全局样式表
   设计灵感：灰机wiki / dndlogs.com
   ============================================================ */

/* --- CSS 变量 --- */
:root {
  --bg-main: #f5f0e8;
  --bg-sidebar: #2c3e50;
  --bg-content: #ffffff;
  --bg-card: #faf6ee;
  --bg-infobox: #e8d5b8;
  --bg-navbar: #1a252f;
  --bg-code: #f0ebe0;
  --bg-table-head: #d4b896;
  --bg-table-stripe: #f7f3ea;
  --text-main: #2c2c2c;
  --text-sidebar: #ecf0f1;
  --text-link: #21618c;
  --text-link-hover: #1a5276;
  --text-heading: #4a2c0a;
  --text-subtle: #7f8c8d;
  --accent-red: #c0392b;
  --accent-gold: #d4a017;
  --accent-blue: #2980b9;
  --accent-green: #27ae60;
  --accent-purple: #8e44ad;
  --border-main: #d4b896;
  --border-light: #e8dcc8;
  --shadow-soft: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-card: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 6px;

  /* 短名别名（供 global-search / spells / 3r 页面使用） */
  --accent: #2980b9;
  --accent-glow: 0 0 8px rgba(41,128,185,0.4);
  --border: #d4b896;
  --text: #2c2c2c;
  --bg: #f5f0e8;
  --text-muted: #7f8c8d;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --font-serif: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --font-sans: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Source Code Pro", "Consolas", "SimHei", monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.7;
  font-size: 15px;
}

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

/* --- 顶部导航栏 --- */
.navbar {
  background: var(--bg-navbar);
  color: #ecf0f1;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.navbar-brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-right: 32px;
  white-space: nowrap;
}
.navbar-links { display: flex; gap: 4px; flex-wrap: wrap; }
.navbar-links a {
  color: var(--text-sidebar);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 14px;
  transition: background 0.2s;
  white-space: nowrap;
}
.navbar-links a:hover { background: rgba(255,255,255,0.12); text-decoration: none; }
.navbar-links a.active { background: var(--accent-gold); color: #1a1a1a; font-weight: 600; }

/* --- 搜索栏 --- */
.navbar-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.navbar-search input {
  padding: 5px 12px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #34495e;
  color: #ecf0f1;
  font-size: 13px;
  width: 180px;
  outline: none;
}
.navbar-search input::placeholder { color: #95a5a6; }
.navbar-search input:focus { border-color: var(--accent-gold); }
.navbar-search button {
  padding: 5px 12px;
  background: var(--accent-gold);
  color: #1a1a1a;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

/* --- 布局 --- */
.layout,
.container {
  display: flex;
  min-height: calc(100vh - 52px);
}

/* --- 侧边栏 --- */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  padding: 20px 0;
  overflow-y: auto;
  position: sticky;
  top: 52px;
  height: calc(100vh - 52px);
}
.sidebar-section { margin-bottom: 20px; }
.sidebar-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #95a5a6;
  padding: 0 18px;
  margin-bottom: 8px;
  font-weight: 600;
}
.sidebar a {
  display: block;
  padding: 7px 18px;
  color: #bdc3c7;
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.sidebar a:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
  border-left-color: var(--accent-gold);
}
.sidebar a.active {
  background: rgba(212,160,23,0.15);
  color: var(--accent-gold);
  border-left-color: var(--accent-gold);
  font-weight: 600;
}

/* --- 主内容区 --- */
.main-content {
  flex: 1;
  padding: 32px 40px;
  max-width: 960px;
  margin: 0 auto;
  background: var(--bg-content);
  box-shadow: var(--shadow-soft);
  min-height: calc(100vh - 52px);
}
.main-content > h1:first-child {
  font-family: var(--font-serif);
  font-size: 32px;
  color: var(--text-heading);
  border-bottom: 3px solid var(--accent-gold);
  padding-bottom: 10px;
  margin-bottom: 24px;
}

/* --- 内容样式 --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--text-heading);
  margin-top: 28px;
  margin-bottom: 14px;
}
h1 { font-size: 28px; border-bottom: 2px solid var(--border-main); padding-bottom: 8px; }
h2 { font-size: 22px; border-bottom: 1px solid var(--border-light); padding-bottom: 6px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; color: #666; }

p { margin-bottom: 14px; }
ul, ol { margin-bottom: 14px; padding-left: 24px; }
li { margin-bottom: 6px; }

blockquote {
  border-left: 4px solid var(--accent-gold);
  background: var(--bg-card);
  padding: 12px 18px;
  margin: 16px 0;
  color: #555;
  font-style: italic;
}

code {
  font-family: var(--font-mono);
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  color: var(--accent-red);
}
pre {
  background: var(--bg-code);
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border-light);
}
pre code { background: none; padding: 0; color: var(--text-main); }

/* --- Infobox（信息盒子）--- */
.infobox {
  float: right;
  width: 300px;
  margin: 0 0 20px 24px;
  background: var(--bg-infobox);
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow-card);
  font-size: 14px;
}
.infobox-title {
  background: #8b6914;
  color: #fff;
  text-align: center;
  padding: 10px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  border-radius: var(--radius) var(--radius) 0 0;
}
.infobox-subtitle {
  text-align: center;
  padding: 6px;
  font-size: 13px;
  color: #666;
  border-bottom: 1px solid var(--border-light);
}
.infobox-img {
  text-align: center;
  padding: 12px;
  background: #f5f0e0;
}
.infobox-img img { max-width: 100%; border-radius: 4px; }
.infobox-table { width: 100%; border-collapse: collapse; }
.infobox-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}
.infobox-table td:first-child {
  font-weight: 600;
  color: #555;
  width: 90px;
  white-space: nowrap;
}
.infobox-table tr:last-child td { border-bottom: none; }

/* --- 数据表格 --- */
.wiki-table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
  box-shadow: var(--shadow-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.wiki-table th {
  background: var(--bg-table-head);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: #4a2c0a;
  border-bottom: 2px solid var(--border-main);
}
.wiki-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
}
.wiki-table tbody tr:nth-child(even) { background: var(--bg-table-stripe); }
.wiki-table tbody tr:hover { background: #e8dcc8; }

/* --- 卡片网格 --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.card h3 { margin-top: 0; font-size: 16px; }
.card p { font-size: 13px; color: #666; margin-bottom: 0; }

/* --- 标签/徽章 --- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 6px;
}
.badge-core { background: #3498db; color: #fff; }
.badge-supplement { background: #2ecc71; color: #fff; }
.badge-race { background: #e67e22; color: #fff; }
.badge-class { background: #9b59b6; color: #fff; }
.badge-spell { background: #1abc9c; color: #fff; }
.badge-feat { background: #e74c3c; color: #fff; }
.badge-conflict { background: #c0392b; color: #fff; }
.badge-note { background: #f39c12; color: #fff; }

/* --- 冲突表格特殊样式 --- */
.conflict-high { background: #fde8e8 !important; }
.conflict-medium { background: #fef5e7 !important; }
.conflict-low { background: #eafaf1 !important; }
.source-tag {
  display: inline-block;
  background: #ecf0f1;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: #555;
  margin-right: 4px;
}

/* --- 目录（TOC）--- */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 20px 0;
  display: inline-block;
  min-width: 260px;
}
.toc-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--text-heading);
}
.toc ol { list-style: none; padding-left: 0; }
.toc ol li { padding: 3px 0; font-size: 14px; }
.toc ol li a { color: var(--text-link); }

/* --- 法术信息块 --- */
.spell-block {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-left: 4px solid var(--accent-purple);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
}
.spell-block h3 { margin-top: 0; color: var(--accent-purple); }
.spell-meta { font-size: 13px; color: #666; margin-bottom: 8px; }
.spell-meta strong { color: #333; }

/* --- 首页特色 --- */
.hero-banner {
  background: linear-gradient(135deg, #2c3e50 0%, #4a2c0a 100%);
  color: #fff;
  padding: 48px 40px;
  border-radius: var(--radius);
  margin-bottom: 32px;
  text-align: center;
}
.hero-banner h1 {
  font-family: var(--font-serif);
  font-size: 40px;
  color: var(--accent-gold);
  margin: 0 0 12px 0;
  border: none;
}
.hero-banner p { font-size: 17px; color: #ccc; max-width: 640px; margin: 0 auto; }

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin: 24px 0;
}
.quick-link {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  font-weight: 600;
  color: var(--text-heading);
  transition: all 0.2s;
  text-decoration: none;
}
.quick-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); text-decoration: none; color: var(--accent-gold); }
.quick-link-icon { font-size: 28px; display: block; margin-bottom: 8px; }

/* --- 首页统计条 --- */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin: 24px 0;
  border: 1px solid var(--border-light);
}
.stat-item { text-align: center; }
.stat-number { font-size: 28px; font-weight: 700; color: var(--accent-gold); }
.stat-label { font-size: 13px; color: #777; }

/* --- 页脚 --- */
.footer, .site-footer {
  background: var(--bg-navbar);
  color: #95a5a6;
  text-align: center;
  padding: 24px;
  font-size: 13px;
  margin-top: 48px;
}
.footer a, .site-footer a { color: #bdc3c7; }
.footer a:hover, .site-footer a:hover { color: var(--accent-gold); }

/* --- 响应式 --- */

/* --- 导航栏下拉菜单 --- */
.nav-dropdown {
  position: relative;
  display: inline-block;
}
.nav-dropdown > .drop-trigger {
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 4px;
  color: #ddd;
  font-size: 14px;
  text-decoration: none;
  background: none;
  border: none;
  font-family: inherit;
  transition: background 0.2s;
}
.nav-dropdown > .drop-trigger:hover {
  background: rgba(255,255,255,0.12);
  text-decoration: none;
}
.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #2c2c2c;
  min-width: 180px;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 1000;
  padding: 6px 0;
}
.nav-dropdown:hover .nav-dropdown-content {
  display: block;
}
.nav-dropdown-content a {
  display: block;
  padding: 8px 16px;
  color: #ddd;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 0;
}
.nav-dropdown-content a:hover {
  background: rgba(255,255,255,0.1);
  color: var(--accent-gold);
}
.nav-dropdown-content .drop-divider {
  border-top: 1px solid rgba(255,255,255,0.08);
  margin: 4px 0;
}

@media (max-width: 900px) {
  .layout, .container { flex-direction: column; }
  .sidebar { width: 100%; min-width: auto; position: static; height: auto; max-height: 280px; overflow-y: auto; }
  .main-content { padding: 20px 16px; }
  .infobox { float: none; width: 100%; margin: 0 0 20px 0; }
  .navbar-links { display: none; }
  .navbar-search { margin-left: 0; }
  .sidebar a { padding: 6px 14px; font-size: 13px; }
}

@media (max-width: 600px) {
  .navbar { padding: 0 12px; height: 48px; }
  .navbar-brand { font-size: 16px; margin-right: 8px; }
  .navbar-search input { width: 120px; }
  .main-content { padding: 14px 12px; }
  .hero-banner { padding: 24px 16px; }
  .hero-banner h1 { font-size: 26px; }
  .stats-bar { gap: 16px; flex-wrap: wrap; }
  .quick-links { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .quick-link { padding: 12px 8px; font-size: 12px; }
  .quick-link-icon { font-size: 22px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  table { font-size: 12px; }
  table th, table td { padding: 5px 6px; }
}

/* --- 面包屑导航 --- */
.breadcrumb {
  font-size: 13px;
  color: var(--text-subtle);
  margin-bottom: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.breadcrumb a { color: var(--text-link); }
.breadcrumb span { color: var(--text-subtle); margin: 0 6px; }

/* --- 移动端汉堡菜单 --- */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: #ecf0f1;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
}
@media (max-width: 900px) {
  .mobile-menu-btn { display: block; }
  .navbar-links.mobile-open { 
    display: flex; 
    flex-direction: column; 
    position: fixed;
    top: 48px; left: 0; right: 0;
    background: var(--bg-navbar);
    padding: 10px 0;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  }
  .navbar-links.mobile-open a { padding: 10px 20px; }
  .navbar-search { order: -1; }
}

/* --- 法术搜索结果改进 --- */
.spell-source-phb { background:#e8f5e9; color:#2e7d32; border:1px solid #a5d6a7; padding:1px 6px; border-radius:4px; font-size:11px; font-weight:600; }
.spell-source-3r  { background:#ede7f6; color:#6a1b9a; border:1px solid #ce93d8; padding:1px 6px; border-radius:4px; font-size:11px; font-weight:600; }

/* --- 打印样式 --- */
@media print {
  .navbar, .sidebar, footer { display: none !important; }
  .main-content { padding: 0; box-shadow: none; }
  .layout, .container { display: block; }
  a[href]:after { content: " (" attr(href) ")"; font-size: 11px; color: #666; }
  h1, h2, h3 { page-break-after: avoid; }
  table { page-break-inside: avoid; }
}
