/* Horizontal Gallery — front end */

.hg-gallery {
	--hg-cols: 3;
	--hg-cols-t: 2;
	--hg-cols-m: 1;
	--hg-gap: 12px;
	margin: 1.5em 0;
}

.hg-gallery,
.hg-gallery * {
	box-sizing: border-box;
}

.hg-gallery img.hg-img {
	display: block;
	width: 100%;
	height: auto;
}

.hg-gallery a.hg-link {
	display: block;
	line-height: 0;
}

.hg-item {
	position: relative;
	margin: 0;
	overflow: hidden;
}

/* ---- Shared column grid: used by GRID layout, and by MASONRY before JS runs ----
   align-items:start keeps rows top-aligned instead of stretching each item to
   the row's full height — needed for "Grid, keep aspect ratio" so a shorter
   image in a row doesn't get an empty gap stretched under it. */
.hg-layout-grid .hg-track,
.hg-layout-masonry:not(.hg-ready) .hg-track {
	display: grid;
	grid-template-columns: repeat(var(--hg-cols), minmax(0, 1fr));
	gap: var(--hg-gap);
	align-items: start;
}

@media (max-width: 1024px) {
	.hg-layout-grid .hg-track,
	.hg-layout-masonry:not(.hg-ready) .hg-track {
		grid-template-columns: repeat(var(--hg-cols-t), minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.hg-layout-grid .hg-track,
	.hg-layout-masonry:not(.hg-ready) .hg-track {
		grid-template-columns: repeat(var(--hg-cols-m), minmax(0, 1fr));
	}
}

/* ---- Grid: forced-ratio tiles (3:2 / squares) ---- */
.hg-has-ratio .hg-img {
	aspect-ratio: var(--hg-ratio, 4 / 3);
	object-fit: cover;
}

/* ---- Masonry: JS builds .hg-col children and fills them round-robin,
       which keeps the reading order left-to-right, row by row. ---- */
.hg-layout-masonry.hg-ready .hg-track {
	display: flex;
	align-items: flex-start;
	gap: var(--hg-gap);
}

.hg-layout-masonry .hg-col {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: var(--hg-gap);
}

.hg-layout-masonry .hg-img {
	aspect-ratio: var(--hg-item-ratio, auto); /* reserve space before load, avoids reflow */
}

/* ---- Captions ---- */
.hg-caption {
	font-size: 0.85em;
	line-height: 1.35;
	margin-top: 0.4em;
	opacity: 0.8;
}

.hg-captions-none .hg-caption {
	display: none;
}

.hg-captions-hover .hg-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 0.7em 0.8em;
	color: #fff;
	opacity: 0;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
	transition: opacity 0.2s ease;
}

.hg-captions-hover .hg-item:hover .hg-caption,
.hg-captions-hover .hg-item:focus-within .hg-caption {
	opacity: 1;
}

/* ---- Lightbox ---- */
.hg-lb {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.92);
}

.hg-lb.is-open {
	display: flex;
}

.hg-lb-fig {
	margin: 0;
	max-width: 92vw;
	max-height: 92vh;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.hg-lb-img {
	max-width: 92vw;
	max-height: 86vh;
	width: auto;
	height: auto;
	object-fit: contain;
}

.hg-lb-cap {
	color: #fff;
	margin-top: 0.7em;
	font-size: 0.9rem;
	text-align: center;
	max-width: 60ch;
}

.hg-lb-btn {
	position: absolute;
	background: transparent;
	border: 0;
	color: #fff;
	cursor: pointer;
	line-height: 1;
	opacity: 0.8;
}

.hg-lb-btn:hover {
	opacity: 1;
}

.hg-lb-close {
	top: 10px;
	right: 16px;
	font-size: 34px;
}

.hg-lb-prev,
.hg-lb-next {
	top: 50%;
	transform: translateY(-50%);
	font-size: 46px;
	padding: 0 16px;
}

.hg-lb-prev {
	left: 6px;
}

.hg-lb-next {
	right: 6px;
}

@media (max-width: 600px) {
	.hg-lb-prev,
	.hg-lb-next {
		font-size: 30px;
	}
}

/* editor placeholder */
.hg-empty {
	padding: 1em;
	border: 1px dashed currentColor;
	opacity: 0.7;
	text-align: center;
}
