/**
 * GTHL Gallery shortcode — responsive 4-up carousel / grid + lightbox.
 */

.gthl-gallery {
	--gthl-gallery-radius: 0;
	--gthl-gallery-nav: var(--gthl-color-navy, #003a80);
	--gthl-gallery-accent: var(--gthl-color-red, #e02826);
	--gthl-gallery-gap: 1.25rem;
	--gthl-gallery-per-view: 4;
	--gthl-gallery-frame: var(--gthl-color-surface, #ededed);
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	font-family: var(--gthl-font-family, "Roboto", sans-serif);
}

.gthl-gallery *,
.gthl-gallery *::before,
.gthl-gallery *::after {
	box-sizing: border-box;
}

.gthl-gallery__title {
	margin: 0 0 var(--gthl-space-lg, 1rem);
	text-align: left;
}

.gthl-gallery__viewport {
	position: relative;
	overflow: hidden;
	border-radius: 0;
	background: transparent;
}

.gthl-gallery__track {
	display: flex;
	align-items: stretch;
	gap: var(--gthl-gallery-gap, 1.25rem);
	width: 100%;
	transition: transform 0.45s ease;
	will-change: transform;
}

.gthl-gallery__slide {
	flex: 0 0 100%;
	min-width: 100%;
	width: 100%;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
}

/* Kill UA figure margins that blow out carousel gaps */
figure.gthl-gallery__slide {
	margin: 0;
}

/* 4-per-row carousel (responsive via --gthl-gallery-per-view) */
.gthl-gallery--slider .gthl-gallery__slide {
	flex: 0 0 calc(
		(100% - (var(--gthl-gallery-per-view) - 1) * var(--gthl-gallery-gap, 1.25rem)) /
			var(--gthl-gallery-per-view)
	);
	min-width: calc(
		(100% - (var(--gthl-gallery-per-view) - 1) * var(--gthl-gallery-gap, 1.25rem)) /
			var(--gthl-gallery-per-view)
	);
	width: calc(
		(100% - (var(--gthl-gallery-per-view) - 1) * var(--gthl-gallery-gap, 1.25rem)) /
			var(--gthl-gallery-per-view)
	);
}

.gthl-gallery__trigger {
	display: block;
	width: 100%;
	aspect-ratio: 4 / 3;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--gthl-gallery-frame);
	cursor: zoom-in;
	line-height: 0;
	overflow: hidden;
	border-radius: var(--gthl-gallery-radius);
	box-shadow: none;
	transition: opacity 0.2s ease;
}

.gthl-gallery__trigger:hover,
.gthl-gallery__trigger:focus-visible {
	opacity: 0.96;
	transform: none;
	outline: none;
	box-shadow: none;
}

.gthl-gallery__img {
	display: block;
	width: 100%;
	height: 100%;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	object-position: center;
	background: var(--gthl-gallery-frame);
	border-radius: var(--gthl-gallery-radius);
}

.gthl-gallery__caption {
	margin: 0;
	padding: 0.55rem 0.65rem;
	font-size: var(--gthl-font-size-body-small, 14px);
	line-height: 1.35;
	color: var(--gthl-color-text-muted, #334155);
	text-align: center;
	background: transparent;
}

/* Bottom-centered controls: prev | dash-dots | next (homepage-style) */
.gthl-gallery__controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1.5rem;
	margin-top: 1.25rem;
	margin-bottom: 1.25rem;
	padding: 0.35rem 0 0.75rem;
}

.gthl-gallery__controls[hidden] {
	display: none !important;
}

.gthl-gallery__nav {
	position: static;
	transform: none;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent !important;
	color: var(--gthl-gallery-nav, #003a80) !important;
	font-size: 1rem;
	line-height: 1;
	text-decoration: none !important;
	cursor: pointer;
	box-shadow: none;
	transition: color 0.2s ease, opacity 0.2s ease;
}

.gthl-gallery__nav[hidden] {
	display: none !important;
}

.gthl-gallery__nav-icon {
	display: block;
	width: 1.85rem;
	height: 1.85rem;
	flex-shrink: 0;
	pointer-events: none;
}

.gthl-gallery__nav-icon path {
	stroke-width: 2.5;
}

.gthl-gallery__nav:hover,
.gthl-gallery__nav:focus,
.gthl-gallery__nav:focus-visible,
.gthl-gallery__nav:active {
	background: transparent !important;
	border: 0;
	color: var(--gthl-gallery-accent, #e02826) !important;
	outline: none;
	box-shadow: none;
	transform: none;
	text-decoration: none !important;
	opacity: 1 !important;
}

.gthl-gallery__nav:hover .gthl-gallery__nav-icon,
.gthl-gallery__nav:focus .gthl-gallery__nav-icon,
.gthl-gallery__nav:focus-visible .gthl-gallery__nav-icon {
	color: inherit;
	stroke: currentColor;
}

.gthl-gallery__nav--prev,
.gthl-gallery__nav--next {
	left: auto;
	right: auto;
}

.gthl-gallery__dots {
	--gthl-gallery-dot-w: 2rem;
	--gthl-gallery-dot-active-w: 2.5rem;
	--gthl-gallery-dot-gap: 0.65rem;
	--gthl-gallery-dot-visible: 5;
	display: block;
	overflow: hidden;
	margin: 0;
	padding: 0.15rem 0;
	width: calc(
		(var(--gthl-gallery-dot-visible) - 1) * var(--gthl-gallery-dot-w) +
			var(--gthl-gallery-dot-active-w) +
			(var(--gthl-gallery-dot-visible) - 1) * var(--gthl-gallery-dot-gap)
	);
	max-width: 100%;
}

.gthl-gallery__dots-track {
	display: flex;
	align-items: center;
	gap: var(--gthl-gallery-dot-gap);
	width: max-content;
	transform: translateX(0);
	transition: transform 0.35s ease;
	will-change: transform;
}

.gthl-gallery__dot {
	display: block;
	width: var(--gthl-gallery-dot-w);
	height: 0.35rem;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: var(--gthl-color-dot, #c5cdd8);
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.2s ease, width 0.2s ease;
}

.gthl-gallery__dot.is-active,
.gthl-gallery__dot:hover,
.gthl-gallery__dot:focus-visible {
	background: var(--gthl-gallery-nav, #003a80);
	outline: none;
}

.gthl-gallery__dot.is-active {
	width: var(--gthl-gallery-dot-active-w);
}

/* Grid mode */
.gthl-gallery__grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: var(--gthl-space-lg, 1rem);
}

.gthl-gallery__grid-item {
	margin: 0;
	overflow: hidden;
	border-radius: var(--gthl-gallery-radius);
	background: var(--gthl-color-card-bg, #f4f4f4);
}

.gthl-gallery__grid-item .gthl-gallery__img {
	aspect-ratio: 4 / 3;
	height: 100%;
	object-fit: cover;
}

/* Lightbox */
.gthl-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 1.25rem;
	background: rgba(0, 0, 0, 0.88);
}

.gthl-gallery-lightbox.is-open {
	display: flex;
}

.gthl-gallery-lightbox__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: min(1100px, 100%);
	max-height: 100%;
}

.gthl-gallery-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: min(82vh, 900px);
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 8px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.gthl-gallery-lightbox__caption {
	margin: 0.75rem 0 0;
	padding: 0 1rem;
	color: #fff;
	font-size: 0.95rem;
	text-align: center;
}

.gthl-gallery-lightbox__close,
.gthl-gallery-lightbox__prev,
.gthl-gallery-lightbox__next {
	position: absolute;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.92);
	color: var(--gthl-gallery-nav, #003a80);
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.gthl-gallery-lightbox__close {
	top: -0.25rem;
	right: -0.25rem;
	width: 2.4rem;
	height: 2.4rem;
	font-size: 1.35rem;
	line-height: 1;
	z-index: 2;
}

.gthl-gallery-lightbox__prev,
.gthl-gallery-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
	width: 2.6rem;
	height: 2.6rem;
	font-size: 1.85rem;
	line-height: 1;
}

.gthl-gallery-lightbox__prev {
	left: 0.25rem;
}

.gthl-gallery-lightbox__next {
	right: 0.25rem;
}

.gthl-gallery-lightbox__close:hover,
.gthl-gallery-lightbox__close:focus-visible,
.gthl-gallery-lightbox__prev:hover,
.gthl-gallery-lightbox__prev:focus-visible,
.gthl-gallery-lightbox__next:hover,
.gthl-gallery-lightbox__next:focus-visible {
	background: #fff;
	outline: 2px solid var(--gthl-gallery-accent, #e02826);
	outline-offset: 2px;
}

body.gthl-gallery-lightbox-open {
	overflow: hidden;
}

@media (max-width: 1024px) {
	.gthl-gallery {
		--gthl-gallery-per-view: 3;
	}

	.gthl-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 900px) {
	.gthl-gallery {
		--gthl-gallery-per-view: 2;
		--gthl-gallery-gap: 0.75rem;
	}

	.gthl-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.gthl-gallery__img {
		aspect-ratio: 4 / 3;
		height: 100%;
		object-fit: cover;
	}

	.gthl-gallery__controls {
		gap: 1.15rem;
		margin-bottom: 1.5rem;
		padding-bottom: 1rem;
	}

	.gthl-gallery__nav {
		width: 2.4rem;
		height: 2.4rem;
	}

	.gthl-gallery__nav-icon {
		width: 1.6rem;
		height: 1.6rem;
	}
}

@media (max-width: 560px) {
	.gthl-gallery {
		--gthl-gallery-per-view: 1;
		--gthl-gallery-gap: 0.65rem;
	}

	.gthl-gallery__grid {
		grid-template-columns: 1fr;
	}

	.gthl-gallery__img {
		aspect-ratio: 4 / 3;
		height: 100%;
		object-fit: cover;
	}

	.gthl-gallery__controls {
		margin-bottom: 1.25rem;
		padding-bottom: 0.85rem;
	}

	.gthl-gallery__dots {
		--gthl-gallery-dot-w: 1.5rem;
		--gthl-gallery-dot-active-w: 1.85rem;
		--gthl-gallery-dot-gap: 0.5rem;
	}

	.gthl-gallery__dot {
		height: 0.3rem;
	}

	.gthl-gallery__nav {
		width: 2.15rem;
		height: 2.15rem;
	}

	.gthl-gallery__nav-icon {
		width: 1.45rem;
		height: 1.45rem;
	}

	.gthl-gallery-lightbox {
		padding: 0.75rem;
	}

	.gthl-gallery-lightbox__prev,
	.gthl-gallery-lightbox__next {
		width: 2.2rem;
		height: 2.2rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gthl-gallery__track,
	.gthl-gallery__nav,
	.gthl-gallery__dot,
	.gthl-gallery__dots-track {
		transition: none;
	}

	.gthl-gallery__nav:hover,
	.gthl-gallery__nav:focus-visible {
		transform: none;
	}
}
