/* RM24 Gallery – frontend (grid + lightbox) */
.rm24gal {
	--rm24gal-cols: 4;
	--rm24gal-cols-t: 3;
	--rm24gal-cols-m: 2;
	--rm24gal-gap: 10px;
	margin-block: 0 1.5em;
}

.rm24gal-grid {
	display: grid;
	grid-template-columns: repeat(var(--rm24gal-cols-m), minmax(0, 1fr));
	gap: var(--rm24gal-gap);
	align-items: start;
}

@media (min-width: 600px) {
	.rm24gal-grid { grid-template-columns: repeat(var(--rm24gal-cols-t), minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
	.rm24gal-grid { grid-template-columns: repeat(var(--rm24gal-cols), minmax(0, 1fr)); }
}

.rm24gal-item {
	margin: 0;
	padding: 0;
	min-width: 0;
	position: relative;
}

.rm24gal-item[hidden] { display: none; }

.rm24gal-link {
	display: block;
	overflow: hidden;
	border-radius: inherit;
	cursor: zoom-in;
}

.rm24gal-link:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
}

.rm24gal .rm24gal-img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	margin: 0;
	border-radius: inherit;
}

.rm24gal--ratio-1-1 .rm24gal-img { aspect-ratio: 1 / 1; object-fit: cover; }
.rm24gal--ratio-4-3 .rm24gal-img { aspect-ratio: 4 / 3; object-fit: cover; }
.rm24gal--ratio-3-2 .rm24gal-img { aspect-ratio: 3 / 2; object-fit: cover; }
.rm24gal--ratio-16-9 .rm24gal-img { aspect-ratio: 16 / 9; object-fit: cover; }

.rm24gal-caption {
	margin: .4em 0 0;
	font-size: .875em;
	line-height: 1.4;
	opacity: .85;
}

/* Lightbox */
html.rm24gal-lock,
html.rm24gal-lock body { overflow: hidden; }

.rm24gal-lb {
	--rm24gal-lb-bg: rgba(10, 12, 16, .94);
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--rm24gal-lb-bg);
	color: #fff;
	opacity: 0;
	transition: opacity .2s ease;
	touch-action: pan-y pinch-zoom;
	-webkit-tap-highlight-color: transparent;
}

.rm24gal-lb[hidden] { display: none; }
.rm24gal-lb.is-open { opacity: 1; }

.rm24gal-lb-stage {
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	max-width: calc(100vw - 120px);
	max-height: calc(100vh - 100px);
	max-height: calc(100dvh - 100px);
}

.rm24gal-lb-img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 140px);
	max-height: calc(100dvh - 140px);
	width: auto;
	height: auto;
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	transition: opacity .2s ease;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

.rm24gal-lb.is-loading .rm24gal-lb-img { opacity: .25; }
.rm24gal-lb-img[hidden] { display: none; }

.rm24gal-lb-video {
	width: min(calc(100vw - 120px), calc((100vh - 160px) * 16 / 9), 1280px);
	width: min(calc(100vw - 120px), calc((100dvh - 160px) * 16 / 9), 1280px);
	aspect-ratio: 16 / 9;
	background: #000;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

.rm24gal-lb-video[hidden] { display: none; }
.rm24gal-lb-video iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Video items in the grid */
.rm24gal-link--video { position: relative; cursor: pointer; }

.rm24gal-play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 58px;
	height: 58px;
	margin: -29px 0 0 -29px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(0, 0, 0, .55);
	color: #fff;
	pointer-events: none;
	transition: background .15s ease, transform .15s ease;
}

.rm24gal-play svg { width: 28px; height: 28px; margin-left: 3px; fill: currentColor; }
.rm24gal-link--video:hover .rm24gal-play,
.rm24gal-link--video:focus-visible .rm24gal-play { background: rgba(0, 0, 0, .78); transform: scale(1.06); }

.rm24gal-lb-caption {
	margin-top: 12px;
	max-width: 70ch;
	text-align: center;
	font-size: 15px;
	line-height: 1.45;
	color: #f1f5f9;
}

.rm24gal-lb-caption:empty { display: none; }

.rm24gal-lb-counter {
	position: absolute;
	top: 18px;
	left: 20px;
	font: 600 14px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
	letter-spacing: .04em;
	color: #e2e8f0;
}

.rm24gal-lb-btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
	transition: background .15s ease;
	line-height: 0;
}

.rm24gal-lb-btn:hover { background: rgba(255, 255, 255, .26); }
.rm24gal-lb-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.rm24gal-lb-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.rm24gal-lb-btn[hidden] { display: none; }

.rm24gal-lb-close { top: 10px; right: 12px; }
.rm24gal-lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.rm24gal-lb-next { right: 14px; top: 50%; transform: translateY(-50%); }

.rm24gal-lb-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(255, 255, 255, .25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: rm24gal-spin .8s linear infinite;
	display: none;
}

.rm24gal-lb.is-loading .rm24gal-lb-spinner { display: block; }

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

@media (max-width: 599px) {
	.rm24gal-lb-stage { max-width: 100vw; }
	.rm24gal-lb-video { width: 100vw; }
	.rm24gal-lb-prev, .rm24gal-lb-next { top: auto; bottom: 14px; transform: none; }
}

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