/**
 * Gallery Grid — Picklemall Widgets
 *
 * One event's photos (markup: Gallery_Grid::render). Colours and layout are
 * --pm-gg-* custom properties set from the widget's Style tab; the defaults
 * match the Coaches Hero / Grid so the pages read as one set.
 */

/*
 * Event pages: the area behind the fixed navbar is the <body>, so match it to
 * the gallery background. single-gallery.php re-syncs this at runtime.
 */
body.pm-single-gallery {
	background-color: var(--pm-color-primary-d80, #052E2C);
}

.pm-gg {
	--pm-gg-columns: 4;
	--pm-gg-gap: 12px;
	--pm-gg-radius: var(--pm-radius-md, 8px);
	--pm-gg-ratio: 3 / 2;
	--pm-gg-max-width: 1280px;
	--pm-gg-bg: var(--pm-color-primary-d80, #052E2C);
	--pm-gg-title: var(--pm-color-white, #FFFFFF);
	--pm-gg-graffiti: var(--pm-color-orange, #E85D22);
	--pm-gg-text: rgba(255, 255, 255, 0.85);
	--pm-gg-accent: var(--pm-color-action, #E1FF2B);

	width: 100%;
	background-color: var(--pm-gg-bg);
	color: var(--pm-gg-text);
}

.pm-gg__inner {
	max-width: var(--pm-gg-max-width);
	margin: 0 auto;
	padding: clamp(2rem, 5vw, 4rem) var(--pm-gutter, clamp(1rem, 4vw, 2rem)) clamp(3rem, 7vw, 6rem);
	box-sizing: border-box;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

.pm-gg__back {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
	font-family: var(--pm-font-sans, 'Inter', system-ui, sans-serif);
	font-size: var(--pm-text-body-sm, 1rem);
	color: var(--pm-gg-text);
	text-decoration: none;
}

.pm-gg__back:hover {
	color: var(--pm-gg-accent);
}

.pm-gg__header {
	margin-bottom: clamp(1.5rem, 3vw, 2.5rem);
}

.pm-gg__title {
	margin: 0;
	font-family: var(--pm-font-header, 'A Love of Thunder', serif);
	font-size: var(--pm-text-large, clamp(1.75rem, 1.203rem + 2.247vw, 3rem));
	font-weight: 400;
	line-height: 1.15;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: var(--pm-gg-title);
}

.pm-gg__graffiti {
	font-family: var(--pm-font-graffiti, 'TheGraffitiFont', cursive);
	color: var(--pm-gg-graffiti);
}

.pm-gg__meta {
	margin: 0.5em 0 0;
	font-family: var(--pm-font-sans, 'Inter', system-ui, sans-serif);
	font-size: var(--pm-text-body-sm, 1rem);
	color: var(--pm-gg-text);
}

/* Event with nothing to show yet, and the editor's hint */
.pm-gg__empty {
	margin: 0;
	padding: 32px;
	border: 1px dashed rgba(255, 255, 255, 0.3);
	border-radius: var(--pm-radius-lg, 16px);
	font-family: var(--pm-font-sans, 'Inter', system-ui, sans-serif);
	font-size: var(--pm-text-body-sm, 1rem);
	color: var(--pm-gg-text);
	text-align: center;
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */

.pm-gg__grid {
	display: grid;
	grid-template-columns: repeat(var(--pm-gg-columns), minmax(0, 1fr));
	gap: var(--pm-gg-gap);
}

.pm-gg__item {
	position: relative;
	margin: 0;
	min-width: 0;
	aspect-ratio: var(--pm-gg-ratio);
	overflow: hidden;
	border-radius: var(--pm-gg-radius);
	background-color: rgba(255, 255, 255, 0.06);
}

.pm-gg__open {
	display: block;
	width: 100%;
	height: 100%;
}

.pm-gg__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--pm-duration-slow, 400ms) var(--pm-ease, ease);
}

.pm-gg__open:hover .pm-gg__img {
	transform: scale(1.03);
}

.pm-gg__open:focus-visible {
	outline: 3px solid var(--pm-gg-accent);
	outline-offset: -3px;
}

/* ── Download button on each photo ────────────────────────────────────────── */

.pm-gg__download {
	position: absolute;
	right: 8px;
	bottom: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background-color: rgba(5, 46, 44, 0.8);
	color: var(--pm-color-white, #FFFFFF);
	opacity: 0;
	transition: opacity var(--pm-duration-fast, 150ms) var(--pm-ease, ease), background-color var(--pm-duration-fast, 150ms) var(--pm-ease, ease);
}

.pm-gg__item:hover .pm-gg__download,
.pm-gg__download:focus-visible {
	opacity: 1;
}

.pm-gg__download:hover {
	background-color: var(--pm-gg-accent);
	color: var(--pm-color-dark, #1F2121);
}

.pm-gg__download:focus-visible {
	outline: 2px solid var(--pm-gg-accent);
	outline-offset: 2px;
}

/* No hover on touch screens, so the button stays visible */
@media (hover: none) {
	.pm-gg__download {
		opacity: 1;
	}
}

/* ── Load more ────────────────────────────────────────────────────────────── */

.pm-gg__more {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	margin-top: clamp(1.5rem, 3vw, 2.5rem);
}

.pm-gg__load-more[hidden] {
	display: none;
}

.pm-gg__status {
	margin: 0;
	font-family: var(--pm-font-sans, 'Inter', system-ui, sans-serif);
	font-size: var(--pm-text-caption, 0.875rem);
	color: var(--pm-gg-text);
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

/* The gutter keeps the page behind from reflowing; it shows the root background */
html.pm-modal-open {
	overflow: hidden;
	scrollbar-gutter: stable;
	background-color: #051918;
}

.pm-gg__lightbox {
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background-color: #051918;
	color: var(--pm-color-white, #FFFFFF);
}

.pm-gg__lightbox[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
}

.pm-gg__lightbox::backdrop {
	background-color: #051918;
}

.pm-gg__lb-bar {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	padding: 12px var(--pm-gutter, clamp(1rem, 4vw, 2rem));
}

.pm-gg__lb-count {
	margin-right: auto;
	font-family: var(--pm-font-sans, 'Inter', system-ui, sans-serif);
	font-size: var(--pm-text-body-sm, 1rem);
	font-variant-numeric: tabular-nums;
}

.pm-gg__lb-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 0 var(--pm-gutter, clamp(1rem, 4vw, 2rem)) var(--pm-gutter, clamp(1rem, 4vw, 2rem));
	touch-action: pan-y pinch-zoom;
}

/*
 * Fills the stage and letterboxes itself, up to the preview's size (set by JS).
 * So its box is the same for the thumb and the preview, and nothing moves at the swap.
 */
.pm-gg__lb-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.pm-gg__lb-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: rgba(255, 255, 255, 0.12);
	color: inherit;
	cursor: pointer;
	transition: background-color var(--pm-duration-fast, 150ms) var(--pm-ease, ease), color var(--pm-duration-fast, 150ms) var(--pm-ease, ease);
}

.pm-gg__lb-btn:hover {
	background-color: var(--pm-gg-accent);
	color: var(--pm-color-dark, #1F2121);
}

.pm-gg__lb-btn:focus-visible {
	outline: 2px solid var(--pm-gg-accent);
	outline-offset: 2px;
}

.pm-gg__lb-prev,
.pm-gg__lb-next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
}

.pm-gg__lb-prev {
	left: 12px;
}

.pm-gg__lb-next {
	right: 12px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

/* Fallbacks for when Elementor's generated responsive CSS isn't present (built-in layout) */
@media (max-width: 1024px) {
	.pm-gg {
		--pm-gg-columns: 3;
	}
}

@media (max-width: 767px) {
	.pm-gg {
		--pm-gg-columns: 2;
		--pm-gg-gap: 8px;
	}
}
