/**
 * Mobile gallery scroll overlay — Digikala-style.
 *
 * Gallery: position fixed IN PLACE (DOM untouched — WoodMart safe)
 * Overlay:  white panel z-index 2 scrolls over gallery z-index 1
 */

body.jwt-mgso-on {
	--jwt-mgso-header-offset: 0px;
	--jwt-mgso-gallery-height: 45vh;
	--jwt-mgso-overlay-radius: 16px;
	--jwt-mgso-overlay-overlap: 24px;
}

/* Neutralize WoodMart transforms that break position:fixed */
body.jwt-mgso-on .jwt-mgso-active,
body.jwt-mgso-on .jwt-mgso-active .product-image-summary-wrap,
body.jwt-mgso-on .jwt-mgso-active .product-image-summary,
body.jwt-mgso-on .jwt-mgso-active .product-image-summary-inner,
body.jwt-mgso-on .jwt-mgso-hero,
body.jwt-mgso-on .jwt-mgso-active .product-images,
body.jwt-mgso-on .jwt-mgso-active .product-images-inner {
	transform: none !important;
	filter: none !important;
	perspective: none !important;
	contain: none !important;
	will-change: auto !important;
}

body.jwt-mgso-on .jwt-mgso-active .product-image-summary-wrap,
body.jwt-mgso-on .jwt-mgso-active .product-image-summary,
body.jwt-mgso-on .jwt-mgso-active .product-image-summary-inner,
body.jwt-mgso-on .jwt-mgso-hero {
	overflow: visible !important;
	background: transparent !important;
	background-color: transparent !important;
	margin: 0 !important;
	padding: 0 !important;
	min-height: 0 !important;
	box-shadow: none !important;
}

body.jwt-mgso-on .jwt-mgso-hero {
	position: relative;
	z-index: 1;
}

body.jwt-mgso-on .jwt-mgso-active .product-image-summary-inner {
	display: block !important;
}

body.jwt-mgso-on .jwt-mgso-gallery-placeholder {
	display: block;
	width: 100%;
	height: var(--jwt-mgso-gallery-height);
	pointer-events: none;
	background: transparent !important;
}

/* Fixed gallery layer — stays in DOM, never reparented */
body.jwt-mgso-on .jwt-mgso-gallery.jwt-mgso-gallery--fixed {
	position: fixed !important;
	top: var(--jwt-mgso-header-offset) !important;
	left: 0 !important;
	right: 0 !important;
	inset-inline: 0 !important;
	width: 100% !important;
	max-width: 100% !important;
	height: var(--jwt-mgso-gallery-height) !important;
	margin: 0 !important;
	padding: 0 !important;
	z-index: 1 !important;
	background: #fff;
	overflow: hidden;
	opacity: 1 !important;
	visibility: visible !important;
}

/* After hero zone — gallery unpins (hidden behind white content) */
body.jwt-mgso-on .jwt-mgso-gallery.jwt-mgso-gallery--fixed.jwt-mgso-gallery--released {
	visibility: hidden !important;
	pointer-events: none !important;
}

body.jwt-mgso-on .jwt-mgso-gallery .product-images-inner,
body.jwt-mgso-on .jwt-mgso-gallery .woocommerce-product-gallery {
	height: 100% !important;
	width: 100% !important;
}

body.jwt-mgso-on .jwt-mgso-gallery .woocommerce-product-gallery__wrapper,
body.jwt-mgso-on .jwt-mgso-gallery .wd-carousel-container,
body.jwt-mgso-on .jwt-mgso-gallery .wd-carousel-wrap {
	height: 100% !important;
}

body.jwt-mgso-on .jwt-mgso-gallery img {
	object-fit: contain;
	max-height: 100%;
	width: auto;
	max-width: 100%;
	margin: 0 auto;
	display: block;
}

/* White content scrolls OVER the gallery */
.jwt-mgso-overlay {
	position: relative !important;
	z-index: 2 !important;
	display: block !important;
	margin-top: calc(-1 * var(--jwt-mgso-overlay-overlap)) !important;
	background: #fff !important;
	border-radius: var(--jwt-mgso-overlay-radius) var(--jwt-mgso-overlay-radius) 0 0 !important;
	box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.1);
	padding-top: 8px;
	padding-bottom: 24px;
	width: 100% !important;
	max-width: 100% !important;
	clear: both;
}

.jwt-mgso-overlay .summary.entry-summary,
.jwt-mgso-overlay .summary,
.jwt-mgso-overlay .product-tabs-wrapper,
.jwt-mgso-overlay .woocommerce-tabs,
.jwt-mgso-overlay .wd-single-tabs,
.jwt-mgso-overlay .related-products,
.jwt-mgso-overlay .upsells,
.jwt-mgso-overlay .wd-related-products,
.jwt-mgso-overlay .shop_attributes,
.jwt-mgso-overlay .woocommerce-Tabs-panel,
.jwt-mgso-overlay .wd-accordion-item,
.jwt-mgso-overlay .wd-tab-content,
.jwt-mgso-overlay .product-tabs-inner,
.jwt-mgso-overlay .poduct-tabs-inner {
	background: #fff !important;
}

.jwt-mgso-overlay .summary.entry-summary,
.jwt-mgso-overlay .summary {
	width: 100% !important;
	max-width: 100% !important;
	flex: none !important;
	float: none !important;
	margin: 0 !important;
	padding: 16px 16px 0 !important;
	position: relative;
}

.jwt-mgso-overlay .product-tabs-wrapper,
.jwt-mgso-overlay .woocommerce-tabs,
.jwt-mgso-overlay .wd-single-tabs {
	margin-top: 0 !important;
}

body.jwt-mgso-on.jwt-mgso-hide-breadcrumbs .single-breadcrumbs-wrapper,
body.jwt-mgso-on.jwt-mgso-hide-breadcrumbs .woocommerce-breadcrumb {
	display: none !important;
}

body.jwt-mgso-on .whb-header,
body.jwt-mgso-on .whb-main-header,
body.jwt-mgso-on .wd-header,
body.jwt-mgso-on .woodmart-header {
	z-index: 390 !important;
}

body.jwt-mgso-on .wd-sticky-btn,
body.jwt-mgso-on .woodmart-sticky-btn,
body.jwt-mgso-on .wd-sticky-add-to-cart {
	z-index: 30 !important;
}
