/*
 * Shared photo grid (sg_gallery()), style gallery pop-ups (sg_style_popup()) and the lightbox (assets/js/gallery.js).
 * Measured on live: Elementor Pro gallery (project pages), Popup Maker "lightbox" theme + WP gallery (style
 * pop-ups), Elementor lightbox.
 */

/* ---------- Project grid: 5 cols (≤1023: 3, ≤767: 2), 5px gaps, 1.57:1 above 1280px, 3:2 below. ---------- */
.sg-gallery--project {
	--cols: 5;
	--gap: 5px;
	--ratio: .636667;
	container-type: inline-size;
}
@media (min-width: 1025px) { .sg-gallery--project { margin-inline: -15px; } }
@media (max-width: 1280px) { .sg-gallery--project { --ratio: .666667; } }
@media (max-width: 1023px) { .sg-gallery--project { --cols: 3; } }
@media (max-width: 767px)  { .sg-gallery--project { --cols: 2; } }

/* 60 tracks so the last rows can be rebalanced (2, 3, 4, 5 or 6 per row) without changing the gutters. */
.sg-gallery--project .sg-gallery__grid {
	display: grid;
	grid-template-columns: repeat(60, minmax(0, 1fr));
	gap: var(--gap);
}
.sg-gallery--project .sg-gallery__item { grid-column-end: span 12; aspect-ratio: 1 / var(--ratio); position: relative; overflow: hidden; }
@media (max-width: 1023px) { .sg-gallery--project .sg-gallery__item { grid-column-end: span 20; } }
@media (max-width: 767px)  { .sg-gallery--project .sg-gallery__item { grid-column-end: span 30; } }

/* Every row keeps the standard row height (wider last-row photos crop a little more). */
@supports (width: 1cqi) {
	.sg-gallery--project .sg-gallery__grid { grid-auto-rows: calc((100cqi - (var(--cols) - 1) * var(--gap)) / var(--cols) * var(--ratio)); }
	.sg-gallery--project .sg-gallery__item { aspect-ratio: auto; }
	/* A gallery shorter than one row: its photos share the row at their own 3:2 shape. */
	.sg-gallery--project.is-single .sg-gallery__grid { grid-auto-rows: auto; }
	.sg-gallery--project.is-single .sg-gallery__item { aspect-ratio: 1 / var(--ratio); }
}

.sg-gallery--project .sg-gallery__link { position: absolute; inset: 0; display: block; overflow: hidden; }
.sg-gallery--project .sg-gallery__img {
	width: 100%; height: 100%; object-fit: cover;
	transform-origin: center top;
	transition: opacity .35s, transform .35s;
}
/* Live: lazy photos zoom from 50% and fade in as they arrive. */
.js .sg-gallery--project .sg-gallery__img:not(.is-loaded) { opacity: 0; transform: scale(.5); }
/* Hover/focus veil: rgba(0,0,0,.5), .8s. */
.sg-gallery--project .sg-gallery__link::after {
	content: ""; position: absolute; inset: 0;
	background: rgba(0, 0, 0, 0); transition: background-color .8s;
	pointer-events: none;
}
.sg-gallery--project .sg-gallery__link:hover::after,
.sg-gallery--project .sg-gallery__link:focus-visible::after { background: rgba(0, 0, 0, .5); }
.sg-gallery--project .sg-gallery__link:focus-visible { outline-offset: -3px; }

/* Filtered out (Galleries page) / filter fade-in. */
.sg-gallery__item[hidden] { display: none !important; }
.sg-gallery__item.is-entering { animation: sgFadeIn .5s ease both; }
@keyframes sgFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Pop-up grid (WP gallery in live's style pop-ups). ---------- */
.sg-gallery--popup .sg-gallery__grid {
	display: flex; flex-wrap: wrap; justify-content: center;
	margin: 0 -10px -10px 0;
	max-height: 75vh; overflow: auto;
	scrollbar-width: thin; scrollbar-color: #888 #f1f1f1;
}
.sg-gallery--popup .sg-gallery__grid::-webkit-scrollbar { width: 6px; }
.sg-gallery--popup .sg-gallery__grid::-webkit-scrollbar-track { background: #f1f1f1; }
.sg-gallery--popup .sg-gallery__grid::-webkit-scrollbar-thumb { background: #888; border-radius: 100px; }
.sg-gallery--popup .sg-gallery__item { flex: 0 0 20%; max-width: 20%; padding: 0 10px 10px 0; }
.sg-gallery--popup.sg-gallery--cols-4 .sg-gallery__item { flex-basis: 25%; max-width: 25%; }
.sg-gallery--popup.sg-gallery--cols-3 .sg-gallery__item { flex-basis: 33.333%; max-width: 33.333%; }
.sg-gallery--popup .sg-gallery__link { display: block; }
.sg-gallery--popup .sg-gallery__img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
@media (max-width: 1024px) { .sg-gallery--popup .sg-gallery__grid { max-height: 70vh; } }
@media (max-width: 767px) {
	.sg-gallery--popup .sg-gallery__item,
	.sg-gallery--popup.sg-gallery--cols-4 .sg-gallery__item,
	.sg-gallery--popup.sg-gallery--cols-3 .sg-gallery__item { flex-basis: 50%; max-width: 50%; }
}

/* ---------- Style pop-up (Popup Maker "lightbox" theme on live). ---------- */
.sg-modal.sg-style-popup { background: rgba(0, 0, 0, .6); padding: 20px 0; transition: opacity .15s ease-in-out; }
.sg-style-popup .sg-style-popup__box {
	width: 95%; max-width: none;
	padding: 38px; /* 18px box + 20px column */
	background: #000; border-radius: 3px;
	box-shadow: 0 0 50px 15px rgba(255, 255, 255, .15);
}
.sg-style-popup .sg-style-popup__close {
	position: absolute; top: 11px; right: 11px;
	width: 44px; height: 44px; color: #fff;
}
.sg-style-popup__close svg { width: 22px; height: 22px; }
.sg-style-popup__title { font-size: 50px; line-height: 1.2; text-align: center; margin: 0 0 30px; }
@media (max-width: 1280px) { .sg-style-popup__title { font-size: 40px; } }
@media (max-width: 1024px) {
	.sg-style-popup .sg-style-popup__box { padding: 28px; }
	.sg-style-popup .sg-style-popup__close { top: 5px; right: 5px; }
	.sg-style-popup__close svg { width: 18px; height: 18px; }
	.sg-style-popup__title { font-size: 35px; }
}
@media (max-width: 767px) { .sg-style-popup__title { font-size: 32px; margin-bottom: 16px; } }

/* ---------- Lightbox (live: Elementor lightbox). ---------- */
.sg-modal.sg-lb {
	display: block; padding: 0; overflow: hidden;
	z-index: 100040;
	background: rgba(0, 0, 0, .8);
	color: rgba(237, 237, 237, .9);
	transition: opacity .3s;
}
.sg-lb__stage { position: absolute; inset: 0; overflow: hidden; touch-action: pan-y; }
.sg-lb.is-open .sg-lb__stage { animation: sgLbZoomIn .3s both; }
@keyframes sgLbZoomIn { from { opacity: 0; transform: scale3d(.3, .3, .3); } 50% { opacity: 1; } }
.sg-lb__track { display: flex; gap: 100px; height: 100%; }
.sg-lb__track.is-animating { transition: transform .5s ease; }
.sg-lb__slide { flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 70px; }
.sg-lb__img {
	max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
	border-radius: 2px;
	box-shadow: 0 0 30px rgba(0, 0, 0, .3), 0 0 8px -5px rgba(0, 0, 0, .3);
	user-select: none; -webkit-user-drag: none;
}
.sg-lb__header {
	position: absolute; top: 0; left: 0; right: 0; z-index: 10;
	display: flex; align-items: center;
	padding: 15px 52px 15px 20px;
	font-size: 20px; pointer-events: none;
}
.sg-lb__header > * { pointer-events: auto; }
.sg-lb__fs { width: 44px; height: 44px; margin: -7px 0; display: grid; place-items: center; color: inherit; }
.sg-lb__fs svg { width: 20px; height: 20px; }
.sg-lb__counter { margin-left: 3px; font-size: 15px; }
.sg-lb .sg-lb__close {
	position: absolute; top: 17px; right: 11px; z-index: 11;
	width: 44px; height: 44px; display: grid; place-items: center; color: #fff;
}
.sg-lb__close svg { width: 22px; height: 22px; }
.sg-lb__prev, .sg-lb__next {
	position: absolute; top: 0; bottom: 0; z-index: 5;
	width: 15%; display: flex; align-items: center; justify-content: center;
	color: inherit;
}
.sg-lb__prev { left: 0; }
.sg-lb__next { right: 0; }
.sg-lb__prev svg, .sg-lb__next svg { width: 25px; height: 25px; }
.sg-lb__prev:hover, .sg-lb__next:hover, .sg-lb__fs:hover, .sg-lb .sg-lb__close:hover { color: #fff; }
.sg-lb.is-single .sg-lb__prev, .sg-lb.is-single .sg-lb__next, .sg-lb.is-single .sg-lb__counter { display: none; }
.sg-lb__footer {
	position: absolute; bottom: 0; left: 0; right: 0; z-index: 5;
	padding: 15px 20px; text-align: center; pointer-events: none;
}
.sg-lb__title { font-size: 16px; font-weight: 700; line-height: 24px; }
.sg-lb__desc { font-size: 14px; line-height: 21px; }
.sg-lb__title:empty, .sg-lb__desc:empty { display: none; }
@media (max-width: 1024px) {
	.sg-lb .sg-lb__close { top: 18px; right: 5px; }
	.sg-lb__close svg { width: 18px; height: 18px; }
}
@media (max-width: 767px) {
	.sg-lb__slide { padding: 70px 0; }
	/* Live (Elementor, phones): 20% tap zones, arrows on a 50% black square at the edges. */
	.sg-lb__prev, .sg-lb__next { width: 20%; }
	.sg-lb__prev { justify-content: flex-start; }
	.sg-lb__next { justify-content: flex-end; }
	.sg-lb__prev svg, .sg-lb__next svg { box-sizing: content-box; padding: 10px; background: rgba(0, 0, 0, .5); }
}
