/*
 * 文献表格通用样式（所有 source 共用）。
 *
 * 用法：把表格 HTML 包在 <div class="fig-table fig-table-{source}"> 中，再按 source 追加
 * {source}.css。同一份文件供三处使用，保持缩略图与全屏 HTML 观感一致：
 *   - Web 前端（index.html 直接 <link>）
 *   - 渲染服务 render/poster_server.py（release.sh 拷贝到 /root/render/table_css/）
 *   - iOS / Android / HarmonyOS 的表格 WebView（运行时拉取 + 缓存，失败回退内置）
 *
 * 颜色全部走 --ft-* 变量，宿主可在 .fig-table 上覆盖（如深色主题）。
 * 每条带背景的规则都同时写 color，避免宿主深色文字色叠在浅底上不可读。
 */

.fig-table {
  --ft-bg: #ffffff;
  --ft-text: #1f2a37;
  --ft-heading: #162233;
  --ft-border: #d8e1ea;
  --ft-border-strong: #6b7a90;
  --ft-header-bg: #eef3f9;
  --ft-stripe: #f7faff;
  --ft-accent: #2b5797;
  --ft-accent-fg: #ffffff;
  --ft-accent-soft: #dfe8f3;
  --ft-accent-soft-fg: #162233;
  --ft-muted-bg: #f1f3f5;
  --ft-muted-bg-strong: #dee2e6;
  --ft-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  --ft-font-size: 15px;
  --ft-line-height: 1.45;
  --ft-cell-padding: 8px 12px;

  color: var(--ft-text);
  font-family: var(--ft-font);
  font-size: var(--ft-font-size);
  line-height: var(--ft-line-height);
}

.fig-table table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: auto;
  margin: 0;
  background: var(--ft-bg);
  color: inherit;
  font: inherit;
  line-height: inherit;
}

.fig-table th,
.fig-table td {
  padding: var(--ft-cell-padding);
  border: 1px solid var(--ft-border);
  vertical-align: top;
  text-align: left;
  font-size: inherit;
  line-height: inherit;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.fig-table th {
  background: var(--ft-header-bg);
  color: var(--ft-heading);
  font-weight: 700;
}

.fig-table thead th,
.fig-table thead td {
  border-bottom: 2px solid var(--ft-border-strong);
}

/* 无 thead 的表把首行当表头；uptodate 自带 subtitle 分区语义，不套这条 */
.fig-table:not(.fig-table-uptodate) table:not(:has(thead)) > tbody > tr:first-child > td,
.fig-table:not(.fig-table-uptodate) table:not(:has(thead)) > tr:first-child > td {
  background: var(--ft-header-bg);
  color: var(--ft-heading);
  font-weight: 700;
}

.fig-table colgroup,
.fig-table col {
  max-width: none;
}

.fig-table p {
  margin: 0;
  font: inherit;
  line-height: inherit;
}

.fig-table p + p {
  margin-top: 6px;
}

.fig-table ul,
.fig-table ol {
  margin: 0;
  padding-left: 1.3em;
  list-style-position: outside;
}

.fig-table li {
  margin: 0;
  line-height: inherit;
}

.fig-table li + li {
  margin-top: 4px;
}

.fig-table sup,
.fig-table sub {
  font-size: 0.72em;
  line-height: 0;
}

.fig-table br {
  line-height: inherit;
}

.fig-table img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.fig-table hr {
  border: 0;
  border-top: 1px solid var(--ft-border);
  margin: 4px 0;
}

/* 通用 HTML 对齐属性（pubmed JATS / 历史 HTML 常见） */
.fig-table [align="center"] { text-align: center; }
.fig-table [align="right"] { text-align: right; }
.fig-table [align="left"] { text-align: left; }
.fig-table [valign="middle"] { vertical-align: middle; }
.fig-table [valign="bottom"] { vertical-align: bottom; }
