/**
 * Mehrsun Store Tweaks
 * Brand: primary #088B87 · dark #0A4B4B · gold #D4A62D · border #E6E9EB · text #2A2C34
 */

:root {
	--ms-primary: #088B87;
	--ms-dark: #0A4B4B;
	--ms-gold: #D4A62D;
	--ms-border: #E6E9EB;
	--ms-bg: #F4F6F7;
	--ms-text: #2A2C34;
	--ms-muted: #6B7478;
}

/* Shop / category page header: see archive-hero.css. */

/* ---------------------------------------------------------------
 * Product grid (next to the filter sidebar)
 * Columns come from the woodmart_option filter (5 desktop / 4 tablet / 3 mobile);
 * 4 on small laptops via the breakpoint below.
 * ------------------------------------------------------------- */
.mh-products-grid .wd-products {
	--wd-gap-lg: 16px !important;
	--wd-gap-sm: 10px !important;
}

/* Elementor Pro's archive widget hard-codes 3 / 2 columns on tablet / mobile; follow Woodmart's --wd-col instead. */
.mh-products-grid .wd-products.wd-grid-g {
	grid-template-columns: repeat(var(--wd-col), minmax(0, 1fr));
}

@media (min-width: 1025px) and (max-width: 1299.98px) {
	.mh-products-grid .wd-products {
		--wd-col-lg: 4 !important;
	}
}

/* ---------------------------------------------------------------
 * Product card
 * Square photo frame (the product photos are tall 3:5 shots, which made every
 * card very tall), compact text block and a slim add-to-cart button.
 * ------------------------------------------------------------- */
.wd-products .wd-product .wd-product-wrapper {
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 8px 8px 10px;
	background: #fff;
	border: 1px solid var(--ms-border);
	border-radius: 14px;
	transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}

.wd-products .wd-product:hover .wd-product-wrapper {
	border-color: rgba(8, 139, 135, .35);
	box-shadow: 0 12px 26px -14px rgba(10, 75, 75, .3);
	transform: translateY(-3px);
}

.wd-products .wd-product .wd-product-card-bg {
	display: none;
}

.wd-products .wd-product .wd-product-thumb {
	margin-bottom: 10px;
	border-radius: 10px;
	overflow: hidden;
	background: var(--ms-bg);
}

.wd-products .wd-product .wd-product-img-link {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1 / 1;
	padding: 8%;
}

.wd-products .wd-product .wd-product-img-link img {
	width: auto;
	max-width: 100%;
	height: 100%;
	object-fit: contain;
	/* White photo backgrounds blend into the grey frame. */
	mix-blend-mode: multiply;
	transition: transform .35s ease;
}

.wd-products .wd-product:hover .wd-product-img-link img {
	transform: scale(1.05);
}

.wd-products .wd-product .wd-product-img-hover img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.wd-products .wd-product .product-element-bottom {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 6px;
	padding: 0 2px;
	text-align: start;
}

.wd-products .wd-product .wd-entities-title {
	display: -webkit-box;
	min-height: 3.2em;
	margin: 0;
	overflow: hidden;
	color: var(--ms-text);
	font-size: 13px;
	font-weight: 700;
	line-height: 1.6;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

/* The title already names the type (شمش / سکه / ساچمه). */
.wd-products .wd-product .wd-product-cats {
	display: none;
}

.wd-products .wd-product .wrap-price {
	margin-top: auto;
}

.wd-products .wd-product .price {
	color: var(--ms-dark);
	font-size: 14px;
	font-weight: 800;
	white-space: nowrap;
}

.wd-products .wd-product .price .woocommerce-Price-currencySymbol {
	color: var(--ms-muted);
	font-size: 11px;
	font-weight: 500;
}

.wd-products .wd-product .wd-add-btn {
	padding-top: 4px;
}

.wd-products .wd-product .wd-add-btn > a,
.wd-products .wd-product .wd-add-btn > a.button {
	width: 100%;
	min-height: 36px;
	padding-inline: 6px;
	border-radius: 9px;
	background-color: var(--ms-dark);
	color: #fff;
	font-size: 12px;
	white-space: nowrap;
	transition: background-color .2s ease;
}

.wd-products .wd-product .wd-add-btn > a:hover {
	background-color: var(--ms-primary);
	color: #fff;
}

.wd-products .wd-product.outofstock .wd-add-btn > a {
	background-color: #9AA3A6;
}

.wd-products .wd-product .wd-buttons {
	inset-inline-end: 6px;
	top: 6px;
}

/* Weight badge + brand line (card.php): used by the mobile card only. */
.mh-card-weight,
.mh-card-brand {
	display: none;
}

/* ---------------------------------------------------------------
 * Mobile / small tablet card
 * Soft card, photo with weight badge, brand + 2-line title,
 * price and a round cart button side by side.
 * ------------------------------------------------------------- */
@media (max-width: 768.98px) {
	.wd-products .wd-product .wd-product-wrapper {
		padding: 6px;
		border-color: #EDF1F1;
		border-radius: 16px;
		box-shadow: 0 8px 20px -14px rgba(10, 75, 75, .35);
	}

	/* No hover effects on touch screens. */
	.wd-products .wd-product:hover .wd-product-wrapper {
		border-color: #EDF1F1;
		box-shadow: 0 8px 20px -14px rgba(10, 75, 75, .35);
		transform: none;
	}

	.wd-products .wd-product:hover .wd-product-img-link img {
		transform: none;
	}

	.wd-products .wd-product .wd-product-img-hover,
	.wd-products .wd-product .wd-buttons {
		display: none;
	}

	.wd-products .wd-product .wd-product-thumb {
		position: relative;
		margin-bottom: 8px;
		border-radius: 12px;
		background: radial-gradient(circle at 50% 42%, #fff 0, #F1F5F5 58%, #E6EEEE 100%);
	}

	.wd-products .wd-product .wd-product-img-link {
		padding: 11%;
	}

	.mh-card-weight {
		position: absolute;
		z-index: 3;
		bottom: 6px;
		inset-inline-start: 6px;
		display: inline-flex;
		align-items: center;
		padding: 2px 8px;
		border-radius: 999px;
		background: rgba(255, 255, 255, .9);
		box-shadow: 0 1px 6px rgba(10, 75, 75, .14);
		color: var(--ms-dark);
		font-size: 10.5px;
		font-weight: 700;
		line-height: 1.7;
		-webkit-backdrop-filter: blur(6px);
		backdrop-filter: blur(6px);
	}

	.wd-products .wd-product .product-element-bottom {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
		gap: 0 6px;
		padding: 0 4px 2px;
	}

	.wd-products .wd-product .product-element-bottom > * {
		grid-column: 1 / -1;
	}

	.mh-card-brand {
		display: block;
		overflow: hidden;
		color: var(--ms-primary);
		font-size: 10.5px;
		font-weight: 600;
		line-height: 1.6;
		white-space: nowrap;
		text-overflow: ellipsis;
	}

	.wd-products .wd-product .wd-entities-title {
		min-height: 3.3em;
		margin-bottom: 8px;
		font-size: 12.5px;
		line-height: 1.65;
	}

	/* Price (start) + cart button (end) on one row. */
	.wd-products .wd-product .wrap-price {
		grid-column: 1;
		margin: 0;
	}

	.wd-products .wd-product .price {
		display: block;
		font-size: 14px;
		line-height: 1.35;
	}

	.wd-products .wd-product .price bdi {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
	}

	.wd-products .wd-product .price .woocommerce-Price-currencySymbol {
		font-size: 10px;
		font-weight: 500;
		line-height: 1.4;
	}

	.wd-products .wd-product .wd-add-btn {
		grid-column: 2;
		padding: 0;
	}

	.wd-products .wd-product .wd-add-btn > a,
	.wd-products .wd-product .wd-add-btn > a.button {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 38px;
		height: 38px;
		min-height: 38px;
		padding: 0;
		border-radius: 12px;
		box-shadow: 0 6px 14px -6px rgba(10, 75, 75, .55);
		font-size: 0;
	}

	.wd-products .wd-product .wd-add-btn > a > span,
	.wd-products .wd-product.wd-hover-fw-button .add-to-cart-loop .wd-action-text {
		display: none !important;
	}

	/* Woodmart uses ::before (absolute, icon font) for its own icon; reset it to hold ours. */
	.wd-products .wd-product .wd-add-btn > a::before {
		content: "" !important;
		position: static !important;
		margin: 0 !important;
		opacity: 1 !important;
		transform: none !important;
		flex: 0 0 auto;
		font-size: 0 !important;
		width: 20px;
		height: 20px;
		background: currentColor;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 8h13l-1.2 12H6.7z'/%3E%3Cpath d='M9 8V7a3 3 0 0 1 6 0v1'/%3E%3Cpath d='M12 11.5v5M9.5 14h5'/%3E%3C/svg%3E") center / contain no-repeat;
		mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 8h13l-1.2 12H6.7z'/%3E%3Cpath d='M9 8V7a3 3 0 0 1 6 0v1'/%3E%3Cpath d='M12 11.5v5M9.5 14h5'/%3E%3C/svg%3E") center / contain no-repeat;
	}

	.wd-products .wd-product .wd-add-btn > a.added::before {
		-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
		mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
	}

	/* Out of stock: the button links to the product page. */
	.wd-products .wd-product.outofstock .wd-add-btn > a {
		box-shadow: none;
	}

	.wd-products .wd-product.outofstock .wd-add-btn > a::before {
		-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E");
		mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 5l-7 7 7 7'/%3E%3C/svg%3E");
	}

	.wd-products .wd-product .wd-add-btn .added_to_cart {
		display: none;
	}
}

/* ---------------------------------------------------------------
 * Phones, 3 per row (cards ~110px wide): compact card.
 * Price gets its own line; the cart button sits on the photo's corner,
 * opposite the weight badge.
 * ------------------------------------------------------------- */
@media (max-width: 575.98px) {
	.mh-products-grid .wd-products {
		--wd-gap-sm: 8px !important;
	}

	.mh-products-grid .wd-product .wd-product-wrapper {
		padding: 4px 4px 8px;
		border-radius: 12px;
	}

	.mh-products-grid .wd-product .wd-product-thumb {
		margin-bottom: 6px;
		border-radius: 9px;
	}

	.mh-products-grid .wd-product .wd-product-img-link {
		padding: 9%;
	}

	.mh-products-grid .mh-card-weight {
		bottom: 4px;
		inset-inline-start: 4px;
		padding: 1px 6px;
		font-size: 9.5px;
	}

	.mh-products-grid .wd-product .product-element-bottom {
		position: relative;
		display: flex;
		flex-direction: column;
		gap: 0;
		padding: 0 3px;
	}

	.mh-products-grid .mh-card-brand {
		font-size: 9.5px;
	}

	.mh-products-grid .wd-product .wd-entities-title {
		min-height: 3.2em;
		margin-bottom: 4px;
		font-size: 11px;
		line-height: 1.6;
	}

	.mh-products-grid .wd-product .wrap-price {
		margin-top: auto;
	}

	.mh-products-grid .wd-product .price {
		font-size: 12px;
	}

	.mh-products-grid .wd-product .price .woocommerce-Price-currencySymbol {
		font-size: 9px;
	}

	/* Lift the button onto the photo's bottom corner, level with the weight badge. */
	.mh-products-grid .wd-product.wd-hover-fw-button .product-element-bottom .wd-add-btn {
		position: absolute;
		z-index: 4;
		top: -45px;
		inset-inline-end: 1px;
	}

	.mh-products-grid .wd-product .wd-add-btn > a,
	.mh-products-grid .wd-product .wd-add-btn > a.button {
		width: 28px;
		height: 28px;
		min-height: 28px;
		border-radius: 50%;
		box-shadow: 0 4px 10px -4px rgba(10, 75, 75, .6);
	}

	.mh-products-grid .wd-product .wd-add-btn > a::before {
		width: 16px;
		height: 16px;
	}
}
