.rk-mag-gallery{
	/* Force the gallery to occupy the full width of its WPBakery/container cell. */
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
	background: transparent;
	column-gap: 18px;
	column-count: 4;

	/*
	 * Chrome needs balanced columns when the container has no fixed height.
	 * With column-fill:auto it can keep every image in the first column,
	 * producing the single vertical stack seen in Chrome. Grouped galleries
	 * already use the JavaScript masonry engine, so balancing is safe here.
	 */
	column-fill: balance;
}

/* When multiple shortcodes are merged (data-group), we switch to a JS masonry
   to keep gallery blocks ordered while still filling vertical gaps. */
.rk-mag-gallery.is-js-masonry{
	column-count: initial;
	column-gap: initial;
	column-fill: initial;
	position: relative;
}

.rk-mag-gallery.is-js-masonry .rk-mag-item{
	break-inside: initial;
	will-change: transform;
}

@media (max-width: 1024px){
	.rk-mag-gallery{ column-count: 2; }
}
@media (max-width: 640px){
	.rk-mag-gallery{ column-count: 1; }
}

.rk-mag-item{
	break-inside: avoid;
	margin: 0 0 18px;
}

.rk-mag-link{
	position: relative;
	display: block;
	border-radius: 30px;
	overflow: hidden;
	transform: translateZ(0);
}

.rk-mag-img{
	width: 100%;
	height: auto;
	display: block;
	border-radius: 30px;
}

.rk-mag-overlay{
	position:absolute;
	inset:0;
	background: rgba(0,0,0,0);
	transition: background 180ms ease;
	pointer-events:none;
}

.rk-mag-link:hover .rk-mag-overlay{
	background: rgba(0,0,0,0.22);
}

/* Lightbox */
.rk-mag-lightbox{
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0,0,0,0.86);
}

.rk-mag-lightbox.is-open{ display:flex; }

.rk-mag-lightbox-inner{
	position: relative;
	max-width: min(1100px, 92vw);
	max-height: 86vh;
}

.rk-mag-lightbox-img{
	display:block;
	max-width: 100%;
	max-height: 86vh;
	border-radius: 18px;
}

.rk-mag-lightbox-btn{
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	border: 0;
	width: 44px;
	height: 44px;
	border-radius: 999px;
	cursor: pointer;
	background: rgba(255,255,255,0.14);
	color: #fff;
	font-size: 22px;
	line-height: 44px;
	text-align:center;
	user-select: none;
}

.rk-mag-lightbox-btn:hover{ background: rgba(255,255,255,0.22); }

.rk-mag-lightbox-prev{ left: -58px; }
.rk-mag-lightbox-next{ right: -58px; }

@media (max-width: 640px){
	.rk-mag-lightbox-prev{ left: 8px; }
	.rk-mag-lightbox-next{ right: 8px; }
}

.rk-mag-lightbox-close{
	position: absolute;
	top: -54px;
	right: 0;
	transform: none;
}

@media (max-width: 640px){
	.rk-mag-lightbox-close{ top: 8px; right: 8px; }
}

.rk-mag-lightbox-close::after{ content: "✕"; }
.rk-mag-lightbox-prev::after{ content: "‹"; }
.rk-mag-lightbox-next::after{ content: "›"; }
