/* =============================================================================
   KA Gallery — Grid + Lightbox Styles
   Version: 1.3.1
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Grid
   ----------------------------------------------------------------------------- */

.ka-gallery-grid {
	--ka-cols: 4;
	--ka-gap: 10px;

	display: grid;
	grid-template-columns: repeat(var(--ka-cols), 1fr);
	gap: var(--ka-gap);
}

.ka-gallery-item {
	position: relative;
	overflow: hidden;
	cursor: pointer;
	/* Aspect ratio driven by Elementor controls (--ka-ratio-w / --ka-ratio-h), defaults to 1:1 */
	aspect-ratio: var(--ka-ratio-w, 1) / var(--ka-ratio-h, 1);
	background-color: #1a1a1a;
	outline-offset: 2px;
}

.ka-gallery-item:focus-visible {
	outline: 2px solid #fff;
}

.ka-gallery-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: opacity 0.2s ease, transform 0.3s ease;
}

.ka-gallery-item:hover img {
	transform: scale(1.04);
}

.ka-gallery-empty {
	padding: 20px;
	text-align: center;
	color: #aaa;
	font-size: 14px;
	border: 1px dashed #ccc;
}

/* -----------------------------------------------------------------------------
   2. Lightbox Overlay
   ----------------------------------------------------------------------------- */

.ka-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background-color: #f5f0ea;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ka-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

/* -----------------------------------------------------------------------------
   3. Back Button (top-left, no background, blue text + icon)
   ----------------------------------------------------------------------------- */

/*
 * Use .ka-lightbox parent for higher specificity so these rules beat any
 * global theme/Elementor button resets (e.g. background, padding, border-radius).
 */
.ka-lightbox .ka-lb-close {
	position: absolute;
	top: 28px;  /* fallback — overridden by Elementor back_btn_top control */
	left: 28px; /* fallback — overridden by Elementor back_btn_left control */
	background: transparent;
	background-color: transparent;
	background-image: none;
	border: none;
	border-radius: 0;
	box-shadow: none;
	cursor: pointer;
	color: #146489;
	font-size: 13px;
	line-height: 1;
	padding: 4px 0;
	display: flex;
	align-items: center;
	gap: 6px;
	z-index: 5;
	transition: color 0.2s ease;
}

.ka-lightbox .ka-lb-close:hover {
	background: transparent;
	background-color: transparent;
	color: #0e4a6e;
}

/* Icon inside back button (Font Awesome <i> or inline SVG) */
.ka-lightbox .ka-lb-close i,
.ka-lightbox .ka-lb-close svg {
	flex-shrink: 0;
	font-size: inherit;
	width: 1em;
	height: 1em;
	fill: currentColor;
	stroke: currentColor;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Image-based back button */
.ka-lightbox .ka-lb-close.is-image-btn img {
	height: 1.2em;
	width: auto;
	vertical-align: middle;
	flex-shrink: 0;
	object-fit: contain;
}

/* -----------------------------------------------------------------------------
   4. Three-image Carousel Stage
   ----------------------------------------------------------------------------- */

.ka-lb-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	/* Leave vertical room for dots + close button */
	height: calc(100vh - 60px);
	/* overflow: visible so side images can peek out from the edges */
	overflow: visible;
}

/* Shared image wrapper */
.ka-lb-img-wrap {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1),
	            opacity  0.38s ease;
	max-height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ka-lightbox .ka-lb-img-wrap img {
	display: block;
	max-width: 100%;
	max-height: 85vh;
	width: auto;
	height: auto;
	border-radius: 4px;
	user-select: none;
	-webkit-user-drag: none;
}

/* --- Current (centre) image --- */
.ka-lightbox .ka-lb-current-img {
	z-index: 3;
	left: 50%;
	transform: translateY(-50%) translateX(-50%);
	max-width: 85vw;
}

/* Soft shadow on the main image itself (applied to the <img> so it respects border-radius) */
.ka-lightbox .ka-lb-current-img img {
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.32), 0 2px 12px rgba(0, 0, 0, 0.18);
}

/* --- Side images (shared) --- */
.ka-lb-side {
	z-index: 1;
	opacity: 0.45;
	pointer-events: none;
}

/*
 * Prev image: right edge anchor — fallback 75%.
 * Overridden by Elementor lightbox_side_anchor control.
 */
.ka-lightbox .ka-lb-prev-img {
	right: 75%;
	transform: translateY(-50%);
	max-width: 42vw;
}

/*
 * Next image: left edge anchor — fallback 75%.
 * Overridden by Elementor lightbox_side_anchor control.
 */
.ka-lightbox .ka-lb-next-img {
	left: 75%;
	transform: translateY(-50%);
	max-width: 42vw;
}

/* Empty slot — used when there's no prev or next */
.ka-lb-img-wrap.is-empty {
	display: none;
}

/* -----------------------------------------------------------------------------
   5. Prev / Next Buttons
   ----------------------------------------------------------------------------- */

/*
 * Use .ka-lightbox parent for higher specificity so these rules beat any
 * global theme/Elementor button resets (e.g. padding: 12px 24px, border-radius: 999px).
 */
.ka-lightbox .ka-lb-btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 4;
	width: 48px;      /* fallback — overridden by Elementor arrow_btn_size control */
	height: 48px;     /* fallback — overridden by Elementor arrow_btn_size control */
	min-width: 48px;  /* fallback — overridden by Elementor arrow_btn_size control */
	min-height: 48px; /* fallback — overridden by Elementor arrow_btn_size control */
	background: rgba(245, 240, 234, 0.88);
	border: none;
	border-radius: 50%;
	color: #146489;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
	transition: background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
	padding: 0;
	margin: 0;
	line-height: 1;
	flex-shrink: 0;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	box-sizing: border-box;
}

.ka-lightbox .ka-lb-btn:hover {
	background: rgba(245, 240, 234, 1);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.ka-lightbox .ka-lb-btn.is-hidden {
	opacity: 0;
	pointer-events: none;
}

/* Positioned relative to .ka-lightbox (their parent).
   Default offset: 21px from the lightbox edges.
   Both values are overridden by Elementor prev_btn_offset / next_btn_offset controls. */
.ka-lb-prev {
	left: 21px;  /* fallback — Elementor selector overrides this */
	right: auto;
}

.ka-lb-next {
	right: 21px; /* fallback — Elementor selector overrides this */
	left: auto;
}

/* Icon inside nav buttons (Font Awesome <i> or inline SVG) */
.ka-lightbox .ka-lb-btn i {
	font-size: 20px;
	line-height: 1;
	display: flex;
}

.ka-lightbox .ka-lb-btn svg {
	width: 20px;
	height: 20px;
	fill: currentColor;
	stroke: currentColor;
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-linejoin: round;
	display: block;
}

/* -----------------------------------------------------------------------------
   5b. Image-based Navigation Buttons
   ----------------------------------------------------------------------------- */

.ka-lightbox .ka-lb-btn.is-image-btn {
	/* Reset ALL base .ka-lb-btn styles — the image renders with no visible wrapper */
	background: transparent;
	box-shadow: none;
	border: none;
	border-radius: 0;
	width: auto;
	height: auto;
	min-width: 0;
	min-height: 0;
	aspect-ratio: auto;
	padding: 0;
	margin: 0;
	overflow: visible;
	line-height: 0;
	flex-shrink: initial;
	display: block;
	transition: opacity 0.2s ease;
}

.ka-lightbox .ka-lb-btn.is-image-btn:hover {
	background: transparent;
	box-shadow: none;
	transform: translateY(-50%) scale(1.05);
}

.ka-lightbox .ka-lb-btn.is-image-btn img {
	max-height: 48px;
	max-width: 80px;
	width: auto;
	height: auto;
	display: block;
	object-fit: contain;
}

/* -----------------------------------------------------------------------------
   6. Dot Navigation — always perfect circles
   ----------------------------------------------------------------------------- */

.ka-lb-dots {
	position: absolute;
	bottom: 20px; /* fallback — overridden by Elementor dots_bottom control */
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 8px;
	align-items: center;
	z-index: 4;
	max-width: 90vw;
	flex-wrap: wrap;
	justify-content: center;
}

.ka-lightbox .ka-lb-dot {
	width: 10px;
	height: 10px;
	min-width: 10px;
	min-height: 10px;
	border-radius: 50%;
	background-color: transparent;
	border: 1.5px solid rgba(30, 60, 90, 0.45);
	cursor: pointer;
	padding: 0;
	margin: 0;
	flex-shrink: 0;
	box-sizing: border-box;
	aspect-ratio: 1 / 1;
	display: block;
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

.ka-lightbox .ka-lb-dot.is-active {
	background-color: #1e4e6e;
	border-color: #1e4e6e;
}

/* -----------------------------------------------------------------------------
   7. Transition animations (stage animating class)
   ----------------------------------------------------------------------------- */

.ka-lb-stage.is-animating .ka-lb-img-wrap {
	transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1),
	            opacity  0.38s ease;
}

/* -----------------------------------------------------------------------------
   8. Mobile / responsive tweaks
   ----------------------------------------------------------------------------- */

@media (max-width: 1024px) {
	.ka-lightbox .ka-lb-prev-img,
	.ka-lightbox .ka-lb-next-img {
		max-width: 35vw;
	}
}

@media (max-width: 767px) {
	.ka-lightbox .ka-lb-current-img {
		max-width: 90vw;
	}

	.ka-lightbox .ka-lb-prev-img,
	.ka-lightbox .ka-lb-next-img {
		max-width: 38vw;
	}

	/* NOTE: .ka-lb-btn size is now fully controlled by the Elementor
	   arrow_btn_size responsive control (desktop/tablet/mobile).
	   No hardcoded override here — use the Elementor panel instead. */
}

@media (max-width: 480px) {
	.ka-lb-stage {
		height: calc(100vh - 70px);
	}
}
