/* Photo grids for the former Modula galleries (inc/gallery.php).
   Cells are square: row height = column width, computed from the gallery's own width. */

.vf-gallery {
	container-type: inline-size;
}

.vf-gallery__grid {
	--c: 12;
	--g: var(--gap-d, 10px);
	display: grid;
	grid-template-columns: repeat(var(--c), minmax(0, 1fr));
	grid-auto-rows: calc((100cqw - (var(--c) - 1) * var(--g)) / var(--c));
	grid-auto-flow: dense;
	gap: var(--g);
}

.vf-gallery__item {
	position: relative;
	grid-column: span var(--wd);
	grid-row: span var(--hd);
	min-width: 0;
	overflow: hidden;
	box-sizing: border-box;
	border: var(--border, 0) solid var(--border-color, transparent);
}

/* Scoped under .vf-gallery so blog-post image rules (e.g. .vf-post-content img margins) don't apply. */
.vf-gallery .vf-gallery__item img {
	display: block;
	margin: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transition: opacity 0.35s;
}

.vf-gallery.vf-gallery--fade .vf-gallery__item:hover img {
	opacity: 0.5;
}

/* Photo credit / caption, revealed on hover like Modula's "pufrobo" effect. */
.vf-gallery__caption {
	position: absolute;
	right: 5%;
	bottom: 20%;
	left: 5%;
	padding: 10px 0;
	color: var(--cap-color, #fff);
	font-size: var(--cap-size, 14px);
	line-height: 1.5;
	letter-spacing: 1px;
	text-align: center;
	opacity: 0;
	transform: translateY(100%);
	transition: opacity 0.35s, transform 0.35s;
	pointer-events: none;
}

.vf-gallery__item:hover .vf-gallery__caption {
	opacity: 1;
	transform: none;
}

@media (max-width: 480px) {
	.vf-gallery__caption {
		font-size: var(--cap-size-m, 10px);
	}
}

@media (max-width: 768px) {
	.vf-gallery__grid {
		--c: var(--cols-t, 2);
		--g: var(--gap-t, 10px);
	}

	.vf-gallery__item {
		grid-column: span var(--wt);
		grid-row: span var(--ht);
	}
}

@media (max-width: 568px) {
	.vf-gallery__grid {
		--c: 1;
		--g: var(--gap-m, 10px);
		grid-auto-rows: auto;
	}

	.vf-gallery__item {
		grid-column: auto;
		grid-row: auto;
		height: calc(var(--hm) * 100cqw + (var(--hm) - 1) * var(--g));
	}
}
