/**
 * 产品详情页相册样式（single-product.php 相册模式）
 * 与主题设计令牌对齐：Epilogue/Poppins 字体、D9D9D9 边框、品牌绿 rgb(14,185,24) 高亮。
 */

.sj-gallery {
  margin-block-end: 40px;
}

/* ---------- 主图查看区 ---------- */
.sj-gallery__viewer {
  position: relative;
  border: 1px solid rgb(var(--border-color));
  background: #fafafa;
  overflow: hidden;
}

.sj-gallery__stage {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}

.sj-gallery__stage img {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 720px);
  width: auto;
  height: auto;
  object-fit: contain;
  margin-inline: auto;
}

/* 大图加载占位：主图切换时闪烁淡入 */
.sj-gallery__stage img.is-loading {
  opacity: 0.25;
  transition: opacity 0.25s ease;
}
.sj-gallery__stage img.is-loaded {
  opacity: 1;
  transition: opacity 0.25s ease;
}

/* 前后切换按钮：悬浮于主图两侧 */
.sj-gallery__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgb(var(--border-color));
  border-radius: 50%;
  background: rgb(var(--background));
  color: rgb(var(--text-color));
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.sj-gallery__nav:hover {
  border-color: rgb(14, 185, 24);
  color: rgb(14, 185, 24);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.sj-gallery__nav--prev { inset-inline-start: 12px; }
.sj-gallery__nav--next { inset-inline-end: 12px; }

/* 计数徽标 */
.sj-gallery__count {
  position: absolute;
  inset-inline-end: 12px;
  inset-block-end: 12px;
  z-index: 2;
  padding: 4px 10px;
  font-family: var(--text-font-family);
  font-size: 12px;
  font-weight: 600;
  color: rgb(var(--text-color));
  background: rgb(255 255 255 / 0.9);
  border: 1px solid rgb(var(--border-color));
  border-radius: 999px;
  line-height: 1.4;
  pointer-events: none;
}

/* ---------- 缩略图网格 ---------- */
.sj-gallery__thumbs {
  margin-block-start: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.sj-gallery__thumb {
  position: relative;
  padding: 0;
  border: 1px solid rgb(var(--border-color));
  border-radius: 0;
  background: #fafafa;
  cursor: pointer;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.sj-gallery__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sj-gallery__thumb:hover {
  border-color: rgb(14, 185, 24, 0.55);
}

/* 当前选中：品牌绿描边 + 加粗阴影 */
.sj-gallery__thumb.is-active {
  border-color: rgb(14, 185, 24);
  border-width: 2px;
  box-shadow: 0 0 0 1px rgb(14, 185, 24);
}

/* ---------- 响应式 ---------- */
@media screen and (max-width: 740px) {
  .sj-gallery__viewer { min-height: 0; }
  .sj-gallery__stage { min-height: 0; }
  .sj-gallery__stage img { max-height: 62vh; }

  /* 移动端缩略图改横向滑动单行 */
  .sj-gallery__thumbs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-block-end: 6px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .sj-gallery__thumb {
    flex: 0 0 auto;
    width: 72px;
    scroll-snap-align: start;
  }
  /* 滑动时自动滚到当前项由 JS 控制，隐藏滚动条保持干净 */
  .sj-gallery__thumbs::-webkit-scrollbar { display: none; }
  .sj-gallery__thumbs { scrollbar-width: none; }

  .sj-gallery__nav { width: 34px; height: 34px; }
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  .sj-gallery__stage img,
  .sj-gallery__nav,
  .sj-gallery__thumb {
    transition: none;
  }
}
