/* ─────────────────────────────────────────────────────────────
   Screenshot lightbox — opt-in per page.

   Loaded only by pages that also load lightbox.js. Nothing here
   touches product.css selectors, so other product pages are
   unaffected until they opt in too.
   ───────────────────────────────────────────────────────────── */

/* The rail's images become interactive, so say so. */
.screenshot-rail .shot-frame {
  cursor: zoom-in;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  /* 0.86 的遮罩會讓頁面文字透出來，跟圖下方的說明混在一起 */
  background: rgb(0 0 0 / 0.93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  /* 手機的瀏海與 home indicator */
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  opacity: 0;
  transition: opacity 0.18s ease;
}

.lightbox.is-open {
  display: flex;
  opacity: 1;
}

.lightbox-figure {
  margin: 0;
  max-width: min(1400px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.lightbox-img {
  display: block;
  max-width: 100%;
  /* 扣掉說明列與計數列，避免圖被推出畫面 */
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.5);
  /* 切換時不要看到上一張殘影 */
  background: rgb(255 255 255 / 0.04);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-caption {
  color: #fff;
  font-size: 0.95rem;
  text-align: center;
  margin: 0;
  text-wrap: balance;
}

.lightbox-count {
  color: rgb(255 255 255 / 0.62);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

/* 控制鈕 */
.lightbox-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgb(255 255 255 / 0.22);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.42);
  color: #fff;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.lightbox-btn:hover,
.lightbox-btn:focus-visible {
  background: rgb(0 0 0 / 0.72);
  border-color: rgb(255 255 255 / 0.5);
}

.lightbox-btn svg {
  width: 20px;
  height: 20px;
}

.lightbox-close {
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
}

.lightbox-prev { left: max(12px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%); }
.lightbox-next { right: max(12px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); }

.lightbox-btn[hidden] { display: none; }

/* 窄螢幕：左右鈕移到底部，不要壓在圖上 */
@media (max-width: 640px) {
  .lightbox-prev,
  .lightbox-next {
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    transform: none;
  }
  .lightbox-img { max-height: calc(100vh - 210px); }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox { transition: none; }
}
