/*
 * Gallery "Slider" style. Every rule is scoped to .rr-slider, which only exists
 * when an editor picks the Slider style, so normal galleries are unaffected.
 * !important is used only to beat core's gallery rules, which use
 * :not(#individual-image) specificity hacks and an overlay caption design.
 */
.rr-slider {
	--rr-slider-gap: 16px;
	--rr-slider-slide: 100%; /* one image visible at a time */
	/* Height of the picture box. gallery-slider.js replaces this with two thirds of the box's
	   real width (a 3:2 box), so a landscape picture reaches the arrows; this is the fallback. */
	--rr-slider-height: clamp(180px, 52vw, 480px);
	--rr-slider-arrow: 44px; /* arrow button size */
	--rr-slider-arrow-gap: 6px; /* space between an arrow and the picture */
	position: relative;
	width: 100%;
	/* Never wider than the screen minus 15px each side, so the arrows do not touch the screen
	   edges when the slider sits in a full-width area (a page without the article column). */
	max-width: calc(100vw - 30px);
	min-width: 0; /* stops flex/grid parents from stretching to the content width */
	margin: 1.5em auto;
	/* Side gaps that hold the arrows, so they are never on top of the picture. */
	padding: 0 calc(var(--rr-slider-arrow) + var(--rr-slider-arrow-gap));
	box-sizing: border-box;
}

/* A slider with one picture has no arrows, so it needs no side gaps. */
.rr-slider--single {
	padding-right: 0;
	padding-left: 0;
}

/* The gallery figure is the scroll container. */
.rr-slider .wp-block-gallery.is-style-rr-slider {
	position: relative;
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: var(--rr-slider-gap) !important;
	width: 100% !important;
	max-width: 100% !important;
	margin: 0 !important;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain; /* a swipe never scrolls the page sideways */
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

/* With a mouse the pictures can be dragged sideways (gallery-slider.js): show a hand. */
@media (hover: hover) and (pointer: fine) {
	.rr-slider:not(.rr-slider--single) .wp-block-gallery.is-style-rr-slider {
		cursor: grab;
	}
}

/* While dragging, the picture follows the cursor: no snapping, no text or image selection. */
.rr-slider--dragging .wp-block-gallery.is-style-rr-slider {
	scroll-snap-type: none;
	cursor: grabbing;
	user-select: none;
}

.rr-slider .wp-block-gallery.is-style-rr-slider::-webkit-scrollbar {
	display: none;
}

.rr-slider .wp-block-gallery.is-style-rr-slider:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 4px;
}

.rr-slider .wp-block-gallery.is-style-rr-slider > figure.wp-block-image {
	position: static !important;
	display: flex !important;
	flex: 0 0 var(--rr-slider-slide) !important;
	flex-direction: column;
	justify-content: flex-start !important;
	width: var(--rr-slider-slide) !important;
	max-width: var(--rr-slider-slide) !important;
	margin: 0 !important;
	scroll-snap-align: start;
}

.rr-slider--single .wp-block-gallery.is-style-rr-slider > figure.wp-block-image {
	flex-basis: 100% !important;
	width: 100% !important;
	max-width: 100% !important;
}

/* Same-height frame for every slide so the layout never jumps. */
.rr-slider .wp-block-gallery.is-style-rr-slider > figure.wp-block-image img {
	display: block;
	flex: none !important;
	width: 100% !important;
	height: var(--rr-slider-height) !important;
	object-fit: contain !important;
	-webkit-user-drag: none;
	user-select: none;
}

/* Captions sit below the image instead of core's overlay. */
.rr-slider .wp-block-gallery.is-style-rr-slider > figure.wp-block-image figcaption {
	position: static !important;
	flex-grow: 0 !important;
	width: auto !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0.5em 0 0 !important;
	overflow: visible !important;
	color: inherit !important;
	font-size: 0.9em;
	text-align: center !important;
	background: none !important;
}

.rr-slider .wp-block-gallery.is-style-rr-slider > figure.wp-block-image::before,
.rr-slider .wp-block-gallery.is-style-rr-slider > figure.wp-block-image::after {
	display: none !important;
}

/* Safety net: the lightbox button is removed server-side, hide it if it ever appears. */
.rr-slider .lightbox-trigger {
	display: none !important;
}

/*
 * Arrows. They sit in the side gaps of .rr-slider (see its padding), so they are always
 * outside the picture, on the page's own background, at every screen size. Each is a green
 * icon on a dark circle, so it is easy to see whatever the picture looks like.
 */
.rr-slider__arrow {
	position: absolute;
	top: calc(var(--rr-slider-height) / 2);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--rr-slider-arrow);
	height: var(--rr-slider-arrow);
	margin: 0;
	padding: 0;
	color: #6eadbc; /* arrow icon: the site's green */
	background: rgba(24, 24, 24, 0.92); /* dark circle */
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transform: translateY(-50%);
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.rr-slider__arrow--prev {
	left: 0;
}

.rr-slider__arrow--next {
	right: 0;
}

.rr-slider__arrow:hover {
	color: #8fc4d1;
	background: #000;
}

.rr-slider__arrow:focus-visible,
.rr-slider__dot:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
}

.rr-slider__arrow:focus-visible {
	outline-color: #181818;
}

/* At the first or last picture the arrow fades but stays visible. */
.rr-slider__arrow[aria-disabled="true"] {
	cursor: default;
	opacity: 0.35;
}

/* Dots: 24px tap target around a 10px dot. */
.rr-slider__dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 2px;
	margin-top: 0.75em;
}

.rr-slider__dot {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin: 0;
	padding: 0;
	color: inherit;
	background: none;
	border: 0;
	cursor: pointer;
}

.rr-slider__dot::before {
	width: 10px;
	height: 10px;
	content: "";
	background: currentColor;
	border-radius: 50%;
	opacity: 0.3;
	transition: opacity 0.2s ease;
}

.rr-slider__dot[aria-current="true"]::before {
	opacity: 1;
}

/* Phones and touch screens: swipe and dots still work; the arrows stay, but smaller, so the picture keeps more of the width. */
@media (max-width: 767px), (hover: none) and (pointer: coarse) {
	.rr-slider {
		--rr-slider-arrow: 32px;
		--rr-slider-arrow-gap: 4px;
	}

	.rr-slider__arrow svg {
		width: 20px;
		height: 20px;
	}
}

/*
 * Desktop (1024px and wider): the image box is a fixed 800px wide, centred, instead of the
 * full width of the column, so the arrows sit close to the picture.
 * 800px box + 2 x (44px arrow + 6px gap) = 900px, the width of the article column.
 */
@media (min-width: 1024px) {
	.rr-slider {
		--rr-slider-height: 533px; /* 800 x 533 = a 3:2 picture fills the box edge to edge */
		max-width: min(100vw - 30px, 800px + 2 * (var(--rr-slider-arrow) + var(--rr-slider-arrow-gap)));
	}
}
