/**
 * Product gallery — rebuilt to replace WooCommerce's FlexSlider-based
 * gallery. Sizing is done entirely with aspect-ratio + object-fit, so the
 * image box is correct by construction in every browser at every screen
 * size — no per-breakpoint fixed pixel heights, no browser sniffing, no
 * slider-library width math to get wrong. See product-image.php and
 * product-gallery.js for the rest of this rebuild.
 */

.nibble-gallery-row {
	display: flex;
	align-items: flex-start;
	gap: 20px;
	position: relative;
}

.nibble-gallery-main {
	position: relative;
	flex: 1;
	min-width: 0;
}

.nibble-gallery-viewport {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #fff;
}

.nibble-gallery-slide {
	position: absolute;
	inset: 0;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease;
}

.nibble-gallery-slide.is-active {
	opacity: 1;
	visibility: visible;
}

.nibble-gallery-slide img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.nibble-gallery-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	color: #102456;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 1px 4px rgba(16, 36, 86, 0.2);
	transition: background-color 0.15s ease;
}

.nibble-gallery-arrow svg {
	width: 20px;
	height: 20px;
}

.nibble-gallery-arrow:hover,
.nibble-gallery-arrow:focus-visible {
	background: #fff;
}

.nibble-gallery-arrow:focus-visible {
	outline: 2px solid #102456;
	outline-offset: 2px;
}

.nibble-gallery-prev {
	left: 12px;
}

.nibble-gallery-next {
	right: 12px;
}

.nibble-gallery-thumbs {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: 15.8%;
	flex: 0 0 15.8%;
	order: -1;
	/* height is set to match .nibble-gallery-main by product-gallery.js;
	   overflow-y here is what makes that safe when there are enough
	   thumbnails that they wouldn't otherwise fit in that height. */
	overflow-y: auto;
}

.nibble-gallery-thumb {
	display: block;
	padding: 0;
	border: 2px solid transparent;
	background: none;
	cursor: pointer;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	transition: border-color 0.15s ease;
}

.nibble-gallery-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.nibble-gallery-thumb.is-active,
.nibble-gallery-thumb:hover,
.nibble-gallery-thumb:focus-visible {
	border-color: #102456;
}

.nibble-gallery-thumb:focus-visible {
	outline: 2px solid #102456;
	outline-offset: 2px;
}

@media (max-width: 767px) {
	.nibble-gallery-row {
		flex-direction: column;
	}

	.nibble-gallery-main {
		/* flex: 1 sizes the main image off the row's own height in the
		   desktop (row-direction) layout, where the row's height comes from
		   its tallest sibling. In this column layout there's no such
		   external height for a flex-grow item to fill, so let the image's
		   own aspect-ratio drive its height instead. */
		flex: none;
		width: 100%;
	}

	.nibble-gallery-thumbs {
		flex-direction: row;
		width: 100%;
		flex: 0 0 auto;
		order: 2;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.nibble-gallery-thumb {
		flex: 0 0 72px;
		width: 72px;
	}

	.nibble-gallery-arrow {
		width: 34px;
		height: 34px;
	}

	.nibble-gallery-arrow svg {
		width: 17px;
		height: 17px;
	}
}
