/* TANDT shared product gallery.
 * The stable image frame is available at first paint. JavaScript enhances
 * captions, accessibility and the viewer; native Blocksy controls stay native.
 */
.woocommerce-product-gallery:not(:has(.flexy-items video, .flexy-items iframe, .flexy-items audio, .flexy-items [data-video], .flexy-items [data-type="video"], .flexy-items [data-media-type="video"], .flexy-items .ct-play-button)) .flexy-items figure.ct-media-container {
  width: 100%;
  margin-inline: 0;
  aspect-ratio: 1;
  height: auto;
  position: relative;
  overflow: hidden;
  background: #FFFFFF;
}

.woocommerce-product-gallery:not(:has(.flexy-items video, .flexy-items iframe, .flexy-items audio, .flexy-items [data-video], .flexy-items [data-type="video"], .flexy-items [data-media-type="video"], .flexy-items .ct-play-button)) .flexy-items figure.ct-media-container > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Keep Blocksy's trigger, icon, shape and behaviour. Its colours are managed
 * in Blocksy; only the Design System hit area is completed here.
 */
.woocommerce-product-gallery .woocommerce-product-gallery__trigger {
  box-sizing: border-box;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
}

.woocommerce-product-gallery[data-tandt-gallery-template="ready"] .epsivol-image-caption,
.woocommerce-product-gallery[data-tandt-gallery-template="ready"] .tandt-image-description {
  box-sizing: border-box;
  height: var(--tandt-gallery-caption-height, 0px);
  min-height: var(--tandt-gallery-caption-height, 0px);
  overflow-y: auto;
}

.woocommerce-product-gallery[data-tandt-gallery-template="ready"] .epsivol-image-caption[hidden],
.woocommerce-product-gallery[data-tandt-gallery-template="ready"] .tandt-image-description[hidden] {
  display: block;
  visibility: hidden;
}

.woocommerce-product-gallery[data-tandt-gallery-template="ready"] .tandt-image-description {
  margin: 12px 0 0;
  color: #4E5D67;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

.woocommerce-product-gallery .flexy-pills li:focus-visible {
  outline: none;
}

.woocommerce-product-gallery .flexy-pills li:focus-visible > span.ct-media-container,
.woocommerce-product-gallery .woocommerce-product-gallery__trigger:focus-visible,
.pswp.tandt-gallery-viewer .pswp__button:focus-visible,
.pswp.tandt-gallery-viewer .tandt-viewer-thumbnail:focus-visible {
  outline: 3px solid #0067B1;
  outline-offset: 3px;
}

.pswp.tandt-gallery-viewer .pswp__top-bar .pswp__button:focus-visible {
  outline-color: #FFFFFF;
}

.woocommerce-product-gallery .flexy-pills li > span.ct-media-container {
  box-sizing: border-box;
  border: 1px solid #C8CECB;
}

.woocommerce-product-gallery .flexy-pills li.active > span.ct-media-container,
.woocommerce-product-gallery .flexy-pills li[aria-current="true"] > span.ct-media-container {
  border: 2px solid #172F46;
}

.woocommerce-product-gallery .flexy-pills li.active:focus-visible > span.ct-media-container,
.woocommerce-product-gallery .flexy-pills li[aria-current="true"]:focus-visible > span.ct-media-container {
  border-color: transparent;
}

/* The fullscreen canvas belongs to the viewport, not to the image ratio. */
.pswp.tandt-gallery-viewer {
  z-index: 100000;
}

.pswp.tandt-gallery-viewer .pswp__scroll-wrap::before {
  content: "";
  position: absolute;
  inset: 44px 0 calc(var(--tandt-viewer-caption-height, 0px) + var(--tandt-viewer-thumbnails-height, 0px));
  background: #FFFFFF;
  pointer-events: none;
}

.pswp.tandt-gallery-viewer .tandt-viewer-thumbnails {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: 0;
  left: 0;
  box-sizing: border-box;
  height: calc(88px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #F3F1ED;
}

.pswp.tandt-gallery-viewer .tandt-viewer-thumbnails__track {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 8px 88px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.pswp.tandt-gallery-viewer .tandt-viewer-thumbnail {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #C8CECB;
  border-radius: 8px;
  background: #FFFFFF;
  cursor: pointer;
  scroll-snap-align: center;
}

/* Centre the complete strip when it fits, while preserving horizontal scroll
   and access to the first and last thumbnails when it overflows. */
.pswp.tandt-gallery-viewer .tandt-viewer-thumbnail:first-child {
  margin-inline-start: auto;
}

.pswp.tandt-gallery-viewer .tandt-viewer-thumbnail:last-child {
  margin-inline-end: auto;
}

.pswp.tandt-gallery-viewer .tandt-viewer-thumbnail[aria-current="true"] {
  border: 2px solid #172F46;
}

.pswp.tandt-gallery-viewer .tandt-viewer-thumbnail[aria-current="true"]:focus-visible {
  border-color: transparent;
}

.pswp.tandt-gallery-viewer .tandt-viewer-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.pswp.tandt-gallery-viewer .pswp__caption {
  bottom: var(--tandt-viewer-thumbnails-height, 0px);
  height: var(--tandt-viewer-caption-height, 0px);
  overflow: auto;
  background: #F3F1ED;
}

.pswp.tandt-gallery-viewer .pswp__caption__center {
  box-sizing: border-box;
  max-width: 420px;
  padding: 8px;
  color: #17212B;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.pswp.tandt-gallery-viewer .pswp__caption--empty {
  display: block;
}

.pswp.tandt-gallery-viewer .pswp__top-bar {
  opacity: 1;
  background: #172F46;
}

.pswp.tandt-gallery-viewer .pswp__button--zoom {
  position: relative;
  width: 44px;
  height: 44px;
  overflow: hidden;
  background: none !important;
}

.pswp.tandt-gallery-viewer .pswp__button--zoom::before {
  content: "+";
  position: absolute;
  top: 9px;
  left: 8px;
  box-sizing: border-box;
  width: 22px;
  height: 22px;
  border: 2px solid #FFFFFF;
  border-radius: 999px;
  color: #FFFFFF;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 17px;
  text-align: center;
  opacity: 1;
}

.pswp.tandt-gallery-viewer .pswp__button--zoom::after {
  content: "";
  position: absolute;
  top: 29px;
  left: 27px;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: #FFFFFF;
  transform: rotate(45deg);
  transform-origin: left center;
}

.pswp.tandt-gallery-viewer .pswp__button--zoom.tandt-zoom-active::before {
  content: "−";
}

.pswp.tandt-gallery-viewer.tandt-viewer-pannable .pswp__zoom-wrap,
.pswp.tandt-gallery-viewer.tandt-viewer-pannable .pswp__img {
  cursor: grab;
}

.pswp.tandt-gallery-viewer.tandt-viewer-pannable.pswp--dragging .pswp__zoom-wrap,
.pswp.tandt-gallery-viewer.tandt-viewer-pannable.pswp--dragging .pswp__img {
  cursor: grabbing;
}

.pswp.tandt-gallery-viewer .pswp__button--arrow--left,
.pswp.tandt-gallery-viewer .pswp__button--arrow--right {
  visibility: visible;
  opacity: 1;
}

.pswp.tandt-gallery-viewer .pswp__button--arrow--left {
  left: 8px;
}

.pswp.tandt-gallery-viewer .pswp__button--arrow--right {
  right: 8px;
}

.pswp.tandt-gallery-viewer .pswp__button--arrow--left::before,
.pswp.tandt-gallery-viewer .pswp__button--arrow--right::before {
  width: 48px;
  height: 48px;
  top: 24px;
  border-radius: 8px;
  background: #172F46;
  /* WooCommerce photoswipe.css forces this pseudo-element to transparent. */
  background-color: #172F46 !important;
}

.pswp.tandt-gallery-viewer .pswp__button--arrow--left::after,
.pswp.tandt-gallery-viewer .pswp__button--arrow--right::after {
  content: "";
  position: absolute;
  top: 40px;
  width: 16px;
  height: 16px;
  border: solid #FFFFFF;
  border-width: 0 2px 2px 0;
}

.pswp.tandt-gallery-viewer .pswp__button--arrow--left::after {
  left: 24px;
  transform: rotate(135deg);
}

.pswp.tandt-gallery-viewer .pswp__button--arrow--right::after {
  right: 24px;
  transform: rotate(-45deg);
}

.pswp.tandt-gallery-viewer .tandt-viewer-status {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  max-width: calc(100% - 40px);
  transform: translate(-50%, -50%);
  color: #17212B;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  pointer-events: none;
}

.pswp.tandt-gallery-viewer:not(.tandt-viewer-loading) .tandt-viewer-status {
  display: none;
}

@media (max-width: 689px) {
  .pswp.tandt-gallery-viewer .tandt-viewer-thumbnails {
    height: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  .pswp.tandt-gallery-viewer .tandt-viewer-thumbnails__track {
    padding: 8px 20px;
  }

  .pswp.tandt-gallery-viewer .tandt-viewer-thumbnail {
    flex-basis: 64px;
    width: 64px;
    height: 64px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .pswp.tandt-gallery-viewer *,
  .pswp.tandt-gallery-viewer *::before,
  .pswp.tandt-gallery-viewer *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
