/* components.css — 顶栏、导航、按钮、卡片、PDF、思维导图、模态框、文档排版 */

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--hairline);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  background: var(--accent);
  color: var(--accent-inv);
  border-radius: 6px;
  font-family: var(--font-serif);
  font-size: 15px;
}
.brand-text { display: inline-flex; align-items: baseline; gap: 8px; }
.brand-text .en {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--fg-faint);
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.control:hover {
  background: var(--bg-raised);
  border-color: var(--accent);
}
.caret { font-size: 10px; color: var(--fg-faint); }

/* ---------- 标签页 ---------- */
.tabs {
  position: relative;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  flex-shrink: 0;
  padding: 10px 16px 12px;
  font-size: 14px;
  color: var(--fg-dim);
  white-space: nowrap;
  transition: color var(--dur) var(--ease);
}
.tab:hover { color: var(--fg); text-decoration: none; }
.tab.is-active { color: var(--accent); font-weight: 600; }

.tab-underline {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  transition: left var(--dur) var(--ease), width var(--dur) var(--ease);
}

/* ---------- 下拉菜单 ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  max-width: calc(100vw - 16px);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 6px;
  z-index: 60;
}
.dropdown-scroll { min-width: 260px; }
.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--fg);
}
.dropdown-item:hover { background: var(--accent-soft); }
.dropdown-item .item-name { font-weight: 600; }
.dropdown-item .sub {
  color: var(--fg-faint);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.dropdown-item .dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- 视图头 ---------- */
.view-header {
  padding: 40px 0 8px;
}
.kicker {
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 8px;
}
.hero-title {
  font-size: 30px;
  margin: 0 0 8px;
}
.hero-sub {
  color: var(--fg-dim);
  font-size: 15px;
  max-width: 60ch;
}

/* ---------- 统计格 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 24px 0 8px;
}
.stat-cell {
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
}
.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-serif);
  color: var(--accent);
}
.stat-label { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }

/* ---------- 区块 ---------- */
.section { margin: 34px 0; }
.section-head { margin-bottom: 14px; }
.section-title {
  font-size: 20px;
  margin: 0 0 2px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.section-sub { color: var(--fg-faint); font-size: 13px; margin: 0; }

/* ---------- 返回链接 ---------- */
.back-link {
  display: inline-block;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--fg-dim);
  padding: 4px 0;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-inv);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur);
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.btn:active { transform: none; }
.btn-ghost {
  color: var(--accent);
  background: transparent;
}
.btn-ghost:hover { background: var(--accent-soft); }
.btn-xs { padding: 4px 10px; font-size: 12px; }

/* ---------- 操作条 ---------- */
.actbar {
  display: inline-flex;
  gap: 4px;
  margin-left: 4px;
  vertical-align: -2px;
}
.act-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  font-size: 14px;
  color: var(--fg-faint);
  transition: transform var(--dur) var(--ease), color var(--dur);
}
.act-btn:hover { transform: scale(1.2); color: var(--accent); }
.act-btn.on { color: var(--accent); }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  vertical-align: 1px;
}

/* ---------- PDF 行 ---------- */
.pdf-list { margin-top: 18px; }
.pdf-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.pdf-row:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-card);
}
.pdf-icon {
  flex-shrink: 0;
  font-size: 22px;
  width: 42px; height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border-radius: 8px;
}
.pdf-main { flex: 1; min-width: 0; }
.pdf-title {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--fg-faint);
}
.pdf-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- 文档阅读 ---------- */
.doc {
  padding: 8px 0 60px;
}
.doc-head {
  padding: 28px 0 16px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 22px;
}
.doc-title {
  font-size: 26px;
  margin: 0 0 8px;
}
.doc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-faint);
}
.doc-body {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.9;
  word-break: break-word;
}

/* ---------- Markdown 正文 ---------- */
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
  margin: 1.6em 0 0.6em;
  line-height: 1.4;
}
.md h1 { font-size: 24px; padding-bottom: 8px; border-bottom: 1px solid var(--hairline); }
.md h2 { font-size: 21px; color: var(--accent); }
.md h3 { font-size: 18px; }
.md p { margin: 0.9em 0; }
.md ul, .md ol { padding-left: 1.6em; margin: 0.9em 0; }
.md li { margin: 0.3em 0; }
.md li.sub { margin-left: 1.4em; }
.md blockquote {
  margin: 1em 0;
  padding: 0.6em 1.1em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  color: var(--fg-dim);
}
.md code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 5px;
}
.md pre {
  margin: 1em 0;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow-x: auto;
}
.md pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
}
.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13.5px;
  font-family: var(--font-sans);
}
.md th, .md td {
  border: 1px solid var(--border);
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
}
.md th { background: var(--bg); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--hairline); margin: 1.6em 0; }
.md a { color: var(--accent); text-decoration: underline; }
.md input[type="checkbox"] { margin-right: 6px; vertical-align: -1px; }

/* ---------- 思维导图树 ---------- */
.mindmap {
  margin: 18px 0;
  padding: 6px 4px 24px;
}
.mm-root {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mm-children {
  list-style: none;
  margin: 0;
  padding-left: 26px;
  border-left: 1px dashed var(--border);
}
.mm-children.collapsed { display: none; }
.mm-node {
  position: relative;
  padding: 5px 0;
}
.mm-node.has-child > .mm-text {
  font-weight: 600;
}
.mm-lv0 { font-size: 18px; }
.mm-lv1 { font-size: 16px; }
.mm-lv2 { font-size: 15px; }
.mm-lv3, .mm-lv4, .mm-lv5 { font-size: 14px; }
.mm-text {
  display: inline-block;
  padding: 4px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  line-height: 1.5;
  word-break: break-word;
}
.mm-node.has-child > .mm-text {
  border-color: var(--border);
}
.mm-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  margin-right: 6px;
  font-size: 12px;
  line-height: 1;
  background: var(--accent);
  color: var(--accent-inv);
  border: none;
  border-radius: 4px;
}
.mm-toggle:hover { opacity: 0.85; }

/* ---------- 模态框（可视化） ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: arc-fade 0.25s var(--ease);
}
.modal-box {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1080px;
  height: 88vh;
  background: var(--bg-raised);
  border-radius: 12px;
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}
.modal-title {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--fg-dim);
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--accent-soft); color: var(--accent); }
.modal-open-new { flex-shrink: 0; padding: 5px 12px; }
.modal-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}
body.modal-open { overflow: hidden; }
