/**
 * Cmrok gallery — justified retci (jednaka visina u retku, širina po omjeru) + lightbox.
 */

.cmrok-gallery {
	--cmrok-gallery-gap: 4px;
	--cmrok-gallery-min-row-h: 96px;
	--cmrok-gallery-max-row-h: 360px;
	margin: 2rem 0;
}

@media (min-width: 768px) {
	.cmrok-gallery {
		--cmrok-gallery-min-row-h: 112px;
		--cmrok-gallery-max-row-h: 400px;
	}
}

.cmrok-gallery__title {
	font-family: var(--font-heading, Oswald), sans-serif;
	font-size: var(--text-2xl, 1.5rem);
	font-weight: 700;
	color: var(--color-gray-900, #111827);
	text-transform: uppercase;
	letter-spacing: var(--tracking-wide, 0.025em);
	margin-bottom: 1rem;
	text-align: center;
}

.cmrok-gallery__justified {
	width: 100%;
	box-sizing: border-box;
}

.cmrok-gallery__row {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	align-items: stretch;
	gap: var(--cmrok-gallery-gap, 4px);
	width: 100%;
	margin-bottom: var(--cmrok-gallery-gap, 4px);
	box-sizing: border-box;
}

.cmrok-gallery__row:last-child {
	margin-bottom: 0;
}

.cmrok-gallery__cell {
	flex: 0 0 auto;
	overflow: hidden;
	box-sizing: border-box;
	background: var(--color-gray-100, #f3f4f6);
	border-radius: 2px;
}

.cmrok-gallery__thumb {
	display: block;
	width: 100%;
	height: 100%;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 2px;
	overflow: hidden;
	cursor: zoom-in;
	background: var(--color-gray-100, #f3f4f6);
	transition:
		box-shadow var(--default-transition-duration, 150ms) ease,
		transform var(--default-transition-duration, 150ms) ease;
}

.cmrok-gallery__thumb:hover {
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
	transform: translateY(-1px);
}

.cmrok-gallery__thumb:focus {
	outline: 2px solid var(--color-red-600, #dc2626);
	outline-offset: 2px;
}

.cmrok-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
	object-position: center;
}

/* Lightbox (jedan za cijelu stranicu, u body) */
.cmrok-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99990;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	background: rgba(15, 23, 42, 0.92);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition:
		opacity 0.2s ease,
		visibility 0.2s ease;
}

.cmrok-gallery-lightbox.cmrok-gallery-lightbox--open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.cmrok-gallery-lightbox__inner {
	position: relative;
	max-width: min(96vw, 1200px);
	max-height: 92vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cmrok-gallery-lightbox__img {
	max-width: 100%;
	max-height: 92vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: var(--radius-sm, 0.25rem);
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.cmrok-gallery-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	border: 0;
	border-radius: var(--radius-sm, 0.25rem);
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	transition: background 0.15s ease;
}

.cmrok-gallery-lightbox__btn:hover {
	background: rgba(255, 255, 255, 0.22);
}

.cmrok-gallery-lightbox__btn:focus {
	outline: 2px solid var(--color-red-400, #f87171);
	outline-offset: 2px;
}

.cmrok-gallery-lightbox__close {
	top: -0.25rem;
	right: -0.25rem;
	font-size: 1.5rem;
	line-height: 1;
}

@media (min-width: 768px) {
	.cmrok-gallery-lightbox__close {
		top: -2.5rem;
		right: 0;
	}
}

.cmrok-gallery-lightbox__prev,
.cmrok-gallery-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
}

.cmrok-gallery-lightbox__prev {
	left: 0.5rem;
}

.cmrok-gallery-lightbox__next {
	right: 0.5rem;
}

@media (min-width: 768px) {
	.cmrok-gallery-lightbox__prev {
		left: -3rem;
	}

	.cmrok-gallery-lightbox__next {
		right: -3rem;
	}
}

.cmrok-gallery-lightbox__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: -2.25rem;
	text-align: center;
	font-size: var(--text-sm, 0.875rem);
	color: rgba(255, 255, 255, 0.85);
	max-width: 100%;
	padding: 0 0.5rem;
}

.cmrok-gallery-lightbox__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

body.cmrok-gallery-lightbox-open {
	overflow: hidden;
}
