/*
 * Product image & video popups (colorbox).
 * Themes force #cboxLoadedContent to "height: auto; min-height; max-height: 80vh; overflow-y: auto", which breaks
 * Colorbox's own size calculations (detached controls, scrollbars, shrunk iframes). Popups opened with the
 * eshop-image-popup / eshop-video-popup class let Colorbox size the content to fit the viewport instead.
 */
#colorbox.eshop-image-popup #cboxLoadedContent,
#colorbox.eshop-image-popup #cboxContent #cboxLoadedContent,
#colorbox.eshop-video-popup #cboxLoadedContent,
#colorbox.eshop-video-popup #cboxContent #cboxLoadedContent {
	min-height: 0 !important;
	max-height: none !important;
	overflow: hidden !important;
}

#colorbox.eshop-image-popup #cboxTopCenter,
#colorbox.eshop-image-popup #cboxBottomCenter,
#colorbox.eshop-video-popup #cboxTopCenter,
#colorbox.eshop-video-popup #cboxBottomCenter {
	height: 0;
}

#colorbox.eshop-image-popup .cboxPhoto {
	display: block;
	max-width: none;
	margin: 0 auto;
}

/* Video popup: keep players at a 16:9 ratio */
#colorbox.eshop-video-popup #cboxLoadedContent .cboxIframe,
#colorbox.eshop-video-popup #cboxLoadedContent .eshop-video-popup-player {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	border: 0;
	background-color: #000;
	object-fit: contain;
}

/* Smaller side paddings on phones so the image/video gets more room */
@media (max-width: 575.98px) {
	#colorbox.eshop-image-popup #cboxContent #cboxLoadedContent,
	#colorbox.eshop-video-popup #cboxContent #cboxLoadedContent {
		padding-left: 10px !important;
		padding-right: 10px !important;
	}
}

/*
 * Themes force "#colorbox { width: 100% !important }" on phones while Colorbox still offsets the box from the left,
 * which pushes it past the right edge of the screen. Pin the full-width box to the left and centre the popup in it.
 */
@media (max-width: 480px) {
	#colorbox.eshop-image-popup,
	#colorbox.eshop-video-popup {
		left: 0 !important;
	}

	#colorbox.eshop-image-popup #cboxWrapper,
	#colorbox.eshop-video-popup #cboxWrapper {
		left: 50%;
		transform: translateX(-50%);
	}
}
