/* ===========================================================
   PRODUCT GALLERY — scoped component styles
   Loaded ONLY on the Product Detail Page.
   Every rule is namespaced under .product-gallery or .pg-lightbox
   so nothing outside the slider is affected.
   Design tokens (--blue, --ink, --paper, --radius…) are reused
   from the existing assets/styles.css — no new framework.
   =========================================================== */

.product-gallery{
  --pg-gap:14px;
  display:flex;
  flex-direction:column;
  gap:var(--pg-gap);
  min-width:0;                 /* allows shrinking inside existing grid column */
}

/* ---------- main stage ---------- */
.product-gallery__main{
  position:relative;
  border-radius:20px;
  overflow:hidden;
  background:radial-gradient(120% 90% at 50% 28%, var(--steel1,#EEF1F6), var(--steel2,#D7DDE7));
  box-shadow:var(--shadow,0 24px 50px rgba(20,30,60,.12));
  aspect-ratio:1/1;            /* stable box → no layout shift, no distortion */
  isolation:isolate;
}
.product-gallery__main::before{  /* subtle grid, matches existing stages */
  content:"";position:absolute;inset:0;z-index:0;
  background-image:linear-gradient(rgba(20,23,28,.07) 1px,transparent 1px),
                   linear-gradient(90deg,rgba(20,23,28,.07) 1px,transparent 1px);
  background-size:46px 46px;opacity:.5;pointer-events:none;
}

.product-gallery__slide{
  position:absolute;inset:0;z-index:1;
  display:flex;align-items:center;justify-content:center;
  padding:6%;
  opacity:0;visibility:hidden;
  transition:opacity .45s ease;
  pointer-events:none;
}
.product-gallery__slide.is-active{opacity:1;visibility:visible;pointer-events:auto}

.product-gallery__img{
  max-width:100%;max-height:100%;
  width:auto;height:auto;
  object-fit:contain;                 /* never crop / never distort */
  display:block;
  filter:drop-shadow(0 26px 38px rgba(20,30,60,.26));
  cursor:zoom-in;
}
.product-gallery__video{
  max-width:100%;max-height:100%;
  width:100%;height:auto;
  border-radius:12px;
  background:#000;
  display:block;
}

/* zoom hint on the main image */
.product-gallery__zoom{
  position:absolute;right:14px;bottom:14px;z-index:4;
  display:inline-flex;align-items:center;gap:7px;
  padding:8px 13px;border-radius:40px;
  background:rgba(255,255,255,.92);
  border:1px solid var(--line-soft,rgba(20,23,28,.07));
  color:var(--soft,#5B6470);
  font:500 11.5px/1 'JetBrains Mono',monospace;
  letter-spacing:.06em;text-transform:uppercase;
  pointer-events:none;
}

/* existing product badge kept in place, repositioned only inside the gallery
   (scoped — the shared .slide-badge used elsewhere is untouched) */
.product-gallery .slide-badge{top:14px;right:14px;left:auto;bottom:auto;z-index:4}

/* ---------- arrows ---------- */
.product-gallery__nav{
  position:absolute;top:50%;transform:translateY(-50%);z-index:5;
  width:44px;height:44px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,.94);
  border:1px solid var(--line-soft,rgba(20,23,28,.07));
  box-shadow:0 8px 22px rgba(20,30,60,.14);
  color:var(--ink,#14171C);cursor:pointer;
  transition:background .2s,color .2s,opacity .2s;
  padding:0;
}
.product-gallery__nav:hover{background:var(--blue,#1763F7);color:#fff}
.product-gallery__nav:focus-visible{outline:3px solid rgba(23,99,247,.45);outline-offset:2px}
.product-gallery__nav--prev{left:12px}
.product-gallery__nav--next{right:12px}
.product-gallery__nav[disabled]{opacity:.35;cursor:default}
.product-gallery__nav[disabled]:hover{background:rgba(255,255,255,.94);color:var(--ink,#14171C)}

/* ---------- counter + dots ---------- */
.product-gallery__count{
  position:absolute;left:14px;top:14px;z-index:4;
  padding:7px 12px;border-radius:40px;
  background:rgba(255,255,255,.92);
  border:1px solid var(--line-soft,rgba(20,23,28,.07));
  color:var(--ink,#14171C);
  font:500 11.5px/1 'JetBrains Mono',monospace;letter-spacing:.06em;
}
.product-gallery__dots{
  display:flex;gap:8px;justify-content:center;align-items:center;
  padding:2px 0;
}
.product-gallery__dot{
  width:8px;height:8px;border-radius:50%;padding:0;
  border:none;background:var(--line,rgba(20,23,28,.12));
  cursor:pointer;transition:width .25s,background .25s;
}
.product-gallery__dot.is-active{background:var(--blue,#1763F7);width:24px;border-radius:4px}
.product-gallery__dot:focus-visible{outline:3px solid rgba(23,99,247,.45);outline-offset:3px}

/* ---------- thumbnails ---------- */
.product-gallery__thumbs{
  display:flex;gap:10px;
  overflow-x:auto;
  scroll-behavior:smooth;
  scrollbar-width:thin;
  padding:2px;
  -webkit-overflow-scrolling:touch;
}
.product-gallery__thumbs::-webkit-scrollbar{height:5px}
.product-gallery__thumbs::-webkit-scrollbar-thumb{background:var(--line,rgba(20,23,28,.12));border-radius:4px}
.product-gallery__thumb{
  position:relative;flex:0 0 82px;height:82px;
  border-radius:12px;overflow:hidden;padding:0;cursor:pointer;
  background:radial-gradient(120% 100% at 50% 20%, var(--steel1,#EEF1F6), var(--steel2,#D7DDE7));
  border:1.5px solid var(--line-soft,rgba(20,23,28,.07));
  transition:border-color .2s,transform .2s;
}
.product-gallery__thumb:hover{transform:translateY(-2px);border-color:rgba(23,99,247,.45)}
.product-gallery__thumb.is-active{border-color:var(--blue,#1763F7);box-shadow:0 0 0 3px rgba(23,99,247,.16)}
.product-gallery__thumb:focus-visible{outline:3px solid rgba(23,99,247,.45);outline-offset:2px}
.product-gallery__thumb img{width:100%;height:100%;object-fit:contain;padding:8px;display:block}
.product-gallery__thumb--video::after{     /* play badge on video thumb */
  content:"";position:absolute;inset:0;
  background:rgba(20,23,28,.34) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/22px no-repeat;
}

/* ---------- fallback when an image fails / none exist ---------- */
.product-gallery__fallback{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;
  width:100%;height:100%;color:var(--faint,#9098A3);
  font:500 13px/1.5 'Poppins',sans-serif;text-align:center;
}
.product-gallery__fallback svg{opacity:.5}

/* single-media mode: controls hidden by the component */
.product-gallery.is-single .product-gallery__nav,
.product-gallery.is-single .product-gallery__dots,
.product-gallery.is-single .product-gallery__thumbs,
.product-gallery.is-single .product-gallery__count{display:none}

/* =========================================================
   LIGHTBOX — appended to <body>, fully namespaced
   ========================================================= */
.pg-lightbox{
  position:fixed;inset:0;z-index:9999;
  display:none;
  flex-direction:column;
  background:rgba(12,15,20,.94);
  backdrop-filter:blur(6px);
  opacity:0;transition:opacity .25s ease;
}
.pg-lightbox.is-open{display:flex;opacity:1}
.pg-lightbox__bar{
  display:flex;align-items:center;justify-content:space-between;gap:16px;
  padding:14px 18px;color:#EDEFF3;flex:0 0 auto;
}
.pg-lightbox__count{font:500 12px/1 'JetBrains Mono',monospace;letter-spacing:.08em;color:#cfd4dc}
.pg-lightbox__close{
  width:44px;height:44px;border-radius:50%;padding:0;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.22);color:#fff;
  transition:background .2s;
}
.pg-lightbox__close:hover{background:var(--blue,#1763F7)}
.pg-lightbox__close:focus-visible{outline:3px solid rgba(255,255,255,.6);outline-offset:2px}

.pg-lightbox__stage{
  position:relative;flex:1 1 auto;min-height:0;
  display:flex;align-items:center;justify-content:center;
  padding:0 64px;
}
.pg-lightbox__media{
  max-width:100%;max-height:100%;
  object-fit:contain;display:block;
  border-radius:8px;
}
.pg-lightbox__nav{
  position:absolute;top:50%;transform:translateY(-50%);
  width:50px;height:50px;border-radius:50%;padding:0;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.22);color:#fff;
  transition:background .2s,opacity .2s;
}
.pg-lightbox__nav:hover{background:var(--blue,#1763F7)}
.pg-lightbox__nav:focus-visible{outline:3px solid rgba(255,255,255,.6);outline-offset:2px}
.pg-lightbox__nav--prev{left:12px}
.pg-lightbox__nav--next{right:12px}
.pg-lightbox__nav[disabled]{opacity:.3;cursor:default}

.pg-lightbox__thumbs{
  display:flex;gap:10px;justify-content:center;
  overflow-x:auto;padding:14px 18px 20px;flex:0 0 auto;
  scrollbar-width:thin;
}
.pg-lightbox__thumb{
  flex:0 0 64px;height:64px;border-radius:10px;overflow:hidden;padding:0;cursor:pointer;
  background:rgba(255,255,255,.08);
  border:1.5px solid rgba(255,255,255,.22);
  transition:border-color .2s;position:relative;
}
.pg-lightbox__thumb img{width:100%;height:100%;object-fit:contain;padding:6px;display:block}
.pg-lightbox__thumb.is-active{border-color:var(--blue,#1763F7);box-shadow:0 0 0 3px rgba(23,99,247,.35)}
.pg-lightbox__thumb:focus-visible{outline:3px solid rgba(255,255,255,.6);outline-offset:2px}

/* body scroll-lock while the lightbox is open (class applied by the component) */
body.pg-lightbox-open{overflow:hidden}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media(max-width:1024px){
  .product-gallery__main{aspect-ratio:4/3}
  .product-gallery__thumb{flex-basis:74px;height:74px}
}
@media(max-width:760px){
  .product-gallery__main{aspect-ratio:1/1;border-radius:16px}
  .product-gallery__nav{width:40px;height:40px}
  .product-gallery__nav--prev{left:8px}
  .product-gallery__nav--next{right:8px}
  .product-gallery__thumb{flex-basis:64px;height:64px}
  .pg-lightbox__stage{padding:0 12px}
  .pg-lightbox__nav{width:42px;height:42px}
  .pg-lightbox__nav--prev{left:6px}
  .pg-lightbox__nav--next{right:6px}
  .pg-lightbox__thumbs{justify-content:flex-start}
}
@media(max-width:560px){
  .product-gallery__zoom{display:none}
  .product-gallery__thumb{flex-basis:58px;height:58px}
  .pg-lightbox__thumb{flex-basis:52px;height:52px}
}

@media (prefers-reduced-motion:reduce){
  .product-gallery__slide,
  .product-gallery__dot,
  .product-gallery__thumb,
  .pg-lightbox{transition:none}
}
