/*
 * The picture viewer (assets/js/lightbox.js): the picture full size on a dark
 * ground, the counter and tools along the top, arrows at the sides (at the
 * foot on a phone), the caption underneath.
 */

.arm-lb-zoomable {
	cursor: zoom-in;
}

html.arm-lb-open,
html.arm-lb-open body {
	overflow: hidden;
}

.arm-lb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	background: #0e0b09;
	color: #fff;
	opacity: 0;
	transition: opacity 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.arm-lb[hidden] {
	display: none;
}

.arm-lb.is-open {
	opacity: 1;
}

/* The stage takes the whole screen; the bars float over it. A flex box, not a
   grid: a grid row has no height of its own, so the picture's max-height
   would not hold and a tall picture ran off the bottom of the screen. */
.arm-lb__stage {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 64px 72px 56px;
	overflow: hidden;
	touch-action: none;
	user-select: none;
	cursor: zoom-in;
}

.arm-lb.is-zoomed .arm-lb__stage {
	cursor: grab;
}

.arm-lb.is-zoomed .arm-lb__stage:active {
	cursor: grabbing;
}

.arm-lb__img {
	display: block;
	flex: 0 1 auto;
	width: auto;
	height: auto;
	min-width: 0;
	min-height: 0;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
	transform-origin: center center;
	will-change: transform;
	pointer-events: none;
	opacity: 1;
	transition: opacity 0.2s ease;
}

.arm-lb__img.is-animated {
	transition: transform 0.25s ease, opacity 0.2s ease;
}

.arm-lb.is-loading .arm-lb__img {
	opacity: 0;
}

.arm-lb__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 38px;
	height: 38px;
	margin: -19px 0 0 -19px;
	border: 3px solid rgba(255, 255, 255, 0.2);
	border-top-color: var(--arm-gold, #d3a349);
	border-radius: 50%;
	opacity: 0;
	animation: arm-lb-spin 0.8s linear infinite;
	pointer-events: none;
}

.arm-lb.is-loading .arm-lb__spinner {
	opacity: 1;
}

@keyframes arm-lb-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ------------------------------------------------------------------ bars */

.arm-lb__top {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
	pointer-events: none;
}

.arm-lb__counter {
	padding-left: 6px;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.08em;
	font-variant-numeric: tabular-nums;
	color: rgba(255, 255, 255, 0.85);
}

.arm-lb__tools {
	display: flex;
	gap: 8px;
	pointer-events: auto;
}

.arm-lb__btn,
.arm-lb__nav {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	transition: background-color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.arm-lb__btn:hover,
.arm-lb__nav:hover,
.arm-lb__btn:focus-visible,
.arm-lb__nav:focus-visible {
	background: rgba(255, 255, 255, 0.24);
	outline: none;
}

.arm-lb__btn:focus-visible,
.arm-lb__nav:focus-visible {
	box-shadow: 0 0 0 2px var(--arm-gold, #d3a349);
}

.arm-lb__btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.arm-lb__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	width: 52px;
	height: 52px;
	margin-top: -26px;
}

.arm-lb__nav--prev {
	left: 14px;
}

.arm-lb__nav--next {
	right: 14px;
}

.arm-lb.is-single .arm-lb__nav {
	display: none;
}

.arm-lb__caption {
	position: relative;
	z-index: 2;
	grid-row: 3;
	margin: 0;
	padding: 14px 20px 18px;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
	color: rgba(255, 255, 255, 0.9);
	pointer-events: none;
}

.arm-lb__caption[hidden] {
	display: none;
}

/* A zoomed picture has the screen to itself: the arrows and caption step aside. */
.arm-lb.is-zoomed .arm-lb__nav,
.arm-lb.is-zoomed .arm-lb__caption {
	opacity: 0;
	pointer-events: none;
}

/* ----------------------------------------------------------------- phone */

@media (max-width: 760px) {
	.arm-lb__stage {
		padding: 56px 0 84px;
	}

	.arm-lb__img {
		border-radius: 0;
		box-shadow: none;
	}

	.arm-lb__top {
		padding: 8px 10px;
		padding-top: max(8px, env(safe-area-inset-top));
	}

	/* The arrows move to the foot, within the thumb's reach. */
	.arm-lb__nav {
		top: auto;
		bottom: max(16px, env(safe-area-inset-bottom));
		margin-top: 0;
		width: 48px;
		height: 48px;
	}

	.arm-lb__nav--prev {
		left: 16px;
	}

	.arm-lb__nav--next {
		right: 16px;
	}

	.arm-lb__caption {
		padding: 10px 76px max(22px, env(safe-area-inset-bottom));
		font-size: 13px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.arm-lb,
	.arm-lb__img,
	.arm-lb__img.is-animated {
		transition: none;
	}
}
