/* Gallery — 3x3 photo grid. */

.gallery { padding-inline: 5px; }

.gallery__container {
	display: flex;
	flex-direction: column;
	gap: 40px;
	align-items: center;
	max-width: 1430px;
	margin: 0 auto;
}

.gallery__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 4.56px;
	width: 100%;
}

.gallery__photo {
	width: 100%;
	aspect-ratio: 3 / 2;
	object-fit: cover;
	display: block;
}

@media (min-width: 768px) {
	.gallery__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
	.gallery__container { gap: 60px; }
	.gallery__grid { grid-template-columns: repeat(3, 1fr); }
}

/*
 * Each tile is a button so the lightbox is keyboard-reachable. Reset the UA
 * chrome rather than styling around it; the photo keeps the Figma geometry.
 */
.gallery__item {
	display: block;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
	overflow: hidden;
}

.gallery__photo { transition: transform 0.4s ease; }

.gallery__item:hover .gallery__photo,
.gallery__item:focus-visible .gallery__photo { transform: scale(1.04); }

.gallery__item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* Lightbox */

/*
 * `display: flex` outranks the UA's `[hidden] { display: none }`, so the closed
 * lightbox would sit open over the page. Restore the hidden state explicitly.
 */
.lightbox[hidden] { display: none; }

.lightbox {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-4);
	padding: 60px 16px;
}

.lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(26, 41, 74, 0.92);
}

.lightbox__figure {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-4);
	margin: 0;
	min-width: 0;
}

.lightbox__image {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 160px);
	border-radius: var(--radius-lg);
	object-fit: contain;
}

.lightbox__counter {
	color: var(--color-neutral-2);
	font-size: var(--body-secondary-size);
	line-height: 1.4;
}

.lightbox__close,
.lightbox__nav {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-pill);
	background: rgba(246, 246, 246, 0.12);
	color: var(--color-neutral-7);
	cursor: pointer;
	transition: background 0.2s ease;
}

.lightbox__close:hover,
.lightbox__nav:hover { background: rgba(246, 246, 246, 0.24); }

.lightbox__close {
	position: absolute;
	top: 16px;
	right: 16px;
	font-size: 28px;
	line-height: 1;
}

/* The shared chevron points right; the prev button reuses it mirrored. */
.lightbox__nav--prev img { transform: scaleX(-1); }

@media (max-width: 767px) {
	/* No room for side rails on a phone — park the arrows under the photo. */
	.lightbox { flex-wrap: wrap; align-content: center; }
	.lightbox__figure { order: -1; flex: 1 0 100%; }
}
