.pmx-pg {
	--pmx-thumb: 112px;
	--pmx-gap: 40px;
	--pmx-radius: 10px;
	--pmx-border: #7A3FB0;
	--pmx-fit: contain;
	display: grid;
	grid-template-columns: var(--pmx-thumb-fit, var(--pmx-thumb)) minmax(0, 1fr);
	gap: var(--pmx-gap);
	align-items: start;
	width: 100%;
}

/* Thumbnail column: as tall as the large image, scrolls if there are many */
.pmx-pg__thumbs {
	display: flex;
	flex-direction: column;
	gap: 6px;
	align-self: stretch;
	height: 0;
	min-height: 100%;
	overflow-y: auto;
	scrollbar-width: thin;
	padding: 2px;
}

.pmx-pg__thumb {
	flex: 0 0 auto;
	width: 100%;
	aspect-ratio: 1 / 1;
	padding: 0;
	margin: 0;
	border: 1px solid var(--pmx-border);
	border-radius: var(--pmx-radius);
	overflow: hidden;
	background: transparent;
	cursor: pointer;
	opacity: 0.75;
	box-shadow: 0 0 4px rgba(0, 0, 0, 0.35);
	transition: opacity 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.pmx-pg__thumb:hover,
.pmx-pg__thumb:focus-visible {
	opacity: 1;
}

/* Transparent PNGs show the page background; stop the theme's button colours (hover/focus/active) */
.pmx-pg .pmx-pg__thumb,
.pmx-pg .pmx-pg__thumb:hover,
.pmx-pg .pmx-pg__thumb:focus,
.pmx-pg .pmx-pg__thumb:active,
.pmx-pg .pmx-pg__thumb.is-active {
	background: transparent !important;
	background-color: transparent !important;
	color: inherit;
}

.pmx-pg__thumb:focus-visible {
	outline: 2px solid var(--pmx-border);
	outline-offset: 2px;
}

.pmx-pg__thumb.is-active {
	opacity: 1;
	box-shadow: 0 0 0 2px var(--pmx-border), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.pmx-pg__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Large square image — images are stacked and cross-fade */
.pmx-pg__stage {
	position: relative;
	aspect-ratio: 1 / 1;
	width: 100%;
	max-width: var(--pmx-max, none);
	border: 1px solid var(--pmx-border);
	border-radius: var(--pmx-radius);
	overflow: hidden;
	background: transparent;
	touch-action: pan-y;
}

.pmx-pg__stage .pmx-pg__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: var(--pmx-fit);
	opacity: 0;
	transition: opacity 0.6s ease;
}

.pmx-pg__stage .pmx-pg__img.is-active {
	opacity: 1;
}

.pmx-pg-empty {
	padding: 24px;
	border: 1px dashed #aaa;
	text-align: center;
	color: #666;
}

/* Phone: large image on top, thumbnails in a row underneath */
@media (max-width: 767px) {
	.pmx-pg {
		grid-template-columns: minmax(0, 1fr);
		gap: 10px;
	}

	.pmx-pg__stage {
		order: 1;
	}

	.pmx-pg__thumbs {
		order: 2;
		flex-direction: row;
		height: auto;
		min-height: 0;
		overflow-x: auto;
		overflow-y: hidden;
	}

	/* Thumbnails share the row evenly (max 72px); with many images the row scrolls */
	.pmx-pg__thumb {
		flex: 1 1 0;
		width: auto;
		min-width: 48px;
		max-width: 72px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pmx-pg__stage .pmx-pg__img,
	.pmx-pg__thumb {
		transition: none;
	}
}
