/**
 * Component: product gallery
 *
 * Coin photography is the one thing a buyer cannot judge from a spec table,
 * so the plate is large, square, and never crops into the object. Images sit
 * on the warm plate ground so an inconsistent shot background does not
 * fracture the layout.
 */

.tcs-gallery {
	display: flex;
	flex-direction: column;
	gap: var(--tcs-space-sm);
}

.tcs-gallery__plate {
	position: relative;
	margin: 0;
	aspect-ratio: 1 / 1;
	background: var(--tcs-plate);
	border: var(--tcs-border);
	border-radius: var(--tcs-radius);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.tcs-gallery__image {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: var(--tcs-space-lg);
}

/* Honest empty state - this theme ships no invented coin photography. */
.tcs-gallery__plate--empty {
	background-image: repeating-linear-gradient(
		45deg,
		transparent,
		transparent 8px,
		var(--tcs-rule-faint) 8px,
		var(--tcs-rule-faint) 9px
	);
	color: var(--tcs-ink-faint);
}

.tcs-gallery__plate--empty .tcs-label {
	background: var(--tcs-surface);
	padding: var(--tcs-space-xs) var(--tcs-space-sm);
	border-radius: var(--tcs-radius-sm);
}

.tcs-gallery__zoom {
	position: absolute;
	inset-block-end: var(--tcs-space-sm);
	inset-inline-end: var(--tcs-space-sm);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: var(--tcs-surface-raised);
	border: var(--tcs-border);
	border-radius: var(--tcs-radius);
	color: var(--tcs-ink);
	box-shadow: var(--tcs-shadow-raised);
}

.tcs-gallery__zoom:hover {
	background: var(--tcs-paper-sunk);
}

/* ---------------------------------------------------------------------- */
/* Thumbnails                                                              */
/* ---------------------------------------------------------------------- */

.tcs-gallery__thumbs {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
	gap: var(--tcs-space-xs);
	list-style: none;
	margin: 0;
	padding: 0;
}

.tcs-gallery__thumb {
	display: block;
	aspect-ratio: 1 / 1;
	background: var(--tcs-plate);
	border: var(--tcs-border);
	border-radius: var(--tcs-radius-sm);
	overflow: hidden;
	transition: border-color var(--tcs-duration) var(--tcs-ease);
}

.tcs-gallery__thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: var(--tcs-space-2xs);
}

.tcs-gallery__thumb:hover {
	border-color: var(--tcs-ink-faint);
}

.tcs-gallery__thumb.is-current {
	border-color: var(--tcs-accent);
	box-shadow: inset 0 0 0 1px var(--tcs-accent);
}

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

/*
 * A native <dialog>: focus trapping, Escape-to-close and the backdrop come
 * from the platform rather than from script.
 */
.tcs-lightbox {
	width: min(92vw, 60rem);
	max-width: none;
	max-height: 92vh;
	padding: 0;
	border: 0;
	border-radius: var(--tcs-radius);
	background: var(--tcs-surface-raised);
	color: var(--tcs-ink);
	overflow: hidden;
}

.tcs-lightbox::backdrop {
	background: rgba(var(--tcs-scrim-rgb), 0.72);
}

.tcs-lightbox__inner {
	position: relative;
	display: flex;
	flex-direction: column;
	max-height: 92vh;
}

.tcs-lightbox__close {
	position: absolute;
	inset-block-start: var(--tcs-space-xs);
	inset-inline-end: var(--tcs-space-xs);
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: var(--tcs-surface-raised);
	border: var(--tcs-border);
	border-radius: var(--tcs-radius);
	color: var(--tcs-ink);
}

.tcs-lightbox__close:hover {
	background: var(--tcs-paper-sunk);
}

.tcs-lightbox__scroll {
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: var(--tcs-space-md);
	display: flex;
	flex-direction: column;
	gap: var(--tcs-space-md);
}

.tcs-lightbox__figure {
	margin: 0;
	background: var(--tcs-plate);
	border-radius: var(--tcs-radius-sm);
	display: flex;
	align-items: center;
	justify-content: center;
}

.tcs-lightbox__figure img {
	width: 100%;
	height: auto;
	max-height: 78vh;
	object-fit: contain;
}

@media (prefers-reduced-motion: reduce) {
	.tcs-gallery__thumb {
		transition: none;
	}
}

@media print {
	.tcs-gallery__zoom,
	.tcs-gallery__thumbs,
	.tcs-lightbox {
		display: none;
	}
}
