/* =========================================================
   Галерея товара.
   Перенесено без изменений из пользовательского CSS шаблона Elementor
   «Страница товара» (ID 216) прежней версии сайта — только «selector»
   заменён на .product-gallery. Работает вместе со сниппетами Code Snippets
   #10 (стрелки у главного фото) и #11 (лента миниатюр со стрелками прокрутки).
   Порядок правил сохранён: поздние блоки намеренно переопределяют ранние.
   ========================================================= */

.product-gallery {
  width: 765px;
  max-width: 100%;
  flex: 0 0 auto;
}

.product-gallery .onsale {
  display: none !important;
}

.product-gallery .woocommerce-product-gallery {
  display: grid !important;
  grid-template-columns: 150px minmax(0, 600px);
  grid-template-areas: "thumbs image";
  gap: 15px;
  width: 100% !important;
  margin: 0 !important;
}

.product-gallery .flex-viewport,
.product-gallery .woocommerce-product-gallery__wrapper {
  grid-area: image;
}

.product-gallery .flex-viewport {
  width: 100% !important;
  background: #fff;
  aspect-ratio: 1;
  border: 2px solid #f2f5f7;
  border-radius: 14px;
  overflow: hidden;
}

.product-gallery .woocommerce-product-gallery__wrapper {
  margin: 0 !important;
  background: #fff;
}

.product-gallery .woocommerce-product-gallery__image,
.product-gallery .woocommerce-product-gallery__image a {
  display: block;
  background: #fff;
  width: 100%;
  height: 100%;
}

.product-gallery .woocommerce-product-gallery__image img {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: 1;
  object-fit: contain;
  box-sizing: border-box;
  padding: 4%;
}

.product-gallery .flex-control-thumbs {
  grid-area: thumbs;
  display: flex !important;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: auto;
  align-self: stretch;
  min-height: 0;
  margin: 0 !important;
  padding: 0 4px 0 0 !important;
  overflow-x: hidden;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
}

.product-gallery .flex-control-thumbs li {
  float: none !important;
  width: 100% !important;
  height: 140px;
  flex: 0 0 140px;
  margin: 0 !important;
  padding: 0 !important;
}

.product-gallery .flex-control-thumbs img {
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box;
  object-fit: contain;
  padding: 4%;
  border: 2px solid #f2f5f7;
  border-radius: 14px;
  opacity: 1 !important;
}

.product-gallery .flex-control-thumbs img.flex-active {
  border-color: #273343;
}

.product-gallery .zoomImg {
  display: none !important;
}

.product-gallery .woocommerce-product-gallery__trigger {
  display: block !important;
  position: absolute !important;
  top: 0 !important;
  right: 0 !important;
  left: auto !important;
  width: calc(100% - 165px);
  height: 100%;
  opacity: 0;
  z-index: 5;
  cursor: pointer;
}

.product-gallery .woocommerce-product-gallery__image a {
  cursor: pointer !important;
}

@media (max-width: 767px) {
  .product-gallery {
    width: 100%;
  }

  .product-gallery .woocommerce-product-gallery {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "image" "thumbs";
    gap: 10px;
  }

  .product-gallery .flex-control-thumbs {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    height: auto;
    padding: 0 0 4px !important;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .product-gallery .flex-control-thumbs li {
    width: auto !important;
    height: auto;
    flex: 0 0 calc((100% - 20px) / 3);
    aspect-ratio: 1;
  }
}

@media (max-width: 767px) {
  .product-gallery .woocommerce-product-gallery__trigger {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }
}

/* Native WooCommerce gallery navigation */
.product-gallery .flex-direction-nav {
  position: absolute !important;
  top: 0;
  right: 0;
  width: calc(100% - 165px);
  height: 100%;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
  pointer-events: none;
  z-index: 6;
}

.product-gallery .flex-direction-nav li {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

.product-gallery .flex-direction-nav a {
  position: absolute;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-top: -21px;
  border: 1px solid #f2f5f7;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 10px rgba(39, 51, 67, 0.12);
  color: #273343;
  font-size: 0;
  line-height: 1;
  text-decoration: none;
  pointer-events: auto;
}

.product-gallery .flex-direction-nav a::before {
  font-size: 32px;
  line-height: 1;
}

.product-gallery .flex-direction-nav .flex-prev {
  left: 14px;
}

.product-gallery .flex-direction-nav .flex-prev::before {
  content: "‹";
}

.product-gallery .flex-direction-nav .flex-next {
  right: 14px;
}

.product-gallery .flex-direction-nav .flex-next::before {
  content: "›";
}

.product-gallery .flex-direction-nav .flex-disabled {
  opacity: 0.3 !important;
  cursor: default;
}

@media (max-width: 767px) {
  .product-gallery .flex-direction-nav {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .product-gallery .flex-direction-nav a {
    width: 38px;
    height: 38px;
    margin-top: -19px;
  }

  .product-gallery .flex-direction-nav .flex-prev {
    left: 10px;
  }

  .product-gallery .flex-direction-nav .flex-next {
    right: 10px;
  }
}

/* Gallery visual polish */
.product-gallery .flex-control-thumbs img {
  background: #fff !important;
}

.product-gallery .woocommerce-product-gallery__image,
.product-gallery .woocommerce-product-gallery__image a,
.product-gallery .woocommerce-product-gallery__image img {
  border-radius: 12px;
}

.product-gallery .woocommerce-product-gallery__image,
.product-gallery .woocommerce-product-gallery__image a {
  overflow: hidden;
}

body .pswp__img {
  border-radius: 14px;
}

.product-gallery .flex-direction-nav a {
  width: 32px;
  height: 44px;
  margin-top: -22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.product-gallery .flex-direction-nav a::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  font-size: 0;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
}

.product-gallery .flex-direction-nav .flex-prev {
  left: 28px;
}

.product-gallery .flex-direction-nav .flex-prev::before {
  border-right: 16px solid #273343;
}

.product-gallery .flex-direction-nav .flex-next {
  right: 28px;
}

.product-gallery .flex-direction-nav .flex-next::before {
  border-left: 16px solid #273343;
}

@media (max-width: 767px) {
  .product-gallery .flex-direction-nav a {
    width: 28px;
    height: 38px;
    margin-top: -19px;
  }

  .product-gallery .flex-direction-nav a::before {
    border-top-width: 9px;
    border-bottom-width: 9px;
  }

  .product-gallery .flex-direction-nav .flex-prev {
    left: 18px;
  }

  .product-gallery .flex-direction-nav .flex-prev::before {
    border-right-width: 14px;
  }

  .product-gallery .flex-direction-nav .flex-next {
    right: 18px;
  }

  .product-gallery .flex-direction-nav .flex-next::before {
    border-left-width: 14px;
  }
}

/* Thin chevrons matching the gallery reference */
.product-gallery .flex-direction-nav a::before,
.product-gallery .flex-direction-nav .flex-prev::before,
.product-gallery .flex-direction-nav .flex-next::before {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  border: solid #bfc5cb;
  border-width: 4px 4px 0 0;
  background: none;
}

.product-gallery .flex-direction-nav .flex-prev::before {
  transform: rotate(-135deg);
}

.product-gallery .flex-direction-nav .flex-next::before {
  transform: rotate(45deg);
}

body .pswp__button--arrow--left,
body .pswp__button--arrow--right {
  top: 50%;
  width: 36px;
  height: 48px;
  margin-top: -24px;
  background: none !important;
  opacity: 1;
}

body .pswp__button--arrow--left {
  left: calc(50% - min(300px, calc(50vw - 12px)) + 28px);
}

body .pswp__button--arrow--right {
  right: calc(50% - min(300px, calc(50vw - 12px)) + 28px);
}

body .pswp__button--arrow--left::before,
body .pswp__button--arrow--right::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: 0;
  border: solid #bfc5cb;
  border-width: 4px 4px 0 0;
  background: none !important;
}

body .pswp__button--arrow--left::before {
  transform: translate(-35%, -50%) rotate(-135deg);
}

body .pswp__button--arrow--right::before {
  transform: translate(-65%, -50%) rotate(45deg);
}

@media (max-width: 767px) {
  .product-gallery .flex-direction-nav a::before,
  .product-gallery .flex-direction-nav .flex-prev::before,
  .product-gallery .flex-direction-nav .flex-next::before,
  body .pswp__button--arrow--left::before,
  body .pswp__button--arrow--right::before {
    width: 13px;
    height: 13px;
    border-width: 3px 3px 0 0;
  }

  body .pswp__button--arrow--left {
    left: calc(50% - min(300px, calc(50vw - 8px)) + 18px);
  }

  body .pswp__button--arrow--right {
    right: calc(50% - min(300px, calc(50vw - 8px)) + 18px);
  }
}

/* Standard 600px lightbox frame */
body .pswp {
  --gallery-frame: min(600px, calc(100vw - 32px), calc(100vh - 96px));
  --gallery-half-frame: min(300px, calc(50vw - 16px), calc(50vh - 48px));
}

body .pswp__zoom-wrap {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: var(--gallery-frame) !important;
  height: var(--gallery-frame) !important;
  transform: translate(-50%, -50%) !important;
  transform-origin: center !important;
}

body .pswp__img {
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box;
  object-fit: contain;
  padding: 4%;
  border: 2px solid #f2f5f7;
  border-radius: 14px;
  background: #fff !important;
}

body .pswp__button--arrow--left {
  left: calc(50% - var(--gallery-half-frame) + 22px);
}

body .pswp__button--arrow--right {
  right: calc(50% - var(--gallery-half-frame) + 22px);
}

@media (max-width: 767px) {
  body .pswp {
    --gallery-frame: min(600px, calc(100vw - 16px), calc(100vh - 80px));
    --gallery-half-frame: min(300px, calc(50vw - 8px), calc(50vh - 40px));
  }

  body .pswp__button--arrow--left {
    left: calc(50% - var(--gallery-half-frame) + 14px);
  }

  body .pswp__button--arrow--right {
    right: calc(50% - var(--gallery-half-frame) + 14px);
  }
}

/* Fullscreen frame larger than the 600px product gallery */
body .pswp {
  --gallery-frame: min(800px, calc(100vw - 32px), calc(100vh - 56px));
  --gallery-half-frame: min(400px, calc(50vw - 16px), calc(50vh - 28px));
}

@media (max-width: 767px) {
  body .pswp {
    --gallery-frame: min(800px, calc(100vw - 16px), calc(100vh - 56px));
    --gallery-half-frame: min(400px, calc(50vw - 8px), calc(50vh - 28px));
  }
}

/* One-row thumbnail rail with overflow arrows */
.product-gallery .gallery-thumb-shell {
  grid-area: thumbs;
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.product-gallery .gallery-thumb-shell .flex-control-thumbs {
  grid-area: auto;
  width: 100%;
  height: 100%;
  flex-wrap: nowrap !important;
  scrollbar-width: none;
}

.product-gallery .gallery-thumb-shell .flex-control-thumbs::-webkit-scrollbar {
  display: none;
}

.product-gallery .gallery-thumb-nav {
  position: absolute;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
  cursor: pointer;
}

.product-gallery .gallery-thumb-nav[hidden] {
  display: none !important;
}

.product-gallery .gallery-thumb-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

.product-gallery .gallery-thumb-nav::before {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border: solid #bfc5cb;
  border-width: 3px 3px 0 0;
}

.product-gallery .gallery-thumb-prev {
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.product-gallery .gallery-thumb-prev::before {
  transform: rotate(-45deg);
}

.product-gallery .gallery-thumb-next {
  right: auto;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.product-gallery .gallery-thumb-next::before {
  transform: rotate(135deg);
}

@media (max-width: 767px) {
  .product-gallery .gallery-thumb-shell {
    height: auto;
  }

  .product-gallery .gallery-thumb-shell .flex-control-thumbs {
    height: auto;
    flex-direction: row;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
  }

  .product-gallery .gallery-thumb-shell .flex-control-thumbs li {
    scroll-snap-align: start;
  }

  .product-gallery .gallery-thumb-prev,
  .product-gallery .gallery-thumb-next {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }

  .product-gallery .gallery-thumb-prev {
    left: 5px;
    right: auto;
  }

  .product-gallery .gallery-thumb-prev::before {
    transform: rotate(-135deg);
  }

  .product-gallery .gallery-thumb-next {
    right: 5px;
    left: auto;
  }

  .product-gallery .gallery-thumb-next::before {
    transform: rotate(45deg);
  }
}/* Transparent thumbnail arrow hit areas */
.product-gallery .gallery-thumb-nav,
.product-gallery .gallery-thumb-nav:hover,
.product-gallery .gallery-thumb-nav:focus,
.product-gallery .gallery-thumb-nav:active {
  background: transparent !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

/* Лента миниатюр — не выше главного фото (замечание владельца 26.09.2026).
   height: 100% у обёртки не работал: у строки сетки нет своей высоты, и 6 миниатюр
   по 140px вытягивали галерею до ~890px — стрелки фото и слой лупы (оба height: 100%
   галереи) уезжали вниз. Теперь строку задаёт квадратное фото, а лента лежит
   поверх обёртки и прокручивается своими стрелками (сниппет #11). */
@media (min-width: 768px) {
  .product-gallery .gallery-thumb-shell {
    height: auto;
    align-self: stretch;
  }

  .product-gallery .gallery-thumb-shell .flex-control-thumbs {
    position: absolute;
    inset: 0;
    height: auto;
  }
}
