/* =========================================================================
 * MARK GALLERY — quick view dialog
 * =========================================================================
 * Opened by the magnifier button in the home "selects" cards. Filled from
 * WooCommerce's own Store API (assets/js/quick-view.js); nothing here knows
 * any product data.
 *
 * Written as a self-contained layer so it can never reach the rest of the
 * store: every selector starts with .mg-qv. The only global it touches is
 * the <html> element, and only while the dialog is open (scroll lock).
 *
 * Square corners and hairlines, like every other surface on this site. The
 * panel is a two-column card on desktop and a bottom sheet on phones.
 * ========================================================================= */

.mg-qv-root {
	position: fixed;
	inset: 0;
	z-index: 9998;
	display: grid;
	place-items: center;
	padding: 24px;
}

.mg-qv-root[hidden] {
	display: none;
}

/* scroll lock while the dialog is open. The padding compensates for the
 * scrollbar that disappears, so the page behind does not jump sideways. */
html.mg-qv-open {
	overflow: hidden;
	padding-inline-end: var(--mg-qv-sbw, 0);
}

.mg-qv-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 10, 10, .62);
	opacity: 0;
	transition: opacity .22s ease;
}

.mg-qv-panel {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: minmax(0, .85fr) minmax(0, 1fr);
	/* the row may not grow past the panel's max-height, so the body column
	 * becomes the scroll container instead of pushing the action button
	 * below the panel's clipped edge */
	grid-template-rows: minmax(0, 1fr);
	width: min(880px, 100%);
	max-height: min(86vh, 760px);
	overflow: hidden;
	background: #fff;
	color: var(--ink, #0a0a0a);
	box-shadow: 0 24px 80px rgba(0, 0, 0, .3);
	opacity: 0;
	transform: translateY(10px);
	transition: opacity .22s ease, transform .3s cubic-bezier(.2, .7, .2, 1);
}

.mg-qv-root.is-open .mg-qv-backdrop {
	opacity: 1;
}

.mg-qv-root.is-open .mg-qv-panel {
	opacity: 1;
	transform: none;
}

/* ---------- media: stage + thumbnail rail ---------- */
.mg-qv-media {
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 0;
	background: #f2f2f0;
}

.mg-qv-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
}

.mg-qv-stage img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* arrows sit at the reading direction's edges: previous on the right,
 * next on the left, which is the way an RTL gallery reads */
.mg-qv-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .92);
	color: var(--ink, #0a0a0a);
	cursor: pointer;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .16);
	-webkit-appearance: none;
	appearance: none;
	transition: background-color .2s, color .2s;
}

.mg-qv-nav:hover {
	background: var(--ink, #0a0a0a);
	color: #fff;
}

.mg-qv-nav:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: 2px;
}

.mg-qv-nav--prev {
	inset-inline-start: 10px;
}

.mg-qv-nav--next {
	inset-inline-end: 10px;
}

.mg-qv-thumbs {
	display: flex;
	flex: none;
	gap: 6px;
	padding: 8px;
	overflow-x: auto;
	background: #fff;
	border-top: 1px solid var(--line, #e6e6e4);
	scrollbar-width: thin;
}

.mg-qv-thumb {
	position: relative;
	flex: none;
	width: 40px;
	height: 50px;
	margin: 0;
	padding: 0;
	border: 1px solid transparent;
	background: #f2f2f0;
	cursor: pointer;
	opacity: .6;
	-webkit-appearance: none;
	appearance: none;
	transition: opacity .2s, border-color .2s;
}

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

.mg-qv-thumb:hover {
	opacity: 1;
}

.mg-qv-thumb[aria-current="true"] {
	opacity: 1;
	border-color: var(--ink, #0a0a0a);
}

.mg-qv-thumb:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: 2px;
}

/* ---------- body ---------- */
.mg-qv-body {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 14px;
	min-height: 0;
	padding: 34px 32px 28px;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

/* The dialog itself takes focus when it opens (a container with tabindex
 * -1). Styling the container would draw a ring around the whole panel for
 * mouse users; the close button still shows its own ring when tabbed to. */
.mg-qv-panel:focus,
.mg-qv-panel:focus-visible {
	outline: none;
}

/* A chip floating on the panel, not a control inside the scrolling column:
 * on a phone it sits over the photo where it can always be reached, and it
 * cannot scroll out of view. */
.mg-qv-close {
	position: absolute;
	z-index: 6;
	inset-block-start: 10px;
	inset-inline-end: 10px;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(0, 0, 0, .08);
	border-radius: 50%;
	background: rgba(255, 255, 255, .94);
	color: var(--ink, #0a0a0a);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
	transition: background-color .2s, color .2s;
}

.mg-qv-close:hover {
	background: var(--ink, #0a0a0a);
	color: #fff;
}

.mg-qv-close:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: 2px;
}

.mg-qv-title {
	margin: 0;
	/* the close button sits at the inline end (left on an RTL page), so the
	 * title reserves that side and keeps its start edge flush with the price
	 * and the attribute rows below it */
	padding-block: 0;
	padding-inline-start: 0;
	padding-inline-end: 44px;
	font-family: var(--mg-font-display, "Arad", Tahoma, sans-serif);
	font-size: clamp(18px, 1.6vw, 22px);
	line-height: 1.55;
	font-weight: 600;
	letter-spacing: 0;
	color: var(--ink, #0a0a0a);
}

.mg-qv-price {
	margin: 0;
	padding: 0;
	font-family: var(--mg-font, "Estedad", Tahoma, sans-serif);
	font-size: 17px;
	line-height: 1.6;
	font-weight: 600;
	letter-spacing: 0;
	color: var(--ink, #0a0a0a);
}

.mg-qv-stock {
	display: inline-block;
	align-self: flex-start;
	margin: 0;
	padding: 2px 10px;
	border: 1px solid var(--line, #e6e6e4);
	font-size: 12px;
	line-height: 1.9;
	color: #767676;
}

/* attribute rows: the size run and the colour */
.mg-qv-attrs {
	margin: 0;
	padding: 0;
	border-top: 1px solid var(--line, #e6e6e4);
}

.mg-qv-attr {
	display: flex;
	gap: 10px;
	padding: 9px 0;
	border-bottom: 1px solid var(--line, #e6e6e4);
	font-size: 13.5px;
	line-height: 1.8;
}

.mg-qv-attr dt {
	flex: none;
	min-width: 54px;
	margin: 0;
	color: #767676;
}

.mg-qv-attr dd {
	flex: 0 1 auto;
	margin: 0;
	color: var(--ink, #0a0a0a);
	text-align: start;
}

/* the product description, which already carries its own
 * «مشخصات محصول» and «مزایای محصول» headings */
.mg-qv-desc {
	font-family: var(--mg-font, "Estedad", Tahoma, sans-serif);
	font-size: 13.5px;
	line-height: 2;
	color: #333;
	letter-spacing: 0;
}

.mg-qv-desc p {
	margin: 0 0 10px;
}

/* Some product descriptions mark their sections with a bold-only paragraph
 * («مشخصات محصول», «مزایای محصول») instead of an <h3>. Giving those the same
 * weight as a real heading keeps the two styles of copy looking alike. */
.mg-qv-desc p > strong:only-child {
	display: block;
	margin-bottom: 2px;
	font-family: var(--mg-font-display, "Arad", Tahoma, sans-serif);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.7;
	color: var(--ink, #0a0a0a);
}

.mg-qv-desc p:last-child {
	margin-bottom: 0;
}

.mg-qv-desc h2,
.mg-qv-desc h3,
.mg-qv-desc h4 {
	margin: 16px 0 6px;
	font-family: var(--mg-font-display, "Arad", Tahoma, sans-serif);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.7;
	letter-spacing: 0;
	color: var(--ink, #0a0a0a);
}

.mg-qv-desc h2:first-child,
.mg-qv-desc h3:first-child {
	margin-top: 0;
}

.mg-qv-desc ul,
.mg-qv-desc ol {
	margin: 0 0 10px;
	padding-inline-start: 20px;
}

.mg-qv-desc li {
	margin: 0 0 5px;
}

/* ---------- primary action ---------- */
.mg-qv-more {
	/* pinned to the bottom of the scrolling column: on a phone the copy is
	 * longer than the sheet, and the one action in the dialog must not be
	 * something the visitor has to scroll to find */
	position: sticky;
	bottom: 0;
	display: block;
	margin-top: auto;
	padding: 13px 18px;
	background: var(--ink, #0a0a0a);
	color: #fff;
	font-family: var(--mg-font, "Estedad", Tahoma, sans-serif);
	font-size: 14px;
	font-weight: 500;
	line-height: 1.4;
	text-align: center;
	text-decoration: none;
	letter-spacing: 0;
	transition: background-color .2s, color .2s;
}

.mg-qv-more:hover {
	background: #fff;
	color: var(--ink, #0a0a0a);
	box-shadow: inset 0 0 0 1px var(--ink, #0a0a0a);
}

.mg-qv-more:focus-visible {
	outline: 2px solid var(--ink, #0a0a0a);
	outline-offset: 3px;
}

.mg-qv-more[aria-disabled="true"] {
	pointer-events: none;
	opacity: .5;
}

/* ---------- loading ---------- */
.mg-qv-loading {
	display: grid;
	gap: 10px;
}

.mg-qv-skel {
	height: 12px;
	background: #f0f0ee;
}

.mg-qv-skel--lg {
	height: 20px;
	width: 74%;
}

.mg-qv-skel--sm {
	width: 42%;
}

/* ---------- phones: bottom sheet ---------- */
@media (max-width: 767px) {
	.mg-qv-root {
		padding: 0;
		align-items: end;
	}

	.mg-qv-panel {
		grid-template-columns: 1fr;
		/* the image gets a fixed strip and the copy the rest, so the body
		 * scrolls instead of overlapping the photo. Taller than it was, to
		 * leave room for the thumbnail rail under the photo. */
		grid-template-rows: 46vh minmax(0, 1fr);
		width: 100%;
		max-height: 90vh;
		transform: translateY(24px);
	}

	.mg-qv-root.is-open .mg-qv-panel {
		transform: none;
	}

	.mg-qv-thumbs {
		gap: 5px;
		padding: 6px;
	}

	.mg-qv-thumb {
		width: 34px;
		height: 42px;
	}

	/* no bottom padding on phones: the sticky action sits flush on the sheet
	 * edge as an action bar, and copy never shows underneath it */
	.mg-qv-body {
		padding: 22px 18px 0;
		gap: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mg-qv-backdrop,
	.mg-qv-panel,
	.mg-qv-close,
	.mg-qv-more {
		transition: none;
	}

	.mg-qv-panel {
		transform: none;
	}
}
