/* Wandering Albums
 * Selectors repeat the style class so they outrank core gallery rules,
 * which use :not(#individual-image) for extra weight.
 */

/* ---------- Album (justified rows, nothing cropped) ---------- */

.wp-block-gallery.has-nested-images.is-style-wandering-album.is-style-wandering-album {
	--wa-row: 170px;
	--wa-gap: var(--wp--style--unstable-gallery-gap, 10px);
	display: flex;
	flex-wrap: wrap;
	gap: var(--wa-gap);
}

@media (min-width: 782px) {
	.wp-block-gallery.has-nested-images.is-style-wandering-album.is-style-wandering-album {
		--wa-row: 260px;
	}
}

/* Keeps the last row from stretching a lone photo across the page. */
.wp-block-gallery.has-nested-images.is-style-wandering-album.is-style-wandering-album::after {
	content: "";
	flex-grow: 1000000;
}

.wp-block-gallery.has-nested-images.is-style-wandering-album.is-style-wandering-album figure.wp-block-image:not(#individual-image) {
	--wa-ratio-safe: var(--wa-ratio, 1.5);
	flex: var(--wa-ratio-safe) 1 calc(var(--wa-ratio-safe) * var(--wa-row));
	width: auto;
	max-width: 100%;
	margin: 0;
	aspect-ratio: var(--wa-ratio-safe);
	overflow: hidden;
	border-radius: 4px;
	background: rgba(127, 127, 127, 0.12);
}

.wp-block-gallery.has-nested-images.is-style-wandering-album.is-style-wandering-album figure.wp-block-image:not(#individual-image) img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	cursor: zoom-in;
	transition: transform 0.5s ease, filter 0.3s ease;
}

@media (hover: hover) {
	.wp-block-gallery.has-nested-images.is-style-wandering-album.is-style-wandering-album figure.wp-block-image:not(#individual-image):hover img {
		transform: scale(1.03);
	}
}

/* ---------- Album cards (uniform grid for an albums index) ---------- */

.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
	gap: clamp(16px, 3vw, 32px);
}

.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards figure.wp-block-image:not(#individual-image) {
	width: auto;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 0.6em;
}

.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards figure.wp-block-image:not(#individual-image) > a,
.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards figure.wp-block-image:not(#individual-image) > img {
	display: block;
	overflow: hidden;
	border-radius: 6px;
	aspect-ratio: 3 / 2;
}

.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards figure.wp-block-image:not(#individual-image) img {
	width: 100%;
	height: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
	transition: transform 0.5s ease;
}

@media (hover: hover) {
	.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards figure.wp-block-image:not(#individual-image):hover img {
		transform: scale(1.04);
	}
}

/* Card titles sit under the photo instead of over it. */
.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards figure.wp-block-image:not(#individual-image) figcaption {
	position: static;
	max-height: none;
	padding: 0;
	background: none;
	color: inherit;
	text-align: left;
	font-size: 1.05em;
	font-weight: 600;
	letter-spacing: 0.01em;
	overflow: visible;
}

.wp-block-gallery.has-nested-images.is-style-wandering-cards.is-style-wandering-cards figure.wp-block-image:not(#individual-image) figcaption a {
	color: inherit;
	text-decoration: none;
}

/* ---------- Lightbox ---------- */

.wa-lightbox {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100dvh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #f4f4f4;
	overflow: hidden;
	touch-action: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.wa-lightbox::backdrop {
	background: transparent;
}

html:has(.wa-lightbox[open]) {
	overflow: hidden;
}

/* The darkening layer fades in as the photo flies to the center. */
.wa-lightbox__shade {
	position: fixed;
	inset: 0;
	background: rgba(8, 8, 10, 0.94);
	opacity: 0;
	transition: opacity 0.42s ease;
}

.wa-lightbox.is-visible .wa-lightbox__shade {
	opacity: 1;
}

.wa-lightbox__img {
	position: fixed;
	transform-origin: 0 0;
	max-width: none;
	object-fit: contain;
	border-radius: 2px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
	cursor: zoom-in;
	-webkit-user-drag: none;
	will-change: transform;
}

.wa-lightbox__img.is-animating {
	transition: transform 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.wa-lightbox.is-zoomed .wa-lightbox__img {
	cursor: grab;
	box-shadow: none;
}

.wa-lightbox.is-zoomed.is-dragging .wa-lightbox__img {
	cursor: grabbing;
}

/* Caption, counter and buttons fade in after the photo arrives,
   and step aside while zoomed in. */
.wa-lightbox__caption,
.wa-lightbox__count,
.wa-lightbox button {
	opacity: 0;
	transition: opacity 0.3s ease 0.12s, background 0.2s ease;
}

.wa-lightbox.is-visible .wa-lightbox__caption,
.wa-lightbox.is-visible .wa-lightbox__count,
.wa-lightbox.is-visible button {
	opacity: 1;
}

.wa-lightbox.is-zoomed .wa-lightbox__caption,
.wa-lightbox.is-zoomed .wa-lightbox__count,
.wa-lightbox.is-zoomed .wa-lightbox__prev,
.wa-lightbox.is-zoomed .wa-lightbox__next {
	opacity: 0;
	pointer-events: none;
}

.wa-lightbox__caption {
	position: fixed;
	left: 50%;
	bottom: 22px;
	translate: -50% 0;
	width: min(70ch, calc(100vw - 32px));
	margin: 0;
	font-size: 0.9rem;
	line-height: 1.4;
	text-align: center;
	color: rgba(244, 244, 244, 0.82);
}

.wa-lightbox__caption:empty {
	display: none;
}

.wa-lightbox__count {
	position: fixed;
	top: 20px;
	left: 22px;
	font-size: 0.8rem;
	letter-spacing: 0.08em;
	color: rgba(244, 244, 244, 0.6);
	font-variant-numeric: tabular-nums;
}

.wa-lightbox button {
	position: fixed;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: inherit;
	font: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.wa-lightbox button[hidden] {
	display: none;
}

.wa-lightbox button:hover,
.wa-lightbox button:focus-visible {
	background: rgba(255, 255, 255, 0.2);
	outline: none;
}

.wa-lightbox__close { top: 10px; right: 12px; }
.wa-lightbox__prev  { left: 14px;  top: 50%; translate: 0 -50%; }
.wa-lightbox__next  { right: 14px; top: 50%; translate: 0 -50%; }

/* On phones, swipe replaces the side arrows. */
@media (hover: none) and (max-width: 600px) {
	.wa-lightbox__prev,
	.wa-lightbox__next {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wa-lightbox__shade,
	.wa-lightbox__img,
	.wp-block-gallery.is-style-wandering-album img,
	.wp-block-gallery.is-style-wandering-cards img {
		transition: none !important;
		transform: none !important;
	}
}
