/**
 * Mobile gallery scroll overlay — Digikala-style.
 *
 * Strategy (1.0.48):
 *   - Gallery is position:fixed behind a solid white overlay (z-index 1 / 2).
 *   - Hide only after full cover; restore early while still under the panel
 *     so scrolling back up feels like the gallery was always behind.
 *   - Soft opacity transition (mostly invisible under the white panel).
 */

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

/* ── Ancestor reset: WoodMart must not create new stacking context ─── */
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-wrap-active,
body.jwt-mgso-on .jwt-mgso-active .product-images-inner {
	transform: none !important;
	filter: none !important;
	perspective: none !important;
	will-change: auto !important;
	contain: none !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-wrap-active {
	overflow: visible !important;
	background: transparent !important;
	background-color: transparent !important;
	box-shadow: none !important;
	margin: 0 !important;
	padding: 0 !important;
	min-height: 0 !important;
}

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

/* ── Hero spacer (transparent) ────────────────────────────────────── */
body.jwt-mgso-on .jwt-mgso-hero-wrap {
	background: transparent !important;
	overflow: visible !important;
	pointer-events: none;
}

/* ── Fixed gallery ────────────────────────────────────────────────── */
body.jwt-mgso-on .jwt-mgso-gallery {
	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;
	visibility: visible;
	pointer-events: auto;
	transform: translate3d(0, 0, 0);
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	/* Soft restore; usually completes while still under white overlay */
	transition: opacity 0.2s ease, visibility 0s linear 0s;
}

/* Fully covered / past cover point — must not paint behind description */
body.jwt-mgso-on .jwt-mgso-gallery--released {
	opacity: 0 !important;
	visibility: hidden !important;
	pointer-events: none !important;
	transition: opacity 0.12s ease, visibility 0s linear 0.12s;
}

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 overlay scrolls over 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;
	isolation: isolate;
}

.jwt-mgso-overlay,
.jwt-mgso-overlay > * {
	background: #fff;
}

.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,
.jwt-mgso-overlay .product-tabs-wrapper .container,
.jwt-mgso-overlay .product-tabs-wrapper .row {
	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;
}
