/* Full Image Masonry Gallery
 * Uses CSS Grid with a FIXED column count, so you always get exactly
 * 2 or 3 (or however many) images per row — no matter how many images
 * are in the gallery. Each image still scales with width:100%/height:auto,
 * so the full picture is always visible and nothing is cropped.
 */

.fimg-gallery {
	--fimg-columns: 3;
	--fimg-columns-desktop: 3;
	--fimg-columns-tablet: 2;
	--fimg-columns-mobile: 1;
	--fimg-gap: 16px;
	--fimg-radius: 8px;

	display: grid;
	grid-template-columns: repeat( var( --fimg-columns, var( --fimg-columns-desktop ) ), 1fr );
	gap: var(--fimg-gap);
	width: 100%;
}

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

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

.fimg-item {
	margin: 0;
	display: flex;
	align-items: center; /* centers shorter images within the row's height */
}

.fimg-link {
	display: block;
	width: 100%;
	overflow: hidden;
	border-radius: var(--fimg-radius);
	line-height: 0;
	cursor: zoom-in;
}

/* The critical rule: width 100%, height auto = the FULL image renders,
   nothing is cropped, and the natural aspect ratio is always preserved. */
.fimg-image {
	display: block;
	width: 100%;
	height: auto;
	border-radius: var(--fimg-radius);
	transition: transform 0.35s ease, opacity 0.35s ease;
}

/* Hover effects */
.fimg-hover-zoom .fimg-link:hover .fimg-image {
	transform: scale(1.05);
}

.fimg-hover-fade .fimg-link:hover .fimg-image {
	opacity: 0.8;
}

/* Lightbox */
.fimg-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.9);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	padding: 40px;
	box-sizing: border-box;
}

.fimg-lightbox.is-open {
	display: flex;
}

.fimg-lightbox-img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain; /* still never cropped, just fitted to the viewport */
	border-radius: 4px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.fimg-lightbox-close,
.fimg-lightbox-prev,
.fimg-lightbox-next {
	position: absolute;
	background: rgba(255, 255, 255, 0.1);
	border: none;
	color: #fff;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	padding: 12px 16px;
	border-radius: 50%;
	transition: background 0.2s ease;
}

.fimg-lightbox-close:hover,
.fimg-lightbox-prev:hover,
.fimg-lightbox-next:hover {
	background: rgba(255, 255, 255, 0.25);
}

.fimg-lightbox-close {
	top: 20px;
	right: 20px;
}

.fimg-lightbox-prev {
	left: 20px;
	top: 50%;
	transform: translateY(-50%);
}

.fimg-lightbox-next {
	right: 20px;
	top: 50%;
	transform: translateY(-50%);
}

@media (max-width: 600px) {
	.fimg-lightbox {
		padding: 16px;
	}
	.fimg-lightbox-prev,
	.fimg-lightbox-next {
		font-size: 20px;
		padding: 8px 12px;
	}
}
