/* Forum image lightbox (attachments + BBCode [img]) */

.faleri-lb {
	position: fixed;
	inset: 0;
	z-index: 10050;
	display: flex;
	flex-direction: column;
	background: rgba(8, 10, 12, 0.92);
	color: #f2f2f2;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.18s ease, visibility 0.18s ease;
	-webkit-tap-highlight-color: transparent;
}

.faleri-lb.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.faleri-lb__top {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 12px;
	min-height: 44px;
}

.faleri-lb__counter {
	font-size: 14px;
	opacity: 0.85;
	letter-spacing: 0.02em;
}

.faleri-lb__close {
	appearance: none;
	border: 0;
	background: rgba(255, 255, 255, 0.12);
	color: inherit;
	width: 40px;
	height: 40px;
	border-radius: 999px;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

.faleri-lb__close:hover,
.faleri-lb__close:focus-visible {
	background: rgba(255, 255, 255, 0.22);
	outline: none;
}

.faleri-lb__stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-x pan-y pinch-zoom;
	padding: 0 8px;
}

.faleri-lb__img {
	display: block;
	max-width: 100%;
	max-height: calc(100dvh - 140px);
	width: auto;
	height: auto;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	cursor: default;
	margin: auto;
}

.faleri-lb__img.is-zoomed {
	max-width: none;
	max-height: none;
}

.faleri-lb__hit {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 28%;
	max-width: 160px;
	border: 0;
	padding: 0;
	background: transparent;
	cursor: pointer;
	z-index: 2;
}

.faleri-lb__hit--prev {
	left: 0;
}

.faleri-lb__hit--next {
	right: 0;
}

.faleri-lb__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 3;
	appearance: none;
	border: 0;
	width: 44px;
	height: 44px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.45);
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.faleri-lb__nav:hover,
.faleri-lb__nav:focus-visible {
	background: rgba(0, 0, 0, 0.7);
	outline: none;
}

.faleri-lb__nav--prev {
	left: 8px;
}

.faleri-lb__nav--next {
	right: 8px;
}

.faleri-lb__nav[hidden],
.faleri-lb__hit[hidden] {
	display: none !important;
}

.faleri-lb__caption {
	flex: 0 0 auto;
	padding: 10px 16px 16px;
	text-align: center;
	font-size: 14px;
	line-height: 1.45;
	max-height: 28vh;
	overflow: auto;
	word-wrap: break-word;
}

.faleri-lb__caption:empty {
	display: none;
	padding: 0;
}

.faleri-lb__caption-author {
	opacity: 0.75;
	white-space: nowrap;
}

body.faleri-lb-open {
	overflow: hidden;
	touch-action: none;
}

/* In-post cue that images open in lightbox */
.postbody img.postimage,
.postbody dl.thumbnail a,
.postbody .attach-image img.postimage {
	cursor: zoom-in;
}

.faleri-lb-caption {
	font-style: italic;
	opacity: 0.9;
}

@media (max-width: 700px) {
	.faleri-lb__nav {
		width: 40px;
		height: 40px;
		font-size: 24px;
	}

	.faleri-lb__nav--prev {
		left: 4px;
	}

	.faleri-lb__nav--next {
		right: 4px;
	}

	.faleri-lb__hit {
		width: 32%;
		max-width: none;
	}

	.faleri-lb__img {
		max-height: calc(100dvh - 120px);
	}

	.faleri-lb__caption {
		font-size: 13px;
		padding: 8px 12px 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.faleri-lb {
		transition: none;
	}
}
