/*!
 * Better Gallery — Frontend Styles
 * Author: Mohamed Zulfikar
 * All selectors are scoped under .bg-gallery / .bg-lightbox to avoid
 * leaking into the host theme. Colors/sizes exposed as CSS custom
 * properties so Elementor's Style tab controls can override per-instance.
 */

.bg-gallery {
	--bg-gap: 12px;
	--bg-radius: 8px;
	--bg-aspect-ratio: 1/1;
	--bg-tile-height: 280px;
	--bg-featured-height: clamp(360px, 42vw, 620px);
	--bg-object-fit: cover;
	box-sizing: border-box;
}

.bg-gallery *,
.bg-gallery *::before,
.bg-gallery *::after {
	box-sizing: border-box;
}

.bg-empty-notice {
	padding: 16px;
	border: 1px dashed #c9c9c9;
	border-radius: 6px;
	color: #666;
	font-size: 14px;
}

/* ------------------------------------------------------------------ */
/* Shared item / figure styles                                        */
/* ------------------------------------------------------------------ */

.bg-item {
	position: relative;
	margin: 0;
	overflow: hidden;
	border-radius: var(--bg-radius);
	background: #eee;
	isolation: isolate;
}

.bg-item-link {
	display: block;
	position: relative;
	width: 100%;
	height: 100%;
	line-height: 0;
}

.bg-item-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: var(--bg-object-fit, cover);
	transition: transform .5s ease, filter .5s ease, opacity .5s ease;
	backface-visibility: hidden;
}

.bg-item-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	opacity: 0;
	background: rgba(0, 0, 0, 0);
	transition: opacity .35s ease, background-color .35s ease;
	pointer-events: none;
}

.bg-item-zoom-icon {
	transform: scale(.6);
	transition: transform .35s ease;
}

/* Hover effect variants */
.bg-hover-zoom:hover .bg-item-img { transform: scale(1.08); }

.bg-hover-overlay:hover .bg-item-overlay {
	opacity: 1;
	background: rgba(0, 0, 0, .45);
}
.bg-hover-overlay:hover .bg-item-zoom-icon { transform: scale(1); }

.bg-hover-fade:hover .bg-item-img { opacity: .8; }

.bg-hover-grayscale .bg-item-img { filter: grayscale(100%); }
.bg-hover-grayscale:hover .bg-item-img { filter: grayscale(0%); }

.bg-item-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 10px 12px;
	font-size: 13px;
	line-height: 1.4;
	background: rgba(0, 0, 0, .6);
	color: #fff;
}

@media (prefers-reduced-motion: reduce) {
	.bg-item-img,
	.bg-item-overlay,
	.bg-item-zoom-icon {
		transition: none !important;
	}
}

/* Visible keyboard focus (accessibility) */
.bg-item-link:focus-visible,
.bg-carousel-btn:focus-visible,
.bg-lb-close:focus-visible,
.bg-lb-nav:focus-visible {
	outline: 3px solid #4d90fe;
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Style 1: Uniform Grid                                              */
/* ------------------------------------------------------------------ */

.bg-grid {
	display: grid;
	grid-template-columns: repeat(var(--bg-cols, 3), 1fr);
	gap: var(--bg-gap);
}

.bg-grid .bg-item {
	aspect-ratio: var(--bg-aspect-ratio);
}

.bg-grid.bg-height-fixed .bg-item {
	aspect-ratio: unset;
	height: var(--bg-tile-height);
}

@media (max-width: 1024px) {
	.bg-grid { grid-template-columns: repeat(var(--bg-cols-tablet, 2), 1fr); }
}

@media (max-width: 600px) {
	.bg-grid { grid-template-columns: repeat(var(--bg-cols-mobile, 1), 1fr); }
}

/* ------------------------------------------------------------------ */
/* Style 2: Featured Grid — 1 large + 4 small (matches reference mock) */
/* ------------------------------------------------------------------ */

.bg-featured-grid {
	display: grid;
	grid-template-columns: 1.6fr 1fr 1fr;
	grid-template-rows: 1fr 1fr;
	gap: var(--bg-gap);
	height: var(--bg-featured-height, clamp(360px, 42vw, 620px));
}

.bg-featured-main {
	grid-column: 1;
	grid-row: 1 / span 2;
	height: 100%;
}

.bg-featured-sub {
	height: 100%;
}

.bg-featured-grid .bg-item-img { height: 100%; }

.bg-has-more { position: relative; }

.bg-more-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, .55);
	color: #fff;
	font-size: 28px;
	font-weight: 700;
	border-radius: var(--bg-radius);
	pointer-events: none;
}

@media (max-width: 900px) {
	.bg-featured-grid {
		grid-template-columns: 1fr 1fr;
		grid-template-rows: repeat(3, minmax(140px, auto));
		height: auto;
	}
	.bg-featured-main {
		grid-column: 1 / span 2;
		grid-row: 1;
		height: 260px;
	}
}

@media (max-width: 480px) {
	.bg-featured-grid {
		grid-template-columns: 1fr;
	}
	.bg-featured-main {
		grid-column: 1;
		height: 220px;
	}
}

/* ------------------------------------------------------------------ */
/* Style 3: Masonry — CSS multi-column flow (lightweight, no JS)       */
/* ------------------------------------------------------------------ */

.bg-masonry {
	column-count: var(--bg-cols, 3);
	column-gap: var(--bg-gap);
}

.bg-masonry-item {
	display: inline-block;
	width: 100%;
	margin: 0 0 var(--bg-gap);
	break-inside: avoid;
}

@media (max-width: 1024px) {
	.bg-masonry { column-count: var(--bg-cols-tablet, 2); }
}

@media (max-width: 600px) {
	.bg-masonry { column-count: var(--bg-cols-mobile, 1); }
}

/* ------------------------------------------------------------------ */
/* Style 4: Carousel — native scroll-snap, no external slider library  */
/* ------------------------------------------------------------------ */

.bg-carousel-wrap {
	position: relative;
}

.bg-carousel {
	display: flex;
	gap: var(--bg-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 4px;
	scrollbar-width: none;
}

.bg-carousel::-webkit-scrollbar { display: none; }

.bg-carousel-slide {
	flex: 0 0 var(--bg-slide-w, 32%);
	scroll-snap-align: start;
	aspect-ratio: var(--bg-aspect-ratio, 4/3);
}

.bg-carousel.bg-height-fixed .bg-carousel-slide {
	aspect-ratio: unset;
	height: var(--bg-tile-height);
}

@media (max-width: 768px) {
	.bg-carousel-slide { flex-basis: 78%; }
}

.bg-carousel-btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .92);
	color: #222;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
	transition: background-color .2s ease;
	z-index: 2;
}

.bg-carousel-btn:hover { background: #fff; }
.bg-carousel-prev { left: -6px; }
.bg-carousel-next { right: -6px; }

@media (max-width: 600px) {
	.bg-carousel-btn { width: 34px; height: 34px; }
}

/* ------------------------------------------------------------------ */
/* Style 5: Justified Rows                                             */
/* ------------------------------------------------------------------ */

.bg-justified {
	display: flex;
	flex-wrap: wrap;
	gap: var(--bg-gap);
}

.bg-justified-item {
	height: var(--bg-row-height, 220px);
	flex-grow: 1;
}

.bg-justified-item .bg-item-img {
	width: 100%;
	height: 100%;
}

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

.bg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: rgba(10, 10, 10, .95);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease;
}

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

.bg-lb-stage {
	position: relative;
	max-width: 92vw;
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.bg-lb-img {
	max-width: 92vw;
	max-height: 80vh;
	width: auto;
	height: auto;
	border-radius: 4px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
	opacity: 0;
	transform: scale(.98);
	transition: opacity .25s ease, transform .25s ease;
}

.bg-lightbox.is-open .bg-lb-img { opacity: 1; transform: scale(1); }

.bg-lb-caption {
	margin: 12px 0 0;
	color: #eee;
	font-size: 14px;
	text-align: center;
	max-width: 70ch;
}

.bg-lb-counter {
	margin: 4px 0 0;
	color: #9c9c9c;
	font-size: 12px;
	letter-spacing: .04em;
}

.bg-lb-close,
.bg-lb-nav {
	position: fixed;
	border: 0;
	background: rgba(255, 255, 255, .08);
	color: #fff;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background-color .2s ease;
}

.bg-lb-close:hover,
.bg-lb-nav:hover { background: rgba(255, 255, 255, .18); }

.bg-lb-close { top: 20px; right: 20px; }
.bg-lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.bg-lb-next { right: 20px; top: 50%; transform: translateY(-50%); }

@media (max-width: 600px) {
	.bg-lb-close { top: 10px; right: 10px; width: 38px; height: 38px; }
	.bg-lb-prev { left: 10px; width: 38px; height: 38px; }
	.bg-lb-next { right: 10px; width: 38px; height: 38px; }
}

body.bg-lightbox-open {
	overflow: hidden;
}
