/* ML Gallery — frontend layout styles */

/* ── Base ───────────────────────────────────────────────────────────────── */

.ml-gallery-container {
	margin: 1em 0;
	padding: 0;
	list-style: none;
	--ml-columns: 3;
	--ml-gap: 8px;
}

.ml-gallery-container > a {
	display: block;
	overflow: hidden;
	line-height: 0;
	text-decoration: none;
}

.ml-gallery-container > a img {
	display: block;
	width: 100%;
	transition: opacity .2s ease;
}

.ml-gallery-container > a:hover img {
	opacity: .85;
}

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

.ml-gallery-container.ml-layout-grid {
	display: grid;
	grid-template-columns: repeat(var(--ml-columns), 1fr);
	gap: var(--ml-gap);
}

.ml-gallery-container.ml-layout-grid > a img {
	height: 220px;
	object-fit: cover;
}

/* ── Masonry ────────────────────────────────────────────────────────────── */

.ml-gallery-container.ml-layout-masonry {
	columns: var(--ml-columns);
	column-gap: var(--ml-gap);
}

.ml-gallery-container.ml-layout-masonry > a {
	break-inside: avoid;
	margin-bottom: var(--ml-gap);
}

.ml-gallery-container.ml-layout-masonry > a img {
	height: auto;
	object-fit: unset;
}

/* ── Justified ──────────────────────────────────────────────────────────── */

.ml-gallery-container.ml-layout-justified {
	display: flex;
	flex-wrap: wrap;
	gap: var(--ml-gap);
}

.ml-gallery-container.ml-layout-justified > a {
	flex-grow: 1;
	overflow: hidden;
}

.ml-gallery-container.ml-layout-justified > a img {
	height: 220px;
	min-width: 100%;
	object-fit: cover;
	vertical-align: bottom;
}

/* Last row: don't stretch orphaned items to fill the whole row */
.ml-gallery-container.ml-layout-justified > a:last-child {
	flex-grow: 0;
}

/* ── Carousel (lightGallery inline carousel) ────────────────────────────── */

/* Give the container a height so lightGallery has space to render into.
   LG inline mode absolutely-positions its stage inside this element. */
.ml-gallery-container.ml-layout-carousel {
	position: relative;
	height: 500px;
}

/* Hide the raw <a> source items — lightGallery replaces them with its own UI */
.ml-gallery-container.ml-layout-carousel > a {
	display: none;
}

/* Scale images to fit within the slide instead of cropping */
.ml-gallery-container.ml-layout-carousel .lg-object {
	object-fit: contain;
	max-height: 100%;
	width: auto;
	max-width: 100%;
}

/* Block: full-width layout */
.ml-gallery-block.is-full-width {
	width: 100vw;
	margin-left: calc(50% - 50vw);
}

/* Showcase layout */
.ml-gallery-container.ml-layout-showcase > a {
	display: none;
}

.ml-showcase-stage {
	position: relative;
	width: 100%;
	overflow: hidden;
	cursor: pointer;
}

.ml-showcase-stage .ml-showcase-img {
	display: block;
	width: 100%;
	height: 420px;
	object-fit: cover;
}

/* Showcase stage caption overlay. Shares the thumbnail-caption custom-property
   hooks so future per-gallery styling controls apply uniformly. */
.ml-showcase-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2; /* stay above the transitioning incoming image */
	margin: 0;
	padding: 12px 16px;
	line-height: 1.35;
	color: var(--ml-thumb-caption-color, #ffffff);
	font-size: var(--ml-thumb-caption-size, 14px);
	text-align: var(--ml-thumb-caption-align, left);
	background: var(--ml-thumb-caption-bg, linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0)));
}

/* Showcase slide transitions — image change honors the gallery Transition
   (mode) setting: fade / slide / zoom. The incoming image (inherits sizing from
   .ml-showcase-stage .ml-showcase-img) animates in over the current base image,
   then JS promotes it to the base and removes the overlay. */
.ml-showcase-incoming {
	position: absolute;
	top: 0;
	left: 0;
}

.ml-showcase-incoming.ml-tr-fade {
	opacity: 0;
}

.ml-showcase-incoming.ml-tr-slide-next {
	transform: translateX(100%);
}

.ml-showcase-incoming.ml-tr-slide-prev {
	transform: translateX(-100%);
}

.ml-showcase-incoming.ml-tr-zoom {
	opacity: 0;
	transform: scale(1.15);
}

.ml-showcase-incoming.ml-tr-active {
	opacity: 1;
	transform: translateX(0) scale(1);
	transition: transform 0.45s ease, opacity 0.45s ease;
}

/* Showcase caption transition — honors the Caption Transition setting. */
.ml-showcase-cap-fade {
	animation: ml-showcase-cap-fade 0.4s ease;
}

.ml-showcase-cap-slide-up {
	animation: ml-showcase-cap-slide-up 0.4s ease;
}

.ml-showcase-cap-slide-down {
	animation: ml-showcase-cap-slide-down 0.4s ease;
}

@keyframes ml-showcase-cap-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes ml-showcase-cap-slide-up {
	from { opacity: 0; transform: translateY(20px); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes ml-showcase-cap-slide-down {
	from { opacity: 0; transform: translateY(-20px); }
	to   { opacity: 1; transform: translateY(0); }
}

.ml-showcase-thumbs {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 8px 0;
}

.ml-showcase-thumb {
	flex-shrink: 0;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 3px;
	cursor: pointer;
	background: none;
	overflow: hidden;
	opacity: 0.6;
	transition: opacity .15s, border-color .15s;
}

.ml-showcase-thumb img {
	display: block;
	width: 80px;
	height: 56px;
	object-fit: cover;
}

.ml-showcase-thumb:hover,
.ml-showcase-thumb.is-active {
	opacity: 1;
}

.ml-showcase-thumb.is-active {
	border-color: var(--ml-orange, #dd6923);
}

.ml-showcase-nav {
	display: flex;
	align-items: center;
	padding: 12px 0;
}

.ml-showcase-btn {
	border: none;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	padding: 6px 10px;
	border-radius: 3px;
	background-color: var(--ml-arrow-bg, #000);
	color: var(--ml-arrow-color, #fff);
}

.ml-showcase-btn:hover {
	opacity: 0.85;
}

.ml-showcase-counter {
	flex: 1;
	font-size: 14px;
	text-align: center;
	background-color: var(--ml-toolbar-bg, #000);
	color: var(--ml-toolbar-color, #fff);
	padding: 6px 8px;
}

.ml-showcase-pager {
	display: flex;
	justify-content: center;
	gap: 6px;
	padding: 8px 0;
}

.ml-showcase-pager-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	padding: 0;
	background-color: var(--ml-toolbar-bg, #000);
	opacity: 0.35;
	transition: opacity 0.2s;
}

.ml-showcase-pager-dot:hover {
	opacity: 0.65;
}

.ml-showcase-pager-dot.is-active {
	opacity: 1;
}

@media (max-width: 768px) {
	/* Override the consuming properties directly. --ml-columns is set inline on
	   the container, so reassigning it from a stylesheet rule has no effect
	   (inline wins); target grid-template-columns / columns instead, both of
	   which read the inline-provided --ml-columns-mobile. */
	.ml-gallery-container.ml-layout-grid {
		grid-template-columns: repeat(var(--ml-columns-mobile, 1), 1fr);
	}

	.ml-gallery-container.ml-layout-masonry {
		columns: var(--ml-columns-mobile, 1);
	}

	.ml-showcase-stage .ml-showcase-img {
		height: 260px;
	}
}

/* Block link navigation when lightbox is disabled */
.ml-gallery-container[data-ml-lightbox="0"] a {
	pointer-events: none;
	cursor: default;
}

/* ── Thumbnail captions ─────────────────────────────────────────────────── */

/* Off by default: rendered in markup but hidden unless the container opts in.
   No layout impact (absolutely positioned) when shown. */
.ml-gallery-caption {
	display: none;
}

.ml-gallery-container.ml-has-thumb-captions > a {
	position: relative;
}

.ml-gallery-container.ml-has-thumb-captions .ml-gallery-caption {
	display: block;
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 10px 12px;
	line-height: 1.35;
	/* Hook points for future per-gallery controls; fall back to sensible defaults. */
	color: var(--ml-thumb-caption-color, #ffffff);
	font-size: var(--ml-thumb-caption-size, 14px);
	text-align: var(--ml-thumb-caption-align, left);
	background: var(--ml-thumb-caption-bg, linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0)));
}
