/* ============================================================================
   content.css —— 栏目档案（列表 / 详情 / 相册 / 灯箱）
   ----------------------------------------------------------------------------
   与 style.css 的分工：style.css 管站点骨架（页头页脚、按钮、区块），
   本文件只管「内容档案」这一种页面形态，便于单独演进而不牵动全站。

   三条硬约束（2026-11-02 图片能力升级时确立）：
   1) 每张图都必须有 width/height 或 aspect-ratio —— 否则图片加载时页面跳动（CLS）。
   2) 首屏图 fetchpriority=high 且不 lazy；其余一律 lazy —— 懒加载首图会拖慢 LCP。
   3) 图注用 --text-secondary，不用更浅的灰 —— 米白底上必须 ≥4.5:1。
   ============================================================================ */

/* ---------------- 详情页骨架 ---------------- */
.cms-article {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 22px 56px;
}

.cms-back { margin: 0 0 18px; font-size: .9375rem; }

.cms-head {
  background: var(--mist);
  padding: 32px 30px;
  border-radius: var(--radius-lg);
  margin: 22px 0 0;
}

.cms-kicker {
  display: inline-block;
  color: var(--gold-ink);
  font-size: .8125rem;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.cms-head h1 {
  margin: 0 0 10px;
  font-size: clamp(1.75rem, 4.4vw, 2.375rem);
  line-height: 1.25;
  color: var(--text-primary);
}

.cms-summary {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.75;
}

.cms-body {
  white-space: pre-wrap;
  line-height: 1.95;
  margin: 30px 0;
  color: var(--text-primary);
  font-size: 1.0625rem;
}

.cms-source {
  border-top: 1px solid var(--line-strong);
  padding-top: 18px;
  margin-top: 32px;
  color: var(--text-secondary);
  font-size: .9375rem;
  line-height: 1.75;
}

.cms-meta {
  color: var(--text-secondary);
  font-size: .875rem;
  margin: 10px 0 0;
}

.cms-shop-link {
  display: inline-block;
  margin-top: 22px;
  padding: 11px 20px;
  border-radius: var(--radius-pill);
  background: var(--action-primary-bg);
  color: var(--action-primary-text);
  text-decoration: none;
}

/* ---------------- 封面 ---------------- */
.cms-hero {
  margin: 0 0 22px;
}

.cms-hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  background: var(--stone);
}

.cms-hero figcaption,
.cms-fig figcaption {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: .8125rem;
  line-height: 1.6;
}

/* ---------------- 相册 ---------------- */
.cms-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin: 34px 0 8px;
  padding: 0;
  list-style: none;
}

.cms-fig { margin: 0; }

.cms-fig-open {
  display: block;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--stone);
}

/* 固定比例 + object-fit：图片未加载时就已占好位置，避免正文被顶下去 */
.cms-fig-open img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform .2s ease;
}

.cms-fig-open:hover img { transform: scale(1.03); }
@media (prefers-reduced-motion: reduce) {
  .cms-fig-open img { transition: none; }
  .cms-fig-open:hover img { transform: none; }
}

.cms-fig-open:focus-visible {
  outline: 3px solid var(--gold-500);
  outline-offset: 3px;
}

/* ---------------- 灯箱 ---------------- */
.cms-lightbox {
  border: 0;
  padding: 0;
  max-width: min(1100px, 94vw);
  max-height: 92vh;
  background: transparent;
  overflow: visible;
}

.cms-lightbox::backdrop {
  background: rgba(8, 31, 24, .88);
}

.cms-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius);
  background: var(--stone);
}

.cms-lightbox-bar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 8px;
}

.cms-lightbox-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(8, 31, 24, .55);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.cms-lightbox-cap {
  margin: 10px 0 0;
  text-align: center;
  color: rgba(255, 255, 255, .86);
  font-size: .875rem;
  line-height: 1.6;
}

/* ---------------- 栏目总览 ---------------- */
.cms-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 22px 56px;
}

.cms-lead {
  background: var(--mist);
  padding: 32px;
  border-radius: var(--radius-lg);
}

.cms-lead.has-cover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 28px;
  align-items: center;
}

.cms-lead h1 {
  margin: 0 0 10px;
  font-size: clamp(1.75rem, 4.6vw, 2.5rem);
  color: var(--text-primary);
}

.cms-lead p {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.75;
}

.cms-lead-media img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--stone);
}

.cms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin: 24px 0 8px;
}

.cms-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  color: var(--text-primary);
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease;
}

a.cms-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.cms-card-flat {
  /* 二级栏目卡片：不是链接，不该有「可点」的视觉暗示 */
  cursor: default;
}

.cms-card-media {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--stone);
}

.cms-card-body { padding: 18px 20px 20px; }

.cms-card-body small {
  color: var(--gold-ink);
  font-size: .75rem;
  letter-spacing: .04em;
}

.cms-card-body h3 {
  margin: 6px 0 8px;
  font-size: 1.125rem;
  line-height: 1.4;
}

.cms-card-body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: .9375rem;
  line-height: 1.7;
}

@media (prefers-reduced-motion: reduce) {
  .cms-card { transition: none; }
  a.cms-card:hover { transform: none; box-shadow: none; }
}

/* ---------------- 草稿预览 ---------------- */
.cms-preview {
  background: var(--gold-ink);
  color: #fff;
  text-align: center;
  padding: 10px;
  font-size: .875rem;
}

.preview-mobile .cms-article,
.preview-mobile .cms-wrap {
  max-width: 390px;
  box-shadow: 0 0 0 1px var(--line-strong);
  margin: 20px auto;
}

.preview-mobile .cms-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 760px) {
  .cms-lead.has-cover { grid-template-columns: 1fr; }
  .cms-lead-media { order: -1; }
  .cms-head { padding: 26px 22px; }
  .cms-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

@media (max-width: 420px) {
  .cms-article { padding: 28px 16px 40px; }
}

/* ---------------- 打印 ---------------- */
@media print {
  .cms-back, .cms-lightbox, .site-header, .site-footer { display: none; }
  .cms-hero img, .cms-fig-open img { break-inside: avoid; }
  .cms-body { font-size: 11pt; }
}
