/**
 * XO Gallery — front-end styles.
 *
 * The unscoped rules are the structural baseline every display shares.
 * Display-specific presentation is scoped under `.xo-gallery--{display}`
 * (`lightbox`, `featured-carousel`) so each display owns its own section
 * without touching the others. Child themes still own
 * project-specific colors, radius, and overlays.
 */

 .xo-gallery__carousel{ position: relative; }
 .xo-gallery__featured-previous, .xo-gallery__featured-next{ z-index: 2; }

.xo-gallery__grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
	gap: var(--xo-gallery-gap, 1rem);
}

.xo-gallery__item {
	margin: 0;
}

.xo-gallery__link,
.xo-gallery__link img {
	display: block;
}

.xo-gallery__link img {
	width: 100%;
	height: auto;
}

/* ==========================================================================
   Display: lightbox — uniform 4:3 grid
   ========================================================================== */

.xo-gallery--lightbox .xo-gallery__grid {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 64rem) {
	.xo-gallery--lightbox .xo-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 48rem) {
	.xo-gallery--lightbox .xo-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.xo-gallery--lightbox .xo-gallery__item {
	aspect-ratio: 4 / 3;
	overflow: hidden;
}

.xo-gallery--lightbox .xo-gallery__link {
	width: 100%;
	height: 100%;
}

/* Portrait and landscape photos share one cell shape; cover crops
   visually only, the attachment itself is untouched. */
.xo-gallery--lightbox .xo-gallery__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 250ms ease;
}

@media (hover: hover) {
	.xo-gallery--lightbox .xo-gallery__link:hover .xo-gallery__image {
		transform: scale(1.03);
	}
}

/* ==========================================================================
   Display: featured carousel
   ========================================================================== */

/* Fixed-shape stage so autoplay never shifts the page as landscape and
   portrait photos alternate; the photo itself is contained, never
   cropped. */
.xo-gallery--featured-carousel .xo-gallery__featured {
	position: relative;
	aspect-ratio: 3 / 2;
	max-height: 80vh;
	max-height: 80svh;
	overflow: hidden;
	z-index: 1;
}

.xo-gallery--featured-carousel .xo-gallery__featured-link {
	display: block;
	width: 100%;
	height: 100%;
}

.xo-gallery--featured-carousel .xo-gallery__featured-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	transition: opacity 150ms ease;
}

.xo-gallery--featured-carousel .xo-gallery__featured-image.is-fading,
.xo-gallery--featured-carousel .xo-gallery__featured-caption.is-fading {
	opacity: 0;
}

/* Caption bar across the bottom of the stage. Clicks pass through to the
   featured link beneath, so the whole photo still opens the lightbox. */
.xo-gallery--featured-carousel .xo-gallery__featured-caption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	margin: 0;
	padding: 0.75rem 1.25rem;
	background: var(--xo-gallery-caption-background, rgba(0, 0, 0, 0.6));
	color: var(--xo-gallery-caption-color, #fff);
	font-size: clamp(0.9375rem, 0.75rem + 1vw, 1.5rem);
	line-height: 1.35;
	text-align: center;
	pointer-events: none;
	transition: opacity 150ms ease;
}

.xo-gallery--featured-carousel .xo-gallery__featured-caption[hidden] {
	display: none;
}

/* Overlay controls share the lightbox's dark translucent disc so they stay
   legible over bright and dark photographs alike. */
.xo-gallery--featured-carousel .xo-gallery__featured-previous,
.xo-gallery--featured-carousel .xo-gallery__featured-next,
.xo-gallery--featured-carousel .xo-gallery__thumbnails-previous,
.xo-gallery--featured-carousel .xo-gallery__thumbnails-next {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.555);
	color: #fff;
	cursor: pointer;
	transition: background-color 150ms ease, opacity 150ms ease;
}

.xo-gallery--featured-carousel .xo-gallery__playback{
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.555);
	color: #fff;
	cursor: pointer;
	transition: background-color 150ms ease, opacity 150ms ease;

}

.xo-gallery--featured-carousel .xo-gallery__featured-previous:hover,
.xo-gallery--featured-carousel .xo-gallery__featured-next:hover,
.xo-gallery--featured-carousel .xo-gallery__playback:hover,
.xo-gallery--featured-carousel .xo-gallery__thumbnails-previous:hover:not(:disabled),
.xo-gallery--featured-carousel .xo-gallery__thumbnails-next:hover:not(:disabled) {
	color: #5c5c5c;
}

.xo-gallery--featured-carousel .xo-gallery__featured-previous:focus-visible,
.xo-gallery--featured-carousel .xo-gallery__featured-next:focus-visible,
.xo-gallery--featured-carousel .xo-gallery__playback:focus-visible,
.xo-gallery--featured-carousel .xo-gallery__thumbnails-previous:focus-visible,
.xo-gallery--featured-carousel .xo-gallery__thumbnails-next:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.6);
}

.xo-gallery--featured-carousel .xo-gallery__featured-link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -4px;
}

.xo-gallery--featured-carousel .xo-gallery__featured-previous[hidden],
.xo-gallery--featured-carousel .xo-gallery__featured-next[hidden],
.xo-gallery--featured-carousel .xo-gallery__playback[hidden],
.xo-gallery--featured-carousel .xo-gallery__thumbnails-previous[hidden],
.xo-gallery--featured-carousel .xo-gallery__thumbnails-next[hidden] {
	display: none;
}

.xo-gallery--featured-carousel .xo-gallery__thumbnails-previous:disabled,
.xo-gallery--featured-carousel .xo-gallery__thumbnails-next:disabled {
	opacity: 0.35;
	cursor: default;
}

.xo-gallery--featured-carousel .xo-gallery__icon {
	display: block;
	width: 1.375rem;
	height: 1.375rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

.xo-gallery--featured-carousel .xo-gallery__icon--play {
	fill: currentColor;
}

.xo-gallery--featured-carousel .xo-gallery__featured-previous,
.xo-gallery--featured-carousel .xo-gallery__featured-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
}

.xo-gallery--featured-carousel .xo-gallery__featured-previous {
	left: 1rem;
}

.xo-gallery--featured-carousel .xo-gallery__featured-next {
	right: 1rem;
}

/* Top corner, clear of the caption bar. */
.xo-gallery--featured-carousel .xo-gallery__playback {
	position: absolute;
	top: 1rem;
	right: 1rem;
	width: 2.25rem;
	height: 2.25rem;
}

.xo-gallery--featured-carousel .xo-gallery__playback .xo-gallery__icon {
	width: 1.125rem;
	height: 1.125rem;
}

/* Pause icon while playing, Play icon while paused. */
.xo-gallery--featured-carousel .xo-gallery__playback .xo-gallery__icon--play,
.xo-gallery--featured-carousel .xo-gallery__playback.is-paused .xo-gallery__icon--pause {
	display: none;
}

.xo-gallery--featured-carousel .xo-gallery__playback.is-paused .xo-gallery__icon--play {
	display: block;
}

/* Screen-reader-only "View image N of M" announcements. */
.xo-gallery--featured-carousel .xo-gallery__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Thumbnail rail — secondary to the featured photo. The number of visible
   thumbnails follows the available width. */
.xo-gallery--featured-carousel .xo-gallery__thumbnail-navigation {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.75rem;
}

.xo-gallery--featured-carousel .xo-gallery__thumbnail-viewport {
	position: relative;
	flex: 1 1 auto;
	min-width: 0;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-x: contain;
	scrollbar-width: thin;
}

/* Padding keeps the active ring and focus outline inside the scroll
   viewport's clip. */
.xo-gallery--featured-carousel .xo-gallery__thumbnail-track {
	display: flex;
	gap: var(--xo-gallery-thumbnail-gap, 0.5rem);
	width: max-content;
	padding: 4px;
}

.xo-gallery--featured-carousel .xo-gallery__thumbnail {
	flex: 0 0 auto;
	width: var(--xo-gallery-thumbnail-width, 7.5rem);
	aspect-ratio: 4 / 3;
	overflow: hidden;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
	opacity: 0.65;
	transition: opacity 150ms ease, box-shadow 150ms ease;
}

.xo-gallery--featured-carousel .xo-gallery__thumbnail img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

@media (hover: hover) {
	.xo-gallery--featured-carousel .xo-gallery__thumbnail:hover {
		opacity: 1;
	}
}

.xo-gallery--featured-carousel .xo-gallery__thumbnail--active {
	opacity: 1;
	box-shadow: 0 0 0 3px var(--xo-gallery-active-color, currentColor);
}

.xo-gallery--featured-carousel .xo-gallery__thumbnail:focus-visible {
	opacity: 1;
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Small screens: smaller overlay controls, and native touch scrolling in
   place of the rail arrows. */
@media (max-width: 48rem) {
	.xo-gallery--featured-carousel .xo-gallery__featured-previous {
		left: 0.5rem;
	}

	.xo-gallery--featured-carousel .xo-gallery__featured-next {
		right: 0.5rem;
	}

	.xo-gallery--featured-carousel .xo-gallery__featured-previous,
	.xo-gallery--featured-carousel .xo-gallery__featured-next {
		width: 2.5rem;
		height: 2.5rem;
	}

	.xo-gallery--featured-carousel .xo-gallery__playback {
		top: 0.5rem;
		right: 0.5rem;
	}

	/* The caption moves from an overlay to a strip under the photo, so a
	   long caption can't cover a small photo or the arrows. The 3:2 stage
	   shape moves from the container to the link. */
	.xo-gallery--featured-carousel .xo-gallery__featured {
		aspect-ratio: auto;
		max-height: none;
		overflow: visible;
		background: none;
		container-type: inline-size;
	}

	.xo-gallery--featured-carousel .xo-gallery__featured-link {
		aspect-ratio: 3 / 2;
		height: auto;
		max-height: 80vh;
		max-height: 80svh;
		overflow: hidden;
		background: var(--xo-gallery-featured-background, rgba(0, 0, 0, 0.05));
	}

	.xo-gallery--featured-carousel .xo-gallery__featured-caption {
		position: static;
		padding: 0.5rem 0.75rem;
	}

	/* Center the arrows on the photo (a third of the width = half the 3:2
	   link's height), not on photo + caption. */
	.xo-gallery--featured-carousel .xo-gallery__featured-previous,
	.xo-gallery--featured-carousel .xo-gallery__featured-next {
		top: 50%;
		top: min(33.333cqi, 40svh);
	}

	.xo-gallery--featured-carousel .xo-gallery__thumbnails-previous,
	.xo-gallery--featured-carousel .xo-gallery__thumbnails-next {
		display: none;
	}

	.xo-gallery--featured-carousel .xo-gallery__thumbnail {
		width: var(--xo-gallery-thumbnail-width-small, 5.5rem);
	}
}

/* ==========================================================================
   Lightbox (one shared instance, built by view.js)
   ========================================================================== */

body.xo-gallery-lightbox-open {
	overflow: hidden;
}

.xo-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
}

.xo-gallery-lightbox[hidden] {
	display: none;
}

.xo-gallery-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.9);
}

.xo-gallery-lightbox__dialog {
	position: absolute;
	inset: 0;
}

.xo-gallery-lightbox__media {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	padding: 2rem;
}

.xo-gallery-lightbox__image {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 4rem);
	max-height: calc(100svh - 4rem);
	width: auto;
	height: auto;
	object-fit: contain;
	transition: opacity 150ms ease;
}

.xo-gallery-lightbox.is-loading .xo-gallery-lightbox__image {
	opacity: 0.4;
}

/* Controls sit on a dark translucent disc with a light edge so they stay
   legible over both bright and dark photographs. */
.xo-gallery-lightbox__close,
.xo-gallery-lightbox__previous,
.xo-gallery-lightbox__next {
	position: absolute;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	cursor: pointer;
	transition: background-color 150ms ease;
}

.xo-gallery-lightbox__close:hover,
.xo-gallery-lightbox__previous:hover,
.xo-gallery-lightbox__next:hover {
	background: rgba(0, 0, 0, 0.85);
}

.xo-gallery-lightbox__close:focus-visible,
.xo-gallery-lightbox__previous:focus-visible,
.xo-gallery-lightbox__next:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.xo-gallery-lightbox__close[hidden],
.xo-gallery-lightbox__previous[hidden],
.xo-gallery-lightbox__next[hidden] {
	display: none;
}

.xo-gallery-lightbox__close svg,
.xo-gallery-lightbox__previous svg,
.xo-gallery-lightbox__next svg {
	display: block;
	width: 1.5rem;
	height: 1.5rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

.xo-gallery-lightbox__close {
	top: 1rem;
	right: 1rem;
}

.xo-gallery-lightbox__previous,
.xo-gallery-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
}

.xo-gallery-lightbox__previous {
	left: 1rem;
}

.xo-gallery-lightbox__next {
	right: 1rem;
}

@media (max-width: 48rem) {
	.xo-gallery-lightbox__media {
		padding: 1rem;
	}

	.xo-gallery-lightbox__close {
		top: 0.5rem;
		right: 0.5rem;
	}

	.xo-gallery-lightbox__previous {
		left: 0.5rem;
	}

	.xo-gallery-lightbox__next {
		right: 0.5rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.xo-gallery--lightbox .xo-gallery__image,
	.xo-gallery-lightbox__image,
	.xo-gallery-lightbox__close,
	.xo-gallery-lightbox__previous,
	.xo-gallery-lightbox__next {
		transition: none;
	}

	.xo-gallery--lightbox .xo-gallery__link:hover .xo-gallery__image {
		transform: none;
	}

	.xo-gallery--featured-carousel .xo-gallery__featured-image,
	.xo-gallery--featured-carousel .xo-gallery__featured-caption,
	.xo-gallery--featured-carousel .xo-gallery__thumbnail,
	.xo-gallery--featured-carousel button {
		transition: none;
	}
}
