/* ============================================================
   gallery/gallery.css — 精选相册
   ============================================================ */

/* ---------- 头部 ---------- */
.gal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: clamp(18px, 3vw, 26px);
  margin-bottom: 16px;
}

.gal-head__title {
  margin: 0;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 750;
  letter-spacing: -0.025em;
}

.gal-head__sub {
  margin: 6px 0 0;
  font-size: 14px;
}

.gal-head__side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 相册筛选 ---------- */
.gal-tabs {
  margin-bottom: 16px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.gal-tabs::-webkit-scrollbar {
  display: none;
}

.gal-tabs__count {
  margin-left: 6px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.65;
}

/* ---------- 图片流 ----------
   用 CSS 多列排版（column-count），列数完全由样式决定，不依赖 JS 测量：
   之前用 flex + JS 分列，在部分环境里会算出 7 列并把内容挤到右侧。
   多列布局天然等宽、自动平衡高度，视觉上就是瀑布流。 */
.gal-grid {
  column-count: 3;
  column-gap: 10px;
  width: 100%;
}

@media (max-width: 1400px) {
  .gal-grid { column-count: 3; }
}
@media (max-width: 900px) {
  .gal-grid { column-count: 2; }
}
@media (max-width: 560px) {
  .gal-grid { column-count: 1; }
}

.gal-cell {
  display: block;
  width: 100%;
  min-width: 0;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  border-radius: var(--lg-radius-sm);
  overflow: hidden;
  cursor: zoom-in;
  background: rgba(120, 135, 165, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  transition: transform var(--lg-base) var(--lg-ease), box-shadow var(--lg-base) var(--lg-ease);
  -webkit-tap-highlight-color: transparent;
  /* 防止在多列里被拆分到两列 */
  break-inside: avoid;
  page-break-inside: avoid;
}

.gal-cell img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 60px;
}

.gal-cell:hover {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), 0 22px 34px -24px rgba(16, 24, 40, 0.85);
}

.gal-cell:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lg-accent) 55%, transparent);
}

.gal-empty {
  margin-top: 6px;
}

/* ---------- 灯箱 ---------- */
body.gal-locked {
  overflow: hidden;
}

/* 灯箱：注意必须用 :not([hidden]) 限定，
   否则 display:flex 会覆盖 hidden 属性，导致遮罩在页面加载时就盖在相册上 */
.gal-lightbox:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  flex-direction: column;
  background: rgba(8, 12, 22, 0.72);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  animation: gal-fade 0.22s var(--lg-ease-out);
}

.gal-lightbox[hidden] {
  display: none !important;
}

@keyframes gal-fade {
  from { opacity: 0; }
}

.gal-lightbox__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
}

.gal-lightbox__info {
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gal-lightbox__bar .lg-icon-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.gal-lightbox__bar .lg-icon-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.gal-lightbox__stage {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 0 14px;
  min-height: 0;
  cursor: zoom-out;
}

.gal-lightbox__stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--lg-radius-sm);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
  animation: gal-pop 0.24s var(--lg-ease-out);
}

@keyframes gal-pop {
  from { opacity: 0; transform: scale(0.97); }
}

.gal-lightbox__foot {
  padding: 12px 18px 18px;
  padding-bottom: max(18px, env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- 小屏 ---------- */
@media (max-width: 640px) {
  .gal-grid {
    gap: 8px;
  }
  .gal-col {
    gap: 8px;
  }
  .gal-head {
    padding: 16px;
  }
  .gal-lightbox__stage {
    padding: 0 8px;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .gal-lightbox {
    background: #0d1220;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
