/**
 * Homepage Custom Styles
 * استایل‌های سفارشی صفحه اصلی
 *
 * رنگ‌های کلی سایت (پیروی از variables.css):
 * - دکمه‌ها: var(--asc-color-bg), var(--asc-color-primary)
 */

/* Homepage padding */
.page-template-template-homepage:not(.has-post-thumbnail) .site-main {
	padding-top: 0.1em;
}

/* اجازه به کاروسل‌های تمام‌عرض برای شکستن از محدوده محتوا */
.page-template-template-homepage #page,
.page-template-template-homepage .site-content,
.page-template-template-homepage #main,
.page-template-template-homepage .content-area {
	overflow-x: visible !important;
}

/* Homepage hero banner */
.asc-homepage-admin-banner {
	width: 100%;
	overflow: hidden;
	margin-bottom: 2rem;
	line-height: normal;
}

.asc-homepage-admin-banner__stage {
	position: relative;
	width: 100%;
}

.asc-homepage-admin-banner--dual .asc-homepage-admin-banner__viewport {
	position: absolute;
	inset: 0;
	pointer-events: none;
}

.asc-homepage-admin-banner--dual .asc-homepage-admin-banner__viewport .asc-homepage-admin-banner__overlay {
	pointer-events: auto;
}

.asc-homepage-admin-banner__viewport {
	position: relative;
	width: 100%;
	overflow: hidden;
	line-height: 0;
}

.asc-homepage-admin-banner__viewport--desktop {
	--asc-admin-banner-title-color: var(--asc-color-bg-alt);
	--asc-admin-banner-text-color: var(--asc-color-bg-alt);
	--asc-admin-banner-title-size: 2rem;
	--asc-admin-banner-text-size: 1.05rem;
}

.asc-homepage-admin-banner__viewport--mobile {
	--asc-admin-banner-title-color: var(--asc-color-bg-alt);
	--asc-admin-banner-text-color: var(--asc-color-bg-alt);
	--asc-admin-banner-title-size: 1.35rem;
	--asc-admin-banner-text-size: 0.9rem;
}

.asc-homepage-admin-banner__media {
	line-height: 0;
}

.asc-homepage-admin-banner__image {
	width: 100%;
	height: auto;
	display: block;
	object-fit: cover;
}

.asc-homepage-admin-banner__media picture,
.asc-homepage-admin-banner__media .asc-homepage-admin-banner__image {
	width: 100%;
	height: auto;
	display: block;
}

.asc-homepage-admin-banner__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	justify-content: flex-start;
	padding: 1.5rem 2rem;
	line-height: 1.5;
	pointer-events: none;
	z-index: 1;
}

.asc-homepage-admin-banner__overlay--desktop {
	align-items: center;
}

.asc-homepage-admin-banner__overlay--mobile {
	align-items: flex-start;
	padding: 1rem;
}

.asc-homepage-admin-banner__content {
	text-align: right;
	max-width: min(50%, 640px);
	pointer-events: auto;
}

.asc-homepage-admin-banner__title {
	margin: 0 0 0.75rem;
	font-size: var(--asc-admin-banner-title-size);
	font-weight: 700;
	line-height: 1.3;
	color: var(--asc-admin-banner-title-color);
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.asc-homepage-admin-banner__text {
	margin: 0 0 1.25rem;
	font-size: var(--asc-admin-banner-text-size);
	line-height: 1.7;
	color: var(--asc-admin-banner-text-color);
	opacity: 0.95;
	text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.asc-homepage-admin-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	justify-content: flex-start;
	align-items: center;
}

.asc-homepage-admin-banner__actions .button {
	margin: 0;
	flex: 0 1 auto;
}

.asc-homepage-admin-banner__viewport--mobile .asc-homepage-admin-banner__content {
	max-width: 100%;
	margin: 15px 10px;
}

.asc-homepage-admin-banner__viewport--mobile .asc-homepage-admin-banner__title {
	margin-bottom: 0.5rem;
}

.asc-homepage-admin-banner__viewport--mobile .asc-homepage-admin-banner__text {
	margin-bottom: 1rem;
}

.asc-homepage-admin-banner__viewport--mobile .asc-homepage-admin-banner__actions {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	width: 100%;
	max-width: none;
}

.asc-homepage-admin-banner__viewport--mobile .asc-homepage-admin-banner__actions .button {
	flex: 1 1 auto;
	min-width: 0;
	max-width: 50%;
	text-align: center;
	font-size: smaller;
}

.asc-homepage-admin-banner__viewport--desktop {
	display: none;
}

.asc-homepage-admin-banner__viewport--mobile {
	display: block;
}

@media (min-width: 769px) {
	.asc-homepage-admin-banner {
		margin-top: 2em;
	}

	.asc-homepage-admin-banner__viewport--desktop {
		display: block;
		max-height: 400px;
	}

	.asc-homepage-admin-banner__viewport--mobile {
		display: none;
	}

	.asc-homepage-admin-banner__viewport--desktop .asc-homepage-admin-banner__image {
		max-height: 400px;
		object-fit: cover;
		object-position: center;
	}
}

@media (max-width: 768px) {
	.asc-homepage-admin-banner {
		margin-bottom: 1.5rem;
		max-height: unset;
	}

	.asc-homepage-admin-banner__viewport {
		max-height: unset;
	}

	.asc-homepage-admin-banner__image {
		max-height: unset;
		object-fit: cover;
		object-position: center;
	}
}

@media (max-width: 480px) {
	.asc-homepage-admin-banner {
		margin-bottom: 1rem;
	}
}

/* Box sizing for all elements */
.asc-product-categories-grid *,
.asc-best-selling-carousel *,
.asc-posts-carousel * {
	box-sizing: border-box;
}

/* Section Title - Global Style */
.section-title {
	margin-bottom: 20px;
}

/* Product Categories Grid */
.asc-product-categories-grid {
	margin: 2rem 0;
	max-width: 100%;
	overflow-x: hidden;
	padding: 0;
	box-sizing: border-box;
}

.categories-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 1rem;
	max-width: 100%;
}

.category-card {
	border: 1px solid var(--asc-color-border);
	max-width: 100%;
	overflow: hidden;
}

.category-link {
	display: block;
	text-decoration: none;
	color: inherit;
	width: 100%;
}

.category-image {
	position: relative;
	width: 100%;
	padding-top: 75%; /* 4:3 Aspect Ratio */
	overflow: hidden;
}

.category-image img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
	max-width: 100%;
}

.category-image picture {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

.category-image picture img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.category-info {
	padding: 1rem 0;
	text-align: center;
}

.category-name {
	margin: 0;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* Best Selling Products Carousel - عرض کامل */
.asc-best-selling-carousel {
	margin: 2rem 0;
	max-width: 100%;
	overflow: visible;
	padding: 0;
	box-sizing: border-box;
}

.asc-best-selling-carousel .section-title {
	padding: 0;
}

.products-carousel-wrapper {
	overflow-x: auto;
	overflow-y: hidden;
	width: 100vw;
	margin-left: unset;
	margin-right: unset;
	padding: unset;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
}

.products-carousel {
	display: flex;
	align-items: stretch;
	gap: 1rem;
	padding: unset;
	width: max-content;
	min-width: 100%;
}

/* دسکتاپ: محدودیت عرض به col-full و نمایش 4 کارت */
@media (min-width: 769px) {
	#content .col-full .asc-best-selling-carousel,
	#content .col-full .asc-posts-carousel {
		max-width: 100%;
	}

	#content .col-full .products-carousel-wrapper,
	#content .col-full .posts-carousel-wrapper {
		width: 100%;
		max-width: 100%;
		container-type: inline-size;
	}

	@container (min-width: 400px) {
		#content .col-full .product-carousel-item {
			flex: 0 0 calc((100cqw - 3rem) / 4);
			width: calc((100cqw - 3rem) / 4);
			max-width: none;
		}

		#content .col-full .post-carousel-item {
			flex: 0 0 calc((100cqw - 3rem) / 4);
			width: calc((100cqw - 3rem) / 4);
			max-width: none;
		}
	}
}

.products-carousel-wrapper::-webkit-scrollbar,
.products-carousel::-webkit-scrollbar {
	display: none; /* Chrome, Safari, Opera */
}

.products-carousel-wrapper {
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.product-carousel-item {
	flex: 0 0 auto;
	width: 220px;
	max-width: calc(100vw - 3rem);
	display: flex;
}

.product-card {
	border: 1px solid var(--asc-color-border);
	max-width: 100%;
	overflow: hidden;
	width: 100%;
	display: flex;
	flex-direction: column;
}

.product-card .product-link {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.product-link {
	text-decoration: none;
	color: inherit;
	width: 100%;
}

.product-image {
	position: relative;
	width: 100%;
	padding-top: 100%; /* 1:1 Aspect Ratio */
	overflow: hidden;
}

.product-image img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	max-width: 100%;
}

.product-info {
	padding: 1rem;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.product-title {
	margin: 0 0 0.5rem 0;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* Add to Cart & View Cart Buttons - پیروی از استایل کلی سایت */
.product-card .add_to_cart_button,
.product-card .added_to_cart,
.product-card .button.product_type_simple,
.product-card .button.product_type_variable,
.product-card .button.product_type_grouped,
.product-card .button.product_type_external {
	margin-top: auto;
	width: 100%;
	text-align: center;
	display: block;
	max-width: 100%;
	box-sizing: border-box;
	padding: 0.5rem 1rem;
	flex-shrink: 0;
	background-color: var(--asc-color-bg);
	border-color: var(--asc-color-bg);
	color: var(--asc-color-primary);
}

.product-card .added_to_cart {
	text-decoration: none;
}

/* همسان‌سازی استایل دکمه added_to_cart در کاروسل با لیست محصولات */
.asc-best-selling-carousel .product-card .added_to_cart.wc-forward {
	margin-bottom: unset !important;
	padding: 0.4em 0.8em !important;
	margin-top: auto !important;
	max-height: fit-content !important;
}

/* Posts Carousel - عرض کامل */
.asc-posts-carousel {
	margin: 2rem 0;
	max-width: 100%;
	overflow: visible;
	padding: 0;
	box-sizing: border-box;
}

.asc-posts-carousel .section-title {
	padding: 0;
}

.posts-carousel-wrapper {
	overflow-x: auto;
	overflow-y: hidden;
	width: 100vw;
	margin-left: unset;
	margin-right: unset;
	padding: unset;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
}

.posts-carousel {
	display: flex;
	align-items: stretch;
	gap: 1rem;
	padding: unset;
	width: max-content;
	min-width: 100%;
}

.posts-carousel-wrapper::-webkit-scrollbar,
.posts-carousel::-webkit-scrollbar {
	display: none;
}

.posts-carousel-wrapper {
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
}

.post-carousel-item {
	flex: 0 0 auto;
	width: 280px;
	max-width: calc(100vw - 3rem);
	display: flex;
}

.post-card {
	border: 1px solid var(--asc-color-border);
	width: 100%;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.post-card .post-card-link {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
	text-decoration: none;
	color: inherit;
}

.post-card-image {
	position: relative;
	width: 100%;
	padding-top: 56.25%;
	overflow: hidden;
	background: #f0f0f0;
}

.post-card-image img,
.post-card-image .post-placeholder {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.post-placeholder {
	background: var(--asc-color-border);
}

.post-card-content {
	padding: 1rem;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.post-card-title {
	margin: 0 0 0.5rem 0;
	font-size: 1rem;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.post-card-excerpt {
	font-size: 0.875rem;
	line-height: 1.5;
	color: var(--asc-color-text-muted);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.post-read-more {
	display: block;
	margin-top: auto;
	padding: 0.5rem 1rem;
	text-align: center;
	text-decoration: none;
	background-color: var(--asc-color-bg);
	border: 1px solid var(--asc-color-bg);
	color: var(--asc-color-primary);
	font-weight: 600;
	font-size: 16px;
	flex-shrink: 0;
	transition: opacity 0.2s;
}

.post-read-more:hover {
	opacity: 0.9;
	color: var(--asc-color-primary);
}

/* Responsive */
@media (max-width: 768px) {
	
	.categories-grid {
		grid-template-columns: repeat(3, 1fr);
		gap: 0.75rem;
		max-width: 100%;
		width: 100%;
	}
	
	.products-carousel {
		gap: 0.75rem;
		padding: 0.75rem 0;
		max-width: 100%;
		width: 100%;
	}
	
	.product-carousel-item {
		width: 180px;
		max-width: calc(50vw - 1.5rem);
		min-width: 0;
	}
	
	.post-carousel-item {
		width: 260px;
		max-width: calc(80vw - 2rem);
		min-width: 0;
	}
}

@media (max-width: 480px) {
	
	.products-carousel-wrapper {
		margin-right: -20px;
	}
	
	.posts-carousel-wrapper {
		margin-right: -20px;
	}
	
	.posts-carousel {
		gap: 0.5rem;
		padding: 0.5rem 1.2rem 0.5rem 0.5rem;
		max-width: 100%;
		width: 100%;
	}
	
	.categories-grid {
		grid-template-columns: repeat(3, 1fr);
		gap: 0.5rem;
		max-width: 100%;
		width: 100%;
	}
	
	.products-carousel {
		gap: 0.5rem;
		padding: 0.5rem 1.2rem 0.5rem 0.5rem;
		max-width: 100%;
		width: 100%;
	}
	
	.product-carousel-item {
		width: 160px;
		max-width: calc(50vw - 0.5rem);
		min-width: 0;
	}
	
	.category-info,
	.product-info {
		padding: 0.75rem;
		max-width: 100%;
		box-sizing: border-box;
	}
	
	.post-carousel-item {
		width: 220px;
		max-width: calc(85vw - 1.5rem);
		min-width: 0;
	}
	
	.post-card-excerpt {
		-webkit-line-clamp: 2;
	}
}

/* Handheld Footer Bar - Base Styles */
.storefront-handheld-footer-bar {
	position: fixed;
	bottom: 0;
	right: 0;
	left: 0;
	border-top: 1px solid rgba(255, 255, 255, .2);
	box-shadow: 0 0 1px rgba(0, 0, 0, .7) !important;
	z-index: var(--asc-z-handheld-footer, 1000002);
}

/* Prevent horizontal overflow on mobile */
@media (max-width: 768px) {
	html,
	body {
		overflow-x: hidden;
		max-width: 100vw;
		width: 100%;
	}
	
	body {
		position: relative;
	}
	
	#page,
	.site-content,
	.site-main,
	#primary,
	#main {
		max-width: 100%;
		overflow-x: hidden;
		width: 100%;
	}
	
	.page-template-template-homepage .site-main {
		padding-bottom: 0rem;
	}
	
	
	/* Ensure handheld footer bar doesn't overflow */
	.storefront-handheld-footer-bar {
		max-width: 100vw !important;
		width: 100vw !important;
		left: 0 !important;
		right: 0 !important;
		box-sizing: border-box !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
		padding-left: 0 !important;
		padding-right: 0 !important;
	}
	
	.storefront-handheld-footer-bar ul {
		max-width: 100% !important;
		width: 100% !important;
		box-sizing: border-box !important;
		margin-left: 0 !important;
		margin-right: 0 !important;
		padding-left: 0 !important;
		padding-right: 0 !important;
	}
	
	.storefront-handheld-footer-bar ul li {
		box-sizing: border-box !important;
		max-width: 100% !important;
	}
	
}
