/*
 * HSH Gallery.
 *
 * Scroll-snap main stage with straddling arrows and a synced thumbnail strip.
 * All rules scoped under .hsh-gallery; sizes and colors driven by custom
 * properties overridable from the widget's Style tab.
 */

.hsh-gallery {
	--hsh-g-ratio: 16 / 9;
	--hsh-g-radius: 24px;
	--hsh-g-arrow-size: 56px;
	--hsh-g-arrow-bg: #2f4b3f;
	--hsh-g-arrow-color: #ffffff;
	--hsh-g-thumb-radius: 12px;
	--hsh-g-thumb-active: #2f4b3f;
	--hsh-g-gap: 16px;
}

/* ---- Stage ---- */

.hsh-gallery__stage-wrap {
	position: relative;
	/* Room for the arrows straddling the stage edges. */
	padding-inline: calc(var(--hsh-g-arrow-size) / 2);
}

.hsh-gallery__stage {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	border-radius: var(--hsh-g-radius);
}

.hsh-gallery__stage::-webkit-scrollbar {
	display: none;
}

.hsh-gallery__stage:focus-visible {
	outline: 2px solid var(--hsh-g-arrow-bg);
	outline-offset: 4px;
}

.hsh-gallery__slide {
	flex: 0 0 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	margin: 0;
	position: relative;
	aspect-ratio: var(--hsh-g-ratio); /* reserves space: zero CLS */
	/* Cap the height on wide screens; object-fit crops gracefully. */
	max-height: var(--hsh-g-maxh, 640px);
	background: #e8e4da;
}

.hsh-gallery__slide img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ---- Arrows ---- */

.hsh-gallery button.hsh-gallery__arrow {
	appearance: none;
	-webkit-appearance: none;
	position: absolute;
	top: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: var(--hsh-g-arrow-size);
	height: var(--hsh-g-arrow-size);
	min-width: var(--hsh-g-arrow-size);
	min-height: var(--hsh-g-arrow-size);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--hsh-g-arrow-bg);
	color: var(--hsh-g-arrow-color);
	font-size: 0;
	line-height: 0;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
	cursor: pointer;
	transition: opacity 0.2s ease;
}

.hsh-gallery__arrow--prev {
	left: 0;
	transform: translateY(-50%);
}

.hsh-gallery__arrow--next {
	right: 0;
	transform: translateY(-50%);
}

.hsh-gallery button.hsh-gallery__arrow svg {
	width: 22px;
	height: 22px;
}

.hsh-gallery button.hsh-gallery__arrow[disabled] {
	opacity: 0.35;
	cursor: default;
}

/* ---- Thumbnails ---- */

.hsh-gallery__thumbs {
	display: flex;
	gap: var(--hsh-g-gap);
	margin-top: 22px;
	padding-inline: calc(var(--hsh-g-arrow-size) / 2);
	overflow-x: auto;
	scroll-snap-type: x proximity;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.hsh-gallery__thumbs::-webkit-scrollbar {
	display: none;
}

/*
 * Thumbnails share the stage width equally (matching the design, where the
 * strip spans exactly the main image). --hsh-g-count is set inline by the
 * widget. With many images the min-width floor kicks in and the strip
 * scrolls horizontally instead of shrinking into slivers.
 */
.hsh-gallery button.hsh-gallery__thumb {
	appearance: none;
	-webkit-appearance: none;
	box-sizing: border-box;
	flex: 0 0 calc((100% - (var(--hsh-g-count, 5) - 1) * var(--hsh-g-gap)) / var(--hsh-g-count, 5));
	min-width: 110px;
	aspect-ratio: 8 / 5;
	max-height: var(--hsh-g-thumb-h, none);
	margin: 0;
	padding: 0;
	border: 2px solid transparent;
	border-radius: var(--hsh-g-thumb-radius);
	overflow: hidden;
	background: #e8e4da;
	font-size: 0;
	line-height: 0;
	box-shadow: none;
	cursor: pointer;
	scroll-snap-align: start;
	transition: border-color 0.2s ease, opacity 0.2s ease;
	opacity: 0.9;
}

.hsh-gallery button.hsh-gallery__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: calc(var(--hsh-g-thumb-radius) - 3px);
}

.hsh-gallery button.hsh-gallery__thumb:hover {
	opacity: 1;
}

.hsh-gallery button.hsh-gallery__thumb.is-active {
	border-color: var(--hsh-g-thumb-active);
	opacity: 1;
}

/* ---- Mobile ---- */

@media (max-width: 767px) {
	.hsh-gallery {
		--hsh-g-arrow-size: 44px;
		--hsh-g-gap: 10px;
	}

	.hsh-gallery button.hsh-gallery__thumb {
		min-width: 84px;
	}
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
	.hsh-gallery__stage,
	.hsh-gallery__thumbs {
		scroll-behavior: auto;
	}
}

/* ---- Video slides ---- */

.hsh-gallery__slide--video video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	background: #000;
}

.hsh-gallery__thumb-video-blank {
	display: block;
	width: 100%;
	height: 100%;
	background: #2f4b3f;
}

.hsh-gallery__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 34px;
	height: 34px;
	transform: translate(-50%, -50%);
	pointer-events: none;
}

.hsh-gallery button.hsh-gallery__thumb {
	position: relative;
}

/* Clickable stage images hint the lightbox. */
.hsh-gallery[data-hsh-g-lightbox] .hsh-gallery__slide[data-hsh-g-type="image"] {
	cursor: zoom-in;
}

/* ---- Lightbox (built by JS on first open) ---- */

.hsh-glb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(12, 18, 15, 0.92);
	animation: hsh-glb-fade 0.25s ease;
}

@keyframes hsh-glb-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

.hsh-glb__media {
	max-width: min(92vw, 1400px);
	max-height: 86vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.hsh-glb__media img,
.hsh-glb__media video {
	max-width: min(92vw, 1400px);
	max-height: 86vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 8px;
	display: block;
}

.hsh-glb button.hsh-glb__btn {
	appearance: none;
	-webkit-appearance: none;
	position: absolute;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 52px;
	height: 52px;
	min-width: 52px;
	min-height: 52px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 0;
	line-height: 0;
	box-shadow: none;
	cursor: pointer;
	transition: background 0.2s ease;
}

.hsh-glb button.hsh-glb__btn:hover,
.hsh-glb button.hsh-glb__btn:focus-visible {
	background: rgba(255, 255, 255, 0.28);
}

.hsh-glb button.hsh-glb__btn svg {
	width: 22px;
	height: 22px;
}

.hsh-glb__close {
	top: 22px;
	right: 22px;
}

.hsh-glb__prev {
	left: 22px;
	top: 50%;
	transform: translateY(-50%);
}

.hsh-glb__next {
	right: 22px;
	top: 50%;
	transform: translateY(-50%);
}

.hsh-glb__count {
	position: absolute;
	bottom: 22px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.75);
	font-size: 14px;
	letter-spacing: 0.08em;
}

body.hsh-glb-open {
	overflow: hidden;
}

@media (max-width: 767px) {
	.hsh-glb button.hsh-glb__btn {
		width: 42px;
		height: 42px;
		min-width: 42px;
		min-height: 42px;
	}

	.hsh-glb__prev { left: 8px; }
	.hsh-glb__next { right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
	.hsh-glb {
		animation: none;
	}
}
