/* ============================================================
   WeChat Gallery — 朋友圈九宫格相册
   作者：shiwei (https://www.90svip.cn)  版本：1.0.0
   ============================================================ */

/* ---------- 外层居中包裹层 ---------- */
.wcg-outer {
  text-align: center;
  margin: 16px 0;
}

/* ---------- 网格容器 ----------
   display 由 PHP 内联样式控制（inline-grid / inline-block），
   此处只设置通用属性，不重复声明 display。               */
.wcg-wrap {
  grid-template-columns: repeat(var(--wcg-cols, 3), 1fr);
  gap: var(--wcg-gap, 4px);
  max-width: 500px;
  vertical-align: top; /* 消除 inline-grid 基线偏移 */
}

/* ---------- 2列布局限制宽度 ---------- */
.wcg-cols-2 {
  max-width: 340px;
}

/* ---------- 单个格子（正方形） ---------- */
.wcg-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--wcg-radius, 8px);
  background: #f0f0f0;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

.wcg-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.25s ease;
  display: block;
}

.wcg-item:hover img {
  transform: scale(1.04);
}

/* ---------- 1张图：大图展示（不用正方形裁切） ---------- */
.wcg-single {
  display: inline-block !important;
  max-width: 300px;
  vertical-align: top;
}

.wcg-single .wcg-item {
  aspect-ratio: auto;
  height: auto;
}

.wcg-single .wcg-item img {
  position: static;
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ---------- 响应式：小屏铺满 ---------- */
@media (max-width: 480px) {
  .wcg-wrap,
  .wcg-single {
    max-width: 100% !important;
  }
}

/* ============================================================
   灯箱（Lightbox）
   注意：默认隐藏用 JS 控制（style="display:none"），
         此处 .wcg-lightbox 不声明 display，避免覆盖。
   ============================================================ */
.wcg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.92);
  /* display 由 JS 设置为 flex / none，CSS 不干预 */
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

/* JS 打开时追加此 class 来触发 flex 布局 */
.wcg-lightbox.wcg-lb-open {
  display: flex;
}

.wcg-lb-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 88vh;
}

.wcg-lb-img {
  max-width: 92vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.wcg-lb-counter {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- 灯箱按钮 ---------- */
.wcg-lb-close,
.wcg-lb-prev,
.wcg-lb-next {
  position: fixed;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  line-height: 1;
  padding: 0;
}

.wcg-lb-close:hover,
.wcg-lb-prev:hover,
.wcg-lb-next:hover {
  background: rgba(255, 255, 255, 0.3);
}

.wcg-lb-close {
  top: 20px;
  right: 20px;
  font-size: 18px;
}

.wcg-lb-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}

.wcg-lb-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

/* 单图时隐藏翻页按钮 */
.wcg-lightbox.wcg-single-lb .wcg-lb-prev,
.wcg-lightbox.wcg-single-lb .wcg-lb-next {
  display: none;
}
