/* Native WooCommerce product gallery presentation. */

.single-product.woocommerce-page #content .site-main div.product > .sola-product-top > .woocommerce-product-gallery {
	float: none;
	inline-size: 100%;
	max-inline-size: 100%;
	min-inline-size: 0;
	width: 100%;
	/* WordPress's emoji replacement keeps a -9999px text-indent. The native
	 * viewport owns the FlexSlider track; hidden establishes a layout overflow
	 * boundary so the track and replacement text cannot widen the document. */
	overflow: hidden;
}

.single-product .woocommerce-product-gallery__wrapper {
	margin: 0;
}

.single-product .woocommerce-product-gallery .flex-viewport {
	position: relative;
	aspect-ratio: 1 / 1;
	block-size: auto !important;
	inline-size: 100%;
	max-inline-size: 100%;
	margin-inline: auto;
	overflow: hidden;
	background: var(--color-surface);
}

.single-product .woocommerce-product-gallery .flex-viewport::before {
	position: absolute;
	inset-block-start: 0;
	inset-inline: 0;
	z-index: 1;
	block-size: clamp(72px, 8vw, 96px);
	background: linear-gradient(to bottom, rgb(32 34 30 / 0.16), rgb(32 34 30 / 0));
	content: '';
	pointer-events: none;
}

.single-product .woocommerce-product-gallery.sola-product-gallery--no-primary-image .flex-viewport {
	background: #F2EEE5;
}

/* The breadcrumb is moved here only after the leading native image reports a
 * non-zero natural size. Its original parent is restored for image errors. */
.single-product .woocommerce-product-gallery .woocommerce-breadcrumb.sola-breadcrumb-overlay {
	position: absolute;
	inset-block-start: 14px;
	inset-inline-start: 20px;
	z-index: 4;
	display: block;
	box-sizing: border-box;
	inline-size: auto;
	max-inline-size: calc(100% - 40px);
	margin: 0;
	padding: 0.45rem 0.7rem;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: #20221E;
	font-size: var(--font-size-ui);
	line-height: var(--line-height-ui);
	direction: rtl;
	text-align: start;
	white-space: normal;
	overflow-wrap: anywhere;
}

.single-product .woocommerce-product-gallery .woocommerce-breadcrumb.sola-breadcrumb-overlay a,
.single-product .woocommerce-product-gallery .woocommerce-breadcrumb.sola-breadcrumb-overlay .sola-catalog-breadcrumb__separator {
	color: #20221E;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

.single-product .woocommerce-product-gallery .woocommerce-breadcrumb.sola-breadcrumb-overlay a:hover {
	color: #20221E;
	text-decoration-thickness: 2px;
}

.single-product .woocommerce-product-gallery .woocommerce-breadcrumb.sola-breadcrumb-overlay:focus-within {
	outline: var(--focus-width) solid var(--focus-color);
	outline-offset: var(--focus-offset);
}

.single-product .woocommerce-product-gallery .woocommerce-breadcrumb.sola-breadcrumb-overlay a:focus-visible {
	outline: var(--focus-width) solid var(--focus-color);
	outline-offset: 2px;
}

/* At stacked tablet widths, reserve a comfortable 560px maximum so the
	* gallery does not push the product decision rail far below the first view. */
@media (min-width: 48rem) and (max-width: 63.99875rem) {
	.single-product .woocommerce-product-gallery .flex-viewport {
		inline-size: min(100%, 35rem);
		margin-inline: auto;
	}
}

.single-product .woocommerce-product-gallery .sola-product-gallery__controls[hidden] {
	display: none;
}

.single-product .woocommerce-product-gallery .sola-product-gallery__controls {
	position: absolute;
	inset-block-start: auto;
	inset-block-end: var(--sola-product-gallery-control-inset-block-end);
	inset-inline-start: auto;
	inset-inline-end: var(--space-3);
	z-index: 3;
	display: flex;
	align-items: center;
	gap: var(--space-2);
	direction: rtl;
	pointer-events: none;
}

.single-product .woocommerce-product-gallery .sola-product-gallery__arrow {
	display: inline-flex;
	position: relative;
	inset: auto;
	align-items: center;
	justify-content: center;
	inline-size: 2.75rem;
	block-size: 2.75rem;
	min-inline-size: 2.75rem;
	min-block-size: 2.75rem;
	margin: 0;
	padding: 0;
	border: 1px solid var(--color-border-strong);
	border-radius: 0;
	background: rgb(255 255 255 / 0.9);
	color: var(--color-ink);
	line-height: 1;
	cursor: pointer;
	pointer-events: auto;
}

.single-product .woocommerce-product-gallery .sola-product-gallery__arrow:hover:not(:disabled) {
	border-color: var(--color-ink);
	background: var(--color-surface);
}

.single-product .woocommerce-product-gallery .sola-product-gallery__arrow:disabled {
	opacity: 0.45;
	cursor: default;
}

.single-product .woocommerce-product-gallery .sola-product-gallery__arrow:focus-visible {
	outline: var(--focus-width) solid var(--focus-color);
	outline-offset: var(--focus-offset);
}

.single-product .woocommerce-product-gallery .sola-product-gallery__arrow-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.75rem;
	font-weight: var(--font-weight-regular);
	line-height: 1;
	direction: ltr;
	unicode-bidi: isolate;
}

.single-product .woocommerce-product-gallery .flex-viewport > .woocommerce-product-gallery__wrapper {
	block-size: 100%;
}

/* The Hebrew product shell keeps the purchase rail inside its physical-left
 * container while the image side uses only the physical-right outer gutter.
 * The square responds to both the gallery track and the visible desktop
 * viewport so the enlarged thumbnail strip begins near the first view cut. */
@media (min-width: 64rem) {
	.single-product.woocommerce-page #content .site-main div.product > .sola-product-top > .woocommerce-product-gallery {
		inline-size: calc(100% + var(--sola-product-gutter));
		max-inline-size: none;
		margin-inline-start: calc(-1 * var(--sola-product-gutter));
	}

	.single-product .woocommerce-product-gallery .flex-viewport {
		inline-size: min(100%, var(--sola-product-main-size));
		max-inline-size: 100%;
		margin-inline-start: 0;
		margin-inline-end: auto;
	}

	@container (min-width: 90rem) {
		.single-product.woocommerce-page #content .site-main div.product > .sola-product-top > .woocommerce-product-gallery {
			inline-size: 100%;
			max-inline-size: 100%;
			margin-inline: 0;
		}
	}
}

/* IKEA-inspired large-desktop mode: preserve the native thumbnail list and
 * rotate only its layout axis. RTL grid ordering places the rail physically
 * to the right of the square main image. */
@media (min-width: 75rem) {
	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) {
		display: grid;
		grid-template-areas: "thumbs viewport";
		grid-template-columns: var(--sola-product-gallery-rail-size) minmax(0, var(--sola-product-gallery-square-size));
		column-gap: var(--sola-product-gallery-rail-gap);
		align-items: start;
		direction: rtl;
	}

	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-viewport {
		grid-area: viewport;
		inline-size: var(--sola-product-gallery-square-size);
		max-inline-size: 100%;
	}

	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs,
	.single-product.woocommerce div.product div.images.woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs {
		--sola-gallery-thumb-hit-size: 8.5rem;
		--sola-gallery-thumb-size: 8rem;
		grid-area: thumbs;
		align-items: center;
		flex-flow: column nowrap;
		inline-size: var(--sola-product-gallery-rail-size);
		max-inline-size: var(--sola-product-gallery-rail-size);
		block-size: var(--sola-product-gallery-square-size);
		max-block-size: var(--sola-product-gallery-square-size);
		margin: 0;
		overflow-x: hidden;
		overflow-y: auto;
		overscroll-behavior-inline: auto;
		overscroll-behavior-block: contain;
	}

	.single-product.woocommerce div.product div.images.woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs li {
		flex: 0 0 var(--sola-gallery-thumb-hit-size);
		inline-size: var(--sola-gallery-thumb-hit-size);
		block-size: var(--sola-gallery-thumb-hit-size);
		width: var(--sola-gallery-thumb-hit-size);
		max-inline-size: var(--sola-gallery-thumb-hit-size);
		padding-block-end: 0;
		padding-inline-start: calc(var(--sola-gallery-thumb-gap) + var(--sola-gallery-thumb-underline-size));
	}

	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs li[aria-current="true"]::after {
		inset-block: 0;
		inset-inline-start: 0;
		inset-inline-end: auto;
		inline-size: var(--sola-gallery-thumb-underline-size);
		block-size: auto;
	}
}

/* Some single-image Woo galleries omit FlexSlider's viewport entirely. Keep
 * that fallback square, while leaving multi-slide wrappers content-driven. */
.single-product .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__wrapper:has(> .woocommerce-product-gallery__image:only-child) {
	position: relative;
	aspect-ratio: 1 / 1;
	block-size: auto;
	inline-size: 100%;
	max-inline-size: 100%;
	overflow: hidden;
	background: #F2EEE5;
}

.single-product .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__wrapper:has(> .woocommerce-product-gallery__image:only-child)::before {
	position: absolute;
	inset-block-start: 0;
	inset-inline: 0;
	z-index: 1;
	block-size: clamp(72px, 8vw, 96px);
	background: linear-gradient(to bottom, rgb(32 34 30 / 0.16), rgb(32 34 30 / 0));
	content: '';
	pointer-events: none;
}

@media (min-width: 64rem) {
	.single-product .woocommerce-product-gallery:not(:has(.flex-viewport)) .woocommerce-product-gallery__wrapper:has(> .woocommerce-product-gallery__image:only-child) {
		inline-size: min(100%, var(--sola-product-main-size));
		max-inline-size: 100%;
		margin-inline-start: 0;
		margin-inline-end: auto;
	}
}

.single-product .woocommerce-product-gallery__image {
	block-size: 100%;
	min-inline-size: 0;
	margin: 0;
	overflow: hidden;
	border: 0;
	background: var(--color-white);
}

.single-product .woocommerce-product-gallery__image > a {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: 100%;
	block-size: 100%;
	min-inline-size: 0;
	max-inline-size: none;
	background: var(--color-white);
}

/* Use the cursor itself as the shared magnifying-plus affordance. The
 * pointer-safe fallback keeps the target discoverable when a browser blocks
 * data cursors, while the native anchor remains the sole keyboard target and
 * owns WooCommerce's PhotoSwipe activation path. */
.single-product .woocommerce-product-gallery__image:not(.clone) > a[data-sola-gallery-zoom-bound],
.single-product .woocommerce-product-gallery__image:not(.clone) > a[data-sola-gallery-zoom-bound] img {
	cursor: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3E%3Ccircle%20cx='13'%20cy='13'%20r='8'%20fill='none'%20stroke='black'%20stroke-width='2'/%3E%3Cpath%20d='M19%2019l8%208M9%2013h8M13%209v8'%20fill='none'%20stroke='black'%20stroke-width='2'%20stroke-linecap='round'/%3E%3C/svg%3E") 12 12, zoom-in;
}

.single-product.woocommerce div.product div.images .woocommerce-product-gallery__image img {
	display: block;
	inline-size: 100%;
	max-inline-size: none;
	block-size: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
	object-position: center;
}

.single-product .woocommerce-product-gallery .flex-control-thumbs {
	--sola-gallery-thumb-gap: var(--space-1);
	--sola-gallery-thumb-underline-size: 2px;
	--sola-gallery-thumb-size: 4rem;
	--sola-gallery-thumb-hit-size: 4.5rem;
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
	flex-flow: row nowrap;
	gap: var(--space-2);
	inline-size: 100%;
	max-inline-size: 100%;
	min-inline-size: 0;
	margin: var(--space-4) 0 0;
	padding: 0;
	list-style: none;
	direction: rtl;
	overflow-x: auto;
	overflow-y: hidden;
	overscroll-behavior-inline: contain;
	scrollbar-width: none;
	scroll-behavior: auto;
}

.single-product .woocommerce-product-gallery .flex-control-thumbs::-webkit-scrollbar {
	display: none;
}

.single-product .woocommerce-product-gallery .flex-control-thumbs.sola-product-gallery__thumbnails--overflow {
	/* Four complete tiles plus a partial fifth preserve the next-image cue
	 * without stretching short galleries across the full rail. */
	--sola-gallery-thumb-hit-size: calc((100% - (4 * var(--space-2))) / 4.5);
	--sola-gallery-thumb-size: 100%;
}

/* WooCommerce ships a deeper list selector than its item selector. Keep
 * these two rail properties at the same product scope so the native list
 * cannot collapse the gap or expose the full overflow track. Do not repeat
 * the thumbnail-size variables here; the overflow modifier must retain the
 * final say over its four-plus-partial geometry. */
.single-product.woocommerce div.product div.images.woocommerce-product-gallery .flex-control-thumbs {
	margin-block-start: var(--space-4);
	overflow-x: auto;
}

.single-product.woocommerce div.product div.images.woocommerce-product-gallery .flex-control-thumbs li {
	display: flex;
	position: relative;
	float: none;
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	inline-size: var(--sola-gallery-thumb-hit-size);
	block-size: auto;
	min-inline-size: 2.75rem;
	min-block-size: 2.75rem;
	aspect-ratio: auto;
	flex: 0 0 var(--sola-gallery-thumb-hit-size);
	width: var(--sola-gallery-thumb-hit-size);
	max-inline-size: var(--sola-gallery-thumb-hit-size);
	max-width: var(--sola-gallery-thumb-hit-size);
	margin: 0;
	padding: 0;
	/* Percentage tile widths cannot establish a height against an auto-height
	 * rail. Let the square image size the tile and reserve the underline gap
	 * with padding so it survives both fixed and percentage thumbnail sizes. */
	padding-block-end: calc(var(--sola-gallery-thumb-gap) + var(--sola-gallery-thumb-underline-size));
	border: 1px solid transparent;
	border-radius: 0;
	background: var(--color-white);
	cursor: pointer;
}

.single-product .woocommerce-product-gallery .flex-control-thumbs li:focus-visible {
	outline: var(--focus-width) solid var(--focus-color);
	outline-offset: var(--focus-offset);
}

.single-product .woocommerce-product-gallery .flex-control-thumbs li[aria-current="true"] {
	border-color: transparent;
}

.single-product .woocommerce-product-gallery .flex-control-thumbs li[aria-current="true"]::after {
	position: absolute;
	inset-block-end: 0;
	inset-inline: 0;
	block-size: var(--sola-gallery-thumb-underline-size);
	background: #000;
	content: '';
}

.single-product .woocommerce-product-gallery .flex-control-thumbs img {
	display: block;
	flex: 0 0 auto;
	inline-size: var(--sola-gallery-thumb-size);
	max-inline-size: 100%;
	block-size: auto;
	aspect-ratio: 1 / 1;
	max-block-size: 100%;
	margin: 0;
	border-radius: 0;
	object-fit: cover;
	opacity: 1;
}

.single-product .woocommerce-product-gallery .flex-control-thumbs li:hover img,
.single-product .woocommerce-product-gallery .flex-control-thumbs li:focus-visible img {
	opacity: 1;
}

/* Desktop media is intentionally generous: the 128px visual tiles make the
 * image sequence legible at a glance, while the 136px hit boxes keep four
 * complete thumbnails and a partial next item in the native scroll rail. */
@media (min-width: 64rem) {
	.single-product .woocommerce-product-gallery .flex-control-thumbs:not(.sola-product-gallery__thumbnails--overflow) {
		--sola-gallery-thumb-size: 8rem;
		--sola-gallery-thumb-hit-size: min(8.5rem, calc((100% - (3 * var(--space-2))) / 4));
	}
}

/* IKEA-inspired large-desktop mode: preserve WooCommerce's native thumbnail
 * list while rotating only its layout axis. In the RTL gallery grid the
 * thumbnail area is the physical-right track and the square viewport follows
 * it with a deliberate gutter. */
@media (min-width: 75rem) {
	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) {
		display: grid;
		grid-template-areas: "thumbs viewport";
		grid-template-columns: var(--sola-product-gallery-rail-size) minmax(0, var(--sola-product-gallery-square-size));
		column-gap: var(--sola-product-gallery-rail-gap);
		align-items: start;
		direction: rtl;
	}

	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-viewport {
		grid-area: viewport;
		inline-size: var(--sola-product-gallery-square-size);
		max-inline-size: 100%;
		aspect-ratio: 1 / 1;
	}

	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs,
	.single-product.woocommerce div.product div.images.woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs {
		--sola-gallery-thumb-hit-size: 8.5rem;
		--sola-gallery-thumb-size: 8rem;
		grid-area: thumbs;
		align-items: center;
		flex-flow: column nowrap;
		inline-size: var(--sola-product-gallery-rail-size);
		max-inline-size: var(--sola-product-gallery-rail-size);
		block-size: var(--sola-product-gallery-square-size);
		max-block-size: var(--sola-product-gallery-square-size);
		margin: 0;
		overflow-x: hidden;
		overflow-y: auto;
		overscroll-behavior-inline: auto;
		overscroll-behavior-block: contain;
	}

	.single-product.woocommerce div.product div.images.woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs li {
		flex: 0 0 var(--sola-gallery-thumb-hit-size);
		inline-size: var(--sola-gallery-thumb-hit-size);
		block-size: var(--sola-gallery-thumb-hit-size);
		width: var(--sola-gallery-thumb-hit-size);
		max-inline-size: var(--sola-gallery-thumb-hit-size);
		padding-block-end: 0;
		padding-inline-start: calc(var(--sola-gallery-thumb-gap) + var(--sola-gallery-thumb-underline-size));
	}

	.single-product .woocommerce-product-gallery:has(> .flex-control-thumbs > li) > .flex-control-thumbs li[aria-current="true"]::after {
		inset-block: 0;
		inset-inline-start: 0;
		inset-inline-end: auto;
		inline-size: var(--sola-gallery-thumb-underline-size);
		block-size: auto;
	}
}

@media (max-width: 47.99rem) {
	.single-product.woocommerce-page #content .site-main div.product > .sola-product-top > .woocommerce-product-gallery {
		inline-size: calc(100% + var(--space-8));
		max-inline-size: none;
		margin-inline: calc(-1 * var(--space-4));
	}

	.single-product .woocommerce-product-gallery .flex-control-thumbs {
		margin-block-start: var(--space-3);
	}

	.single-product.woocommerce div.product div.images.woocommerce-product-gallery .flex-control-thumbs {
		margin-block-start: var(--space-3);
	}

	.single-product .woocommerce-product-gallery .flex-control-thumbs li {
		inline-size: var(--sola-gallery-thumb-hit-size);
		block-size: auto;
		width: var(--sola-gallery-thumb-hit-size);
	}
	.single-product .woocommerce-product-gallery .woocommerce-breadcrumb.sola-breadcrumb-overlay {
		inset-block-start: 12px;
		inset-inline-start: 18px;
		max-inline-size: calc(100% - 36px);
		padding: 0.35rem 0.55rem;
		font-size: 0.8125rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.single-product .woocommerce-product-gallery .sola-product-gallery__arrow {
		transition: none;
	}

	.single-product .woocommerce-product-gallery .flex-control-thumbs img {
		transition: none;
	}
}
