/* =============================================================
   Custom Justified Gallery — styles
   All sizing knobs are CSS variables set inline by Elementor
   controls, with sane fallbacks here.
   ============================================================= */

.cgw-gallery {
	--cgw-row-height: 280px;
	--cgw-gap: 8px;
	--cgw-radius: 0;
	--cgw-overlay-bg: rgba(0, 0, 0, 0.55);
	--cgw-overlay-icon-color: #ffffff;
	--cgw-overlay-text-color: #ffffff;
	--cgw-tile-bg: #111111;
	--cgw-tile-color: #ffffff;
	--cgw-lightbox-bg: rgba(10, 10, 10, 0.96);
	--cgw-lightbox-control-color: #ffffff;
	--cgw-mobile-cols: 1;
	--cgw-mobile-ratio: 1/1;

	display: flex;
	flex-direction: column;
	gap: var(--cgw-gap);
	width: 100%;
	box-sizing: border-box;
}

.cgw-empty-notice {
	padding: 24px;
	border: 1px dashed #ccc;
	color: #888;
	text-align: center;
	font-size: 14px;
}

/* ---------- Justified rows (desktop / tablet) ---------- */

.cgw-row {
	display: flex;
	flex-direction: row;
	gap: var(--cgw-gap);
	width: 100%;
	height: var(--cgw-row-height);
	overflow: hidden; /* safety net: never let a rounding fraction of a px cause horizontal scroll */
}

.cgw-cell {
	position: relative;
	overflow: hidden;
	border-radius: var(--cgw-radius);
	height: 100%;
	flex-shrink: 0;
	/* width is set inline (px) by JS once natural aspect ratios are known */
	cursor: pointer;
	background: #eee;
}

.cgw-cell img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.35s ease;
}

.cgw-image-cell:hover img {
	transform: scale(1.035);
}

/* ---------- Hover overlay ---------- */

.cgw-hover-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: var(--cgw-overlay-bg);
	opacity: 0;
	transition: opacity 0.25s ease;
	pointer-events: none;
}

.cgw-overlay-icon {
	font-size: 22px;
	line-height: 1;
	color: var(--cgw-overlay-icon-color);
}

.cgw-overlay-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.cgw-overlay-text {
	color: var(--cgw-overlay-text-color);
	font-size: 13px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-weight: 600;
}

@media (hover: hover) {
	.cgw-image-cell:hover .cgw-hover-overlay,
	.cgw-image-cell:focus-visible .cgw-hover-overlay {
		opacity: 1;
	}
}

/* Touch devices: JS toggles this class on first tap so the user sees
   the overlay before the second tap opens the lightbox. */
.cgw-image-cell.cgw-overlay-visible .cgw-hover-overlay {
	opacity: 1;
}

/* ---------- "View Photo" CTA tile ---------- */

.cgw-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	background: var(--cgw-tile-bg);
	color: var(--cgw-tile-color);
}

.cgw-tile-icon {
	font-size: 20px;
	line-height: 1;
}

.cgw-tile-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.cgw-tile-text {
	font-size: 12px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	font-weight: 600;
}

/* ---------- Mobile: simple uniform grid ---------- */

.cgw-gallery.cgw-mobile-mode .cgw-row {
	display: none; /* emptied by JS; hidden as a safety net in case JS hasn't run yet */
}

.cgw-gallery.cgw-mobile-mode {
	display: grid;
	grid-template-columns: repeat(var(--cgw-mobile-cols), 1fr);
}

.cgw-gallery.cgw-mobile-mode .cgw-cell {
	width: 100% !important;
	height: auto;
	/* Fallback for multi-column mode; single-column mode overrides this
	   per-cell with each image's own natural aspect ratio (set inline by JS)
	   so tall and wide photos keep their real proportions, edge to edge. */
	aspect-ratio: var(--cgw-mobile-ratio);
}

/* ---------- Lightbox ---------- */

.cgw-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: var(--cgw-lightbox-bg);
	display: none;
	align-items: center;
	justify-content: center;
}

.cgw-lightbox.cgw-open {
	display: flex;
}

.cgw-lb-stage {
	position: relative;
	max-width: 92vw;
	max-height: 88vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cgw-lb-image {
	max-width: 92vw;
	max-height: 88vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 2px;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.cgw-lb-image.cgw-loaded {
	opacity: 1;
}

.cgw-lb-counter {
	position: absolute;
	bottom: -34px;
	left: 50%;
	transform: translateX(-50%);
	color: var(--cgw-lightbox-control-color);
	font-size: 13px;
	letter-spacing: 0.06em;
	opacity: 0.8;
}

.cgw-lb-close,
.cgw-lb-prev,
.cgw-lb-next {
	position: fixed;
	background: transparent;
	border: none;
	color: var(--cgw-lightbox-control-color);
	cursor: pointer;
	z-index: 1000000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 !important;
}

.cgw-lb-close {
	top: 20px;
	right: 24px;
	font-size: 34px;
	line-height: 1;
	width: 44px;
	height: 44px;
	color: white !important;
}

.cgw-lb-prev,
.cgw-lb-next {
	top: 50%;
	transform: translateY(-50%);
	font-size: 22px;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
}

.cgw-lb-prev {
	left: 16px;
}

.cgw-lb-next {
	right: 16px;
}

.cgw-lb-prev:hover,
.cgw-lb-next:hover,
.cgw-lb-close:hover {
	background: rgba(255, 255, 255, 0.18);
	color: white !important;
}

.cgw-lb-close:focus-visible,
.cgw-lb-prev:focus-visible,
.cgw-lb-next:focus-visible,
.cgw-cell:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

@media (max-width: 600px) {
	.cgw-lb-prev,
	.cgw-lb-next {
		width: 40px;
		height: 40px;
		font-size: 16px;
	}
	.cgw-lb-close {
		top: 10px;
		right: 12px;
	}
}
