/* Keep Kadence visual style; only minimal fixes for video sizing */
.pg-product-gallery-splide .splide__slide {
	display: flex;
	align-items: center;
	justify-content: center;
}
.pg-product-gallery-splide .splide__track,
.pg-product-gallery-splide .splide__list {
	width: 100%;
}

/* Safety caps against oversized widths/heights due to race conditions */
.pg-product-gallery-splide,
.pg-product-gallery-splide .splide__track,
.pg-product-gallery-splide .splide__list,
.pg-product-gallery-splide .splide__slide {
	max-width: 100% !important;
	box-sizing: border-box;
}
.pg-product-gallery-splide .splide__track,
.pg-product-gallery-splide .splide__list,
.pg-product-gallery-splide .splide__slide {
	height: auto !important;
}

/* When JS detects abnormal dimensions, we force reset transforms */
.pg-product-gallery-splide.pg-normalize .splide__list {
	transform: none !important;
}

.woocommerce div.product .woocommerce-product-gallery__wrapper {
	height: auto !important;
}
.pg-video-file,
.pg-video-embed {
	max-width: 100%;
	width: 100%;
	height: 100%;
	aspect-ratio: 4 / 3;
}

/* Ensure thumbnails styles from Kadence remain intact; no overrides here */

/* Woo-like thumbnails below slider */
.pg-product-gallery-splide + .flex-control-thumbs,
.woocommerce .flex-control-thumbs {
    list-style: none;
    margin: 12px 0 0 !important; /* небольшой отступ от слайдера */
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.flex-control-thumbs li {
	width: 70px;
	height: 70px;
	cursor: pointer;
	border: 1px solid rgba(0,0,0,.08);
	box-sizing: border-box;
}
.flex-control-thumbs li:hover img,
.woocommerce div.product div.images .flex-control-thumbs li.flex-active img {
	opacity: 1; /* активная как при наведении */
}
.flex-control-thumbs li.flex-active {
    outline: none; /* убрать рамку */
    border-color: transparent; /* убрать бордер на активном */
}
.flex-control-thumbs img {
    width: 100%;
    height: 100%;
    object-fit: cover;
	opacity: .6;
	transition: opacity .2s ease;
}

/* Ensure arrows visible */
.pg-product-gallery-splide .splide__arrows .splide__arrow {
	background: rgba(0,0,0,0.4);
	color: #fff;
	border: 0;
}

/* Avoid partially visible slide due to external paddings */
.pg-product-gallery-splide {
	overflow: hidden;
}

/* Override Kadence rule that shrinks subsequent images to 65px inside our slider */
.pg-product-gallery-splide .woocommerce-product-gallery__image img {
	height: auto !important;
}

/* Kill thumbnail-like layout rules applied to default Woo wrapper when inside our Splide */
.pg-product-gallery-splide .woocommerce-product-gallery__image {
	display: block !important;
	height: auto !important;
	width: 100% !important;
	margin-top: 0 !important;
}

/* Stronger override against Kadence selector chain */
.woocommerce div.product div.images .woocommerce-product-gallery__wrapper .pg-product-gallery-splide .woocommerce-product-gallery__image {
	display: block !important;
	height: auto !important;
	width: 100% !important;
	margin-top: 0 !important;
}

/* Ensure anchors are clickable and not covered */
.pg-product-gallery-splide .woocommerce-product-gallery__image a {
	display: block;
	position: relative;
	z-index: 2;
	pointer-events: auto;
}
.pg-product-gallery-splide .splide__slide::before,
.pg-product-gallery-splide .splide__track::before {
	pointer-events: none;
}

/* Ensure PhotoSwipe hidden after close (in case of state sticks) */
.pswp:not(.pswp--open) {
	display: none !important;
}
/* Reset pswp element quickly after close to avoid sticky visible state */
.pswp.pswp--visible[aria-hidden="true"] {
	display: none !important;
}

/* Video in PhotoSwipe lightbox */
.pswp-video-container {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #000;
}

.pswp-video-youtube,
.pswp-video-local {
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.pswp-video-youtube {
	aspect-ratio: 4 / 3;
}

.pswp-video-local {
	aspect-ratio: 4 / 3;
}

/* Ensure video containers fit properly in PhotoSwipe */
.pswp__item .pswp-video-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

/* Video thumbnail styling */
.flex-control-thumbs li.pg-video-thumb {
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.8);
	color: var(--global-palette4);
	font-size: 24px;
	font-weight: bold;
	position: relative;
	overflow: hidden;
}

.flex-control-thumbs li.pg-video-thumb span {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	line-height: 1;
}

/* YouTube icon overlay for video thumbnails */
.flex-control-thumbs li.pg-video-thumb::after,
.flex-control-thumbs li.pg-video-thumb-youtube::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 32px;
	height: 22px;
	background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMjIiIHZpZXdCb3g9IjAgMCAzMiAyMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTMxLjMzIDMuNDFDMzAuOTIgMS44NSAyOS43IDAuNjMgMjguMTQgMC4yM0MyNS42OCAwIDMuNiAwIDMuNiAwUzEuNTIgMC4wMSAtMC45NCAwLjIzQy0yLjUgMC42MyAtMy43MiAxLjg1IC00LjEzIDMuNDFDLTQuMzcgNS45MyAtNC4zNyAxMC45OSAtNC4zNyAxMC45OVMtNC4zNyAxNi4wNSAtNC4xMyAxOC41N0MtMy43MiAyMC4xMyAtMi41IDIxLjM1IC0wLjk0IDIxLjc1QzEuNTIgMjEuOTggMy42IDIxLjk4IDMuNiAyMS45OFMyNS42OCAyMS45OCAyOC4xNCAyMS43NUMyOS43IDIxLjM1IDMwLjkyIDIwLjEzIDMxLjMzIDE4LjU3QzMxLjU3IDE2LjA1IDMxLjU3IDEwLjk5IDMxLjU3IDEwLjk5UzMxLjU3IDUuOTMgMzEuMzMgMy40MVoiIGZpbGw9IiNGRjAwMDAiLz4KPHBhdGggZD0iTTEyLjggMTUuNjhMMjAuOCAxMC45OUwxMi44IDYuM1YxNS42OFoiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPgo=');
	background-size: contain;
	background-repeat: no-repeat;
	background-position: center;
	pointer-events: none;
	z-index: 2;
}

/* Video thumbnail with actual image but YouTube overlay */
.flex-control-thumbs li.pg-video-thumb-youtube {
	position: relative;
}

.flex-control-thumbs li.pg-video-thumb-youtube img {
	opacity: 0.8;
}

.flex-control-thumbs li.pg-video-thumb-youtube:hover img {
	opacity: 1;
}

/* Play button overlay for all video thumbnails */
.flex-control-thumbs li.pg-video-thumb::before,
.flex-control-thumbs li.pg-video-thumb-youtube::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 0;
	height: 0;
	border-left: 12px solid rgba(255, 255, 255, 0.9);
	border-top: 8px solid transparent;
	border-bottom: 8px solid transparent;
	z-index: 1;
	pointer-events: none;
}

/* Hide play button when YouTube icon is present */
.flex-control-thumbs li.pg-video-thumb-youtube::before {
	display: none;
}


.woocommerce div.product div.images .woocommerce-product-gallery__wrapper .flex-control-thumbs li img {
	border: none;
}

.woocommerce div.product div.images .woocommerce-product-gallery__wrapper .flex-control-thumbs li {
	padding-left: 0 !important;
}

/* Скрываем значок лупы в галерее товара */
.woocommerce-product-gallery__trigger {
	display: none !important;
}