/* 破产重整知识库 — 经典金融出版物设计系统 v2 */
/* 配色：象牙纸底 + 深海军蓝 + 金色点缀 */

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

:root {
  --navy:          #1B2A4A;
  --navy-light:    #2C3E6B;
  --navy-dark:     #0F1A30;
  --gold:          #C5A55A;
  --gold-light:    #D4BC7C;
  --gold-muted:    #B8975A;
  --gold-dim:      rgba(197, 165, 90, 0.15);
  --ivory:         #FAF6F0;
  --ivory-warm:    #F5EFE5;
  --ivory-deep:    #EDE5D8;
  --parchment:     #F0E9DC;
  --text-primary:  #2A2520;
  --text-body:     #3D3730;
  --text-muted:    #7A7265;
  --text-faint:    #A09888;
  --border-light:  #E0D8CC;
  --border-medium: #C8BFB0;
  --border-gold:   rgba(197, 165, 90, 0.3);
  --green:         #3A7D5C;
  --blue:          #3B6FA0;
  --amber:         #B8860B;
  --red:           #A0413A;
  --font-serif:    "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --font-sans:     "Noto Sans SC", "Source Han Sans SC", -apple-system, "Segoe UI", sans-serif;
  --shadow-sm:     0 1px 3px rgba(27, 42, 74, 0.06);
  --shadow-md:     0 4px 12px rgba(27, 42, 74, 0.08);
  --shadow-lg:     0 8px 24px rgba(27, 42, 74, 0.12);
  --sidebar-width: 280px;
}

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

/* ── 入场动画 ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes goldReveal {
  from { width: 0; }
  to { width: 60px; }
}

body {
  font-family: var(--font-sans);
  background-color: var(--ivory);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.008) 2px, rgba(0,0,0,0.008) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0,0,0,0.005) 2px, rgba(0,0,0,0.005) 4px);
  color: var(--text-body);
  line-height: 1.8;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* ── 侧边栏 ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy-dark);
  color: var(--ivory-deep);
  padding: 1.5rem 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  border-right: 1px solid rgba(197, 165, 90, 0.2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar::before {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: var(--gold);
  margin: 0 1.5rem 1.5rem;
}
.sidebar-close {
  display: none;
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  background: none;
  border: none;
  color: var(--gold-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  line-height: 1;
  z-index: 5;
}
.sidebar-close:hover { color: #fff; }

.nav-section { margin-bottom: 0.6rem; }
.nav-section-title {
  /* 全部板块标题统一为醒目的大字号 */
  padding: 0.55rem 1.5rem;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 1.2rem;
}

/* ── 可折叠板块（details/summary） ── */
.nav-collapsible {
  margin-bottom: 0.6rem;
}
.nav-collapsible > summary.nav-section-title {
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-left-color 0.15s;
}
.nav-collapsible > summary::-webkit-details-marker { display: none; }
.nav-collapsible > summary::marker { content: ''; }
.nav-collapsible > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.75rem;
  color: var(--gold-muted);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.nav-collapsible[open] > summary::before {
  transform: rotate(90deg);
  color: var(--gold);
}
.nav-collapsible > summary:hover {
  color: #fff;
  background: rgba(197, 165, 90, 0.08);
  border-left-color: rgba(197, 165, 90, 0.4);
}
.nav-collapsible[open] > summary {
  border-left-color: rgba(197, 165, 90, 0.25);
}
.nav-count {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  background: rgba(197, 165, 90, 0.15);
  color: var(--gold-muted);
  margin-left: auto;
}
.nav-collapsible > ul {
  margin-top: 0.3rem;
  margin-bottom: 0.3rem;
  animation: navFadeIn 0.18s ease;
}
@keyframes navFadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sidebar ul { list-style: none; }
.sidebar li a {
  display: block;
  padding: 0.35rem 1.5rem;
  color: var(--ivory-deep);
  text-decoration: none;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar li a:hover {
  background: rgba(197, 165, 90, 0.08);
  color: #fff;
  border-left-color: rgba(197, 165, 90, 0.3);
}
.sidebar li.active a {
  background: rgba(197, 165, 90, 0.12);
  color: var(--gold-light);
  border-left-color: var(--gold);
  font-weight: 500;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(197,165,90,0.2); border-radius: 2px; }

/* ── 手机端菜单按钮 + 遮罩 ── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  background: var(--navy);
  color: var(--gold);
  border: 1px solid rgba(197, 165, 90, 0.3);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  line-height: 1;
  transition: opacity 0.2s;
}
.sidebar-toggle:hover { background: var(--navy-light); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 48, 0.6);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open {
  display: block;
  opacity: 1;
}

/* ── 主内容（宽屏居中） ── */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2.5rem 3rem;
  max-width: 1100px;
  animation: fadeIn 0.4s ease both;
}
/* 宽屏居中：内容在 sidebar 右侧居中 */
@media (min-width: 1600px) {
  .content {
    margin-left: max(var(--sidebar-width), calc((100vw - 1100px) / 2));
  }
}

/* ── 页面头部（入场动画） ── */
.page-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  animation: fadeInUp 0.6s ease both;
}
.page-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--gold);
  animation: goldReveal 0.8s ease 0.3s both;
}
.page-header h1 {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 900;
  color: var(--navy);
  margin-top: 0.6rem;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.type-badge, .status-badge {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border-radius: 3px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: 0.5rem;
  letter-spacing: 0.03em;
}

.tags { margin-top: 0.6rem; }
.tag {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  background: var(--gold-dim);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--navy);
  margin-right: 0.35rem;
  font-weight: 500;
}

/* ── CSS Grid 双栏：文章 + 反向引用 ── */
.page-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  animation: fadeInUp 0.6s ease 0.15s both;
}
@media (min-width: 1024px) {
  .page-body {
    grid-template-columns: 1fr 260px;
  }
}
.backlinks-panel {
  align-self: start;
}
@media (min-width: 1024px) {
  .backlinks-panel {
    position: sticky;
    top: 2rem;
  }
}

/* ── 文章内容排版 ── */
article h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--navy);
  margin: 2.8rem 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}
article h2::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--gold);
}
article h3 {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--navy-light);
  margin: 2rem 0 0.6rem;
  padding-left: 0.75rem;
  border-left: 3px solid var(--gold);
}
article h4 {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--navy-light);
  margin: 1.5rem 0 0.5rem;
}
article p {
  margin-bottom: 0.9rem;
  text-align: justify;
}
article strong {
  color: var(--navy);
  font-weight: 700;
}
article ul, article ol { padding-left: 1.5rem; margin-bottom: 1.1rem; }
article li { margin-bottom: 0.35rem; line-height: 1.7; }
article ul > li::marker { color: var(--gold); }

article blockquote {
  border-left: 3px solid var(--gold);
  padding: 0.8rem 1.2rem;
  margin: 1.2rem 0;
  background: var(--ivory-warm);
  color: var(--text-muted);
  border-radius: 0 4px 4px 0;
  font-style: italic;
}
article hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-light) 15%, var(--gold) 50%, var(--gold-light) 85%, transparent);
  margin: 2.5rem 0;
}

/* ── 表格 ── */
.table-wrapper { overflow-x: auto; margin: 1.5rem 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
  box-shadow: var(--shadow-sm);
}
thead tr { background: var(--navy); }
th {
  color: #fff;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.65rem 0.9rem;
  text-align: left;
  border: none;
  letter-spacing: 0.03em;
}
td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
  border-left: none;
  border-right: none;
  color: var(--text-body);
}
tbody tr { transition: background 0.15s; }
tbody tr:nth-child(even) { background: rgba(197, 165, 90, 0.04); }
tbody tr:hover { background: var(--gold-dim); }
td:first-child { font-weight: 600; color: var(--navy); white-space: nowrap; }

/* ── Wiki-links ── */
.wiki-link {
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
  padding-bottom: 1px;
  font-weight: 500;
  transition: all 0.2s;
}
.wiki-link:hover {
  color: var(--gold-muted);
  background: var(--gold-dim);
}
.broken-link {
  color: var(--red);
  border-bottom: 1px dashed var(--red);
  cursor: help;
  opacity: 0.7;
}

/* ── 反向链接面板 ── */
.backlinks {
  padding: 1.2rem 1.5rem;
  background: var(--ivory-warm);
  border-radius: 6px;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--gold);
}
.backlinks h3 {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--navy);
  margin-bottom: 0.6rem;
  border: none;
  padding: 0;
}
.backlinks ul { list-style: none; padding: 0; }
.backlinks li { padding: 0.25rem 0; }
.backlinks li a {
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid var(--border-gold);
  transition: all 0.15s;
}
.backlinks li a:hover {
  color: var(--gold-muted);
  background: var(--gold-dim);
}

/* ── 滚动触发动画 ── */
.scroll-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.scroll-reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── 首页 ── */
.home-header {
  text-align: center;
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2.5rem;
  position: relative;
  animation: fadeInUp 0.6s ease both;
}
.home-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 2px;
  background: var(--gold);
  animation: goldReveal 0.8s ease 0.3s both;
}
.home-header h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 900;
  color: var(--navy);
  letter-spacing: 0.05em;
}
.subtitle {
  font-family: var(--font-serif);
  color: var(--text-muted);
  margin: 0.6rem 0 1.8rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.stats-bar {
  display: flex;
  gap: 2.5rem;
  justify-content: center;
  margin-top: 1.8rem;
}
.stat { text-align: center; }
.stat-num {
  display: block;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 900;
  color: var(--navy);
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.home-section { margin: 3rem 0; }
.home-section h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--navy);
  margin-bottom: 1.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}
.home-section h2::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--gold);
}
.home-section h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--navy-light);
  margin: 1.5rem 0 0.6rem;
}

/* ── 概念卡片（悬停上浮 + 金线） ── */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.85rem;
}
.concept-card {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 1rem;
  background: var(--ivory-warm);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text-body);
  border-left: 3px solid var(--gold);
  border-bottom: 2px solid transparent;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-bottom-color 0.3s ease, background 0.2s ease;
}
.concept-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-bottom-color: var(--gold);
  background: #fff;
}
.concept-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--navy);
}
.concept-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── 搜索 ── */
.search-box { position: relative; max-width: 480px; margin: 0 auto; }
#search-input {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  background: #fff;
  color: var(--text-body);
}
#search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.15);
}
#search-input::placeholder { color: var(--text-faint); }

#search-results {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  margin-top: 4px;
  display: none;
  max-height: 400px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-md);
}

.status-sm {
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  background: var(--gold-dim);
  border: 1px solid var(--border-gold);
  border-radius: 3px;
  color: var(--navy);
  font-weight: 500;
  margin-left: 0.3rem;
}

.page-footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.78rem;
  color: var(--text-faint);
  font-family: var(--font-serif);
  letter-spacing: 0.02em;
  animation: fadeIn 0.6s ease 0.3s both;
}

li.task { list-style: none; margin-left: -1.5rem; }
li.task.done { opacity: 0.7; }

/* ── 平板端 ── */
@media (max-width: 1024px) {
  .page-body { grid-template-columns: 1fr; }
  .backlinks-panel { position: static; }
}

/* ── 手机端 ── */
@media (max-width: 768px) {
  .sidebar-toggle { display: block; }
  .sidebar-close { display: block; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  .content {
    margin-left: 0;
    padding: 1.5rem 1rem;
    padding-top: 3.5rem;
  }
  .page-body { grid-template-columns: 1fr; }
  .backlinks-panel { position: static; }
  .stats-bar { flex-wrap: wrap; gap: 1.2rem; }
  .page-header h1 { font-size: 1.5rem; }
  .home-header h1 { font-size: 1.6rem; }
  .home-header { padding-top: 1rem; }
  .concept-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ── 打印 ── */
@media print {
  body { background: #fff; }
  .sidebar, .sidebar-toggle, .sidebar-overlay { display: none !important; }
  .content { margin-left: 0; max-width: 100%; padding: 0; }
  .page-body { grid-template-columns: 1fr; }
  thead tr { background: #eee; }
  th { color: #000; }
  table { box-shadow: none; }
  .page-header::after, article h2::before { display: none; }
  .scroll-reveal { opacity: 1; transform: none; }
}
