/**
 * ONC3D Gallery.
 *
 * Monochrome and quiet, so the project imagery carries the page (Design.MD).
 */

/* Triggers ---------------------------------------------------------------- */

.onc3d-gallery-item {
	cursor: zoom-in;
}

.onc3d-gallery-item:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
	box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.55);
}

/* Overlay left behind by the previous inline implementation. */
.onc3d-gallery-legacy-hidden {
	display: none !important;
}

/* Page state -------------------------------------------------------------- */

.onc3d-gallery-open,
.onc3d-gallery-open body {
	overflow: hidden;
}

.onc3d-gallery-open body {
	padding-right: var(--onc3d-gallery-scrollbar, 0);
}

/* Lightbox ---------------------------------------------------------------- */

.onc3d-gallery-lightbox {
	--onc3d-gallery-control: rgba(255, 255, 255, 0.82);
	--onc3d-gallery-control-active: #fff;

	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 220ms ease;
}

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

.onc3d-gallery-lightbox.is-open {
	opacity: 1;
}

.onc3d-gallery-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: #0b0b0b;
	cursor: zoom-out;
}

/* Stage ------------------------------------------------------------------- */

.onc3d-gallery-lightbox__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 72px 88px;
	box-sizing: border-box;
	pointer-events: none;
}

.onc3d-gallery-lightbox__figure {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 18px;
	margin: 0;
	max-width: 100%;
	max-height: 100%;
	pointer-events: auto;
}

.onc3d-gallery-lightbox__image {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - 190px);
	object-fit: contain;
	opacity: 1;
	transition: opacity 180ms ease;
}

.onc3d-gallery-lightbox.is-loading .onc3d-gallery-lightbox__image {
	opacity: 0.25;
}

.onc3d-gallery-lightbox__caption {
	max-width: 60ch;
	margin: 0;
	font-family: "Bodoni 72", "Miller", Georgia, "Times New Roman", serif;
	font-size: 15px;
	font-style: italic;
	line-height: 1.5;
	letter-spacing: 0.04em;
	text-align: center;
	color: rgba(255, 255, 255, 0.72);
}

.onc3d-gallery-lightbox__caption[hidden] {
	display: none;
}

/* Controls ---------------------------------------------------------------- */

.onc3d-gallery-lightbox__close,
.onc3d-gallery-lightbox__nav {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	background: none;
	border: 0;
	color: var(--onc3d-gallery-control);
	cursor: pointer;
	transition: color 160ms ease, transform 160ms ease, opacity 160ms ease;
	-webkit-appearance: none;
	appearance: none;
}

.onc3d-gallery-lightbox__close:hover,
.onc3d-gallery-lightbox__nav:hover,
.onc3d-gallery-lightbox__close:focus-visible,
.onc3d-gallery-lightbox__nav:focus-visible {
	color: var(--onc3d-gallery-control-active);
}

.onc3d-gallery-lightbox__close:focus-visible,
.onc3d-gallery-lightbox__nav:focus-visible {
	outline: 1px solid var(--onc3d-gallery-control-active);
	outline-offset: 6px;
}

.onc3d-gallery-lightbox__close[hidden],
.onc3d-gallery-lightbox__nav[hidden] {
	display: none;
}

/* Close: a thin monochrome cross drawn in CSS, no icon font. */
.onc3d-gallery-lightbox__close {
	top: 26px;
	right: 26px;
	width: 44px;
	height: 44px;
}

.onc3d-gallery-lightbox__close::before,
.onc3d-gallery-lightbox__close::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 22px;
	height: 1px;
	background: currentColor;
}

.onc3d-gallery-lightbox__close::before {
	transform: translate(-50%, -50%) rotate(45deg);
}

.onc3d-gallery-lightbox__close::after {
	transform: translate(-50%, -50%) rotate(-45deg);
}

/* Prev/next: chevrons drawn from two borders. */
.onc3d-gallery-lightbox__nav {
	top: 50%;
	width: 56px;
	height: 56px;
	margin-top: -28px;
}

.onc3d-gallery-lightbox__nav::before {
	content: "";
	width: 16px;
	height: 16px;
	border-top: 1px solid currentColor;
	border-right: 1px solid currentColor;
}

.onc3d-gallery-lightbox__nav--prev {
	left: 18px;
}

.onc3d-gallery-lightbox__nav--prev::before {
	transform: translateX(4px) rotate(-135deg);
}

.onc3d-gallery-lightbox__nav--next {
	right: 18px;
}

.onc3d-gallery-lightbox__nav--next::before {
	transform: translateX(-4px) rotate(45deg);
}

.onc3d-gallery-lightbox__nav--prev:hover {
	transform: translateX(-2px);
}

.onc3d-gallery-lightbox__nav--next:hover {
	transform: translateX(2px);
}

/* Counter ----------------------------------------------------------------- */

.onc3d-gallery-lightbox__counter {
	position: absolute;
	bottom: 26px;
	left: 0;
	right: 0;
	z-index: 2;
	margin: 0;
	font-family: "mr-eaves-modern", -apple-system, "Segoe UI", sans-serif;
	font-size: 12px;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	text-align: center;
	color: rgba(255, 255, 255, 0.62);
}

.onc3d-gallery-lightbox__counter[hidden] {
	display: none;
}

/* Responsive -------------------------------------------------------------- */

@media only screen and (max-width: 1024px) {
	.onc3d-gallery-lightbox__stage {
		padding: 64px 20px 96px;
	}

	.onc3d-gallery-lightbox__image {
		max-height: calc(100vh - 200px);
	}

	/* Below the image on touch, where side chevrons are awkward to reach. */
	.onc3d-gallery-lightbox__nav {
		top: auto;
		bottom: 58px;
		margin-top: 0;
	}

	.onc3d-gallery-lightbox__nav--prev {
		left: 50%;
		margin-left: -68px;
	}

	.onc3d-gallery-lightbox__nav--next {
		right: 50%;
		margin-right: -68px;
	}

	.onc3d-gallery-lightbox__counter {
		bottom: 74px;
	}
}

@media only screen and (max-width: 767px) {
	.onc3d-gallery-lightbox__stage {
		padding: 56px 12px 96px;
	}

	.onc3d-gallery-lightbox__close {
		top: 12px;
		right: 12px;
	}

	.onc3d-gallery-lightbox__caption {
		font-size: 14px;
	}
}

/*
 * Short viewports (landscape phones, split-screen windows).
 *
 * The fixed chrome above and below the image is a large share of a ~400px tall
 * viewport, which leaves the render almost no room. Shrink the chrome and let
 * the image take what is left.
 */
@media only screen and (max-height: 620px) {
	.onc3d-gallery-lightbox__stage {
		padding: 44px 64px;
	}

	.onc3d-gallery-lightbox__figure {
		gap: 8px;
	}

	.onc3d-gallery-lightbox__image {
		max-height: calc(100vh - 88px);
	}

	.onc3d-gallery-lightbox__close {
		top: 8px;
		right: 8px;
		width: 36px;
		height: 36px;
	}

	/* Keep the chevrons at the sides here; there is no room beneath. */
	.onc3d-gallery-lightbox__nav {
		top: 50%;
		bottom: auto;
		margin-top: -22px;
		width: 44px;
		height: 44px;
	}

	.onc3d-gallery-lightbox__nav--prev {
		left: 6px;
		margin-left: 0;
	}

	.onc3d-gallery-lightbox__nav--next {
		right: 6px;
		margin-right: 0;
	}

	/* The caption and counter are the first things to go when space is tight. */
	.onc3d-gallery-lightbox__caption {
		display: none;
	}

	.onc3d-gallery-lightbox__counter {
		bottom: 8px;
	}
}

/* Motion preferences ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.onc3d-gallery-lightbox,
	.onc3d-gallery-lightbox__image,
	.onc3d-gallery-lightbox__close,
	.onc3d-gallery-lightbox__nav {
		transition: none;
	}

	.onc3d-gallery-lightbox__nav--prev:hover,
	.onc3d-gallery-lightbox__nav--next:hover {
		transform: none;
	}
}
