/**
 * Product gallery: show the first photo before the slider is built.
 *
 * "Gallery Slider for WooCommerce" (preloader "normal") keeps the gallery
 * under a white preloader with the carousel hidden until its script has
 * built the slider after DOMContentLoaded, and prints the gallery at
 * max-width: 50% until then. When the first slide is an inline video, the
 * poster image is printed with visibility: hidden and only shown once the
 * video player script is ready. Measured on a live tour page (Slow 4G, 4x
 * CPU): the photo was downloaded at 9.7 s but painted at 13.4 s.
 *
 * Only selectors inside #wpgs-gallery. !important is needed against the
 * inline styles the gallery prints and sets from its script.
 *
 * Module: MHMExcursions\Perf\GalleryRevealEarly.
 */

/* Full width before init, as the script sets it at init (no jump). */
#wpgs-gallery.wcgs-spswiper-before-init {
	max-width: 100% !important;
	width: 100%;
}

/* The carousel stays visible, also while the script rebuilds it. */
#wpgs-gallery .wcgs-carousel {
	opacity: 1 !important;
	visibility: visible !important;
}

/*
 * Before init no click handlers are bound and the lightbox icon is a real link
 * (the YouTube embed or the raw image): no taps until the slider is built, as
 * when the carousel was hidden.
 */
#wpgs-gallery.wcgs-spswiper-before-init .wcgs-carousel {
	pointer-events: none;
}

/* Before init each slide takes the full width; the rest overflow hidden. */
#wpgs-gallery.wcgs-spswiper-before-init .wcgs-carousel .spswiper-slide {
	flex: 0 0 100%;
	width: 100%;
}

/*
 * A video slide's poster image stays visible until the video starts: the
 * gallery then hides it itself and an iframe (or a started YouTube player,
 * .initialized) takes its place, so this rule stops matching. Browsers
 * without :has() drop this rule and keep the old behaviour.
 */
#wpgs-gallery .wcgs-carousel .wcgs-iframe-wrapper:not(:has(iframe, video, .initialized)) > img.wcgs-slider-image-tag {
	visibility: visible !important;
}

/* No white veil over the photo while the slider is built. */
#wpgs-gallery .wcgs-gallery-preloader {
	display: none !important;
}
