/* ============================================================
   MST Product Box — باکس محصول
   ============================================================ */

.mstg-card {
	--mstg-card-bg: #ffffff;
	--mstg-card-radius: 18px;
	--mstg-img-h: 300px;
	--mstg-img-radius: 12px;
	--mstg-img-fit: cover;
	--mstg-notch-r: 20px;
	--mstg-notch-pad: 8px;
	--mstg-overlay: rgba(15, 20, 28, 0.35);
	--mstg-lift: -5px;

	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--mstg-card-bg);
	border-radius: var(--mstg-card-radius);
	transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
	will-change: transform;
}

.mstg-card:hover {
	transform: translateY(var(--mstg-lift));
}

/* ---------- تصویر ---------- */
.mstg-card__media {
	position: relative;
	aspect-ratio: 1 / 1; /* پیش‌فرض: مربع در همه دستگاه‌ها */
	width: 100%;
	flex-shrink: 0;
	border-radius: var(--mstg-img-radius);
	overflow: hidden;
	isolation: isolate;
	background: #f2f3f5;
}

.mstg-card__img {
	display: block;
	width: 100%;
	height: 100%;
}

.mstg-card__img img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: var(--mstg-img-fit);
	transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.mstg-card__overlay {
	position: absolute;
	inset: 0;
	pointer-events: none;
	background: linear-gradient(to top, var(--mstg-overlay) 0%, transparent 42%);
	z-index: 1;
}

/* ---------- نشان تخفیف / ناموجود ---------- */
.mstg-card__badge {
	position: absolute;
	top: 12px;
	inset-inline-start: 12px;
	z-index: 3;
	display: inline-block;
	padding: 5px 12px;
	border-radius: 999px;
	line-height: 1.6;
	letter-spacing: 0.2px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.mstg-card__badge.is-oos {
	background-color: #565d69 !important;
}

/* ---------- بریدگی گوشه + دکمه ---------- */
.mstg-card__notch {
	position: absolute;
	bottom: 0;
	z-index: 2;
	background: var(--mstg-card-bg);
}

/* سمت چپ (پیش‌فرض — مثل جای قلب در طرح قبلی) */
.mstg-side-left .mstg-card__notch {
	left: 0;
	border-top-right-radius: var(--mstg-notch-r);
	padding: var(--mstg-notch-pad) var(--mstg-notch-pad) 0 0;
}

.mstg-side-right .mstg-card__notch {
	right: 0;
	border-top-left-radius: var(--mstg-notch-r);
	padding: var(--mstg-notch-pad) 0 0 var(--mstg-notch-pad);
}

/* قطعات انحنای معکوس (کنج‌های نرم بریدگی) */
.mstg-card__notch-c {
	position: absolute;
	width: var(--mstg-notch-r);
	height: var(--mstg-notch-r);
	pointer-events: none;
}

.mstg-side-left .mstg-card__notch-c {
	background: radial-gradient(
		circle at 100% 0,
		transparent var(--mstg-notch-r),
		var(--mstg-card-bg) calc(var(--mstg-notch-r) + 0.5px)
	);
}

.mstg-side-right .mstg-card__notch-c {
	background: radial-gradient(
		circle at 0 0,
		transparent var(--mstg-notch-r),
		var(--mstg-card-bg) calc(var(--mstg-notch-r) + 0.5px)
	);
}

/* قطعه‌ی روی لبه‌ی عمودی (بالای بریدگی) */
.mstg-side-left .mstg-card__notch-c--v {
	bottom: 100%;
	left: 0;
}

.mstg-side-right .mstg-card__notch-c--v {
	bottom: 100%;
	right: 0;
}

/* قطعه‌ی روی لبه‌ی افقی (کنار بریدگی) */
.mstg-side-left .mstg-card__notch-c--h {
	bottom: 0;
	left: 100%;
}

.mstg-side-right .mstg-card__notch-c--h {
	bottom: 0;
	right: 100%;
}

/* ---------- دکمه ---------- */
.mstg-card__notch {
	max-width: 100%;
	box-sizing: border-box;
}

.mstg-card__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	max-width: 100%;
	box-sizing: border-box;
	overflow: hidden;
	white-space: nowrap;
	line-height: 1;
	text-decoration: none;
	transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.mstg-card__btn:hover {
	transform: translateY(-1px);
}

.mstg-card__btn i,
.mstg-card__btn svg {
	display: inline-block;
	transition: transform 0.25s ease;
	fill: currentColor;
}

.mstg-card__btn:hover i,
.mstg-card__btn:hover svg {
	transform: translateX(-3px);
}

.mstg-side-right .mstg-card__btn:hover i,
.mstg-side-right .mstg-card__btn:hover svg {
	transform: translateX(3px);
}

.mstg-card__btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* ---------- محتوا ---------- */
.mstg-card__content {
	padding: 0 4px;
	display: flex;
	flex-direction: column;
	flex-grow: 1;
}

/* قیمت همیشه پایین باکس بنشیند تا ردیف‌ها تراز بمانند */
.mstg-card__price {
	margin-top: auto;
	padding-top: 6px;
}

.mstg-card__cat {
	margin-top: 12px;
	line-height: 1.7;
}

.mstg-card__cat + .mstg-card__title {
	margin-top: 4px !important;
}

.mstg-card__title {
	margin: 12px 0 0;
	line-height: 1.8;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.mstg-card__title a {
	text-decoration: none;
	transition: color 0.25s ease;
}

.mstg-card__price {
	line-height: 1.7;
}

.mstg-card__price del {
	margin-inline-start: 6px;
	font-weight: 400;
	opacity: 0.85;
}

.mstg-card__price ins {
	text-decoration: none;
}

/* ---------- موبایل ---------- */
@media (max-width: 767px) {
	/* نشان تخفیف/ناموجود جمع‌وجورتر تا روی تصویر مربعی جا شود */
	.mstg-card__badge {
		top: 8px;
		inset-inline-start: 8px;
		padding: 3px 9px;
		font-size: 11px;
		box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
	}

	/* دکمه‌ی گوشه: کوچک‌تر و بدون سرریز از لبه‌ی کارت */
	.mstg-card__btn {
		gap: 5px;
		padding: 8px 10px !important;
		font-size: 11px !important;
	}

	.mstg-card__btn i,
	.mstg-card__btn svg {
		font-size: 12px !important;
		width: 12px !important;
		height: 12px !important;
	}

	.mstg-card {
		--mstg-notch-r: 14px;
		--mstg-notch-pad: 6px;
	}

	.mstg-card__title {
		line-height: 1.7;
	}

	/* فاصله‌ها کم شود تا کادر تصویر بزرگ‌تر و کامل دیده شود */
	.mstg {
		--mstg-gap-col: 8px;
		--mstg-gap-row: 14px;
	}

	.mstg-card__content {
		padding: 0 2px;
	}

	.mstg-card__media {
		border-radius: 10px;
	}
}

@media (max-width: 380px) {
	.mstg-card__btn {
		padding: 7px 8px !important;
		font-size: 10px !important;
	}
}

/* ---------- کاهش حرکت ---------- */
@media (prefers-reduced-motion: reduce) {
	.mstg-card,
	.mstg-card__img img,
	.mstg-card__btn,
	.mstg-card__btn i,
	.mstg-card__btn svg {
		transition: none !important;
	}

	.mstg-card:hover {
		transform: none;
	}

	.mstg-card:hover .mstg-card__img img {
		transform: none !important;
	}
}

/* ============================================================
   چیدمان گرید — ردیف ناقص و تک‌محصولی همیشه وسط‌چین
   ============================================================ */
.mstg {
	--mstg-cols: 4;
	--mstg-gap-col: 22px;
	--mstg-gap-row: 26px;
	--mstg-card-max: 400px;

	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: stretch;
	column-gap: var(--mstg-gap-col);
	row-gap: var(--mstg-gap-row);
	direction: inherit;
}

.mstg__item {
	min-width: 0;
	display: flex;
	flex: 0 1 calc(
		(100% - (var(--mstg-cols) - 1) * var(--mstg-gap-col)) / var(--mstg-cols)
	);
	max-width: var(--mstg-card-max);
}

/* کارت‌ها همیشه هم‌قد در هر ردیف */
.mstg .mstg-card {
	width: 100%;
	height: 100%;
}

/* ============================================================
   دکمه بارگذاری بیشتر
   ============================================================ */
.mstg-more {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	margin-top: 28px;
	width: 100%;
}

.mstg-more .mstg-more__btn {
	all: unset;
	box-sizing: border-box !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 10px !important;
	padding: 14px 34px !important;
	border: 0 !important;
	border-radius: 14px !important;
	background-color: #23a24d !important;
	background-image: none !important;
	color: #ffffff !important;
	font: inherit !important;
	font-weight: 700 !important;
	line-height: 1 !important;
	text-decoration: none !important;
	cursor: pointer !important;
	outline: none !important;
	-webkit-appearance: none !important;
	appearance: none !important;
	box-shadow: 0 10px 24px -12px rgba(20, 25, 35, 0.5) !important;
	transition: background-color 0.25s ease, color 0.25s ease,
		transform 0.25s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.mstg-more .mstg-more__btn:hover {
	transform: translateY(-2px) !important;
}

.mstg-more .mstg-more__btn:focus-visible {
	outline: 2px solid currentColor !important;
	outline-offset: 3px !important;
}

.mstg-more .mstg-more__btn.is-hidden {
	display: none !important;
}

.mstg-more .mstg-more__btn.is-loading {
	cursor: progress !important;
	opacity: 0.85;
}

/* چرخنده بارگذاری */
.mstg-more__spinner {
	display: none;
	width: 15px;
	height: 15px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: mstg-spin 0.7s linear infinite;
}

.mstg-more .mstg-more__btn.is-loading .mstg-more__spinner {
	display: inline-block;
}

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

.mstg-more__done {
	margin: 0;
	font-size: 13px;
	line-height: 1.8;
	color: #8a919d;
}

/* ظاهر شدن نرم محصولات تازه */
.mstg__item--new {
	animation: mstg-fade-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes mstg-fade-up {
	from { opacity: 0; transform: translateY(14px); }
	to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
	.mstg__item--new,
	.mstg-more__spinner {
		animation: none !important;
	}

	.mstg-more .mstg-more__btn:hover {
		transform: none !important;
	}
}
