.piemme-gallery,
.piemme-gallery *,
.piemme-lightbox,
.piemme-lightbox * {
	box-sizing: border-box;
}

.piemme-gallery {
	width: 100%;
	max-width: 100rem;
	margin-inline: auto;
}

.piemme-gallery--duo {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	align-items: start;
	column-gap: clamp(1.25rem, 2.8vw, 3.25rem);
	row-gap: clamp(3.5rem, 6vw, 7rem);
}

.piemme-gallery--duo .piemme-gallery__item {
	width: 100%;
	align-self: start;
}

.piemme-gallery--exhibition {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: clamp(5rem, 9vw, 10rem);
}

.piemme-gallery--exhibition .piemme-gallery__item {
	flex: 0 0 auto;
}

.piemme-gallery--exhibition .piemme-gallery__item--panorama {
	width: 100%;
}

.piemme-gallery--exhibition .piemme-gallery__item--landscape {
	width: min(88%, 86rem);
}

.piemme-gallery--exhibition .piemme-gallery__item--square {
	width: min(62%, 62rem);
}

.piemme-gallery--exhibition .piemme-gallery__item--portrait {
	width: min(48%, 48rem);
}

.piemme-gallery--exhibition .piemme-gallery__item--left {
	align-self: flex-start;
}

.piemme-gallery--exhibition .piemme-gallery__item--right {
	align-self: flex-end;
}

.piemme-gallery--exhibition .piemme-gallery__item--center {
	align-self: center;
}

.piemme-gallery--masonry {
	display: grid;
	grid-template-columns: repeat(var(--piemme-cols-desktop, 4), minmax(0, 1fr));
	align-items: start;
	gap: var(--piemme-gallery-gap, 18px);
}

.piemme-gallery--masonry.piemme-gallery--enhanced {
	grid-auto-rows: 8px;
}

.piemme-gallery__item {
	min-width: 0;
	min-height: 0 !important;
	max-height: none !important;
	height: auto !important;
	margin: 0;
	aspect-ratio: auto !important;
}

.piemme-gallery__open {
	position: relative;
	display: block;
	overflow: visible;
	width: 100%;
	min-height: 0 !important;
	max-height: none !important;
	height: auto !important;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: inherit;
	aspect-ratio: auto !important;
	line-height: 0;
	cursor: zoom-in;
}

.piemme-gallery img.piemme-gallery__image {
	display: block !important;
	width: 100% !important;
	min-width: 0 !important;
	max-width: 100% !important;
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	aspect-ratio: auto !important;
	object-fit: unset !important;
	contain: none !important;
	contain-intrinsic-size: none !important;
	content-visibility: visible !important;
	margin: 0;
	transition: transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1), filter 320ms ease;
}

.piemme-gallery--motion-ready .piemme-gallery__item {
	opacity: 0;
	transform: translateY(42px);
	transition: opacity 720ms ease var(--piemme-reveal-delay, 0ms),
		transform 850ms cubic-bezier(0.2, 0.7, 0.2, 1) var(--piemme-reveal-delay, 0ms);
}

.piemme-gallery--motion-ready .piemme-gallery__item.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.piemme-gallery__open:hover .piemme-gallery__image {
	transform: scale(1.025);
	filter: brightness(0.88);
}

.piemme-gallery__open:focus-visible {
	outline: 3px solid #111;
	outline-offset: 3px;
}

.piemme-gallery__zoom {
	position: absolute;
	right: 14px;
	bottom: 14px;
	width: 34px;
	height: 34px;
	border: 1px solid rgba(255, 255, 255, 0.7);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.42);
	backdrop-filter: blur(5px);
	opacity: 0;
	transform: translateY(5px);
	transition: opacity 220ms ease, transform 220ms ease;
}

.piemme-gallery__zoom::before,
.piemme-gallery__zoom::after {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 12px;
	height: 1px;
	background: #fff;
	content: '';
	transform: translate(-50%, -50%);
}

.piemme-gallery__zoom::after {
	transform: translate(-50%, -50%) rotate(90deg);
}

.piemme-gallery__open:hover .piemme-gallery__zoom,
.piemme-gallery__open:focus-visible .piemme-gallery__zoom {
	opacity: 1;
	transform: translateY(0);
}

.piemme-gallery__caption {
	margin: 10px 0 0;
	color: #5e5e5a;
	font-size: 0.875rem;
	line-height: 1.45;
}

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

.piemme-lightbox[hidden] {
	display: none;
}

.piemme-lightbox {
	position: fixed;
	z-index: 100000;
	inset: 0;
	display: block;
	padding: 0;
	color: #fff;
}

.piemme-lightbox__backdrop {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	background: rgba(5, 5, 5, 0.975);
	cursor: zoom-out;
}

.piemme-lightbox__panel {
	position: relative;
	z-index: 1;
	display: block;
	width: 100vw;
	height: 100vh;
	height: 100dvh;
}

.piemme-lightbox__image {
	position: absolute;
	top: 50%;
	left: 50%;
	display: block !important;
	width: auto !important;
	min-width: 0 !important;
	max-width: calc(100vw - 40px) !important;
	height: auto !important;
	min-height: 0 !important;
	max-height: calc(100vh - 40px) !important;
	max-height: calc(100dvh - 40px) !important;
	aspect-ratio: auto !important;
	object-fit: contain !important;
	object-position: center !important;
	transform: translate(-50%, -50%);
}

.piemme-lightbox__close,
.piemme-lightbox__nav {
	border: 0;
	background: transparent;
	color: #fff;
	cursor: pointer;
}

.piemme-lightbox__close:focus-visible,
.piemme-lightbox__nav:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.piemme-lightbox__close {
	position: absolute;
	z-index: 4;
	top: clamp(12px, 2vw, 28px);
	right: clamp(12px, 2vw, 28px);
	width: 48px;
	height: 48px;
	border: 1px solid rgba(255, 255, 255, 0.36);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.48);
	font-size: 36px;
	font-weight: 200;
	line-height: 1;
	backdrop-filter: blur(8px);
}

.piemme-lightbox__nav {
	position: absolute;
	z-index: 4;
	top: 50%;
	width: clamp(44px, 5vw, 68px);
	height: clamp(56px, 7vw, 82px);
	border: 1px solid rgba(255, 255, 255, 0.25);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.4);
	font-size: clamp(48px, 6vw, 76px);
	font-weight: 200;
	line-height: 0.7;
	opacity: 0.78;
	transform: translateY(-50%);
	transition: opacity 160ms ease, background-color 160ms ease;
	backdrop-filter: blur(8px);
}

.piemme-lightbox__nav:hover {
	opacity: 1;
	background: rgba(0, 0, 0, 0.7);
}

.piemme-lightbox__nav--prev {
	left: clamp(10px, 2vw, 28px);
}

.piemme-lightbox__nav--next {
	right: clamp(10px, 2vw, 28px);
}

.piemme-lightbox__meta {
	position: absolute;
	z-index: 4;
	right: 50%;
	bottom: clamp(12px, 2vw, 28px);
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 24px;
	max-width: calc(100vw - 40px);
	padding: 9px 14px;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.5);
	font-size: 0.875rem;
	transform: translateX(50%);
	backdrop-filter: blur(8px);
}

.piemme-lightbox__caption {
	margin: 0;
	color: rgba(255, 255, 255, 0.84);
}

.piemme-lightbox__count {
	flex: 0 0 auto;
	color: rgba(255, 255, 255, 0.62);
	font-variant-numeric: tabular-nums;
}

@media (max-width: 1024px) {
	.piemme-gallery--masonry {
		grid-template-columns: repeat(var(--piemme-cols-tablet, 3), minmax(0, 1fr));
	}

	.piemme-gallery--exhibition {
		gap: clamp(4rem, 8vw, 7rem);
	}

	.piemme-gallery--exhibition .piemme-gallery__item--landscape {
		width: 94%;
	}

	.piemme-gallery--exhibition .piemme-gallery__item--square {
		width: 74%;
	}

	.piemme-gallery--exhibition .piemme-gallery__item--portrait {
		width: 62%;
	}
}

@media (max-width: 640px) {
	.piemme-gallery--duo {
		grid-template-columns: 1fr;
		row-gap: clamp(2.75rem, 12vw, 4.5rem);
	}

	.piemme-gallery--masonry {
		grid-template-columns: repeat(var(--piemme-cols-mobile, 1), minmax(0, 1fr));
	}

	.piemme-gallery--exhibition {
		gap: clamp(3.75rem, 16vw, 5.5rem);
	}

	.piemme-gallery--exhibition .piemme-gallery__item--panorama,
	.piemme-gallery--exhibition .piemme-gallery__item--landscape {
		width: 100%;
	}

	.piemme-gallery--exhibition .piemme-gallery__item--square {
		width: 94%;
	}

	.piemme-gallery--exhibition .piemme-gallery__item--portrait {
		width: 82%;
	}

	.piemme-lightbox {
		padding: 0;
	}

	.piemme-lightbox__panel {
		width: 100vw;
		height: 100vh;
		height: 100dvh;
	}

	.piemme-lightbox__image {
		max-width: calc(100vw - 16px) !important;
		max-height: calc(100vh - 16px) !important;
		max-height: calc(100dvh - 16px) !important;
	}

	.piemme-lightbox__close {
		top: 10px;
		right: 10px;
	}

	.piemme-lightbox__nav {
		width: 42px;
		height: 56px;
		padding: 0;
		font-size: 52px;
	}

	.piemme-lightbox__nav--prev {
		left: 6px;
	}

	.piemme-lightbox__nav--next {
		right: 6px;
	}

	.piemme-lightbox__meta {
		bottom: 10px;
		max-width: calc(100vw - 20px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.piemme-gallery__image,
	.piemme-gallery__item,
	.piemme-gallery__zoom,
	.piemme-lightbox__nav {
		transition: none;
	}
}
