/* ============================================================
   B&N International — 图片轮播 / 全屏灯箱增强样式
   ------------------------------------------------------------
   作用页面：product-detail.php（主营产品详情）
   功能：同一内容多张图片时 → 自动循环 + 手动切换的平滑轮播；
        单张图片时 → 普通静态展示（不启用轮显）；
        另在页面内以「全部图片」网格铺列所有图片，点击任意一张 →
        放大进入全屏灯箱（缩放淡入动画 + 全屏遮罩 + 关闭 X + 左右箭头轮显）。
   视觉变量全部复用 style.css 的 :root（--brand / --radius / --shadow-* / …）。
   ============================================================ */

/* ---------- 1. 轮播容器 ---------- */
.bn-carousel {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1.5rem;   /* 维持原封面图与正文之间的节奏（单图静态态同样适用） */
}

.bn-carousel-viewport {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  background: var(--bg-soft);
}

/* 滑动轨道：所有幻灯片横向并排，靠 transform 平移切换 */
.bn-carousel-track {
  display: flex;
  transition: transform .6s cubic-bezier(.22, .61, .36, 1);
  will-change: transform;
}

.bn-slide {
  flex: 0 0 100%;
  margin: 0;
  position: relative;
}

.bn-slide img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: cover;            /* 仅在 max-height 触发时等比裁切，避免超长图撑破布局 */
  background: var(--bg-soft);
}

/* 单图静态态：去掉滑动过渡带来的轻微位移感（保留圆角/边框/阴影） */
.bn-carousel[data-single="1"] .bn-carousel-track { transition: none; }

/* ---------- 2. 左右切换箭头 ---------- */
.bn-carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: rgba(10, 31, 68, .42);
  color: #fff; font-size: 1.5rem; line-height: 1;
  cursor: pointer;
  opacity: 0;
  backdrop-filter: blur(2px);
  transition: opacity var(--transition), background var(--transition), transform var(--transition);
  z-index: 4;
}
.bn-carousel-viewport:hover .bn-carousel-arrow { opacity: 1; }
.bn-carousel-arrow:hover { background: rgba(10, 31, 68, .72); }
.bn-carousel-arrow:active { transform: translateY(-50%) scale(.92); }
.bn-carousel-arrow.prev { left: .85rem; }
.bn-carousel-arrow.next { right: .85rem; }
.bn-carousel-arrow:focus-visible { opacity: 1; outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- 3. 底部圆点指示器 ---------- */
.bn-carousel-dots {
  position: absolute;
  left: 0; right: 0; bottom: .9rem;
  display: flex; justify-content: center; align-items: center;
  gap: .5rem; z-index: 4;
  pointer-events: none;
}
.bn-dot {
  width: 9px; height: 9px; padding: 0;
  border: none; border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  cursor: pointer; pointer-events: auto;
  transition: width var(--transition), background var(--transition);
}
.bn-dot.is-active { width: 24px; background: #fff; }
.bn-dot:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- 4. 全部图片铺列网格 ---------- */
.pd-gallery-all { margin: 1.75rem 0 0; }
.pd-gallery-all-title {
  font-size: 1.1rem; font-weight: 700; color: var(--ink);
  margin-bottom: 1rem;
  padding-left: 12px;
  border-left: 3px solid var(--brand);
  line-height: 1.4;
}
.bn-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.bn-gallery-cell {
  padding: 0; margin: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  overflow: hidden; cursor: pointer;
  aspect-ratio: 4 / 3;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}
.bn-gallery-cell img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .45s cubic-bezier(.22, .61, .36, 1);
}
.bn-gallery-cell:hover {
  border-color: var(--brand-light);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.bn-gallery-cell:hover img { transform: scale(1.06); }
.bn-gallery-cell:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- 6. 全屏灯箱 Lightbox ---------- */
.bn-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 16, 32, .92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .28s ease;
}
.bn-lightbox.is-open { display: flex; opacity: 1; }

.bn-lb-stage {
  margin: 0;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bn-lb-img {
  display: block;
  max-width: 92vw;
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  object-fit: contain;
  /* 初始缩小 + 透明，.is-zoom 时过渡到正常尺寸（缩放淡入动画） */
  transform: scale(.82);
  opacity: 0;
  transition: transform .34s cubic-bezier(.22, .61, .36, 1), opacity .34s ease;
}
.bn-lb-img.is-zoom { transform: scale(1); opacity: 1; }

/* 关闭按钮：右上角最方便位置 */
.bn-lb-close {
  position: absolute;
  top: 1.1rem; right: 1.3rem;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff; font-size: 1.7rem; line-height: 1;
  cursor: pointer; z-index: 2;
  transition: background var(--transition), transform var(--transition);
}
.bn-lb-close:hover { background: rgba(255, 255, 255, .28); transform: rotate(90deg); }
.bn-lb-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* 遮罩上的左右切换箭头（轮显） */
.bn-lb-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 2rem; line-height: 1;
  cursor: pointer; z-index: 2;
  transition: background var(--transition), transform var(--transition);
}
.bn-lb-nav:hover { background: rgba(255, 255, 255, .26); }
.bn-lb-nav:active { transform: translateY(-50%) scale(.92); }
.bn-lb-nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.bn-lb-prev { left: 1.6rem; }
.bn-lb-next { right: 1.6rem; }

/* 计数（仅多图时显示） */
.bn-lb-count {
  position: absolute;
  bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  color: rgba(255, 255, 255, .85);
  font-size: .9rem; letter-spacing: .08em;
  background: rgba(0, 0, 0, .35);
  padding: .25rem .85rem; border-radius: 999px;
}

/* 锁住背景滚动 */
body.bn-lb-lock { overflow: hidden; }

/* ---------- 7. 响应式 ---------- */
@media (max-width: 900px) {
  .bn-slide img { max-height: 420px; }
  .bn-carousel-arrow { width: 38px; height: 38px; font-size: 1.35rem; }
}
@media (max-width: 520px) {
  .bn-slide img { max-height: 320px; }
  .bn-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
  .bn-carousel-thumb { width: 56px; height: 56px; }
  .bn-lb-nav { width: 44px; height: 44px; font-size: 1.6rem; }
  .bn-lb-prev { left: .6rem; }
  .bn-lb-next { right: .6rem; }
  .bn-lb-close { top: .8rem; right: .8rem; }
}
