/* Styles: marquee = Marquee, slider = Slider, track = Track */

/* core/gallery, style "marquee": a logo strip that scrolls left in an endless loop (ticker tape).
   Figma: Event & Commercial Home › Client Logos 7217:15355 (Ticker Tape Logos 7217:15357)
   The front end prints the images twice (render filter in inc/blocks/core-gallery.php, copies inert + aria-hidden),
   so moving the row by -50% loops without a seam. Editor: a still, centred, wrapping row.
   Reduced motion: a still row that scrolls sideways, copies hidden.
   Logo size: the image `width` attribute (inline style; the seeded logos carry their Figma width, the editor has no
   width control inside a gallery), else 136px (the design's usual logo). Capped at the 77px logo height. */

.wp-block-gallery.is-style-marquee {
	--fews-marquee-gap: 7.5rem;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 0 var(--fews-marquee-gap);
	margin: 0;
	padding-inline: calc(var(--fews-marquee-gap) / 2);
}

/* core sizes the images as columns (width rules carry an ID, so min/max pin them to the logo instead) */
.wp-block-gallery.has-nested-images.is-style-marquee figure.wp-block-image {
	flex: none;
	min-inline-size: max-content;
	max-inline-size: max-content;
	block-size: 6.25rem;
}

/* a logo without a width (added in the editor): 136px box */
.wp-block-gallery.has-nested-images.is-style-marquee figure.wp-block-image:has(img:not([style*="width"])) {
	min-inline-size: 0;
	max-inline-size: 8.5rem;
}

.wp-block-gallery.has-nested-images.is-style-marquee figure.wp-block-image img {
	max-block-size: 4.8125rem;
	object-fit: contain;
}

/* front end only (the copies exist): one row */
.wp-block-gallery.is-style-marquee:has(> [inert]) {
	flex-wrap: nowrap;
	justify-content: flex-start;
}

@media (prefers-reduced-motion: no-preference) {
	.wp-block-gallery.is-style-marquee:has(> [inert]) {
		inline-size: max-content;
		animation: fews-marquee 60s linear infinite;
	}

	.wp-block-gallery.is-style-marquee:has(> [inert]):hover {
		animation-play-state: paused;
	}

	:has(> .wp-block-gallery.is-style-marquee) {
		overflow-x: clip;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-gallery.is-style-marquee:has(> [inert]) {
		overflow-x: auto;
		scrollbar-width: thin;
	}

	.wp-block-gallery.has-nested-images.is-style-marquee > [inert] {
		display: none;
	}
}

@keyframes fews-marquee {
	to {
		transform: translateX(-50%);
	}
}

@media (width < 782px) {
	.wp-block-gallery.is-style-marquee {
		--fews-marquee-gap: 3.75rem;
	}
}

/* Styles "slider" and "track": Splide carousels on the front end (markup: inc/blocks/core-gallery.php, mount:
   assets/js/gallery-slider.js, structure: assets/vendor/splide/splide-core.min.css); the editor shows the plain gallery.
   Before Splide mounts (or without JS) the row scrolls sideways. */
.wp-block-gallery.splide {
	visibility: visible;
	margin: 0;
}

.wp-block-gallery.splide:not(.is-initialized) .splide__track {
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
}

.wp-block-gallery.splide:not(.is-initialized) .splide__slide {
	scroll-snap-align: start;
}

.wp-block-gallery.splide .wp-block-image {
	margin: 0;
}

.wp-block-gallery.splide .wp-block-image img {
	display: block;
	inline-size: 100%;
	object-fit: cover;
}

.wp-block-gallery.splide .wp-element-caption {
	margin: 0.625rem 0 0;
	font-size: var(--wp--preset--font-size--text-12);
	line-height: 1.5;
}

.wp-block-gallery.splide:focus-visible,
.wp-block-gallery.splide .splide__arrow:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 3px;
}

.wp-block-gallery.splide .splide__arrow {
	position: absolute;
	z-index: 2;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	color: var(--wp--preset--color--base);
	cursor: pointer;
	transition: background-color 0.2s;
}

.wp-block-gallery.splide .splide__arrow svg {
	display: none;
}

.wp-block-gallery.splide .splide__arrow::before {
	content: "";
	inline-size: 1.25rem;
	block-size: 1.25rem;
	background: currentColor;
	mask: url("../../icons/chevron-right.svg") center / contain no-repeat;
}

.wp-block-gallery.splide .splide__arrow--prev::before {
	transform: scaleX(-1);
}

/* "slider": one photo at a time, 709 × 548, square buttons on the sides.
   Figma: Event Structures Article › Image left, "Blog / Image slider" 7026:27931 */
.wp-block-gallery.is-style-slider .splide__slide {
	inline-size: 100%;
}

/* beats the Article's column image ratio (sections/article.css) */
.wp-block-gallery.splide.is-style-slider .splide__slide .wp-block-image img {
	aspect-ratio: 709 / 548;
}

.wp-block-gallery.is-style-slider .splide__arrow {
	top: 50%;
	inline-size: 3.125rem;
	block-size: 3.125rem;
	border-radius: 3px;
	background: var(--wp--preset--color--contrast);
	transform: translateY(-50%);
}

.wp-block-gallery.is-style-slider .splide__arrow:is(:hover, :focus-visible) {
	background: var(--wp--preset--color--primary);
}

.wp-block-gallery.is-style-slider .splide__arrow--prev {
	left: 0;
}

.wp-block-gallery.is-style-slider .splide__arrow--next {
	right: 0;
}

/* "track": 3:2 photos in a row that runs off the right edge, 5px apart, 72px in; round buttons above the row on the
   right, in line with the container. Turn on "Expand on click" for the zoom button (core's lightbox trigger, restyled;
   core places it 16px in, so it is moved to the corner). Figma: Event Structures Case Study › Gallery 7511:23191
   Photo height capped at the screen minus the header and the section's title (20rem), so both show at once. */
.wp-block-gallery.is-style-track {
	--fews-track-slide: min(66.5625vw, 79.875rem, (100svh - 20rem) * 1.5);
}

.wp-block-gallery.is-style-track .splide__slide {
	inline-size: var(--fews-track-slide);
}

.wp-block-gallery.is-style-track:not(.is-initialized) .splide__slide {
	margin-inline-end: 0.3125rem;
}

.wp-block-gallery.is-style-track:not(.is-initialized) .splide__slide:first-child {
	margin-inline-start: 4.5rem;
}

.wp-block-gallery.splide.is-style-track .splide__slide .wp-block-image img {
	aspect-ratio: 3 / 2;
}

.wp-block-gallery.is-style-track .lightbox-trigger {
	inline-size: 3.125rem;
	block-size: 3.125rem;
	padding: 0;
	border: 0;
	border-radius: 0;
	opacity: 1;
	backdrop-filter: none;
	transform: translate(1rem, -1rem);
}

/* beats core's button:not(:hover):not(:active):not(.has-background) grey */
.wp-block-gallery.is-style-track .wp-lightbox-container button.lightbox-trigger:not(.has-background) {
	background-color: color-mix(in srgb, var(--wp--preset--color--ink) 50%, transparent);
}

.wp-block-gallery.is-style-track .lightbox-trigger svg {
	display: none;
}

.wp-block-gallery.is-style-track .lightbox-trigger::before {
	content: "";
	inline-size: 1.5625rem;
	block-size: 1.5625rem;
	background: var(--wp--preset--color--base);
	mask: url("../../icons/zoom.svg") center / contain no-repeat;
}

.wp-block-gallery.is-style-track .splide__arrow {
	bottom: calc(100% + 1.875rem);
	inline-size: 4.375rem;
	block-size: 4.375rem;
	border-radius: 50%;
	background: color-mix(in srgb, var(--wp--preset--color--contrast) 55%, var(--wp--preset--color--muted)); /* Figma greyscale/600 #4a5565 */
}

.wp-block-gallery.is-style-track .splide__arrow:is(:hover, :focus-visible) {
	background: var(--wp--preset--color--primary);
}

.wp-block-gallery.is-style-track .splide__arrow::before {
	mask-image: url("../../icons/arrow-right.svg");
}

.wp-block-gallery.is-style-track .splide__arrow--next {
	right: max(1.25rem, (100% - 80.9375rem) / 2);
}

.wp-block-gallery.is-style-track .splide__arrow--prev {
	right: calc(max(1.25rem, (100% - 80.9375rem) / 2) + 4.375rem + 0.625rem);
}

/* Photo viewer (a <dialog> made by assets/js/gallery-viewer.js): white page, the photo as large as fits above a strip
   of 106 × 71 thumbnails (the current one outlined orange), round prev/next on the sides, close square top right.
   Figma: Gallery 6927:10733 */
.fews-gallery-viewer {
	--fews-viewer-grey: color-mix(in srgb, var(--wp--preset--color--contrast) 55%, var(--wp--preset--color--muted)); /* Figma greyscale/600 #4a5565 */
	box-sizing: border-box;
	inline-size: 100%;
	max-inline-size: none;
	block-size: 100%;
	max-block-size: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--wp--preset--color--base);
	overflow: hidden;
}

.fews-gallery-viewer[open] {
	display: grid;
	grid-template-rows: minmax(0, 1fr) auto;
}

.fews-gallery-viewer::backdrop {
	background: var(--wp--preset--color--base);
}

.fews-gallery-viewer__stage {
	box-sizing: border-box;
	min-block-size: 0;
	margin: 0;
	padding: 0.875rem 5.625rem 0.6875rem;
}

/* fills the stage, the photo contained in it */
.fews-gallery-viewer__stage img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: contain;
}

.fews-gallery-viewer__thumbs {
	display: flex;
	gap: 0.3125rem;
	padding: 0 0.9375rem 0.5rem;
	overflow-x: auto;
	scrollbar-width: thin;
}

.fews-gallery-viewer__thumbs button {
	flex: none;
	inline-size: 6.625rem;
	block-size: 4.4375rem;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
}

.fews-gallery-viewer__thumbs img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
}

.fews-gallery-viewer__thumbs [aria-current] {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: -2px;
}

.fews-gallery-viewer__close,
.fews-gallery-viewer__arrow {
	position: absolute;
	z-index: 1;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0;
	color: var(--wp--preset--color--base);
	background: var(--fews-viewer-grey);
	cursor: pointer;
	transition: background-color 0.2s;
}

.fews-gallery-viewer__close:is(:hover, :focus-visible),
.fews-gallery-viewer__arrow:is(:hover, :focus-visible) {
	background: var(--wp--preset--color--primary);
}

.fews-gallery-viewer__close {
	top: 0;
	right: 0;
	inline-size: 3.125rem;
	block-size: 3.125rem;
}

.fews-gallery-viewer__arrow {
	top: calc(50% - 2.375rem);
	inline-size: 4.375rem;
	block-size: 4.375rem;
	border-radius: 50%;
	transform: translateY(-50%);
}

.fews-gallery-viewer__arrow::before {
	content: "";
	inline-size: 1.25rem;
	block-size: 1.25rem;
	background: currentColor;
	mask: url("../../icons/arrow-right.svg") center / contain no-repeat;
}

.fews-gallery-viewer__arrow.is-prev {
	left: 0.625rem;
}

.fews-gallery-viewer__arrow.is-prev::before {
	transform: scaleX(-1);
}

.fews-gallery-viewer__arrow.is-next {
	right: 0.625rem;
}

.fews-gallery-viewer :focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

.fews-gallery-viewer__status {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	margin: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

@media (width < 782px) {
	.fews-gallery-viewer__stage {
		padding: 3.75rem 0.625rem 0.6875rem;
	}

	.fews-gallery-viewer__arrow {
		top: auto;
		bottom: 5.5rem;
		inline-size: 3.125rem;
		block-size: 3.125rem;
		transform: none;
	}
}

@media (width < 782px) {
	.wp-block-gallery.is-style-track {
		--fews-track-slide: 85vw;
		padding-block-end: 4.375rem; /* room for the buttons under the row */
	}

	.wp-block-gallery.is-style-track:not(.is-initialized) .splide__slide:first-child {
		margin-inline-start: 1.25rem;
	}

	/* under the row, right-aligned */
	.wp-block-gallery.is-style-track .splide__arrow {
		top: auto;
		bottom: 0;
		inline-size: 3.125rem;
		block-size: 3.125rem;
	}

	.wp-block-gallery.is-style-track .splide__arrow--next {
		right: 1.25rem;
	}

	.wp-block-gallery.is-style-track .splide__arrow--prev {
		right: 5rem;
	}
}
