/* Native WordPress gallery laid out the way FooGallery did it on the public
   site: justified rows. Every row is stretched to the full width and each
   photo keeps its own aspect ratio, so nothing is cropped - unlike a fixed
   column grid, which forces one ratio on every photo. gallery.js measures the
   rows; the values below are what the browser paints until it does. */
.wp-block-gallery.restart-native-gallery {
	align-items: flex-start;
	display: flex !important;
	flex-wrap: wrap;
	gap: 2px !important;
	grid-template-columns: none !important;
	margin: 30px 0;
}

/* The !important is load bearing: core ships
   ".wp-block-gallery.has-nested-images figure.wp-block-image { flex-grow: 1 }",
   which outweighs this selector and would stretch the measured widths - most
   visibly on a trailing row that is meant to stay short. */
.wp-block-gallery.restart-native-gallery > .wp-block-image {
	box-sizing: border-box;
	flex: 0 0 auto !important;
	height: 250px;
	margin: 0 !important;
	overflow: hidden;
	position: relative;
}

/* Before the rows are measured, fall back to thirds so the block occupies
   roughly its final height instead of collapsing. */
.wp-block-gallery.restart-native-gallery:not(.is-justified) > .wp-block-image {
	flex: 1 1 calc(33.333% - 2px) !important;
	width: auto;
}

.wp-block-gallery.restart-native-gallery > .wp-block-image img {
	display: block;
	height: 100% !important;
	object-fit: cover;
	transition: transform 180ms ease;
	width: 100% !important;
}

.wp-block-gallery.restart-native-gallery > .wp-block-image > a {
	display: block;
	height: 100%;
	width: 100%;
}

.wp-block-gallery.restart-native-gallery > .wp-block-image:hover img {
	transform: scale(1.02);
}

.wp-block-gallery.restart-native-gallery .wp-element-caption {
	background: linear-gradient(transparent, rgba(0, 0, 0, .7));
	bottom: 0;
	box-sizing: border-box;
	color: #fff;
	font-size: 13px;
	left: 0;
	margin: 0;
	padding: 24px 12px 10px;
	position: absolute;
	right: 0;
}

.restart-gallery-open {
	overflow: hidden;
}

.restart-gallery-lightbox {
	align-items: center;
	background: rgba(0, 0, 0, .92);
	display: flex;
	inset: 0;
	justify-content: center;
	padding: 48px 70px;
	position: fixed;
	z-index: 100000;
}

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

.restart-gallery-lightbox figure {
	margin: 0;
	max-height: 100%;
	max-width: 100%;
	text-align: center;
}

.restart-gallery-lightbox img {
	max-height: calc(100vh - 110px);
	max-width: calc(100vw - 140px);
	object-fit: contain;
}

.restart-gallery-lightbox figcaption {
	color: #fff;
	padding-top: 8px;
}

.restart-gallery-lightbox button {
	background: transparent !important;
	border: 0;
	color: #fff !important;
	cursor: pointer;
	font-size: 48px;
	line-height: 1;
	padding: 12px;
	position: fixed;
}

.restart-gallery-close {
	right: 18px;
	top: 12px;
}

.restart-gallery-prev {
	left: 12px;
	top: 50%;
}

.restart-gallery-next {
	right: 12px;
	top: 50%;
}

@media (max-width: 900px) {
	.wp-block-gallery.restart-native-gallery:not(.is-justified) > .wp-block-image {
		flex-basis: calc(50% - 2px);
	}
}

@media (max-width: 520px) {
	.wp-block-gallery.restart-native-gallery:not(.is-justified) > .wp-block-image {
		flex-basis: 100%;
	}

	.restart-gallery-lightbox {
		padding: 48px 42px;
	}

	.restart-gallery-lightbox img {
		max-width: calc(100vw - 84px);
	}
}
