/* The lightbox trigger is a real <button> overlaid on the image (or the
   image's existing link). The image itself is never made interactive. */
.wp-block-media-text.mtlb-has-lightbox .wp-block-media-text__media.mtlb-media {
	position: relative;
}

.mtlb-trigger-button {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	background-color: unset !important;
	color: inherit;
	font: inherit;
	cursor: zoom-in;
}

.mtlb-trigger-link {
	cursor: zoom-in;
}

/* Visible keyboard focus ring, kept inside the image edge so it shows over
   the picture, with a dark halo for contrast on light OR dark images. */
.mtlb-trigger-button:focus-visible,
.mtlb-trigger-link:focus-visible {
	outline: 3px solid #fff;
	outline-offset: -3px;
	box-shadow: inset 0 0 0 6px rgba( 0, 0, 0, 0.55 );
}

/* Full-screen overlay. */
.mtlb-overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: 2rem;
	background: rgba( 0, 0, 0, 0.9 );
	opacity: 0;
	transition: opacity 0.25s ease;
	cursor: zoom-out;
}

.mtlb-overlay.is-visible {
	opacity: 1;
}

/* The enlarged image. */
.mtlb-image {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	box-shadow: 0 4px 40px rgba( 0, 0, 0, 0.5 );
	transform: scale( 0.96 );
	opacity: 1;
	transition: transform 0.25s ease, opacity 0.15s ease;
	cursor: default;
}

.mtlb-overlay.is-visible .mtlb-image {
	transform: scale( 1 );
}

/* Brief fade while navigating to a new image. */
.mtlb-image.is-loading {
	opacity: 0;
}

/* Shared button styling. */
.mtlb-close,
.mtlb-nav {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	color: #fff;
	background: rgba( 0, 0, 0, 0.45 );
	border: 1px solid rgba( 255, 255, 255, 0.35 );
	border-radius: 50%;
	cursor: pointer;
	transition: background 0.15s ease;
}

.mtlb-close:hover,
.mtlb-nav:hover {
	background: rgba( 255, 255, 255, 0.2 );
}

/* Always-visible, high-contrast keyboard focus indicator. */
.mtlb-close:focus-visible,
.mtlb-nav:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
	background: rgba( 255, 255, 255, 0.2 );
}

/* Close button. */
.mtlb-close {
	top: 1rem;
	right: 1rem;
	width: 3rem;
	height: 3rem;
	font-size: 2rem;
	line-height: 1;
}

/* Previous / next arrows. */
.mtlb-nav {
	top: 50%;
	width: 3.25rem;
	height: 3.25rem;
	font-size: 2.5rem;
	line-height: 1;
	transform: translateY( -50% );
}

.mtlb-prev {
	left: 1rem;
}

.mtlb-next {
	right: 1rem;
}

/* Image counter (e.g. "2 / 5"); decorative, announced via the live region. */
.mtlb-counter {
	position: absolute;
	bottom: 1.25rem;
	left: 50%;
	transform: translateX( -50% );
	padding: 0.25rem 0.75rem;
	font-size: 0.875rem;
	color: #fff;
	background: rgba( 0, 0, 0, 0.55 );
	border-radius: 1rem;
	pointer-events: none;
}

/* Visually-hidden live region for screen-reader announcements. */
.mtlb-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
}

/* Lock background scroll while open. */
body.mtlb-open {
	overflow: hidden;
}

@media ( max-width: 600px ) {
	.mtlb-nav {
		width: 2.75rem;
		height: 2.75rem;
		font-size: 2rem;
	}
	.mtlb-prev {
		left: 0.5rem;
	}
	.mtlb-next {
		right: 0.5rem;
	}
}

/* High-contrast / forced-colors support. */
@media ( forced-colors: active ) {
	.mtlb-close,
	.mtlb-nav {
		border: 1px solid ButtonText;
	}
	.mtlb-close:focus-visible,
	.mtlb-nav:focus-visible {
		outline: 3px solid Highlight;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.mtlb-overlay,
	.mtlb-image {
		transition: none;
	}
}
