/**
 * Motta Quick View fixes.
 *
 * Scoped to Motta's #quick-view-modal. Every visual value is a custom property
 * set from WooCommerce → Motta Elements by MPE_Quickview::tokens_css(); the
 * fallbacks here only mirror those defaults. The mobile button layout lives in
 * the inline CSS because its breakpoint is a setting.
 */

/* -------------------------------------------- Fix 3: height and scrolling */

/* Stop the page scrolling behind the open modal. */
html.mpe-qv-lock,
html.mpe-qv-lock body {
	overflow: hidden;
}

#quick-view-modal .modal__quickview {
	position: relative;
	height: auto;
	max-height: var(--mpe-qv-max-h, 90vh);
	overflow: hidden;
}

/* The modal scrolls internally, never the page. */
#quick-view-modal .modal__content {
	height: auto;
	max-height: var(--mpe-qv-max-h, 90vh);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

/* Columns size to content: no stretched right column, no dead space below
   "View full details". */
#quick-view-modal .product-quickview {
	align-items: flex-start;
}

#quick-view-modal .product-quickview .summary {
	height: auto;
	min-height: 0;
	align-self: flex-start;
}

/* Gallery: main image capped so the thumbnail strip stays on screen. */
#quick-view-modal .product-quickview .woocommerce-product-gallery {
	display: flex;
	flex-direction: column;
	gap: var(--mpe-qv-thumb-gap, 8px);
	min-width: 0;
}

#quick-view-modal .product-quickview .woocommerce-product-gallery__image img {
	display: block;
	width: 100%;
	height: auto;
	max-height: var(--mpe-qv-main-max-h, 60vh);
	object-fit: contain;
}

/* Horizontal thumbnail strip. */
#quick-view-modal .product-quickview .flex-control-thumbs {
	display: flex;
	flex: 0 0 auto;
	flex-wrap: nowrap;
	gap: var(--mpe-qv-thumb-gap, 8px);
	margin: 0;
	padding: 0;
	overflow-x: auto;
	list-style: none;
	scrollbar-width: thin;
}

#quick-view-modal .product-quickview .flex-control-thumbs li {
	flex: 0 0 var(--mpe-qv-thumb-size, 72px);
	width: var(--mpe-qv-thumb-size, 72px);
	margin: 0;
	float: none;
}

#quick-view-modal .product-quickview .flex-control-thumbs img {
	display: block;
	box-sizing: border-box;
	width: 100%;
	height: auto;
	aspect-ratio: var(--mpe-qv-thumb-ratio, 1 / 1);
	object-fit: cover;
	border: var(--mpe-qv-thumb-border-w, 2px) solid transparent;
	border-radius: var(--mpe-qv-thumb-radius, 6px);
	opacity: var(--mpe-qv-thumb-idle-opacity, 0.65);
	cursor: pointer;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

#quick-view-modal .product-quickview .flex-control-thumbs img:hover,
#quick-view-modal .product-quickview .flex-control-thumbs img.flex-active,
#quick-view-modal .product-quickview .flex-control-thumbs img.mpe-qv-active {
	opacity: 1;
}

/* Active thumbnail. */
#quick-view-modal .product-quickview .flex-control-thumbs img.flex-active,
#quick-view-modal .product-quickview .flex-control-thumbs img.mpe-qv-active {
	border-color: var(--mpe-qv-thumb-active, #7a1420);
}

/* Used only when FlexSlider failed to initialise and the enhancer swaps
   slides itself: undo FlexSlider's track sizing so one slide shows. */
#quick-view-modal .woocommerce-product-gallery.mpe-qv-manual .woocommerce-product-gallery__wrapper {
	width: auto !important;
	transform: none !important;
}

/* ------------------------------------------------- Fix 2: close button */

/* Every box property is pinned so a flex parent cannot stretch it into a
   pill, and the ID-scoped selector outranks the theme's class rules. */
#quick-view-modal .modal__button-close {
	position: absolute;
	top: var(--mpe-qv-close-offset, 12px);
	right: var(--mpe-qv-close-offset, 12px);
	bottom: auto;
	left: auto;
	z-index: var(--mpe-qv-close-z, 20);
	display: grid;
	place-items: center;
	box-sizing: border-box;
	flex: 0 0 var(--mpe-qv-close-size, 36px);
	width: var(--mpe-qv-close-size, 36px);
	height: var(--mpe-qv-close-size, 36px);
	min-width: var(--mpe-qv-close-size, 36px);
	min-height: var(--mpe-qv-close-size, 36px);
	max-width: var(--mpe-qv-close-size, 36px);
	max-height: var(--mpe-qv-close-size, 36px);
	margin: 0;
	padding: 0;
	border: var(--mpe-qv-close-border-w, 1px) solid var(--mpe-qv-close-border, #e6e2dc);
	border-radius: 50%;
	background: var(--mpe-qv-close-bg, #ffffff);
	color: var(--mpe-qv-close-color, #1c1c1c);
	line-height: 0;
	cursor: pointer;
}

/* Optically centred ×: block-level icon in a grid cell, no inline baseline. */
#quick-view-modal .modal__button-close svg {
	display: block;
	width: var(--mpe-qv-close-icon, 16px);
	height: var(--mpe-qv-close-icon, 16px);
	margin: 0;
	fill: currentColor;
}

/* ------------------------------------------- Fix 4: description clamp */

#quick-view-modal .woocommerce-product-details__short-description {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--mpe-qv-excerpt-lines, 2);
	line-clamp: var(--mpe-qv-excerpt-lines, 2);
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Block children (<p>) break line-clamp; flatten them into one run. */
#quick-view-modal .woocommerce-product-details__short-description > * {
	display: inline;
	margin: 0;
}
