/* ============================================
 * 多多量化 - 文章页样式 (与前端 ArticleView.vue 保持一致)
 * ============================================ */

/* ==================== 1. CSS Variables ==================== */
:root {
  /* 品牌色 */
  --brand: #409EFF;
  --brand-light: #79bbff;
  --brand-dark: #337ecc;
  /* 语义色 */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  /* 文字色 */
  --text-primary: #111827;
  --text-secondary: #475569;
  --text-tertiary: #64748B;
  --text-inverse: #FFFFFF;
  /* 背景色 */
  --bg-page: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-secondary: #F1F5F9;
  --bg-card-hover: #F8FAFC;
  /* 边框色 */
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --border-dark: #D1D5DB;
  /* 阴影 */
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.04), 0 2px 4px rgba(15, 23, 42, 0.03);
  /* 圆角 */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  /* 字体 */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  /* 移动端 */
  --mobile-nav-toggle-size: 32px;
  --font-xs: 12px;
  --font-sm: 14px;
  --font-base: 15px;
  --font-md: 16px;
  --font-lg: 18px;
  --font-xl: 22px;
  --font-2xl: 26px;
  /* 行高 */
  --lh-tight: 1.3;
  --lh-base: 1.5;
  --lh-loose: 1.6;
  --lh-article: 1.8;
}

/* ==================== 2. Base ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-family);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==================== 3. Skip Link (Accessibility) ==================== */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--brand);
  color: #fff;
  padding: 8px 16px;
  z-index: 100;
  text-decoration: none;
  font-size: var(--font-sm);
  border-radius: 0 0 var(--radius-sm) 0;
  transition: top 0.3s;
}
.skip-link:focus { top: 0; }

/* ==================== 4. Layout ==================== */
.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
main.container { padding-bottom: var(--space-8); }

/* ==================== 5. Header ==================== */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-4) 0;
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-logo {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
  transition: color 0.2s;
}
.site-logo:hover { color: var(--brand-dark); }
.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  margin-left: var(--space-4);
  font-size: var(--font-sm);
  transition: color 0.2s;
}
.site-nav a:hover { color: var(--brand); }

/* ==================== 6. Breadcrumb ==================== */
.breadcrumb {
  font-size: var(--font-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
}
.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.breadcrumb a:hover { color: var(--brand); }
.breadcrumb span { margin: 0 var(--space-1); color: var(--text-tertiary); }

/* ==================== 7. Article Card ==================== */
.article-card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.article-card:hover { box-shadow: var(--shadow-md); }

/* ==================== 8. Article Title ==================== */
.article-title {
  font-size: var(--font-2xl);
  font-weight: 700;
  line-height: var(--lh-tight);
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

/* ==================== 9. Article Meta ==================== */
.article-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--font-sm);
  color: var(--text-tertiary);
  flex-wrap: wrap;
}
.article-meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  line-height: 1;
  vertical-align: middle;
}
.article-meta a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
.article-meta a:hover { color: var(--brand); }
.like-btn { cursor: pointer; user-select: none; transition: color 0.2s; }
.like-btn:hover { color: var(--danger); }
.like-btn.liked { color: var(--danger); }

/* ==================== 10. Article Content (md-preview) ==================== */
.article-content {
  font-family: var(--font-family);
  font-size: var(--font-md);
  line-height: var(--lh-article);
  color: var(--text-primary);
  word-break: break-word;
}

/* Headings */
.article-content h1 {
  font-size: var(--font-2xl);
  margin: var(--space-8) 0 var(--space-4);
  font-weight: 700;
  line-height: var(--lh-tight);
  color: var(--text-primary);
}
.article-content h2 {
  font-size: var(--font-xl);
  margin: var(--space-6) 0 var(--space-3);
  font-weight: 700;
  line-height: 1.35;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}
.article-content h3 {
  font-size: var(--font-lg);
  margin: var(--space-6) 0 var(--space-3);
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}
.article-content h4 {
  font-size: var(--font-md);
  margin: var(--space-5) 0 var(--space-2);
  font-weight: 600;
  line-height: 1.45;
  color: var(--text-primary);
}

/* Paragraphs */
.article-content p { margin: var(--space-2) 0; }

/* Lists */
.article-content ul, .article-content ol {
  padding-left: var(--space-6);
  margin: var(--space-2) 0;
}
.article-content li { margin: var(--space-1) 0; }

/* Links */
.article-content a {
  color: var(--brand-dark);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.article-content a:hover { border-bottom-color: var(--brand-dark); }

/* Strong */
.article-content strong { font-weight: 700; }

/* Blockquote */
.article-content blockquote {
  border-left: 3px solid var(--brand-dark);
  padding: var(--space-2) var(--space-4);
  margin: var(--space-3) 0;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Code */
.article-content code {
  background: var(--bg-secondary);
  padding: 2px var(--space-1);
  border-radius: var(--radius-sm);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: var(--font-sm);
  color: var(--danger);
}
.article-content pre {
  background: var(--text-primary);
  color: var(--bg-secondary);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: var(--space-3) 0;
  line-height: 1.6;
}
.article-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: var(--font-xs);
}

/* Images */
.article-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: var(--space-3) 0;
  height: auto;
}

/* Tables */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-4) 0;
  font-size: var(--font-base);
  line-height: 1.6;
  border-radius: var(--radius);
  overflow: hidden;
  table-layout: fixed;
}
.article-content th {
  background: var(--bg-secondary);
  font-weight: 600;
  text-align: left;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  font-size: var(--font-sm);
}
.article-content td {
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  word-break: break-word;
}
.article-content tr:nth-child(even) td { background: var(--bg-secondary); }
.article-content tr:hover td { background: var(--bg-card-hover); }
/* 表格列宽控制：第1列（细分赛道/风险分类）150px，最后两列（催化等级/兑现周期/风险等级/冲击维度）90px */
.article-content th:first-child,
.article-content td:first-child { width: 150px !important; min-width: 150px; }
.article-content th:nth-last-child(2),
.article-content td:nth-last-child(2),
.article-content th:last-child,
.article-content td:last-child { width: 120px !important; min-width: 120px; }

/* 表格横向滚动容器（新文章由 HTML 生成器自动包裹） */
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-4) 0;
}
.table-scroll-wrapper table { margin: 0; }

/* HR */
.article-content hr {
  border: none;
  height: 1px;
  background: var(--border-light);
  margin: var(--space-6) 0;
}

/* ==================== 11. Article Footer ==================== */
.article-footer {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  line-height: 1.8;
}
.article-footer p { margin: var(--space-1) 0; }
.article-footer a {
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.2s;
}
.article-footer a:hover { color: var(--brand); }

/* ==================== 12. Share Bar ==================== */
.share-bar {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.share-bar a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--font-sm);
  transition: all 0.2s;
  border: 1px solid var(--border-light);
}
.share-bar a:hover {
  background: var(--brand);
  color: var(--text-inverse);
  border-color: var(--brand);
}

/* ==================== 13. Related Articles ==================== */
.related-articles { margin-top: var(--space-6); }
.related-articles h3 {
  font-size: var(--font-lg);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}
.related-articles ul { list-style: none; padding: 0; }
.related-articles li { margin: var(--space-2) 0; }
.related-articles a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--font-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: color 0.2s;
}
.related-articles a:hover { color: var(--brand); }
.related-articles a::before {
  content: "•";
  color: var(--brand);
}

/* ==================== 14. Site Footer ==================== */
.site-footer {
  text-align: center;
  padding: var(--space-6) 0;
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-4);
  background: var(--bg-surface);
}
.site-footer a {
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.2s;
}
.site-footer a:hover { color: var(--brand); }

/* ==================== 15. Nav Toggle (Mobile) ==================== */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: var(--font-xl);
  color: var(--text-primary);
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
  width: var(--mobile-nav-toggle-size);
  height: var(--mobile-nav-toggle-size);
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.nav-toggle:hover { background: var(--bg-secondary); }

/* ==================== 16. Mobile Responsive ==================== */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .site-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
    margin-top: var(--space-3);
    padding: var(--space-2) 0;
  }
  .site-nav.open { display: flex; }
  .site-nav a {
    margin-left: 0;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
  }
  .site-nav a:hover { background: var(--bg-secondary); }
  .site-header .container { flex-wrap: wrap; }
  .container { padding: var(--space-3); }
  .article-card { padding: var(--space-4); border-radius: var(--radius-sm); }
  .article-title { font-size: var(--font-xl); }
  .article-meta { font-size: var(--font-xs); gap: var(--space-2); }
  .share-bar { gap: var(--space-1); }
  .share-bar a { padding: var(--space-1) var(--space-2); font-size: var(--font-xs); }

  /* 🔧 移动端表格适配：横向滚动，不变形
     - display:block + overflow-x:auto 让表格本身成为可滚动容器
     - table-layout:auto 让列宽按内容自适应
     - 取消固定列宽，让表格自然撑开后横向滚动
     - 对已有文章（无 wrapper）和新文章（有 wrapper）都生效 */
  .article-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    table-layout: auto;
    white-space: nowrap;
    width: max-content;
    max-width: 100%;
    font-size: var(--font-xs);
  }
  /* 移动端取消固定列宽 */
  .article-content th:first-child,
  .article-content td:first-child,
  .article-content th:nth-last-child(2),
  .article-content td:nth-last-child(2),
  .article-content th:last-child,
  .article-content td:last-child {
    width: auto !important;
    min-width: auto;
  }
  /* 有 wrapper 的新文章：wrapper 负责滚动，table 恢复正常显示 */
  .table-scroll-wrapper table {
    display: table;
    width: max-content;
    max-width: none;
  }
}

/* ==================== 17. Print ==================== */
@media print {
  .site-header, .site-footer, .breadcrumb, .share-bar, .related-articles { display: none; }
  .article-card { border: none; box-shadow: none; }
  body { background: #fff; }
}