/*
 * Majestic Native Product Gallery
 * v0.5.1
 */

.majestic-product-gallery {
	--majestic-gallery-gap: 8px;
	display: flow-root;
	position: relative;
	width: 100%;
	min-width: 0;
	color: var(--majestic-color-text, #222);
	font-family: var(--majestic-font-body, inherit);
}

/* Reset Elementor/global button styling inside this component only. */
.elementor .majestic-product-gallery button,
.majestic-product-gallery button {
	min-width: 0 !important;
	min-height: 0;
	margin: 0;
	box-shadow: none !important;
	text-shadow: none !important;
	text-decoration: none !important;
}

.majestic-product-gallery__stage {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: visible;
	border: 1px solid #d8d8d8;
	border-radius: 4px;
	background: #f7f7f7;
}

.majestic-product-gallery__media {
	position: absolute;
	inset: 0;
	overflow: hidden;
	border-radius: inherit;
}

.elementor .majestic-product-gallery__main-button,
.majestic-product-gallery__main-button {
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	color: inherit !important;
	box-shadow: none !important;
	cursor: zoom-in;
}

.majestic-product-gallery__main {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	opacity: 1;
	transition: opacity .18s ease;
}

.majestic-product-gallery.is-changing .majestic-product-gallery__main,
.majestic-product-gallery.is-changing .majestic-product-gallery__video-wrap {
	opacity: .55;
}

.majestic-product-gallery__video-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: #111;
	transition: opacity .18s ease;
}

.majestic-product-gallery__video,
.majestic-product-gallery__video-embed {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #111;
	object-fit: contain;
}

/* Reference-style arrows: black circles half outside the image. */
.elementor .majestic-product-gallery__nav,
.majestic-product-gallery__nav {
	position: absolute !important;
	z-index: 6;
	top: 50%;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 42px !important;
	height: 42px !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 999px !important;
	background: #050505 !important;
	color: #fff !important;
	box-shadow: none !important;
	transform: translateY(-50%);
	cursor: pointer;
}

.elementor .majestic-product-gallery__nav:hover,
.elementor .majestic-product-gallery__nav:focus,
.majestic-product-gallery__nav:hover,
.majestic-product-gallery__nav:focus {
	border: 0 !important;
	background: #050505 !important;
	color: #fff !important;
	opacity: .86;
}

.majestic-product-gallery__nav--prev {
	left: 14px;
}

.majestic-product-gallery__nav--next {
	right: 14px;
}

.majestic-product-gallery__nav svg {
	display: block;
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
}

/* Reference does not show a separate zoom icon. Image remains clickable. */
.majestic-product-gallery__zoom {
	display: none !important;
}

/* Thumbnails */
.majestic-product-gallery__thumbs {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - (4 * var(--majestic-gallery-gap))) / 5);
	align-items: stretch;
	justify-content: start;
	gap: var(--majestic-gallery-gap);
	width: 100%;
	margin-top: 8px;
	padding: 0;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.majestic-product-gallery__thumbs::-webkit-scrollbar {
	display: none;
}

.elementor .majestic-product-gallery__thumb,
.majestic-product-gallery__thumb {
	position: relative;
	display: block !important;
	width: 100% !important;
	min-width: 0 !important;
	max-width: none !important;
	aspect-ratio: 1 / 1;
	padding: 0 !important;
	overflow: hidden;
	border: 1px solid #dedede !important;
	border-radius: 4px !important;
	background: #fafafa !important;
	box-shadow: none !important;
	cursor: pointer;
	scroll-snap-align: start;
}

.elementor .majestic-product-gallery__thumb:hover,
.elementor .majestic-product-gallery__thumb:focus,
.majestic-product-gallery__thumb:hover,
.majestic-product-gallery__thumb:focus {
	border-color: #888 !important;
	background: #fafafa !important;
}

.elementor .majestic-product-gallery__thumb.is-active,
.majestic-product-gallery__thumb.is-active {
	border-color: #111 !important;
	background: #fafafa !important;
}

.majestic-product-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.majestic-product-gallery__thumb.is-video {
	background: #111 !important;
}

.majestic-product-gallery__thumb.is-video img {
	opacity: .72;
}

.majestic-product-gallery__thumb-play {
	position: absolute;
	top: 50%;
	left: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 999px;
	background: rgba(0,0,0,.82);
	color: #fff;
	transform: translate(-50%, -50%);
	pointer-events: none;
}

.majestic-product-gallery__thumb-play svg {
	width: 13px;
	height: 13px;
	fill: currentColor;
}

.majestic-product-gallery__thumb[hidden],
.majestic-product-gallery__nav[hidden],
.majestic-product-gallery__thumbs[hidden] {
	display: none !important;
}

/* Lightbox */
.majestic-gallery-lightbox {
	position: fixed;
	z-index: 999999;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 28px;
	background: rgba(12, 12, 12, .92);
}

.majestic-gallery-lightbox.is-open {
	display: flex;
}

.majestic-gallery-lightbox__image {
	display: block;
	max-width: min(92vw, 1400px);
	max-height: 88vh;
	width: auto;
	height: auto;
	object-fit: contain;
}

.elementor .majestic-gallery-lightbox button,
.majestic-gallery-lightbox button {
	border: 0 !important;
	box-shadow: none !important;
}

.majestic-gallery-lightbox__close,
.majestic-gallery-lightbox__nav {
	position: absolute;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border-radius: 999px;
	background: #fff !important;
	color: #171717 !important;
	cursor: pointer;
}

.majestic-gallery-lightbox__close {
	top: 18px;
	right: 18px;
	font-size: 28px;
	line-height: 1;
}

.majestic-gallery-lightbox__nav {
	top: 50%;
	transform: translateY(-50%);
}

.majestic-gallery-lightbox__nav--prev {
	left: 18px;
}

.majestic-gallery-lightbox__nav--next {
	right: 18px;
}

.majestic-gallery-lightbox__nav svg {
	width: 17px;
	height: 17px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.7;
}

.majestic-gallery-lightbox__counter {
	position: absolute;
	right: 0;
	bottom: 18px;
	left: 0;
	color: #fff;
	font-size: 12px;
	text-align: center;
}

/* Tablet */
@media (max-width: 1024px) and (min-width: 768px) {
	.majestic-product-gallery__nav--prev {
		left: 12px;
	}
	.majestic-product-gallery__nav--next {
		right: 12px;
	}

	.majestic-product-gallery__thumbs {
		grid-auto-columns: calc((100% - (4 * var(--majestic-gallery-gap))) / 5);
	}
}

/* Mobile */
@media (max-width: 767px) {
	.majestic-product-gallery {
		--majestic-gallery-gap: 8px;
	}

	.majestic-product-gallery__nav {
		width: 38px !important;
		height: 38px !important;
	}

	.majestic-product-gallery__nav--prev {
		left: 8px;
	}

	.majestic-product-gallery__nav--next {
		right: 8px;
	}

	.majestic-product-gallery__thumbs {
		margin-top: 8px;
	}

	/*
	 * Keep a stable thumbnail footprint on phones.
	 * Do not let a two-image variation suddenly create two huge 50%-width
	 * thumbnails, as that changes the gallery height and can collide with
	 * the stacked Elementor buying column.
	 */
	.majestic-product-gallery__thumbs {
		grid-auto-columns: calc((100% - (3 * var(--majestic-gallery-gap))) / 4);
	}

	.majestic-product-gallery__thumb {
		padding: 0 !important;
	}

	.majestic-gallery-lightbox {
		padding: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.majestic-product-gallery__main,
	.majestic-product-gallery__video-wrap {
		transition: none;
	}
}


/* Product-specific sale badge, shown only when WooCommerce says the product is on sale. */
.majestic-product-gallery__sale-badge {
	position: absolute;
	z-index: 6;
	top: 14px;
	right: 14px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 46px;
	min-height: 46px;
	max-width: 120px;
	padding: 8px 10px;
	border-radius: 999px;
	background: var(--majestic-color-accent, #aa7f79);
	color: var(--majestic-color-on-dark, #fff);
	font-size: 11px;
	font-weight: 600;
	line-height: 1.1;
	text-align: center;
}

@media (max-width: 767px) {
	.majestic-product-gallery__sale-badge {
		top: 10px;
		right: 10px;
		min-width: 40px;
		min-height: 40px;
		padding: 7px 8px;
		font-size: 10px;
	}
}
