/* Basic grid styling */
.hp-gallery {
	--hp-gallery-gap: 12px;
	--hp-gallery-columns: 3;
}

.hp-gallery-grid {
	display: grid;
	grid-template-columns: repeat(var(--hp-gallery-columns), minmax(0, 1fr));
	gap: var(--hp-gallery-gap);
	align-items: stretch;
}

.hp-gallery-item {
	position: relative;
	overflow: hidden;
	border-radius: 6px;
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
	background: #f7f7f7;
	aspect-ratio: 1 / 1;
	cursor: pointer;
}

.hp-gallery-link {
	display: block;
	color: inherit;
	text-decoration: none;
}

.hp-gallery-item img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 180ms ease-out, filter 180ms ease-out;
}

.hp-gallery-link:hover img,
.hp-gallery-link:focus img {
	transform: scale(1.025);
	filter: saturate(1.03);
}

.hp-gallery-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 10px 12px;
	font-size: 14px;
	color: #fff;
	background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.65) 100%);
	box-sizing: border-box;
}

.hp-gallery-empty {
	padding: 16px;
	background: #fff8e1;
	border: 1px solid #ffe0b2;
	color: #7c5b00;
	border-radius: 4px;
}

/* Lightbox */
.hp-gallery-lightbox {
	position: fixed;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 99999;
}

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

.hp-gallery-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.82);
}

.hp-gallery-lightbox__body {
	position: relative;
	max-width: 90vw;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	z-index: 2;
	padding: 48px 64px 32px;
	box-sizing: border-box;
}

.hp-gallery-lightbox__img {
	max-width: 90vw;
	max-height: 80vh;
	border-radius: 6px;
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
	display: block;
}

.hp-gallery-lightbox__caption {
	color: #fff;
	font-size: 15px;
	text-align: center;
	max-width: 80vw;
	word-break: break-word;
}

.hp-gallery-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	height: 44px;
	width: 44px;
	border-radius: 50%;
	border: none;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	display: grid;
	place-items: center;
	cursor: pointer;
	z-index: 3;
}

.hp-gallery-lightbox__nav:hover,
.hp-gallery-lightbox__nav:focus {
	background: rgba(0, 0, 0, 0.8);
	outline: none;
}

.hp-gallery-lightbox__nav--prev { left: 16px; }
.hp-gallery-lightbox__nav--next { right: 16px; }

/* Ensure nav and close sit above the image but not shifted by margins */
.hp-gallery-lightbox__body {
	position: relative;
}
.hp-gallery-lightbox__close {
	position: absolute;
	top: 16px;
	right: 16px;
	height: 38px;
	width: 38px;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	border: none;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	display: grid;
	place-items: center;
	z-index: 3;
}

.hp-gallery-lightbox__close:focus {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

@media (max-width: 900px) {
	.hp-gallery {
		--hp-gallery-columns: 2;
	}
}

@media (max-width: 520px) {
	.hp-gallery {
		--hp-gallery-columns: 1;
	}
}

