/* Anue Helper galleries: carousel, grid and lightbox (Anue Helper › Galleries). */

.anue-gallery {
	--ag-cw: var(--ag-w);
	--ag-ch: var(--ag-h);
	position: relative;
	isolation: isolate; /* keep the carousel's own layering (z-index) inside the gallery, so it scrolls under the sticky header */
	box-sizing: border-box;
	margin: 0 auto;
}
.anue-gallery .ag-item {
	position: relative;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
.anue-gallery .ag-link {
	position: relative;
	display: block;
	overflow: hidden;
	color: inherit;
	text-decoration: none;
	background: #f4f3f2;
}
.anue-gallery .ag-img {
	display: block;
	width: var(--ag-cw);
	height: var(--ag-ch);
	max-width: none;
	object-fit: cover;
	transition: transform 0.3s ease;
}
.anue-gallery .ag-caption {
	display: block;
	padding: 6px 2px 0;
	font-size: 0.85rem;
	line-height: 1.35;
	text-align: center;
}
.anue-gallery .ag-caption-title {
	display: -webkit-box;
	-webkit-line-clamp: 1;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-weight: 600;
}
.anue-gallery .ag-caption-desc {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.anue-gallery .ag-caption-desc br {
	display: none;
}

/* Hover: zoom slightly and show a "+" (only where clicking enlarges the image). */
.anue-gallery.has-lightbox .ag-link::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 32px;
	height: 32px;
	margin: -16px 0 0 -16px;
	border: 2px solid #fff;
	border-radius: 50%;
	background:
		linear-gradient(#fff, #fff) center / 14px 2px no-repeat,
		linear-gradient(#fff, #fff) center / 2px 14px no-repeat,
		rgba(0, 0, 0, 0.15);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}
.anue-gallery.has-lightbox .ag-link:hover::after,
.anue-gallery.has-lightbox .ag-link:focus-visible::after {
	opacity: 1;
}
.anue-gallery.has-lightbox .ag-link:hover .ag-img {
	transform: scale(1.05);
}
.anue-gallery--carousel.is-ready .ag-item:not(.is-active) .ag-link::after {
	display: none;
}
.anue-gallery--carousel.is-ready .ag-item:not(.is-active) .ag-link:hover .ag-img {
	transform: none;
}

/* ---------- Grid ---------- */

.anue-gallery--grid .ag-track {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--ag-gap);
}
.anue-gallery--grid .ag-item {
	width: var(--ag-w);
	max-width: calc(50% - var(--ag-gap) / 2);
}
.anue-gallery--grid .ag-img {
	width: 100%;
	height: auto;
	aspect-ratio: var(--ag-ratio, 1);
}

/* ---------- Carousel ---------- */

.anue-gallery--carousel {
	padding: 0 64px;
	user-select: none;
	-webkit-user-select: none;
}
/* Before the script runs (and in the page editor): a plain row. */
.anue-gallery--carousel .ag-track {
	position: relative;
	display: flex;
	justify-content: center;
	gap: 10px;
	overflow: hidden;
}
.anue-gallery--carousel.is-ready .ag-track {
	display: block;
	overflow: visible;
	height: var(--ag-track-h, var(--ag-ch));
	touch-action: pan-y;
}
.anue-gallery--carousel.is-ready .ag-item {
	position: absolute;
	top: 0;
	left: 50%;
	width: var(--ag-cw);
	margin-left: calc(var(--ag-cw) / -2);
	transform-origin: 50% 50%;
	transition: transform 0.3s ease, opacity 0.3s ease;
	cursor: pointer;
}
.anue-gallery--carousel.is-ready .ag-item.is-hidden {
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
	transition: transform 0.3s ease, opacity 0.3s ease, visibility 0s 0.3s;
}
.anue-gallery--carousel.is-ready .ag-item:not(.is-active) .ag-caption {
	opacity: 0;
}
.anue-gallery .ag-nav {
	position: absolute;
	top: calc(var(--ag-ch) / 2);
	z-index: 60;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 72px;
	margin-top: -36px;
	padding: 0;
	border: 0;
	background: none;
	color: #b8b8b8;
	cursor: pointer;
}
.anue-gallery .ag-nav[hidden] {
	display: none;
}
.anue-gallery .ag-nav:hover,
.anue-gallery .ag-nav:focus-visible {
	color: #555;
}
.anue-gallery .ag-nav svg {
	width: 48px;
	height: 48px;
	fill: currentColor;
}
.anue-gallery .ag-prev {
	left: 0;
}
.anue-gallery .ag-next {
	right: 0;
}
.anue-gallery .ag-dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 14px;
}
.anue-gallery .ag-dots[hidden] {
	display: none;
}
.anue-gallery .ag-dots button {
	width: 14px;
	height: 14px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #c8c8c8;
	cursor: pointer;
}
.anue-gallery .ag-dots button[aria-current="true"] {
	background: #444;
}
@media (max-width: 767px) {
	.anue-gallery--carousel {
		padding: 0 40px;
	}
	.anue-gallery .ag-nav {
		width: 40px;
	}
	.anue-gallery .ag-nav svg {
		width: 36px;
		height: 36px;
	}
}

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

html.ag-lb-open {
	overflow: hidden;
}
.ag-lb {
	position: fixed;
	inset: 0;
	z-index: 100001;
	display: flex;
	flex-direction: column;
	background: #ededed;
	color: #222;
	opacity: 0;
	transition: opacity 0.25s ease;
}
.ag-lb[hidden] {
	display: none;
}
.ag-lb.is-open {
	opacity: 1;
}
.ag-lb-stage {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 4px 56px;
}
.ag-lb-fig {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
}
.ag-lb-img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 100px);
	max-height: calc(100dvh - 100px);
	width: auto;
	height: auto;
	object-fit: contain;
	transition: opacity 0.25s ease;
}
.ag-lb-img.is-loading {
	opacity: 0;
}
.ag-lb-info {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	max-height: 45%;
	overflow: auto;
	padding: 12px 18px;
	background: rgba(255, 255, 255, 0.88);
	font-size: 0.85rem;
	line-height: 1.45;
	text-align: center;
}
.ag-lb-info[hidden],
.ag-lb.no-info .ag-lb-info {
	display: none;
}
.ag-lb-info .ag-info-title {
	margin: 0 0 6px;
	font-size: 1rem;
	font-weight: 600;
}
.ag-lb-info .ag-info-desc p {
	margin: 0;
}
.ag-lb-tools {
	position: absolute;
	top: 6px;
	right: 6px;
	z-index: 3;
	display: flex;
	flex-direction: column;
	gap: 6px;
}
.ag-lb button {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 1px solid #ddd;
	background: #fff;
	color: #333;
	cursor: pointer;
}
.ag-lb button:hover,
.ag-lb button:focus-visible {
	background: #333;
	color: #fff;
}
.ag-lb-tools button {
	width: 32px;
	height: 32px;
}
.ag-lb-tools button[aria-pressed="true"] {
	background: #333;
	color: #fff;
}
.ag-lb button svg {
	width: 16px;
	height: 16px;
	fill: currentColor;
}
.ag-lb-prev,
.ag-lb-next {
	position: absolute;
	top: 50%;
	z-index: 2;
	width: 32px;
	height: 80px;
	margin-top: -40px;
}
.ag-lb-prev {
	left: 6px;
}
.ag-lb-next {
	right: 6px;
}
.ag-lb-thumbs {
	display: flex;
	flex: none;
	gap: 4px;
	padding: 4px;
	overflow-x: auto;
	background: #fff;
	scrollbar-width: thin;
}
.ag-lb-thumbs[hidden] {
	display: none;
}
.ag-lb .ag-lb-thumbs button {
	flex: none;
	width: 110px;
	height: 76px;
	padding: 0;
	border: 2px solid transparent;
	background: #eee;
	opacity: 0.75;
}
.ag-lb .ag-lb-thumbs button[aria-current="true"] {
	border-color: var(--sage, #99a37d);
	opacity: 1;
}
.ag-lb .ag-lb-thumbs button:hover {
	background: #eee;
	opacity: 1;
}
.ag-lb-thumbs img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
@media (max-width: 767px) {
	.ag-lb-stage {
		padding: 44px 44px 0;
	}
	.ag-lb-fig {
		width: 100%;
	}
	.ag-lb-img {
		max-height: 55vh;
		max-height: 55dvh;
	}
	.ag-lb-info {
		position: static;
		max-height: 30vh;
		max-height: 30dvh;
		width: calc(100% + 88px);
		margin: 8px -44px 0;
		box-sizing: border-box;
		background: #fff;
	}
	.ag-lb-thumbs button {
		width: 90px;
		height: 64px;
	}
}
@media (prefers-reduced-motion: reduce) {
	.anue-gallery .ag-img,
	.anue-gallery--carousel.is-ready .ag-item,
	.ag-lb,
	.ag-lb-img {
		transition: none;
	}
}
