/* Shared native galleries and legacy organisation pages; stored blocks stay intact. */
:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 24px;
	margin-block: 24px 48px;
}

:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image {
	position: relative;
	display: block;
	width: 100% !important; /* Overrides core's per-gallery column width selector. */
	height: auto !important;
	min-width: 0;
	margin: 0 !important;
	aspect-ratio: 1;
	overflow: hidden;
}

:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image > a {
	display: block;
	width: 100%;
	height: 100%;
}

:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
}

:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image::after {
	position: absolute;
	inset: 0;
	z-index: 1;
	background: linear-gradient(180deg, transparent 20%, rgba(4, 15, 26, 0.55) 55%, rgba(4, 15, 26, 0.95));
	content: "";
	opacity: 0;
	transition: opacity 180ms ease;
	pointer-events: none;
}

:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image > figcaption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2;
	display: block;
	width: auto;
	max-height: 100%;
	padding: 24px;
	margin: 0;
	overflow: hidden;
	background: transparent;
	color: #fff;
	font: 400 16px/1.55 var(--eiro-font-body);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
	text-align: left;
	opacity: 0;
	transition: opacity 180ms ease;
	pointer-events: none;
}

:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image:hover::after,
:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image:focus-within::after,
:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image:hover > figcaption,
:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image:focus-within > figcaption {
	opacity: 1;
}

:is(.eiro-photo-gallery .wp-block-gallery, .wp-block-gallery.eiro-gallery) figure.wp-block-image:focus-within {
	outline: 2px solid var(--eiro-color-focus);
	outline-offset: 4px;
}

.photo-lightbox {
	position: fixed;
	inset: 0;
	width: 100vw;
	max-width: none;
	height: 100dvh;
	max-height: none;
	padding: 20px 32px;
	margin: 0;
	border: 0;
	background: #08131e;
	color: #fff;
}

.photo-lightbox[open] {
	display: grid;
	grid-template-rows: 44px minmax(0, 1fr) auto;
	gap: 16px;
}

.photo-lightbox::backdrop {
	background: rgba(4, 12, 20, 0.94);
}

.photo-lightbox__toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.photo-lightbox__counter {
	color: #cad4dd;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
}

.photo-lightbox button {
	display: grid;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid transparent;
	background: transparent;
	color: #fff;
	font: 28px/1 Arial, sans-serif;
	place-items: center;
	cursor: pointer;
}

.photo-lightbox button:hover {
	background: rgba(255, 255, 255, 0.1);
}

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

.photo-lightbox button:focus-visible,
.photo-lightbox a:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.photo-lightbox__stage {
	display: grid;
	grid-template-columns: 44px minmax(0, 1fr) 44px;
	align-items: center;
	gap: 20px;
	min-height: 0;
}

.photo-lightbox__image {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 0;
	object-fit: contain;
}

.photo-lightbox__stage.is-single {
	grid-template-columns: minmax(0, 1fr);
}

.photo-lightbox__caption {
	width: min(100%, 960px);
	max-height: 25dvh;
	margin-inline: auto;
	overflow-y: auto;
	color: #e0e7ed;
	font-size: 14px;
	line-height: 1.6;
	text-align: center;
}

.photo-lightbox__caption a {
	color: #fff;
}

@media (max-width: 900px) {
	:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 20px;
	}
}

@media (max-width: 600px) {
	:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) {
		grid-template-columns: 1fr;
		gap: 20px;
	}

	.photo-lightbox {
		padding: 12px;
	}

	.photo-lightbox__stage {
		position: relative;
		display: block;
	}

	.photo-lightbox__stage button {
		position: absolute;
		top: 50%;
		background: rgba(4, 12, 20, 0.65);
		transform: translateY(-50%);
	}

	.photo-lightbox__next {
		right: 0;
	}
}

@media (hover: none) {
	:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image::after,
	:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image > figcaption {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image::after,
	:is(.eiro-photo-gallery .entry-content .wp-block-gallery.has-nested-images, .wp-block-gallery.eiro-gallery) > figure.wp-block-image > figcaption {
		transition: none;
	}
}
.photo-lightbox button .eiro-icon {
	width: 24px;
	height: 24px;
}
