/**
 * Project photograph gallery.
 *
 * Uniform 4:3 cells. Portrait and landscape photographs crop to the
 * same frame so every row lines up. Phones use two columns so the
 * page is not one long strip. One page stylesheet, loaded only
 * with this template.
 */

.vdm-photo-gallery {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	grid-auto-flow: row;
	align-items: stretch;
	gap: var(--vdm-space-3);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 48rem) {
	.vdm-photo-gallery {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--vdm-space-6);
	}
}

@media (min-width: 64rem) {
	.vdm-photo-gallery {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

@media (min-width: 90rem) {
	.vdm-photo-gallery {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}
}

.vdm-photo-gallery__item {
	display: flex;
	flex-direction: column;
	min-width: 0;
	margin: 0;
	background-color: var(--vdm-color-surface);
	border: 1px solid var(--vdm-color-border);
	border-radius: var(--vdm-radius);
	overflow: hidden;
}

.vdm-photo-gallery__open {
	display: block;
	flex: 0 0 auto;
	width: 100%;
	aspect-ratio: 4 / 3;
	min-width: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: 0;
	color: inherit;
	font: inherit;
	text-align: start;
	cursor: pointer;
	background-color: var(--vdm-color-background);
	appearance: none;
}

.vdm-photo-gallery__open:focus-visible {
	outline-offset: -3px;
	border-radius: 0;
}

.vdm-photo-gallery__open img {
	display: block;
	width: 100%;
	max-width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
}

.vdm-photo-gallery__caption {
	margin: 0;
	padding: var(--vdm-card-padding);
	font-family: var(--vdm-font-body);
	font-size: var(--vdm-font-size-body);
	font-weight: var(--vdm-font-weight-regular);
	line-height: var(--vdm-line-height-body);
	color: var(--vdm-color-text-secondary);
	overflow-wrap: anywhere;
}

.vdm-photo-gallery__section + .vdm-photo-gallery__section {
	padding-block-start: 0;
}

/* Lightbox. The dialog fills the viewport; its dark padding is the backdrop. */

.vdm-photo-lightbox {
	position: fixed;
	inset: 0;
	z-index: var(--vdm-z-modal);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--vdm-space-20) var(--vdm-space-16) var(--vdm-space-4);
	background-color: color-mix(in srgb, var(--vdm-color-text-primary) 88%, transparent);
	overflow: auto;
	touch-action: pan-y;
}

.vdm-photo-lightbox__close,
.vdm-photo-lightbox__nav {
	position: absolute;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--vdm-btn-height);
	height: var(--vdm-btn-height);
	min-width: var(--vdm-btn-height);
	min-height: var(--vdm-btn-height);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--vdm-radius);
	background-color: var(--vdm-color-surface);
	color: var(--vdm-color-primary);
	box-shadow: var(--vdm-shadow-md);
	cursor: pointer;
}

.vdm-photo-lightbox__close {
	top: var(--vdm-space-4);
	right: var(--vdm-space-4);
}

.vdm-photo-lightbox__nav {
	top: 50%;
	transform: translateY(-50%);
}

.vdm-photo-lightbox__nav--prev {
	left: var(--vdm-space-4);
}

.vdm-photo-lightbox__nav--next {
	right: var(--vdm-space-4);
}

.vdm-photo-lightbox__nav--prev .vdm-icon {
	transform: rotate(180deg);
}

.vdm-photo-lightbox :focus-visible {
	outline-color: var(--vdm-color-surface);
	outline-offset: 3px;
}

.vdm-photo-lightbox__image {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - var(--vdm-space-24));
	max-height: calc(100dvh - var(--vdm-space-24));
	object-fit: contain;
	border-radius: var(--vdm-radius);
	background-color: var(--vdm-color-surface);
	box-shadow: var(--vdm-shadow-lg);
}

.vdm-photo-lightbox__image:not([src]) {
	display: none;
}

html.vdm-photo-lightbox-open,
html.vdm-photo-lightbox-open body {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.vdm-photo-lightbox {
		scroll-behavior: auto;
	}
}
