/**
 * GM Gallery – frontend styles.
 *
 * Grid: 12 columns of square cells, tiles span --gm-w x --gm-h cells.
 * `grid-auto-flow: dense` places every tile at the top-most, then left-most
 * free slot, the same packing Modula's custom grid (Packery) uses.
 * Gutters are applied as tile padding plus a negative grid margin, so a tile
 * of n cells is exactly n * cell - gutter wide (identical to Modula).
 */

.gm-gallery {
	--gm-gutter: 10px;
	--gm-hover-color: #fff;
	--gm-hover-opacity: 0.5;
	container-type: inline-size;
	width: 100%;
}

.gm-gallery .gm-gallery__grid {
	--gm-cols: 12;
	display: grid;
	grid-template-columns: repeat(var(--gm-cols), minmax(0, 1fr));
	grid-auto-rows: calc((100cqw + var(--gm-gutter)) / var(--gm-cols));
	grid-auto-flow: dense;
	margin: 0 calc(-1 * var(--gm-gutter)) calc(-1 * var(--gm-gutter)) 0;
	padding: 0;
	list-style: none;
}

.gm-gallery .gm-gallery__item {
	grid-column: span var(--gm-w, 4);
	grid-row: span var(--gm-h, 3);
	box-sizing: border-box;
	min-width: 0;
	margin: 0;
	padding: 0 var(--gm-gutter) var(--gm-gutter) 0;
	list-style: none;
}

.gm-gallery .gm-gallery__item::before,
.gm-gallery .gm-gallery__item::marker {
	content: none;
}

/* Mobile: 24 columns; tiles are half or full width (set per tile in PHP). */
@container (max-width: 599px) {
	.gm-gallery .gm-gallery__grid {
		--gm-cols: 24;
	}

	.gm-gallery .gm-gallery__item {
		grid-column: span var(--gm-mw, 12);
		grid-row: span var(--gm-mh, 9);
	}
}

.gm-gallery .gm-gallery__link {
	display: block;
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background-color: var(--gm-hover-color);
}

.gm-gallery .gm-gallery__link--lightbox {
	cursor: zoom-in;
}

.gm-gallery .gm-gallery__link:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
}

.gm-gallery .gm-gallery__item img.gm-gallery__img {
	display: block;
	width: 100%;
	max-width: none;
	height: 100%;
	margin: 0;
	object-fit: cover;
	object-position: center;
	transition: opacity 0.2s linear;
}

.gm-gallery .gm-gallery__item > img.gm-gallery__img {
	background-color: var(--gm-hover-color);
}

.gm-gallery .gm-gallery__link:hover img.gm-gallery__img,
.gm-gallery .gm-gallery__link:focus-visible img.gm-gallery__img {
	opacity: var(--gm-hover-opacity);
}

.gm-gallery--protected img {
	-webkit-user-drag: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;
}

/* License notice */
.gm-gallery .gm-gallery__license {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em 0.75em;
	align-items: center;
	margin: 1.25em 0 0;
	font-size: 0.875em;
	line-height: 1.5;
}

.gm-gallery .gm-gallery__license-badge {
	display: inline-block;
	padding: 0.1em 0.5em;
	border: 1px solid currentColor;
	border-radius: 3px;
	font-size: 0.85em;
	font-weight: 600;
	line-height: 1.6;
	text-decoration: none;
	white-space: nowrap;
}

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

.gm-lightbox-open {
	overflow: hidden;
}

.gm-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: rgba(30, 30, 30, 0.9);
	color: #eee;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 14px;
	-webkit-user-select: none;
	user-select: none;
}

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

.gm-lightbox:focus {
	outline: none;
}

.gm-lightbox button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: rgba(24, 24, 27, 0.65);
	color: #ddd;
	cursor: pointer;
	box-shadow: none;
}

.gm-lightbox button:hover {
	color: #fff;
	background: rgba(24, 24, 27, 0.9);
}

.gm-lightbox button:focus-visible {
	outline: 2px solid #fff;
	outline-offset: -2px;
}

.gm-lightbox button[aria-pressed="true"] {
	color: #fff;
}

.gm-lightbox svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

/* Slideshow progress (0.2.1): a line at the top that fills until the next
   photo – the same 3 px line as the reading progress of the GM Theme. */
.gm-lightbox__progress {
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	z-index: 3;
	height: 3px;
	background: rgba(255, 255, 255, 0.9);
	transform: scaleX(0);
	transform-origin: 0 50%;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.gm-lightbox.is-playing .gm-lightbox__progress {
	opacity: 1;
}

.gm-lightbox__progress.is-running {
	animation: gm-lightbox-progress var(--gm-lb-speed, 5000ms) linear forwards;
}

@keyframes gm-lightbox-progress {
	from {
		transform: scaleX(0);
	}
	to {
		transform: scaleX(1);
	}
}

@media (prefers-reduced-motion: reduce) {

	.gm-lightbox__progress.is-running {
		animation: none;
		transform: scaleX(1);
		opacity: 0.5;
	}
}

.gm-lightbox__toolbar {
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	z-index: 2;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	pointer-events: none;
}

.gm-lightbox__toolbar > * {
	pointer-events: auto;
}

.gm-lightbox__counter {
	padding: 12px 14px;
	font-variant-numeric: tabular-nums;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.gm-lightbox__actions {
	display: flex;
}

.gm-lightbox__main {
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	justify-content: center;
	min-height: 0;
	touch-action: pan-y pinch-zoom;
}

.gm-lightbox__stage {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 52px 56px 12px;
	box-sizing: border-box;
}

.gm-lightbox__img {
	display: block;
	flex: 0 1 auto;
	min-height: 0;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	opacity: 1;
	transition: opacity 0.25s ease;
	-webkit-user-drag: none;
}

.gm-lightbox.is-loading .gm-lightbox__img {
	opacity: 0;
}

.gm-lightbox__caption {
	flex: 0 0 auto;
	max-width: 100%;
	padding: 10px 0 0;
	text-align: center;
	line-height: 1.4;
}

.gm-lightbox__caption:empty {
	display: none;
}

.gm-lightbox__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	transform: translateY(-50%);
}

.gm-lightbox .gm-lightbox__nav {
	width: 48px;
	height: 72px;
	background: transparent;
}

.gm-lightbox .gm-lightbox__nav:hover {
	background: transparent;
}

.gm-lightbox__nav--prev {
	left: 4px;
}

.gm-lightbox__nav--next {
	right: 4px;
}

.gm-lightbox__nav svg {
	width: 28px;
	height: 28px;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.gm-lightbox__thumbs {
	display: flex;
	flex: 0 0 auto;
	gap: 6px;
	padding: 8px;
	overflow-x: auto;
	background: rgba(0, 0, 0, 0.35);
	scrollbar-width: thin;
}

.gm-lightbox__thumbs[hidden] {
	display: none;
}

.gm-lightbox .gm-lightbox__thumb {
	flex: 0 0 auto;
	width: 72px;
	height: 54px;
	padding: 0;
	background: #111;
	opacity: 0.55;
}

.gm-lightbox .gm-lightbox__thumb[aria-current="true"],
.gm-lightbox .gm-lightbox__thumb:hover {
	opacity: 1;
}

.gm-lightbox__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}

/* ---------- Photo data (0.2.2) ----------
   "i" button in the toolbar (top right). The panel shows camera, lens and
   exposure of the current photo below the toolbar, as a dark card. */

.gm-lightbox__info {
	position: absolute;
	top: 52px;
	right: 8px;
	z-index: 3;
	box-sizing: border-box;
	width: 18.5rem;
	max-width: calc(100% - 16px);
	padding: 14px 16px 15px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 14px;
	background: rgba(24, 24, 27, 0.84);
	-webkit-backdrop-filter: blur(16px) saturate(150%);
	backdrop-filter: blur(16px) saturate(150%);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
	color: rgba(255, 255, 255, 0.92);
	font-size: 13px;
	line-height: 1.4;
	animation: gm-lightbox-info-in 0.18s ease;
}

.gm-lightbox__info[hidden] {
	display: none;
}

@keyframes gm-lightbox-info-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}

.gm-lightbox__info p,
.gm-lightbox__info dl,
.gm-lightbox__info dd {
	margin: 0;
}

.gm-lightbox__info-camera,
.gm-lightbox__info-lens {
	display: flex;
	align-items: flex-start;
	gap: 9px;
}

.gm-lightbox__info-camera {
	color: #fff;
	font-size: 14px;
	font-weight: 600;
}

.gm-lightbox__info-lens {
	color: rgba(255, 255, 255, 0.78);
}

.gm-lightbox__info .gm-lightbox__info-lens,
.gm-lightbox__info .gm-lightbox__info-grid,
.gm-lightbox__info .gm-lightbox__info-date {
	margin-top: 12px;
}

.gm-lightbox__info .gm-lightbox__info-camera + .gm-lightbox__info-lens {
	margin-top: 6px;
}

.gm-lightbox__info > :first-child {
	margin-top: 0;
}

.gm-lightbox__info-camera svg,
.gm-lightbox__info-lens svg {
	flex: none;
	width: 17px;
	height: 17px;
	margin-top: 1px;
	stroke-width: 1.5;
	opacity: 0.7;
}

/* Shutter speed, aperture, ISO, focal length: two columns, name above value. */
.gm-lightbox__info-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px 16px;
}

.gm-lightbox__info-grid dt {
	margin: 0 0 2px;
	color: rgba(255, 255, 255, 0.55);
	font-size: 10.5px;
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.gm-lightbox__info-grid dd {
	color: #fff;
	font-size: 15px;
	font-weight: 500;
	font-variant-numeric: tabular-nums;
}

.gm-lightbox__info-date {
	color: rgba(255, 255, 255, 0.6);
	font-size: 12px;
}

.gm-lightbox__info-none {
	color: rgba(255, 255, 255, 0.75);
}

.gm-lightbox__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 599px) {
	.gm-lightbox__stage {
		padding: 48px 8px 8px;
	}

	.gm-lightbox__info {
		right: 8px;
		left: 8px;
		width: auto;
		max-width: none;
	}

	.gm-lightbox .gm-lightbox__nav {
		width: 40px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gm-gallery .gm-gallery__item img.gm-gallery__img,
	.gm-lightbox__img {
		transition: none;
	}

	.gm-lightbox__info {
		animation: none;
	}
}
