/*
 * #23: photography presentation for native WP galleries and image blocks.
 * All selectors are scoped so existing article, Master Slider and editor
 * styles retain their current behavior.
 */

.entry-content .wp-block-gallery[hidden],
.entry-content .gallery[hidden] {
	display: none !important;
}

.entry-content .mlz-photo-carousel {
	width: 100%;
	max-width: 100%;
	margin: 1.5em 0 2em;
}

.mlz-photo-carousel__stage {
	position: relative;
	width: 100%;
	/* JS supplies the first photo's proportions; one ratio for all slides. */
	aspect-ratio: var(--mlz-gallery-ratio, 5 / 3);
	min-width: 0;
	overflow: hidden;
	background: transparent;
	border-radius: 5px;
}

.mlz-photo-carousel__open {
	display: block;
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	cursor: zoom-in;
	touch-action: pan-y;
}

.mlz-photo-carousel__image {
	display: block;
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	object-fit: contain;
	object-position: center;
}

.mlz-photo-carousel__arrow,
.mlz-lightbox__arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 50px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: rgb(9 11 13 / 60%);
	color: white;
	cursor: pointer;
	transition: background 150ms ease;
}

.mlz-photo-carousel__arrow:hover,
.mlz-lightbox__arrow:hover {
	background: rgb(9 11 13 / 90%);
}

.mlz-photo-carousel__arrow::before,
.mlz-lightbox__arrow::before {
	content: "";
	display: block;
	width: 12px;
	height: 12px;
	border: solid currentColor;
	border-width: 0 3px 3px 0;
}

.mlz-photo-carousel__arrow--prev,
.mlz-lightbox__arrow--prev {
	left: 10px;
}

.mlz-photo-carousel__arrow--prev::before,
.mlz-lightbox__arrow--prev::before {
	transform: rotate(135deg);
	margin-left: 5px;
}

.mlz-photo-carousel__arrow--next,
.mlz-lightbox__arrow--next {
	right: 10px;
}

.mlz-photo-carousel__arrow--next::before,
.mlz-lightbox__arrow--next::before {
	transform: rotate(-45deg);
	margin-right: 5px;
}

/* Photo controls appear on hover, but remain accessible to touch and keyboard. */
.mlz-photo-carousel__arrow {
	background: transparent;
	color: #fff;
	filter: drop-shadow(0 1px 3px rgb(0 0 0 / 75%));
	opacity: 0;
	pointer-events: none;
	transition: opacity 170ms ease;
}

.mlz-photo-carousel__arrow:hover,
.mlz-photo-carousel__arrow:focus,
.mlz-photo-carousel__arrow:active {
	background: transparent;
}

.mlz-photo-carousel:hover .mlz-photo-carousel__arrow,
.mlz-photo-carousel:has(:focus-visible) .mlz-photo-carousel__arrow {
	opacity: 1;
	pointer-events: auto;
}

@media (hover: none) {
	.mlz-photo-carousel__arrow {
		opacity: 1;
		pointer-events: auto;
	}
}

.entry-content .mlz-photo-carousel__caption {
	margin-top: 9px;
	color: #62666d;
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
}

.entry-content .mlz-photo-carousel__gallery-caption {
	margin-top: 8px;
	color: #62666d;
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
}

.mlz-photo-carousel__strip {
	display: flex;
	margin-top: 10px;
	padding: 0 0 4px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scrollbar-width: thin;
	scroll-snap-type: x proximity;
}

.mlz-photo-carousel__strip-track {
	display: flex;
	flex: 0 0 auto;
	gap: 7px;
	margin: 0 auto;
}

.mlz-photo-carousel__thumb {
	flex: 0 0 80px;
	width: 80px;
	height: 58px;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	cursor: pointer;
	scroll-snap-align: center;
	transition: none;
}

/* The theme gives every button a grey background on :hover/:focus.
 * Keep the thumb button completely neutral and fade only its image so
 * neighbouring thumbnails never share a faded/composited button surface. */
.mlz-photo-carousel__thumb:hover,
.mlz-photo-carousel__thumb:focus,
.mlz-photo-carousel__thumb:active {
	background: transparent;
}

.mlz-photo-carousel__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	object-fit: cover;
	object-position: center;
	opacity: .42;
	/* Overrides the theme-wide img { transition: all .2s } which caused
	 * visible re-rasterization of adjacent cropped thumbnails on hover. */
	transition: none;
}

.mlz-photo-carousel__thumb:hover img,
.mlz-photo-carousel__thumb:focus-visible img {
	opacity: .72;
}

.mlz-photo-carousel__thumb[aria-current="true"] img {
	opacity: 1;
}

.entry-content .mlz-single-image__trigger {
	display: inline-block;
	max-width: 100%;
	padding: 0;
	border: 0;
	background: none;
	vertical-align: middle;
	cursor: zoom-in;
}

.entry-content .mlz-single-image__trigger img {
	display: block;
	margin: 0;
}

.entry-content .mlz-single-image > a:has(img) {
	cursor: zoom-in;
}

.mlz-photo-carousel button:focus-visible,
.mlz-single-image button:focus-visible,
.mlz-single-image a:focus-visible,
.mlz-lightbox button:focus-visible {
	outline: 3px solid #f4b451;
	outline-offset: 3px;
}

html.mlz-lightbox-open {
	/* Do not hide or replace the scrollbar. The viewer blocks scrolling in JS
	 * while preserving the original scrollbar geometry and thumb position. */
	overflow-y: auto;
	overscroll-behavior: none;
}

.mlz-lightbox[hidden],
.mlz-photo-carousel [hidden] {
	display: none !important;
}

.mlz-lightbox {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	padding: 0;
	background: rgb(7 9 12 / 97%);
	color: #fff;
	overscroll-behavior: contain;
	opacity: 0;
	pointer-events: none;
	transition: opacity 200ms ease;
}

.mlz-lightbox.is-open {
	opacity: 1;
	pointer-events: auto;
}

.mlz-lightbox__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	min-height: 0;
	padding: 56px 36px 14px;
	box-sizing: border-box;
	opacity: .96;
	transform: translateY(8px) scale(.988);
	transition: opacity 200ms ease, transform 220ms cubic-bezier(.22, 1, .36, 1);
}

.mlz-lightbox.is-open .mlz-lightbox__panel {
	opacity: 1;
	transform: none;
}

.mlz-lightbox__viewport {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 0;
	touch-action: pan-y;
}

.mlz-lightbox__image {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	object-fit: contain;
}

.mlz-lightbox__close {
	position: absolute;
	z-index: 3;
	top: 8px;
	right: 15px;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: rgb(28 32 36 / 75%);
	color: white;
	font: 300 33px / 42px Arial, sans-serif;
	cursor: pointer;
}

.mlz-lightbox__arrow {
	width: 48px;
	height: 54px;
	background: rgb(28 32 36 / 75%);
}

/* Theme-wide button:focus uses #555; keep modal buttons consistent after click. */
.mlz-lightbox__arrow:focus,
.mlz-lightbox__close:focus {
	background: rgb(28 32 36 / 75%);
}

.mlz-lightbox__close:hover,
.mlz-lightbox__arrow:hover {
	background: rgb(57 63 70 / 90%);
}

.mlz-lightbox__details {
	display: flex;
	flex: 0 0 auto;
	justify-content: center;
	align-items: center;
	gap: 20px;
	min-height: 35px;
	padding: 8px 2px 0;
	font-size: 13px;
	line-height: 1.5;
	color: #d4d7db;
}

.mlz-lightbox__caption {
	max-width: min(780px, 76%);
	text-align: center;
}

.mlz-lightbox__counter {
	flex: 0 0 auto;
	font-variant-numeric: tabular-nums;
	color: #9da3a9;
}

@media (max-width: 600px) {
	.mlz-photo-carousel__arrow {
		width: 36px;
		height: 44px;
	}
	.mlz-photo-carousel__arrow--prev {
		left: 5px;
	}
	.mlz-photo-carousel__arrow--next {
		right: 5px;
	}
	.mlz-photo-carousel__thumb {
		flex-basis: 66px;
		width: 66px;
		height: 50px;
	}
	.mlz-lightbox__panel {
		padding: 54px 6px 12px;
	}
	.mlz-lightbox__arrow {
		width: 38px;
		height: 46px;
	}
	.mlz-lightbox__arrow--prev {
		left: 0;
	}
	.mlz-lightbox__arrow--next {
		right: 0;
	}
	.mlz-lightbox__details {
		font-size: 12px;
		gap: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mlz-photo-carousel__arrow,
	.mlz-lightbox,
	.mlz-lightbox__panel {
		transition: none;
	}
	.mlz-photo-carousel__strip {
		scroll-behavior: auto;
	}
}
