/* DF Mosaic Gallery */

.dfmg {
	--dfmg-gap: 4px;
	--dfmg-lb-bg: #fff;
	--dfmg-lb-fg: #111;
	clear: both;
	margin: 0 0 1.5em;
}

/* Mosaico ------------------------------------------------------------ */

.dfmg-row {
	display: grid;
	grid-template-rows: minmax(0, 1fr);
	gap: var(--dfmg-gap);
	width: 100%;
	margin: 0 0 var(--dfmg-gap);
}

.dfmg-group {
	display: grid;
	gap: var(--dfmg-gap);
	min-width: 0;
	min-height: 0;
}

.dfmg .dfmg-item {
	position: relative;
	display: block;
	overflow: hidden;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: #f2f2f2;
	cursor: zoom-in;
}

.dfmg .dfmg-item .dfmg-img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: cover;
	transition: opacity 0.2s ease;
}

.dfmg .dfmg-item:hover .dfmg-img {
	opacity: 0.88;
}

.dfmg .dfmg-item:focus-visible {
	outline: 2px solid #111;
	outline-offset: -2px;
}

/* Griglia quadrata / tonda ------------------------------------------ */

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

.dfmg--grid .dfmg-item {
	aspect-ratio: 1;
}

.dfmg--circle .dfmg-item {
	border-radius: 50%;
}

@media (max-width: 600px) {
	.dfmg--grid {
		grid-template-columns: repeat(min(var(--dfmg-cols, 3), 2), minmax(0, 1fr));
	}
}

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

.dfmg-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	background: var(--dfmg-lb-bg, #fff);
	color: var(--dfmg-lb-fg, #111);
	touch-action: pan-y pinch-zoom;
	-webkit-tap-highlight-color: transparent;
}

.dfmg-lb.is-open {
	display: block;
	animation: dfmg-fade 0.18s ease-out;
}

@keyframes dfmg-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

.dfmg-lb-figure {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin: 0;
	padding: 56px 16px 44px;
	box-sizing: border-box;
}

.dfmg-lb-img {
	display: block;
	flex: 0 1 auto;
	min-height: 0;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	cursor: zoom-out;
	user-select: none;
	-webkit-user-drag: none;
}

.dfmg-lb-caption {
	flex: 0 0 auto;
	max-width: 70ch;
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	text-align: center;
}

.dfmg-lb-caption:empty {
	display: none;
}

.dfmg-lb-counter {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 14px;
	font-size: 13px;
	line-height: 1;
	text-align: center;
	font-variant-numeric: tabular-nums;
	opacity: 0.6;
	pointer-events: none;
}

.dfmg-lb .dfmg-lb-btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	line-height: 1;
	cursor: pointer;
	opacity: 0.65;
	transition: opacity 0.15s ease, background-color 0.15s ease;
}

.dfmg-lb .dfmg-lb-btn:hover,
.dfmg-lb .dfmg-lb-btn:focus-visible {
	opacity: 1;
	background: rgba(0, 0, 0, 0.06);
}

.dfmg-lb .dfmg-lb-btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.dfmg-lb .dfmg-lb-btn svg {
	display: block;
	width: 24px;
	height: 24px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.dfmg-lb-close { top: 6px; right: 6px; }
.dfmg-lb-prev { top: 50%; left: 6px; margin-top: -24px !important; }
.dfmg-lb-next { top: 50%; right: 6px; margin-top: -24px !important; }

.dfmg-lb.is-single .dfmg-lb-prev,
.dfmg-lb.is-single .dfmg-lb-next,
.dfmg-lb.is-single .dfmg-lb-counter {
	display: none;
}

@media (min-width: 850px) {
	.dfmg-lb-figure {
		padding-left: 72px;
		padding-right: 72px;
	}
}

html.dfmg-lock,
html.dfmg-lock body {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.dfmg .dfmg-item .dfmg-img,
	.dfmg-lb .dfmg-lb-btn {
		transition: none;
	}
	.dfmg-lb.is-open {
		animation: none;
	}
}
