/* ==========================================================================
   Shared photo gallery (astrum-core, block astrum/gallery).

   Loaded by `block.json` only on views that render the block. Every value
   goes through a theme.json token — the plugin must not invent colours the
   design system does not know (see docs/predani.md §3).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. The grid
   -------------------------------------------------------------------------- */

.astrum-gallery__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--wp--preset--spacing--20);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 700px) {
	.astrum-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--wp--preset--spacing--30);
	}
}

.astrum-gallery__item {
	margin: 0;
}

.astrum-gallery__link {
	display: block;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	border-radius: var(--wp--custom--corner--md);
	background-color: var(--wp--preset--color--iron);
}

.astrum-gallery__link:focus-visible {
	outline: 2px solid var(--wp--preset--color--chartreuse);
	outline-offset: 3px;
}

.astrum-gallery__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--wp--custom--duration--slow) var(--wp--custom--easing--out);
}

.astrum-gallery__link:hover .astrum-gallery__image,
.astrum-gallery__link:focus-visible .astrum-gallery__image {
	transform: scale(1.03);
}

/* --------------------------------------------------------------------------
   2. The lightbox
   -------------------------------------------------------------------------- */

.astrum-gallery__lightbox {
	width: 100vw;
	max-width: none;
	height: 100vh;
	height: 100dvh;
	max-height: none;
	margin: 0;
	padding: var(--wp--preset--spacing--50) var(--wp--preset--spacing--20);
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--white);
}

.astrum-gallery__lightbox[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

.astrum-gallery__lightbox::backdrop {
	background-color: var(--wp--preset--color--ink);
	opacity: 0.94;
}

.astrum-gallery__stage {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--wp--preset--spacing--20);
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	/* The stage itself must not swallow backdrop clicks around the photo. */
	pointer-events: none;
}

.astrum-gallery__full {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: calc(100dvh - 2 * var(--wp--preset--spacing--50) - 2em);
	border-radius: var(--wp--custom--corner--sm);
	object-fit: contain;
	pointer-events: auto;
}

.astrum-gallery__counter {
	color: var(--wp--preset--color--silver);
	font-size: var(--wp--preset--font-size--x-small);
	letter-spacing: var(--wp--custom--tracking--wide);
}

.astrum-gallery__nav,
.astrum-gallery__close {
	position: absolute;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	/* Same 44px touch target as the menu items in the theme's §2.3. */
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--corner--pill);
	background-color: var(--wp--preset--color--graphite);
	color: var(--wp--preset--color--white);
	cursor: pointer;
	transition: background-color var(--wp--custom--duration--base) var(--wp--custom--easing--standard);
}

.astrum-gallery__nav:hover,
.astrum-gallery__close:hover {
	background-color: var(--wp--preset--color--steel);
}

.astrum-gallery__nav:focus-visible,
.astrum-gallery__close:focus-visible {
	outline: 2px solid var(--wp--preset--color--chartreuse);
	outline-offset: 2px;
}

.astrum-gallery__close {
	top: var(--wp--preset--spacing--20);
	right: var(--wp--preset--spacing--20);
}

.astrum-gallery__nav {
	top: 50%;
	transform: translateY(-50%);
}

.astrum-gallery__nav--prev {
	left: var(--wp--preset--spacing--20);
}

.astrum-gallery__nav--next {
	right: var(--wp--preset--spacing--20);
}

@media (prefers-reduced-motion: reduce) {
	.astrum-gallery__image,
	.astrum-gallery__nav,
	.astrum-gallery__close {
		transition: none;
	}

	.astrum-gallery__link:hover .astrum-gallery__image,
	.astrum-gallery__link:focus-visible .astrum-gallery__image {
		transform: none;
	}
}
