/* ==========================================================================
   PRODUCT DETAIL PAGE — Premium B2B Gallery Layout
   Desktop: Vertical thumb rail (left) + large main image (right)
   Mobile:  Single column, horizontal scrollable thumb rail below image
   ========================================================================== */

/* ── Page Layout ─────────────────────────────────────────────────────────── */
.product-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}

/* ── Gallery Column ───────────────────────────────────────────────────────── */
.product-gallery-col {
  display: flex;
  flex-direction: row;
  gap: 0.85rem;
  align-items: flex-start;
  position: sticky;
  top: 110px;  /* sticky below header */
}

/* ── Vertical Thumbnail Rail (Desktop) ───────────────────────────────────── */
.gallery-vertical-rail {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex-shrink: 0;
  width: 80px;
  max-height: calc(80px * 6 + 0.55rem * 5);  /* max 6 thumbs visible */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.gallery-vertical-rail::-webkit-scrollbar {
  width: 3px;
}
.gallery-vertical-rail::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 3px;
}

/* ── Thumbnail Button ─────────────────────────────────────────────────────── */
.gallery-thumb-btn {
  width: 80px;
  height: 100px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  overflow: hidden;
  cursor: pointer;
  background: var(--color-cream);
  padding: 0;
  flex-shrink: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
  outline: none;
}

.gallery-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.82;
  transition: opacity 150ms ease;
}

.gallery-thumb-btn:hover img,
.gallery-thumb-btn.active img {
  opacity: 1;
}

.gallery-thumb-btn:hover {
  border-color: var(--color-olive);
}

.gallery-thumb-btn.active {
  border-color: var(--color-olive-dark);
  box-shadow: 0 0 0 2px var(--color-olive-dark);
}

.gallery-thumb-btn:focus-visible {
  border-color: var(--color-olive-dark);
  box-shadow: 0 0 0 3px rgba(95, 103, 79, 0.35);
}

/* ── Main Image Wrapper ───────────────────────────────────────────────────── */
.product-main-image-wrap {
  position: relative;
  flex: 1;
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 4 / 5;
}

/* Main image — fades on swap */
#main-product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 180ms ease;
}

#main-product-img.is-fading {
  opacity: 0;
}

/* No-image placeholder */
.product-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--color-text-subtle);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  text-align: center;
  padding: 2rem;
}

.product-img-placeholder svg {
  opacity: 0.35;
}

.product-img-placeholder p {
  margin: 0;
  line-height: 1.4;
}

/* ── Zoom Button (top-right of main image) ────────────────────────────────── */
.gallery-zoom-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(39, 37, 32, 0.62);
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 150ms ease;
  z-index: 2;
}

.gallery-zoom-btn:hover {
  background: rgba(39, 37, 32, 0.82);
}

.gallery-zoom-btn:focus-visible {
  outline: 2px solid var(--color-olive-dark);
  outline-offset: 2px;
}

/* Hide zoom button if no image */
.product-main-image-wrap:not(:has(#main-product-img)) .gallery-zoom-btn {
  display: none;
}

/* ── Lightbox Overlay ─────────────────────────────────────────────────────── */
#pdp-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(16, 14, 12, 0.92);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: zoom-out;
}

#pdp-lightbox.is-open {
  display: flex;
}

#pdp-lightbox-img {
  max-width: min(90vw, 820px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  cursor: default;
  animation: lbFadeIn 0.2s ease-out;
}

#pdp-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 700;
  transition: background 150ms ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

#pdp-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
}

#pdp-lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

@keyframes lbFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Product Info Panel ───────────────────────────────────────────────────── */
.product-info-panel h1 {
  font-size: clamp(1.85rem, 3vw, 2.5rem);
  margin-bottom: 0.75rem;
  line-height: 1.1;
}

.product-sku-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-subtle);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Specs Table ──────────────────────────────────────────────────────────── */
.specs-dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.75rem 1rem;
  font-size: 0.9rem;
  margin: 1.5rem 0;
  padding: 1.25rem 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.specs-dl dt {
  font-weight: 700;
  color: var(--color-text-muted);
}

.specs-dl dd {
  margin: 0;
  color: var(--color-text);
}

/* ── Tablet (768px – 1024px) ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .product-detail-layout {
    gap: 2.25rem;
  }

  .product-gallery-col {
    position: static; /* don't sticky on tablet */
    top: auto;
  }

  .gallery-vertical-rail {
    width: 68px;
  }

  .gallery-thumb-btn {
    width: 68px;
    height: 85px;
  }
}

/* ── Mobile (< 768px) ─────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .product-detail-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  /* Stack: main image top, then horizontal thumb rail below */
  .product-gallery-col {
    flex-direction: column;
    gap: 0.65rem;
    position: static;
  }

  .product-main-image-wrap {
    order: 1;
    width: 100%;
  }

  /* Vertical rail becomes horizontal scrollable rail */
  .gallery-vertical-rail {
    order: 2;
    flex-direction: row;
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 4px; /* space for scrollbar */
    scrollbar-width: thin;
  }

  .gallery-thumb-btn {
    width: 64px;
    height: 80px;
    flex-shrink: 0;
  }
}

/* ── Reduced Motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #main-product-img,
  .gallery-thumb-btn,
  .gallery-thumb-btn img,
  #pdp-lightbox-img {
    transition: none !important;
    animation: none !important;
  }
}
