/* LT Gallery for Elementor — layout
 *
 * Every dimension is driven by a custom property that the widget's Elementor
 * controls write into. Nothing here needs editing to retheme the gallery.
 */

.lt-gallery {
	--lt-gap: 15px;
	--lt-wide: 66%;
	--lt-ratio: 64.69%;
	--lt-max-h: 100vh;

	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	/* A real gap, not space-between. space-between hands the LEFTOVER room to
	   the gutter, so one mis-sized tile silently changes the spacing of its
	   whole row. A fixed gap doesn't care what the tiles measure. */
	justify-content: flex-start;
	align-items: stretch;
	gap: var(--lt-gap);
	width: 100%;
	margin: 0;
	padding: 0;
	font-size: 0;
	line-height: 0;

	/* Tile height comes from a ::after padding spacer, so the gallery's own
	   box must be free to grow. If an ancestor Container has a fixed height,
	   Min Height, or a height set on a single breakpoint, the grid paints its
	   later rows outside its layout box and whatever follows draws on top. */
	height: auto !important;
	min-height: 0;
	overflow: visible;
}

.lt-gallery > .lt-sq {
	position: relative;
	display: block;
	margin: 0;
	padding: 0;
	overflow: hidden;
	line-height: 0;
	align-self: stretch;
	max-height: var(--lt-max-h);
	text-decoration: none;
	background: transparent;
}

/*
 * The aspect-ratio spacer, and the whole trick behind the layout.
 * Only WIDE tiles get a padding-bottom, so only they have an intrinsic
 * height. Narrow tiles have none and take their height from
 * `align-items: stretch`, matching whatever the wide tile on that row
 * worked out to. That's what keeps rows flush with no equal-height JS.
 */
.lt-gallery > .lt-sq::after {
	content: "";
	display: block;
}

.lt-gallery > .lt-sq:nth-child(4n + 1),
.lt-gallery > .lt-sq:nth-child(4n + 4) {
	/* The 0.5px is slack against sub-pixel rounding. Without it a row can
	   overflow by a fraction and wrap the second tile onto its own line. */
	flex: 0 0 calc(var(--lt-wide) - var(--lt-gap) - 0.5px);
	max-width: calc(var(--lt-wide) - var(--lt-gap) - 0.5px);
}

.lt-gallery > .lt-sq:nth-child(4n + 1)::after,
.lt-gallery > .lt-sq:nth-child(4n + 4)::after {
	/* min() clamps the ratio against the height cap, so on wide-and-short
	   viewports the tile stops growing and the image crops via object-fit
	   instead of running off the screen. */
	padding-bottom: min(var(--lt-ratio), var(--lt-max-h));
}

.lt-gallery > .lt-sq:nth-child(4n + 2),
.lt-gallery > .lt-sq:nth-child(4n + 3) {
	flex: 0 0 calc(100% - var(--lt-wide) - 0.5px);
	max-width: calc(100% - var(--lt-wide) - 0.5px);
}

/* A trailing narrow tile with no wide sibling has nothing to stretch to,
   so it needs its own ratio or it collapses to nothing. */
.lt-gallery > .lt-sq.lt-solo::after {
	padding-bottom: min(100%, var(--lt-max-h));
}

/* Images fill their tile regardless of their own aspect */
.lt-gallery > .lt-sq img {
	position: absolute;
	top: 0;
	left: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	object-position: center;
	border-radius: inherit;
}

/* View More */
.lt-gallery-more {
	display: flex;
	justify-content: center;
	width: 100%;
}

.lt-view-more {
	display: inline-block;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	cursor: pointer;
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 0;
	transition: all 0.3s ease-in-out;
}

.lt-gallery-empty {
	padding: 40px;
	text-align: center;
	border: 1px dashed currentColor;
	opacity: 0.6;
	font-size: 14px;
	line-height: 1.5;
}

/* Optional mobile stack — off by default, matching the reference site */
@media (max-width: 767px) {
	.lt-stack-mobile-yes .lt-gallery > .lt-sq,
	.lt-stack-mobile-yes .lt-gallery > .lt-sq:nth-child(4n + 1),
	.lt-stack-mobile-yes .lt-gallery > .lt-sq:nth-child(4n + 2),
	.lt-stack-mobile-yes .lt-gallery > .lt-sq:nth-child(4n + 3),
	.lt-stack-mobile-yes .lt-gallery > .lt-sq:nth-child(4n + 4) {
		flex: 0 0 100%;
		max-width: 100%;
	}

	.lt-stack-mobile-yes .lt-gallery > .lt-sq::after {
		padding-bottom: min(var(--lt-ratio), var(--lt-max-h));
	}
}

@media (prefers-reduced-motion: reduce) {
	.lt-gallery > .lt-sq img,
	.lt-view-more {
		transition: none;
	}
}

/* ---------------------------------------------------------------------------
 * Lightbox UI
 *
 * Elementor renders its lightbox into <body>, outside every widget wrapper,
 * so these have to hang off body classes that the script sets on click.
 * Arrows and the counter are Elementor defaults — these rules only ever
 * remove chrome, never add it.
 * ------------------------------------------------------------------------- */

body.lt-lb-no-arrows .elementor-lightbox .elementor-swiper-button,
body.lt-lb-no-arrows .elementor-lightbox .elementor-swiper-button-prev,
body.lt-lb-no-arrows .elementor-lightbox .elementor-swiper-button-next {
	display: none !important;
}

body.lt-lb-no-counter .elementor-lightbox .elementor-slideshow__counter {
	display: none !important;
}

body.lt-lb-no-icons .elementor-lightbox .elementor-slideshow__icon-zoom-in,
body.lt-lb-no-icons .elementor-lightbox .elementor-slideshow__icon-zoom-out,
body.lt-lb-no-icons .elementor-lightbox .elementor-slideshow__icon-expand,
body.lt-lb-no-icons .elementor-lightbox .elementor-slideshow__icon-share,
body.lt-lb-no-icons .elementor-lightbox .elementor-slideshow__share {
	display: none !important;
}

/* Keep the header row from collapsing when only one field is present */
.elementor-lightbox .elementor-slideshow__title:empty,
.elementor-lightbox .elementor-slideshow__description:empty {
	display: none;
}
