/*
 * Photo slider: a core Gallery block carrying the class imx-gallery-slider becomes a horizontal scroll-snap strip.
 * Works without script (swipe or scroll); assets/js/gallery-slider.js adds autoplay, buttons and the loop.
 * Front end only (not loaded in the editor, where the gallery stays a normal grid). RTL site.
 *
 * Slides visible at once: change --imx-slider-visible (per breakpoint below, or on a single instance).
 */

.imx-photo-slider__title {
	margin: 0 0 32px;
	text-align: center;
}

/* ":not(#imx)" lifts these rules above core's gallery rules, which use ":not(#individual-image)". */
.wp-block-gallery.has-nested-images.imx-gallery-slider:not(#imx) {
	--imx-slider-visible: 2;
	--imx-slider-gap: 12px;
	--imx-slider-ratio: 4 / 3;
	--imx-slider-pad: 6px;
	--wp--style--unstable-gallery-gap: var(--imx-slider-gap);
	display: flex;
	flex-flow: row nowrap;
	justify-content: flex-start;
	gap: var(--imx-slider-gap);
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0;
	padding: 8px var(--imx-slider-pad) 24px;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-padding-inline: var(--imx-slider-pad);
	-webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
	.wp-block-gallery.has-nested-images.imx-gallery-slider:not(#imx) {
		--imx-slider-visible: 3;
		--imx-slider-gap: 16px;
	}
}

@media (min-width: 1024px) {
	.wp-block-gallery.has-nested-images.imx-gallery-slider:not(#imx) {
		--imx-slider-visible: 4;
		--imx-slider-gap: 20px;
	}
}

.wp-block-gallery.has-nested-images.imx-gallery-slider:not(#imx) > figure.wp-block-image:not(#imx) {
	flex: 0 0 calc((100% - (var(--imx-slider-visible) - 1) * var(--imx-slider-gap)) / var(--imx-slider-visible));
	box-sizing: border-box;
	width: auto;
	max-width: none;
	min-width: 0;
	margin: 0;
	aspect-ratio: var(--imx-slider-ratio);
	position: relative;
	overflow: hidden;
	border-radius: 16px;
	background: var(--imx-line, #e2e8ed);
	box-shadow: 0 1px 2px rgba(31, 58, 82, 0.06), 0 6px 18px rgba(31, 58, 82, 0.12);
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

.wp-block-gallery.has-nested-images.imx-gallery-slider:not(#imx) > figure.wp-block-image img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/* Captions off: the photos carry the message. */
.wp-block-gallery.has-nested-images.imx-gallery-slider:not(#imx) figcaption {
	display: none;
}

/* With script: the strip is driven by the buttons, so the native scrollbar goes. */
.imx-slider--js > .wp-block-gallery.imx-gallery-slider:not(#imx) {
	scrollbar-width: none;
}
.imx-slider--js > .wp-block-gallery.imx-gallery-slider::-webkit-scrollbar {
	display: none;
}

/* Few photos: no strip behaviour. */
.imx-slider--static > .wp-block-gallery.imx-gallery-slider:not(#imx) {
	justify-content: center;
	overflow-x: hidden;
}

.wp-block-gallery.imx-gallery-slider:focus-visible {
	outline: 2px solid var(--imx-primary, #1476ad);
	outline-offset: 2px;
}

/* -------------------------------------------------------------- controls */
.imx-slider {
	position: relative;
}
.imx-slider__controls {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 12px;
	margin-top: 4px;
}
.imx-slider--static > .imx-slider__controls {
	display: none;
}
.imx-slider__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--imx-line, #e2e8ed);
	border-radius: 50%;
	background: #fff;
	color: var(--imx-navy, #1f3a52);
	box-shadow: 0 1px 2px rgba(31, 58, 82, 0.1), 0 4px 12px rgba(31, 58, 82, 0.12);
	cursor: pointer;
	transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.imx-slider__btn:hover {
	background: var(--imx-surface, #f5f7f9);
}
.imx-slider__btn svg {
	display: block;
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.25;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}
.imx-slider__btn--toggle svg {
	fill: currentColor;
	stroke: none;
}
/* The site is RTL: "previous" sits on the right and points right, "next" sits on the left and points left. */
.imx-slider__btn--prev svg {
	transform: scaleX(-1);
}
.imx-slider__btn[hidden] {
	display: none;
}
/* The default focus ring (brand blue) is too faint on the navy band. */
.imx-band--navy .imx-slider__btn:focus-visible {
	outline-color: #fff;
}

.imx-slider__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-gallery.has-nested-images.imx-gallery-slider:not(#imx) {
		scroll-behavior: auto;
	}
}
