/**
 * CompactGallery lightbox styles.
 */

.cg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
	color: #fff;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.cg-lightbox.is-open {
	opacity: 1;
}

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

.cg-lightbox-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 10, 12, 0.94);
	cursor: zoom-out;
}

.cg-lightbox-toolbar {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	z-index: 3;
}

.cg-lightbox-counter {
	margin: 0;
	font-size: 14px;
	letter-spacing: 0.02em;
	opacity: 0.85;
}

.cg-lightbox-actions {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
}

.cg-lightbox-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease;
}

.cg-lightbox-button:hover,
.cg-lightbox-button:focus-visible {
	background: rgba(255, 255, 255, 0.26);
}

.cg-lightbox-button:focus-visible,
.cg-lightbox-nav:focus-visible,
.cg-lightbox-thumb:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.cg-lightbox-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	padding: 0 0 4px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 34px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease, opacity 0.2s ease;
}

.cg-lightbox-nav:hover {
	background: rgba(255, 255, 255, 0.26);
}

.cg-lightbox-nav[disabled] {
	opacity: 0.35;
	cursor: default;
}

.cg-lightbox-prev {
	left: 12px;
}

.cg-lightbox-next {
	right: 12px;
}

.cg-lightbox-content {
	position: relative;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: 100%;
	height: 100%;
	overflow: hidden;
	touch-action: none;
}

.cg-lightbox-image {
	max-width: 100%;
	max-height: 100%;
	margin: auto;
	object-fit: contain;
	user-select: none;
	transform-origin: center center;
	transition: transform 0.2s ease, opacity 0.25s ease;
}

.cg-lightbox.is-zoomed .cg-lightbox-image {
	cursor: grab;
}

.cg-lightbox.is-zoomed .cg-lightbox-content {
	cursor: grab;
}

.cg-lightbox.is-loading .cg-lightbox-image {
	opacity: 0.25;
}

.cg-lightbox-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	opacity: 0;
	animation: cg-spin 0.8s linear infinite;
}

.cg-lightbox.is-loading .cg-lightbox-spinner {
	opacity: 1;
}

.cg-lightbox-footer {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 3;
	padding: 10px 14px max(10px, env(safe-area-inset-bottom));
	text-align: center;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
}

.cg-lightbox-title {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
}

.cg-lightbox-caption {
	margin: 2px 0 0;
	font-size: 13px;
	opacity: 0.85;
}

.cg-lightbox-title:empty,
.cg-lightbox-caption:empty {
	display: none;
}

.cg-lightbox-carousel {
	display: flex;
	gap: 6px;
	justify-content: center;
	overflow-x: auto;
	padding: 10px 2px 2px;
	scrollbar-width: thin;
}

.cg-lightbox-carousel:empty {
	display: none;
}

.cg-lightbox-thumb {
	flex: 0 0 auto;
	width: 56px;
	height: 42px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.1);
	cursor: pointer;
	overflow: hidden;
	opacity: 0.6;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.cg-lightbox-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cg-lightbox-thumb:hover {
	opacity: 0.9;
}

.cg-lightbox-thumb.is-active {
	border-color: #fff;
	opacity: 1;
}

/* Animations -------------------------------------------------------------- */

.cg-lightbox.cg-anim-slide .cg-lightbox-image.is-entering {
	animation: cg-slide-in 0.28s ease both;
}

@keyframes cg-slide-in {
	from {
		opacity: 0;
		transform: translateX(24px);
	}
}

.cg-lightbox.cg-anim-none,
.cg-lightbox.cg-anim-none .cg-lightbox-image {
	transition: none;
}

/* Scroll lock ------------------------------------------------------------- */

html.cg-lightbox-open,
body.cg-lightbox-open {
	overflow: hidden;
	touch-action: none;
	overscroll-behavior: contain;
}

@media (max-width: 600px) {
	.cg-lightbox-nav {
		width: 44px;
		height: 44px;
		font-size: 28px;
	}

	.cg-lightbox-prev {
		left: 6px;
	}

	.cg-lightbox-next {
		right: 6px;
	}

	.cg-lightbox-thumb {
		width: 48px;
		height: 36px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cg-lightbox,
	.cg-lightbox-image,
	.cg-lightbox-nav,
	.cg-lightbox-button {
		transition: none;
	}

	.cg-lightbox.cg-anim-slide .cg-lightbox-image.is-entering {
		animation: none;
	}
}
