/* =============================================================================
   配色令牌（只有变量，没有任何组件规则）

   抽出来的原因：模板族各自带一份 CSS，如果颜色变量也跟着族复制，12 套主题
   就要维护 12 × 6 份；而颜色变量本身不构成结构指纹，共用是安全的。

   取值链路：模板 <html data-theme="{theme}"> ← themes.yaml（或 prefix 散列兜底）。
   :root 兜底 jade，同时兼容「老 HTML 没有 data-theme 属性」的缓存页。
   ========================================================================== */
:root,
[data-theme="jade"] {
  --bg: #f6f7f9; --surface: #ffffff; --surface-soft: #f7f9f8;
  --accent: #1a7f64; --accent-deep: #146a53; --accent-soft: #eef6f2;
  --border: #e4e7eb; --border-soft: #eceff2;
  --text: #24292f; --text-2: #3d4650; --text-3: #5a6470; --text-4: #6b7480; --muted: #98a1ab;
  --warn: #8c5b53; --warn-border: #cf8a80; --warn-bg: #fdf8f7; --warn-line: #eddcd8;
}
[data-theme="rose"] {
  --bg: #fbf6f7; --surface: #fffdfd; --surface-soft: #fdf2f4;
  --accent: #c0455f; --accent-deep: #a33350; --accent-soft: #fbeef1;
  --border: #f0e2e5; --border-soft: #f5eaec;
}
[data-theme="ocean"] {
  --bg: #f5f8fb; --surface: #ffffff; --surface-soft: #edf4fa;
  --accent: #1f6fb2; --accent-deep: #17588f; --accent-soft: #e9f2fa;
  --border: #dfe7ef; --border-soft: #e9eff5;
}
[data-theme="amber"] {
  --bg: #fbf8f2; --surface: #fffdf9; --surface-soft: #faf1e0;
  --accent: #b8791b; --accent-deep: #96600f; --accent-soft: #faf1e0;
  --border: #eee4d1; --border-soft: #f4ecdd;
}
[data-theme="violet"] {
  --bg: #f8f6fc; --surface: #ffffff; --surface-soft: #f3eefa;
  --accent: #7a5bb5; --accent-deep: #64489c; --accent-soft: #f1ecf9;
  --border: #e6e0f0; --border-soft: #eeeafa;
}
[data-theme="slate"] {
  --bg: #f6f8fa; --surface: #ffffff; --surface-soft: #eef2f6;
  --accent: #4a5f78; --accent-deep: #3a4b60; --accent-soft: #edf1f5;
  --border: #dfe5ec; --border-soft: #e9eef3;
}
[data-theme="teal"] {
  --bg: #f4fafa; --surface: #ffffff; --surface-soft: #eaf6f6;
  --accent: #0f8a8a; --accent-deep: #0a6d6d; --accent-soft: #e6f5f5;
  --border: #d9eaea; --border-soft: #e6f2f2;
}
[data-theme="clay"] {
  --bg: #fbf7f4; --surface: #fffdfc; --surface-soft: #f9ece3;
  --accent: #b05730; --accent-deep: #93431f; --accent-soft: #f9ece3;
  --border: #efe0d5; --border-soft: #f5eade;
}
[data-theme="moss"] {
  --bg: #f8faf3; --surface: #fffefb; --surface-soft: #f1f6e6;
  --accent: #5d7a2a; --accent-deep: #4a641e; --accent-soft: #f0f5e3;
  --border: #e3e9d4; --border-soft: #eef2e2;
}
[data-theme="indigo"] {
  --bg: #f6f7fd; --surface: #ffffff; --surface-soft: #eff1fc;
  --accent: #3f4bb0; --accent-deep: #323b92; --accent-soft: #eceefb;
  --border: #dfe1f0; --border-soft: #e9ebf7;
}
[data-theme="sand"] {
  --bg: #faf8f4; --surface: #fffdfb; --surface-soft: #f7f1e7;
  --accent: #8a6a3f; --accent-deep: #715431; --accent-soft: #f6efe4;
  --border: #ebe2d5; --border-soft: #f2ebdf;
}
[data-theme="cherry"] {
  --bg: #fdf6fa; --surface: #ffffff; --surface-soft: #fbedf5;
  --accent: #b84a8a; --accent-deep: #9a3971; --accent-soft: #fbedf5;
  --border: #f2dfe9; --border-soft: #f7e9f1;
}

/* =============================================================================
   主域图文增强（.fam-*）

   只出现在三个主域（prefix 为空）的列表页与正文页，由 PageService._root_visuals
   输出；子域页面的 DOM 里根本没有这些节点，所以这里的样式不会波及其他站。

   theme.css 在所有族 CSS 之前加载，`.dir-page img { height:auto }` 这类族规则
   特异性是 (0,1,1)，会把缩略图的 height:100% 顶掉——统一加 `body` 前缀压回去。
   ========================================================================== */

/* 列表缩略图：固定比例，裁切不变形 */
body .fam-thumb {
  display: block; flex: 0 0 auto; width: 132px; aspect-ratio: 16 / 10;
  border-radius: 9px; overflow: hidden; background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}
body .fam-thumb img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform .45s cubic-bezier(.2, .7, .3, 1);
}
body .dir-li.has-thumb:hover .fam-thumb img,
body .table-row:hover .fam-thumb img { transform: scale(1.045); }

/* 目录型：一行从「标题 + 日期」升级成「缩略图 + 标题 + 日期」 */
body .dir-list.is-roomy .dir-li.has-thumb {
  display: grid; grid-template-columns: 132px minmax(0, 1fr) auto;
  align-items: center; gap: 18px; padding: 13px 0;
}
body .dir-li.has-thumb .dir-link { font-size: 16px; line-height: 1.5; }
body .dir-li.has-thumb .dir-date { align-self: center; }

/* 清单型：条目格里并排缩略图与标题。
   带缩略图后「条目」列内容变宽，窄屏会把「更新」列挤成一个字宽（表头竖排）。
   给日期列一个下限，日期用 nowrap 顶住。:has 只命中主域这些行。 */
body .table-tbl:has(.fam-thumb) thead th:last-child { width: 118px; }
/* flex 必须落在 td 的内层 wrapper 上：直接把 td 改成 display:flex 会剥夺它的
   table-cell 身份，td 只剩第一列宽——「更新」列变成旁边一条空白，日期永远
   对不齐表头。td 自己保持 table-cell，行内布局交给 .table-cell-in。 */
body .table-cell.has-thumb .table-cell-in { display: flex; align-items: center; gap: 16px; }
body .table-cell.has-thumb .fam-thumb { width: 132px; }
body .table-cell.has-thumb a { font-size: 15px; line-height: 1.6; flex: 1 1 auto; min-width: 0; }

/* 正文首图 */
body .fam-lead { margin: 20px 0 28px; }
body .fam-lead img {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 14px; background: var(--surface-soft);
  box-shadow: 0 18px 40px -32px rgba(20, 24, 16, .55);
}

/* 延伸阅读：补页尾空白，也是跨栏目的内链 */
body .fam-more { margin: 46px 0 12px; padding-top: 22px; border-top: 1px solid var(--border); }
body .fam-more-h {
  margin: 0 0 16px; font-size: 12.5px; font-weight: 500;
  letter-spacing: .2em; color: var(--muted);
}
body .fam-more-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 18px; }
body .fam-more a.fam-more-card {
  display: flex; flex-direction: column; gap: 7px;
  color: var(--text); text-decoration: none;
}
body .fam-more-thumb {
  display: block; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden;
  background: var(--surface-soft); box-shadow: inset 0 0 0 1px var(--border-soft);
}
body .fam-more-thumb img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform .45s cubic-bezier(.2, .7, .3, 1);
}
body .fam-more-card:hover .fam-more-thumb img { transform: scale(1.05); }
body .fam-more-card:hover .fam-more-t { color: var(--accent-deep); }
body .fam-more-cat { font-size: 11px; letter-spacing: .14em; color: var(--muted); }
body .fam-more-t {
  font-size: 14.5px; line-height: 1.55; font-weight: 500;
  /* 标题统一占两行：三列卡片等高，第二排的图不会因上一排标题短而错位 */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 3.1em;
}
body .fam-row-date {
  flex: 0 0 auto; margin-left: auto; padding-left: 16px; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--muted);
}

@media (max-width: 700px) {
  body .fam-thumb { width: 104px; border-radius: 7px; }
  body .dir-list.is-roomy .dir-li.has-thumb {
    grid-template-columns: 104px minmax(0, 1fr); gap: 14px;
  }
  body .dir-li.has-thumb .dir-date { grid-column: 2; font-size: 11px; }
  body .table-cell.has-thumb .table-cell-in { gap: 12px; }
  /* 窄屏放不下「缩略图 + 标题 + 日期」三者：日期连同表头这一列一起收掉，
     标题独占剩余宽度。桌面端两列都在，不影响信息完整度。 */
  body .table-tbl:has(.fam-thumb) thead th:last-child { display: none; }
  body .fam-row-date { display: none; }
  body .table-cell.has-thumb .fam-thumb { width: 92px; }
  body .fam-more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
  body .fam-more-t { font-size: 13.5px; }
  body .fam-lead img { border-radius: 10px; }
}
