/* ============================================================
   FengInvest 研究库 · 公共站增量样式
   基础：fengweb/public/css/tokens.css + style.css（构建时拷贝）
   本文件只加公共站独有的版块与阅读器控件，不改设计令牌。
   ============================================================ */

/* ---------- 阅读进度 ---------- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 300;
  transition: transform .08s linear;
  pointer-events: none;
}

/* ---------- 侧栏 ---------- */
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.sidebar-logo { color: var(--sidebar-text); text-decoration: none; font-weight: 600; letter-spacing: .02em; }
.sidebar-logo img { width: 26px; height: 26px; border-radius: 6px; }
.sidebar-foot {
  margin-top: auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
  color: var(--sidebar-text);
  opacity: .6;
  font-size: var(--fs-xs);
  line-height: 1.7;
}

/* ---------- 顶栏 ---------- */
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 16px;
}
.icon-link:hover { background: var(--bg-inset); color: var(--text); }
.theme-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.theme-btn:hover { background: var(--bg-inset); color: var(--text); }
.theme-btn svg, .icon-link svg { display: block; }

/* ---------- 首页 ---------- */
.hero {
  padding: var(--space-8) 0 var(--space-7);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-7);
}
.hero-kicker {
  font-size: var(--fs-xxs);
  letter-spacing: .18em;
  color: var(--text-faint);
  margin-bottom: var(--space-3);
}
.hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.2;
  letter-spacing: -.01em;
  margin-bottom: var(--space-4);
}
.hero > p:not(.hero-kicker):not(.philosophy-links) {
  max-width: 40em;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1.85;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-5); }

.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.entry-card {
  display: block;
  padding: var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.entry-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: var(--border-strong);
  text-decoration: none;
}
.ec-label { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.ec-desc { font-size: var(--fs-small); color: var(--text-muted); line-height: 1.65; }
.ec-count { font-size: var(--fs-xs); color: var(--text-faint); margin-top: var(--space-3); }

.section-block { margin-bottom: var(--space-8); }
.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-h3);
  font-weight: 600;
  margin-bottom: var(--space-3);
}
.section-count {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-weight: 400;
  background: var(--bg-inset);
  border-radius: 999px;
  padding: 1px 8px;
}
.section-desc { color: var(--text-muted); font-size: var(--fs-small); margin-bottom: var(--space-4); max-width: 46em; }

.philosophy-card { padding: var(--space-6); margin-top: var(--space-4); }
.philosophy-card p { color: var(--text-secondary); line-height: 1.9; margin-bottom: var(--space-3); }
.philosophy-links { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--fs-small); }

/* ---------- 报告行 ---------- */
.report-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.report-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background .12s ease;
}
.report-row:hover { background: var(--bg-inset); text-decoration: none; }
.rr-main { min-width: 0; }
.rr-title { font-weight: 600; font-size: 16px; line-height: 1.5; }
.rr-ticker { color: var(--text-faint); font-weight: 400; font-size: var(--fs-small); font-family: var(--font-serif); }
.rr-summary {
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: 1.65;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rr-meta { display: flex; align-items: center; gap: var(--space-3); flex: 0 0 auto; }
.rr-date, .rr-market { color: var(--text-faint); font-size: var(--fs-xs); white-space: nowrap; }
.report-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--fs-small);
  margin-top: var(--space-2);
}

/* ---------- 知识条目 ---------- */
.entry-list { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.entry-item {
  display: block;
  padding: var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background .12s ease;
}
.entry-item:hover { background: var(--bg-inset); text-decoration: none; }
.entry-title { font-weight: 600; font-size: 15px; }
.entry-preview { color: var(--text-muted); font-size: var(--fs-small); line-height: 1.65; margin-top: 3px; }
.entry-meta { color: var(--text-faint); font-size: var(--fs-xs); margin-top: var(--space-2); }

/* ---------- 页头与筛选 ---------- */
.page-header { margin-bottom: var(--space-6); }
.page-title { font-size: var(--fs-h1); line-height: 1.3; margin: var(--space-2) 0 var(--space-2); }
.page-sub { color: var(--text-muted); font-size: var(--fs-small); line-height: 1.75; max-width: 48em; }
.page-ticker { font-size: var(--fs-small); color: var(--text-faint); font-weight: 400; font-family: var(--font-serif); }
.breadcrumb { font-size: var(--fs-xs); color: var(--text-faint); }
.breadcrumb a { color: var(--text-muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-5); }
.chip {
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: var(--fs-xs);
  font-family: inherit;
  transition: all .12s ease;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  font-size: var(--fs-small);
  color: var(--text-muted);
  margin-top: var(--space-3);
}
.meta-label { color: var(--text-faint); font-size: var(--fs-xs); margin-right: 6px; }

/* ---------- 阅读器 ---------- */
.reader-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.reader-tools button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-family: inherit;
  font-size: var(--fs-xs);
}
.reader-tools button:hover { border-color: var(--border-strong); color: var(--text); }
.page-header { position: relative; }
.page-header .reader-tools { position: absolute; right: 0; bottom: 0; }

/* 字号（CSS 变量之外单独覆盖正文） */
html[data-fs="s"] .md-content { font-size: 15px; }
html[data-fs="l"] .md-content { font-size: 18px; }
html[data-fs="s"] .report-reader .md-content p,
html[data-fs="s"] .report-reader .md-content li { font-size: 15px; }
html[data-fs="l"] .report-reader .md-content p,
html[data-fs="l"] .report-reader .md-content li { font-size: 18px; }

.toc-card { padding: var(--space-4) var(--space-5); margin-bottom: var(--space-5); }
.toc-card summary {
  cursor: pointer;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
}
.toc-card summary::-webkit-details-marker { display: none; }
.toc-card summary::before { content: "▸ "; color: var(--text-faint); }
.toc-card[open] summary::before { content: "▾ "; }
.toc-list {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-3);
  padding-left: var(--space-2);
  border-left: 1px solid var(--border);
}
.toc-list a {
  display: block;
  padding: 3px 0 3px var(--space-3);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--text-muted);
  text-decoration: none;
}
.toc-list a:hover { color: var(--accent); }
.toc-list a.toc-l3 { padding-left: var(--space-6); font-size: var(--fs-xs); }

/* 正文里的锚点偏移，防被顶栏遮住 */
.md-content :is(h1, h2, h3, h4) { scroll-margin-top: 80px; }

.prev-next {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-small);
}
.prev-next a { color: var(--text-muted); text-decoration: none; max-width: 48%; }
.prev-next a:hover { color: var(--accent); }
.prev-next a span { display: block; color: var(--text-faint); font-size: var(--fs-xs); }
.pn-right { text-align: right; margin-left: auto; }

.page-disclaimer {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--fs-xs);
  line-height: 1.7;
}

/* ---------- 搜索 ---------- */
.search-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results { margin-top: var(--space-5); }
.search-hint { color: var(--text-faint); font-size: var(--fs-small); }
.search-item { display: block; padding: var(--space-4) 0; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.search-item:hover { text-decoration: none; }
.search-item .si-title { font-weight: 600; font-size: 15px; }
.search-item .si-cat { color: var(--text-faint); font-size: var(--fs-xs); margin-left: var(--space-2); }
.search-item .si-excerpt { color: var(--text-muted); font-size: var(--fs-small); line-height: 1.65; margin-top: 3px; }
.search-item mark { background: var(--accent-soft); color: var(--text); border-radius: 2px; padding: 0 1px; }

/* ---------- 页脚 ---------- */
.site-footer {
  padding: var(--space-6) 0 calc(var(--space-6) + 56px);
  color: var(--text-faint);
  font-size: var(--fs-xs);
  line-height: 1.8;
}
.site-footer p { margin-bottom: var(--space-2); }
.site-footer a { color: var(--text-muted); }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  .hero { padding: var(--space-6) 0 var(--space-5); }
  .hero h1 { font-size: 30px; }
  .hero > p:not(.hero-kicker):not(.philosophy-links) { font-size: 15px; }
  .entry-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .entry-card { padding: var(--space-4); }
  .report-row { padding: var(--space-3) var(--space-1); gap: var(--space-2); }
  .rr-summary { -webkit-line-clamp: 3; }
  .rr-meta { flex-direction: column; align-items: flex-end; gap: 4px; }
  .page-header .reader-tools { position: static; margin-top: var(--space-3); }
  .prev-next { flex-direction: column; }
  .prev-next a { max-width: 100%; }
  .pn-right { text-align: left; margin-left: 0; }
  .philosophy-card { padding: var(--space-5); }
}
@media (max-width: 420px) {
  .entry-grid { grid-template-columns: 1fr; }
}

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .topbar, .bottom-nav, .progress-bar, .reader-tools,
  .toc-card, .prev-next, .site-footer, .chip-row { display: none !important; }
  .layout, .main-content { display: block; margin: 0; padding: 0; max-width: none; }
  .card, .report-reader { border: 0; box-shadow: none; padding: 0; background: #fff; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .md-content a { color: #000; text-decoration: underline; }
  .md-content h2, .md-content h3 { page-break-after: avoid; }
  .md-content table { page-break-inside: avoid; }
}

/* 打印时展开目录无所谓；减少动画 */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* 侧栏 logo：标题加「投资库」字样后容易换行，锁死单行并收一点字号 */
.sidebar-logo {
  font-size: 16px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-logo span { font-size: 16px; }

/* 侧栏加到 240px：logo 与关闭按钮之间留呼吸感（原 220px 偏挤） */
.sidebar { width: 240px; }
@media (min-width: 769px) {
  .main-content.sidebar-open {
    margin-left: calc(240px + max(0px, (100% - 240px - 1200px) / 2));
  }
}
