/**
 * WooCommerce Shop Loop Quick Gallery — styles
 * Version 2.0.0
 *
 * نکته: تمام موقعیت‌ها با خواص منطقی (logical properties) نوشته شده‌اند
 * تا در حالت RTL به‌صورت خودکار معکوس شوند.
 */

:root {
	--wcqg-accent: #3b82f6;
	--wcqg-accent-soft: #3b82f633;
	--wcqg-btn: 1;
	--wcqg-bg: rgba(9, 12, 20, 0.97);
	--wcqg-text: #f8fafc;
	--wcqg-radius: 14px;
	--wcqg-bar: rgba(255, 255, 255, 0.09);
	--wcqg-bar-hover: rgba(255, 255, 255, 0.2);
	--wcqg-border: rgba(255, 255, 255, 0.14);
	--wcqg-z: 999999;
	--wcqg-adminbar: 0px;
}

body.admin-bar {
	--wcqg-adminbar: 32px;
}

/* ---------------------------------------------------------------- trigger */

ul.products li.product,
.wc-block-grid__product,
.products .product {
	position: relative;
}

.wcqg-trigger {
	position: absolute;
	inset-block-start: 10px;
	inset-inline-start: 10px;
	z-index: 15;
	width: 38px;
	height: 38px;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid rgba(15, 23, 42, 0.06);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	color: #1e293b;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
	opacity: var(--wcqg-btn, 1);
	transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
		color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.wcqg-trigger:hover,
.wcqg-trigger:focus-visible {
	color: var(--wcqg-accent);
	background: #fff;
	transform: scale(1.08);
	box-shadow: 0 8px 22px rgba(15, 23, 42, 0.2);
}

.wcqg-trigger:active {
	transform: scale(0.95);
}

.wcqg-trigger:focus-visible {
	outline: 2px solid var(--wcqg-accent);
	outline-offset: 2px;
}

/* موقعیت‌ها */
.wcqg-trigger--top-start    { inset-block-start: 10px; inset-inline-start: 10px; inset-block-end: auto; inset-inline-end: auto; }
.wcqg-trigger--top-end      { inset-block-start: 10px; inset-inline-end: 10px; inset-block-end: auto; inset-inline-start: auto; }
.wcqg-trigger--bottom-start { inset-block-end: 10px; inset-inline-start: 10px; inset-block-start: auto; inset-inline-end: auto; }
.wcqg-trigger--bottom-end   { inset-block-end: 10px; inset-inline-end: 10px; inset-block-start: auto; inset-inline-start: auto; }

/* فقط هنگام هاور (در دستگاه‌های لمسی همیشه دیده شود تا کاربر گیج نشود) */
html:not(.wcqg-touch) .wcqg-trigger--hover {
	opacity: 0;
	pointer-events: none;
}
html:not(.wcqg-touch) li.product:hover .wcqg-trigger--hover,
html:not(.wcqg-touch) li.product:focus-within .wcqg-trigger--hover,
html:not(.wcqg-touch) .wcqg-trigger--hover:focus-visible {
	opacity: 1;
	pointer-events: auto;
}

/* مخفی در دستگاه لمسی */
html.wcqg-touch .wcqg-trigger--touch_hidden {
	display: none !important;
}

/* هدف لمسی بزرگ‌تر روی موبایل */
html.wcqg-touch .wcqg-trigger {
	width: 44px;
	height: 44px;
}

.wcqg-ico {
	width: 19px;
	height: 19px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

/* --------------------------------------------------------------- lightbox */

.wcqg {
	position: fixed;
	inset-block-start: var(--wcqg-adminbar, 0px);
	inset-inline: 0;
	inset-block-end: 0;
	z-index: var(--wcqg-z);
	display: flex;
	align-items: stretch;
	justify-content: center;
	direction: ltr;
	visibility: hidden;
	opacity: 0;
	transition: opacity 0.22s ease, visibility 0s linear 0.22s;
	overscroll-behavior: contain;
}

/* در حالت راست‌به‌چپ، کل چیدمان (جای پیکان‌ها، نوار بالا و پایین) خودکار معکوس می‌شود */
.wcqg.is-rtl {
	direction: rtl;
}

.wcqg.is-open {
	visibility: visible;
	opacity: 1;
	transition: opacity 0.22s ease, visibility 0s;
}

/* ارتفاع واقعی ویوپورت در موبایل (با جمع/باز شدن نوار آدرس مرورگر) */
@supports (height: 100dvh) {
	.wcqg {
		inset-block-end: auto;
		height: calc(100dvh - var(--wcqg-adminbar, 0px));
	}
}

.wcqg[hidden] {
	display: none !important;
}

.wcqg-backdrop {
	position: absolute;
	inset: 0;
	background: var(--wcqg-bg);
	-webkit-backdrop-filter: blur(10px) saturate(120%);
	backdrop-filter: blur(10px) saturate(120%);
}

.wcqg-panel {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	padding-block-start: env(safe-area-inset-top, 0px);
	padding-inline: env(safe-area-inset-right, 0px) env(safe-area-inset-left, 0px);
	padding-block-end: env(safe-area-inset-bottom, 0px);
	transform: scale(0.985);
	opacity: 0;
	transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.24s ease;
}

.wcqg.is-open .wcqg-panel {
	transform: none;
	opacity: 1;
}

/* top bar */
.wcqg-topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	min-height: 58px;
	padding: 8px 12px;
}

.wcqg-counter {
	color: rgba(248, 250, 252, 0.82);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.4px;
	font-variant-numeric: tabular-nums;
	min-width: 56px;
	white-space: nowrap;
}

.wcqg-tools {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wcqg-zoomlevel {
	color: rgba(248, 250, 252, 0.7);
	font-size: 12px;
	min-width: 44px;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.wcqg-btn,
.wcqg-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border-radius: 50%;
	border: 1px solid var(--wcqg-border);
	background: var(--wcqg-bar);
	color: var(--wcqg-text);
	cursor: pointer;
	transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease, opacity 0.18s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
	flex: 0 0 auto;
}

.wcqg-btn:hover,
.wcqg-close:hover {
	background: var(--wcqg-bar-hover);
	transform: scale(1.06);
}

.wcqg-btn:active,
.wcqg-close:active {
	transform: scale(0.94);
}

.wcqg-btn:focus-visible,
.wcqg-close:focus-visible,
.wcqg-nav:focus-visible,
.wcqg-thumb:focus-visible {
	outline: 2px solid var(--wcqg-accent);
	outline-offset: 2px;
}

.wcqg-btn--ghost {
	width: auto;
	padding-inline: 12px;
	border-radius: 20px;
	font-size: 12px;
}

.wcqg-btn.is-disabled,
.wcqg-nav.is-disabled {
	opacity: 0.32;
	cursor: default;
	pointer-events: none;
}

.wcqg-close {
	width: 44px;
	height: 44px;
	background: rgba(255, 255, 255, 0.14);
}

/* body / stage */
.wcqg-body {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
}

.wcqg-stage {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none; /* کلید اصلی مدیریت ژست‌های لمسی بدون تداخل با اسکرول صفحه */
	-webkit-user-select: none;
	user-select: none;
	cursor: default;
}

.wcqg-stage.is-zoomed {
	cursor: grab;
}

.wcqg-stage.is-dragging {
	cursor: grabbing;
}

.wcqg-img {
	position: relative;
	max-width: 96%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	opacity: 0;
	will-change: transform;
	transform-origin: 50% 50%;
	-webkit-user-drag: none;
	user-select: none;
	pointer-events: none; /* همه ژست‌ها روی stage مدیریت می‌شوند */
	box-shadow: 0 28px 60px -20px rgba(0, 0, 0, 0.65);
	border-radius: 4px;
	background: rgba(255, 255, 255, 0.03);
}

.wcqg-img.is-ready {
	opacity: 1;
	transition: opacity 0.18s ease;
}

.wcqg-spinner {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 50%;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid rgba(255, 255, 255, 0.18);
	border-top-color: var(--wcqg-accent);
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.wcqg.is-loading .wcqg-spinner {
	opacity: 1;
	animation: wcqg-spin 0.85s linear infinite;
}

@keyframes wcqg-spin {
	to { transform: rotate(360deg); }
}

/* navigation arrows */
.wcqg-nav {
	position: absolute;
	top: 50%;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	margin-top: -24px;
	border-radius: 50%;
	border: 1px solid var(--wcqg-border);
	background: var(--wcqg-bar);
	color: var(--wcqg-text);
	cursor: pointer;
	transition: background 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.wcqg-nav:hover {
	background: var(--wcqg-bar-hover);
	transform: scale(1.07);
}

.wcqg-nav--prev { inset-inline-start: 12px; }
.wcqg-nav--next { inset-inline-end: 12px; }

.wcqg-nav--prev .wcqg-ico { transform: none; }
.wcqg-nav--next .wcqg-ico { transform: scaleX(-1); }

/* در حالت راست‌به‌چپ فقط جهت خودِ آیکون پیکان‌ها معکوس می‌شود (جایشان با direction عوض شده) */
.wcqg.is-rtl .wcqg-nav--prev .wcqg-ico { transform: scaleX(-1); }
.wcqg.is-rtl .wcqg-nav--next .wcqg-ico { transform: none; }

.wcqg-nav .wcqg-ico { width: 24px; height: 24px; }

/* footer / thumbs */
.wcqg-footer {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 64px;
	padding: 10px 12px 14px;
}

.wcqg-thumbs-toggle {
	display: none;
}

.wcqg-thumbs {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	gap: 10px;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 4px;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
	direction: ltr;
}

.wcqg.is-rtl .wcqg-thumbs { direction: rtl; }

.wcqg-thumbs::-webkit-scrollbar {
	display: none;
}

.wcqg-thumb {
	position: relative;
	flex: 0 0 auto;
	width: 58px;
	height: 58px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.06);
	cursor: pointer;
	overflow: hidden;
	opacity: 0.55;
	transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
	-webkit-tap-highlight-color: transparent;
}

.wcqg-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
}

.wcqg-thumb:hover {
	opacity: 0.85;
	transform: translateY(-2px);
}

.wcqg-thumb.is-active {
	opacity: 1;
	border-color: var(--wcqg-accent);
	box-shadow: 0 0 0 3px var(--wcqg-accent-soft);
}

.wcqg-dots {
	display: none;
	gap: 7px;
	align-items: center;
	justify-content: center;
	padding-block: 14px;
}

.wcqg-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.35);
	transition: transform 0.2s ease, background 0.2s ease;
}

.wcqg-dot.is-active {
	background: var(--wcqg-accent);
	transform: scale(1.5);
}

.wcqg.no-thumbs .wcqg-footer,
.wcqg.single-image .wcqg-footer { display: none; }

.wcqg-sprite {
	position: absolute;
	width: 0;
	height: 0;
	overflow: hidden;
}

/* قفل اسکرول صفحه هنگام باز بودن گالری */
html.wcqg-lock,
html.wcqg-lock body {
	overflow: hidden !important;
	touch-action: none;
	overscroll-behavior: none;
}

/* کاهش انیمیشن برای کاربران حساس */
@media (prefers-reduced-motion: reduce) {
	.wcqg,
	.wcqg-panel,
	.wcqg-img,
	.wcqg-trigger,
	.wcqg-thumb {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
	.wcqg-thumbs { scroll-behavior: auto; }
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 768px) {
	body.admin-bar { --wcqg-adminbar: 46px; }

	.wcqg-topbar { min-height: 50px; padding: 6px 8px; }
	.wcqg-btn, .wcqg-close { width: 42px; height: 42px; }
	.wcqg-zoomlevel { display: none; }
	.wcqg-counter { font-size: 12px; min-width: 44px; }

	.wcqg-nav {
		width: 40px;
		height: 40px;
		margin-top: -20px;
		background: rgba(255, 255, 255, 0.12);
	}
	.wcqg-nav--prev { inset-inline-start: 6px; }
	.wcqg-nav--next { inset-inline-end: 6px; }

	.wcqg-footer { min-height: 0; padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }

	/* در موبایل: بندانگشتی‌ها جمع‌شونده هستند تا فضای بیشتری به تصویر برسد */
	.wcqg-thumbs-toggle {
		display: inline-flex;
		width: 40px;
		height: 40px;
	}
	.wcqg.thumbs-collapsed .wcqg-thumbs { display: none; }
	.wcqg.thumbs-collapsed .wcqg-dots { display: flex; }
	.wcqg.thumbs-collapsed .wcqg-footer { justify-content: center; }

	.wcqg-thumb { width: 52px; height: 52px; border-radius: 8px; }
}

@media (max-width: 480px) {
	.wcqg-img { max-width: 100%; border-radius: 0; }
	.wcqg-thumbs { gap: 8px; }
}

/* تبلت‌ها و صفحه‌های کوتاه */
@media (max-height: 520px) {
	.wcqg-topbar { min-height: 44px; }
	.wcqg-footer { min-height: 0; padding-block: 4px; }
	.wcqg-thumb { width: 44px; height: 44px; }
}
