/* =============================================================================
   族 gallery —— 图集型
   骨架：宽容器 + 首屏整幅图 + CSS 多列瀑布流（figure/figcaption），无摘要文字。
   与 card 的区别：card 是等高卡片、带标题与两行摘要；这里是图为主、列高不齐。
   ========================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.gallery-page {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 15px; line-height: 1.8;
  display: flex; flex-direction: column; min-height: 100vh;
}
body.gallery-page > .gallery-main { flex: 1 0 auto; }
.gallery-page a { color: var(--accent-deep); text-decoration: none; }
.gallery-page img { max-width: 100%; height: auto; }

/* ------------------------------------------------------------------ header */
.gallery-head { background: var(--surface); border-bottom: 1px solid var(--border); }
.gallery-head.is-center { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 20px 12px; }
.gallery-head.is-left { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 22px; }
.gallery-head.is-stack {
  display: flex; align-items: center; gap: 18px;
  padding: 12px max(22px, calc(50% - 640px));
}
.gallery-bar { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; }
.gallery-rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.gallery-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; white-space: nowrap; }
.gallery-mark { border-radius: 50%; }
/* 页头导航恒为一行：放不下就横向滑，不折行。
   折行会把刊头挤成高低不齐的两行（移动端最明显），而这里是全站唯一的主入口，
   一旦折掉就是「菜单看着断了一截」。滚动条隐掉，横滑不带动整页。 */
.gallery-nav {
  display: flex; flex-wrap: nowrap; gap: 4px 16px;
  min-width: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none; overscroll-behavior-x: contain;
}
.gallery-nav::-webkit-scrollbar { display: none; }
.gallery-nav a { flex: 0 0 auto; white-space: nowrap; }
.gallery-nav a { transition: color .16s ease; font-size: 13px; color: var(--text-3); }
.gallery-nav-wide {
  flex: 0 1 auto; min-width: 0; margin: 0; padding: 0; border-top: 0; gap: 0;
}
.gallery-head.is-stack .gallery-nav-wide a { font-size: 12.5px; letter-spacing: .045em; }
.gallery-head.is-stack .gallery-nav-wide a + a {
  margin-left: 13px; padding-left: 13px; border-left: 1px solid var(--border);
}

/* hero：本族首屏图已停用（页面紧跟一块 gallery-intro，站名与描述都在那里，
   首屏图只是装饰且全站同一套模板生成），不再有首屏元素需要样式。 */

/* -------------------------------------------------------------------- main */
.gallery-main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 26px 22px 56px; }
.gallery-intro { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.gallery-title { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: .01em; }
.gallery-sub { margin: 0; color: var(--text-3); font-size: 14px; }
.gallery-crumb { margin-bottom: 14px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; }
.gallery-sec { margin-top: 28px; }
.gallery-sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.gallery-count { color: var(--muted); font-size: 12.5px; font-weight: 400; }

/* ----------------------------------------------------------- masonry grid */
.gallery-grid { columns: 3 260px; column-gap: 16px; }
.gallery-grid.is-tight { columns: 4 200px; }
.gallery-card {
  margin: 0 0 16px; break-inside: avoid; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.gallery-fig { display: block; position: relative; color: inherit; }
.gallery-img { width: 100%; display: block; }
.gallery-cap {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 9px 12px; font-size: 13px; background: var(--surface);
}
.gallery-cap-t { color: var(--text); font-weight: 500; }
.gallery-cap-d { color: var(--muted); font-size: 12px; white-space: nowrap; }
.gallery-card:hover .gallery-cap-t { color: var(--accent); }
.gallery-grid-links { columns: 4 180px; }
.gallery-tile {
  display: flex; align-items: center; justify-content: center; min-height: 92px; margin-bottom: 14px;
  padding: 14px; break-inside: avoid; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-2); font-size: 14px;
}
.gallery-tile:hover { border-color: var(--accent); color: var(--accent-deep); }

/* -------------------------------------------------------------------- post */
.gallery-post { max-width: 900px; margin: 0 auto; }
.gallery-post-narrow { max-width: 720px; }
.gallery-lead { width: 100%; aspect-ratio: 16 / 8; object-fit: cover; border-radius: 12px; margin: 6px 0 22px; }
.gallery-body { font-size: 16.5px; line-height: 1.9; color: var(--text-2); }
.gallery-body p { margin: 0 0 1.1em; }
.gallery-body h2 { margin: 1.7em 0 .6em; font-size: 21px; color: var(--text); }
.gallery-rel { max-width: 900px; margin: 36px auto 0; }
.gallery-rel-h { margin: 0 0 12px; font-size: 14px; }
.gallery-rel-list { margin: 0; padding-left: 18px; color: var(--text-2); }
.gallery-rel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gallery-rel-tile { display: flex; flex-direction: column; gap: 6px; }
.gallery-rel-img { aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }
.gallery-rel-t { font-size: 13px; }
.gallery-code { margin: 0; font-size: 56px; font-weight: 700; color: var(--accent-soft); }

/* ------------------------------------------------------------------ footer */
.gallery-foot { margin-top: 40px; background: var(--surface); border-top: 1px solid var(--border); padding: 22px; font-size: 13px; color: var(--text-3); }
.gallery-foot.is-min { text-align: center; }
.gallery-foot-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; max-width: 1280px; margin: 0 auto 10px; }
.gallery-foot-nav { display: flex; gap: 14px; flex-wrap: wrap; }
.gallery-foot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; max-width: 1280px; margin: 0 auto 14px; }
.gallery-foot-h { margin: 0 0 6px; font-size: 12px; letter-spacing: .12em; color: var(--muted); }
.gallery-foot-t { margin: 0; }
.gallery-foot-col { display: flex; flex-direction: column; gap: 4px; }
.gallery-friends { display: flex; gap: 4px 14px; flex-wrap: wrap; justify-content: center; max-width: 1280px; margin: 0 auto; }
.gallery-copy { margin: 0; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  .gallery-grid, .gallery-grid.is-tight, .gallery-grid-links { columns: 2 150px; column-gap: 12px; }
  /* 两列后卡片变窄，图注一行放不下「标题 + 日期」：日期换到标题下方 */
  .gallery-cap { flex-direction: column; align-items: flex-start; gap: 1px; }
  .gallery-main { padding: 18px 16px 44px; }
  .gallery-rel-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-foot-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .gallery-grid, .gallery-grid.is-tight, .gallery-grid-links { columns: 1; }
  .gallery-title { font-size: 22px; }
  .gallery-body { font-size: 15.5px; }
}

@media (max-width: 680px) {
  /* stack 窄屏也是「站名 + 导航」同排：站名过长自身省略，宽导航拿剩余宽度横滑。
     拆成两行会让刊头孤零零占一行、频道条贴在下边，视觉上明显更难看。 */
  .gallery-head.is-stack { flex-wrap: nowrap; gap: 10px; padding: 12px 14px; }
  .gallery-head.is-stack .gallery-bar { flex: 0 1 auto; min-width: 0; }
  .gallery-head.is-stack .gallery-rule { display: none; }
  .gallery-head.is-stack .gallery-brand { min-width: 0; overflow: hidden; }
  .gallery-head.is-stack .gallery-brand span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .gallery-head.is-stack .gallery-nav-wide {
    flex: 1 1 auto; min-width: 0; gap: 4px 14px; margin-top: 0; padding-top: 0; border-top: 0;
  }
  .gallery-head.is-stack .gallery-nav-wide a + a { margin-left: 0; padding-left: 0; border-left: 0; }
}

/* 居中变体：导航撑满整行再居中。不撑满的话盒宽按 fit-content 走，
   导航一 nowrap 就把页头撑出屏幕；safe center 保证溢出时首项滚得到。 */
.gallery-head.is-center .gallery-nav { align-self: stretch; justify-self: stretch; justify-content: safe center; }

.gallery-nav a[aria-current="page"] {
  color: var(--accent-deep);
  text-decoration: underline; text-decoration-thickness: 1.5px;
  text-underline-offset: 5px; text-decoration-color: var(--accent);
}

/* 极窄屏（≤480）：站名与导航保持同一行，站名过长时自身省略，导航拿剩余宽度横滑。
   拆成两行会让刊头孤零零占一行、导航贴在下边，视觉上明显更难看。 */
@media (max-width: 480px) {
  .gallery-head.is-left { flex-wrap: nowrap; gap: 10px; padding-left: 14px; padding-right: 14px; }
  .gallery-head.is-left .gallery-bar { flex: 0 1 auto; min-width: 0; }
  .gallery-head.is-left .gallery-brand { min-width: 0; overflow: hidden; }
  .gallery-head.is-left .gallery-brand span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .gallery-head.is-left .gallery-nav { flex: 1 1 auto; min-width: 0; }
}
