/**
 * FH Gallery
 *
 * Native CSS scroll-snap gallery — replaces WooThumbs Premium.
 * The browser owns all drag/swipe/momentum; JS only handles click nav + active state.
 *
 * @package FH Classic Parts
 *  */

/* ─────────────────────────────────────────────────────────────────────────────
   Design tokens — light mode defaults
───────────────────────────────────────────────────────────────────────────── */

.fh-gal {
	--fh-gal-bg:           var(--paper-2);
	--fh-gal-thumb-border: var(--line-dark);
	--fh-gal-thumb-bg:     #fff;
	--fh-gal-arrow-bg:     rgba(245, 240, 230, 0.85);
	--fh-gal-arrow-color:  var(--ink);
	--fh-gal-dot-color:    rgba(14, 14, 14, 0.7);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Gallery wrapper
───────────────────────────────────────────────────────────────────────────── */

.fh-gal {
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Viewport — clips the scroll container, anchors the arrows
───────────────────────────────────────────────────────────────────────────── */

.fh-gal__viewport {
	position: relative;
	width: 100%;
	border-radius: 14px;
	overflow: hidden;          /* clips off-screen slides + hides scrollbar track */
	background: var(--fh-gal-bg);
	aspect-ratio: 1 / 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Main scroll container — the browser handles ALL drag/swipe/momentum
───────────────────────────────────────────────────────────────────────────── */

.fh-gal__main {
	display: flex;
	width: 100%;
	height: 100%;
	overflow-x: scroll;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	touch-action: pan-x pan-y; /* allow vertical page scroll; browser still owns horizontal swipe */
	user-select: none;         /* prevent text selection while mouse-dragging */
}

.fh-gal__main::-webkit-scrollbar {
	display: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Individual slide
───────────────────────────────────────────────────────────────────────────── */

.fh-gal__slide {
	flex: 0 0 100%;
	scroll-snap-align: start;
	width: 100%;
	height: 100%;
}

.fh-gal__slide-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Videos letterbox instead of cropping — framing matters more than fill. */
.fh-gal__slide--video .fh-gal__slide-img {
	object-fit: contain;
	background: #000;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Prev / Next arrows — frosted glass disc, always readable
───────────────────────────────────────────────────────────────────────────── */

.fh-gal__arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 34px;
	height: 34px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--fh-gal-arrow-bg) !important;
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	border-radius: 50%;
	border: none;
	box-shadow: none !important;
	cursor: pointer;
	z-index: 10;
	padding: 0;
	color: var(--fh-gal-arrow-color);
	transition: opacity 150ms ease-out;
}

.fh-gal__arrow:hover,
.fh-gal__arrow:focus,
.fh-gal__arrow:active,
.fh-gal__arrow:focus-visible {
	background: var(--fh-gal-arrow-bg) !important;
	box-shadow: none !important;
	outline: none;
	opacity: 0.85;
}

.fh-gal__arrow svg {
	display: block;
	width: 9px;
	height: 16px;
	pointer-events: none;
	transition: transform 100ms ease-out;
}

.fh-gal__arrow--prev {
	left: 10px;
}

.fh-gal__arrow--prev:hover svg {
	transform: translateX(-2px);
}

.fh-gal__arrow--next {
	right: 10px;
}

.fh-gal__arrow--next:hover svg {
	transform: translateX(2px);
}

/* ─────────────────────────────────────────────────────────────────────────────
   Thumbnail strip (desktop)
───────────────────────────────────────────────────────────────────────────── */

.fh-gal__thumbs {
	display: flex;
	flex-direction: row;
	gap: 6px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	padding-bottom: 2px;
}

.fh-gal__thumbs::-webkit-scrollbar {
	display: none;
}

.fh-gal__thumb {
	flex-shrink: 0;
	scroll-snap-align: start;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 72px;
	height: 60px;
	padding: 3px;
	border-radius: 8px;
	border: 1px solid var(--fh-gal-thumb-border);
	background: var(--fh-gal-thumb-bg);
	cursor: pointer;
	transition: border-color 0.15s ease, outline-color 0.15s ease;
	outline: 2px solid transparent;
	outline-offset: 0;
}

.fh-gal__thumb:hover {
	border-color: color-mix(in srgb, currentColor 30%, transparent);
}

.fh-gal__thumb--active {
	border-color: transparent;
	outline-color: currentColor;
}

/* Play badge over video thumbnails. */
.fh-gal__thumb--video {
	position: relative;
}

.fh-gal__thumb--video::after {
	content: '';
	position: absolute;
	inset: 50% auto auto 50%;
	width: 22px;
	height: 22px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--fh-gal-arrow-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'%3E%3Cpath d='M1 1l8 5-8 5z' fill='%231a1a1a'/%3E%3C/svg%3E") 55% 50% / 8px no-repeat;
	backdrop-filter: blur(6px);
	pointer-events: none;
}

.fh-gal__thumb-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 6px;
	aspect-ratio: 1.2 / 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Dot indicators (mobile) — growing pill, WooThumbs spec
───────────────────────────────────────────────────────────────────────────── */

.fh-gal__dots {
	display: none;
	justify-content: center;
	align-items: center;
	gap: 6px;
	padding: 4px 0;
}

.fh-gal__dot {
	width: 10px;
	height: 10px;
	border-radius: 100%;
	background: var(--fh-gal-dot-color);
	opacity: 0.35;
	border: none;
	padding: 0;
	cursor: pointer;
	transition: width 100ms ease-out, border-radius 100ms ease-out, opacity 100ms ease-out;
	overflow: hidden;
	text-indent: 250%;
	white-space: nowrap;
}

.fh-gal__dot:hover {
	opacity: 0.6;
}

.fh-gal__dot--active {
	width: 30px;
	border-radius: 68px;
	opacity: 1;
	cursor: default;
}

.fh-gal__dot--active:hover {
	opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Single-image mode — hide chrome when there's nothing to navigate
───────────────────────────────────────────────────────────────────────────── */

.fh-gal--single .fh-gal__arrow,
.fh-gal--single .fh-gal__thumbs,
.fh-gal--single .fh-gal__dots {
	display: none;
}

.fh-gal--single .fh-gal__main {
	user-select: auto;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive — swap thumbs ↔ dots at mobile breakpoint
───────────────────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
	.fh-gal__thumbs {
		display: none;
	}

	.fh-gal__dots {
		display: flex;
	}
}
