/* ============================================================
   照片墙（gallery.html）
   ----------------------------------------------------
   混排网格：三列 + grid-auto-flow:dense，个别图占两列/两行，形成错落；
   灯箱复用站点弹窗语言（.modal-overlay / .lg-dim / .modal-panel），
   只在上面补大图容器、说明条与切换按钮。
   ============================================================ */

#gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
  margin: 0.4rem 0 0;
}
@media (max-width: 1023px) {
  #gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 639px) {
  #gallery-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}

.gal-tile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  background: #0e1015;
  aspect-ratio: 4 / 3;
  cursor: zoom-in;
  transition: border-color 0.2s ease, box-shadow 0.3s var(--ease-swift);
}
.gal-tile.gal-wide {
  grid-column: span 2;
  aspect-ratio: 16 / 9;
}
.gal-tile.gal-tall {
  grid-row: span 2;
  aspect-ratio: 3 / 4;
}
/* ❗必须写在上面两条之后：媒体查询不加特指度，同选择器后写的赢。
   单列时不能再跨列——跨 2 列会在 1 列网格里撑出隐式第二列 */
@media (max-width: 639px) {
  .gal-tile.gal-wide,
  .gal-tile.gal-tall {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 4 / 3;
  }
}
.gal-tile:hover,
.gal-tile:focus-visible {
  border-color: rgba(143, 184, 255, 0.4);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.gal-tile:focus-visible {
  outline: 2px solid rgba(143, 184, 255, 0.7);
  outline-offset: 2px;
}

.gal-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease-swift);
}
.gal-tile:hover img,
.gal-tile:focus-visible img {
  transform: scale(1.03);
}

/* 说明条：常驻（触摸设备没有 hover，藏起来等于看不见） */
.gal-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.8rem 0.9rem 0.7rem;
  text-align: left;
  background: linear-gradient(to top, rgba(3, 7, 18, 0.92), rgba(3, 7, 18, 0.55) 45%, rgba(3, 7, 18, 0));
  pointer-events: none;
}
.gal-cap b {
  display: block;
  overflow: hidden;
  color: #f5f5f7;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gal-cap span {
  display: block;
  margin-top: 2px;
  color: rgba(158, 176, 202, 0.75);
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

/* ---------- 灯箱 ---------- */
#gal-lightbox .gal-panel {
  max-width: min(1120px, 94vw);
  width: 100%;
}
.gal-figure {
  background: #04060a;
}
.gal-figure img {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
}
/* 大图入场：轻缩放 + 淡入（js/gallery.js 每次换图重新挂一次 is-in 让动画重放） */
#gal-img.is-in {
  animation: gal-zoom 0.34s var(--ease-swift);
}
@keyframes gal-zoom {
  from {
    opacity: 0.55;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  #gal-img.is-in {
    animation: none;
  }
}
.gal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.gal-bar b {
  display: block;
  color: #f5f5f7;
  font-size: 13px;
}
.gal-bar .gal-meta {
  display: block;
  margin-top: 2px;
  color: #86868b;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.gal-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
}
.gal-index {
  margin-right: 0.3rem;
  color: #86868b;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.gal-actions button,
.gal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  color: #f5f5f7;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.gal-actions button:hover,
.gal-close:hover {
  background: rgba(255, 255, 255, 0.14);
}
.gal-actions svg,
.gal-close svg {
  width: 16px;
  height: 16px;
}
.gal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  background: rgba(12, 14, 20, 0.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

@media (prefers-reduced-motion: reduce) {
  .gal-tile,
  .gal-tile img {
    transition: none;
  }
  .gal-tile:hover img,
  .gal-tile:focus-visible img {
    transform: none;
  }
}
