/* ============================================================
   "A closer look" (The Caravan): a masonry of photos, two columns on
   phones, three from 761px; every third photo from the second is cropped
   square for rhythm. Each opens in the photo viewer (the lightbox:
   assets/js/gallery.js). (prototype: .gallery, .lightbox)
   ============================================================ */

.gallery__grid {
	margin: 0;
	padding: 0;
	list-style: none;
	columns: 2;
	column-gap: 12px;
}

.gallery__item {
	margin: 0 0 12px;
	break-inside: avoid;
}

.gallery__open {
	display: block;
	width: 100%;
	padding: 0;
	overflow: hidden;
	border: 0;
	background: var(--color-line);
	cursor: zoom-in;
}

.gallery__open img {
	width: 100%;
	height: auto;
	transition: transform 1s var(--ease);
}

.gallery__item:nth-child(3n + 2) img {
	aspect-ratio: 1;
	object-fit: cover;
}

.gallery__open:focus-visible {
	outline-offset: 3px;
}

@media (hover: hover) {
	.gallery__open:hover img {
		transform: scale(1.04);
	}
}

@media (min-width: 761px) {
	.gallery__grid {
		columns: 3;
		column-gap: 20px;
	}

	.gallery__item {
		margin-bottom: 20px;
	}
}

/* The photo viewer: navy over the page, the photo as large as fits, long
   arrows either side, "Close" top right, the count below. */
.lightbox {
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--color-overlay);
	color: var(--color-on-dark);
}

.lightbox[open] {
	display: grid;
	place-items: center;
	animation: tlo-lightbox-in 0.3s var(--ease);
}

.lightbox::backdrop {
	background: transparent;
}

.lightbox__figure {
	display: grid;
	justify-items: center;
	gap: 16px;
	margin: 0;
}

.lightbox__img {
	width: auto;
	max-width: min(92vw, 1100px);
	height: auto;
	max-height: 78vh;
	max-height: 78dvh;
	object-fit: contain;
	user-select: none;
}

.lightbox__img.is-changing {
	animation: tlo-lightbox-photo 0.32s var(--ease);
}

.lightbox__count {
	font-size: var(--size-label);
	font-weight: 600;
	letter-spacing: 0.2em;
}

.lightbox__close,
.lightbox__nav {
	position: absolute;
	padding: 12px;
	border: 0;
	background: transparent;
	color: var(--color-on-dark);
	cursor: pointer;
	transition: color 0.4s var(--ease);
}

/* Gold on hover and focus, like every button (main.css). */
.lightbox__close:focus-visible,
.lightbox__nav:focus-visible {
	color: var(--color-hover);
}

.lightbox__close {
	top: max(12px, env(safe-area-inset-top, 0px));
	right: max(12px, env(safe-area-inset-right, 0px));
	font-size: var(--size-label);
	font-weight: 700;
	letter-spacing: 0.2em;
	text-transform: uppercase;
}

/* On phones the arrows sit at the foot, either side of the count. */
.lightbox__nav {
	bottom: max(12px, env(safe-area-inset-bottom, 0px));
	transition: transform 0.4s var(--ease), color 0.4s var(--ease);
}

.lightbox__nav .icon {
	display: block;
}

.lightbox__nav--prev {
	left: max(8px, env(safe-area-inset-left, 0px));
}

.lightbox__nav--next {
	right: max(8px, env(safe-area-inset-right, 0px));
}

@media (hover: hover) {
	.lightbox__close:hover,
	.lightbox__nav:hover {
		color: var(--color-hover);
	}

	.lightbox__nav--prev:hover {
		transform: translateX(-5px);
	}

	.lightbox__nav--next:hover {
		transform: translateX(5px);
	}
}

@media (min-width: 761px) {
	.lightbox__nav {
		top: 50%;
		bottom: auto;
		translate: 0 -50%;
	}

	.lightbox__close {
		top: max(20px, env(safe-area-inset-top, 0px));
		right: max(20px, env(safe-area-inset-right, 0px));
	}
}

@keyframes tlo-lightbox-in {
	from {
		opacity: 0;
	}
}

@keyframes tlo-lightbox-photo {
	from {
		opacity: 0;
		transform: scale(0.985);
	}
}
