/* ==========================================================================
   صفحه دسته (و بعدا برند، برچسب و فروشگاه)، از components.css دمو:
   کارت زیردسته، فیلتر، نوار ابزار.
   فیلترها، شمارش و مرتب سازی بلوک های ووکامرس اند. اینجا فقط ظاهر.
   مسیر راهنما، سر صفحه و صفحه بندی در components.css است (بلاگ و محصول هم دارند).
   ========================================================================== */

/* گروه های وردپرس بین فرزندها blockGap می گذارند. فاصله ها اینجا مثل دمو است. */
main.wp-block-group > *,
main > .container > * {
	margin-block: 0;
}

/* ---- Sub-category cards: همان کاشی دسته خانه، در شبکه زیردسته به شکل کارت افقی ---- */
.subcat-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--wp--preset--spacing--1);
	margin: 0;
	padding: 0;
	list-style: none;
}

.subcat-grid .cat-tile {
	gap: var(--wp--preset--spacing--1);
	min-height: var(--wp--custom--size--subcat);
	padding: var(--wp--preset--spacing--1);
	overflow: visible;
	font-weight: var(--wp--custom--font-weight--bold);
	font-size: var(--wp--preset--font-size--sm);
	line-height: var(--wp--custom--line-height--tight);
	transition: none;
}

.subcat-grid .cat-tile:hover {
	box-shadow: none;
}

.subcat-grid .cat-tile img {
	width: var(--wp--custom--size--subcat-thumb);
	height: var(--wp--custom--size--subcat-thumb);
	border-radius: var(--wp--preset--border-radius--default);
}

.subcat-grid .cat-tile__name {
	display: inline;
	flex: initial;
	min-height: 0;
	padding: 0;
}

@media (min-width: 48em) {
	.subcat-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--wp--preset--spacing--2);
	}

	/* کاشی خانه در این عرض عمودی می شود. کارت زیردسته افقی می ماند. */
	.subcat-grid .cat-tile {
		flex-direction: row;
		align-items: center;
	}

	.subcat-grid .cat-tile img {
		aspect-ratio: auto;
	}

	.subcat-grid .cat-tile__name {
		justify-content: flex-start;
		min-height: 0;
		text-align: start;
	}
}

@media (min-width: 64em) {
	.subcat-grid {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}
}

/* ---- Catalog: فیلترها و شبکه داخل «مجموعه محصولات» ---- */
.wp-block-woocommerce-product-collection.catalog {
	display: grid;
	gap: var(--wp--preset--spacing--3);
}

.catalog > *,
.catalog__main > * {
	margin-block: 0;
}

/* جای پیام های ووکامرس (خالی در حالت کاتالوگ) ستون فیلتر را نگیرد */
.catalog > .wc-block-components-notices {
	display: contents;
}

.catalog > .wc-block-components-notices > * {
	grid-column: 1 / -1;
}

@media (min-width: 64em) {
	.wp-block-woocommerce-product-collection.catalog {
		grid-template-columns: var(--wp--custom--size--filters) minmax(0, 1fr);
		align-items: start;
		gap: var(--wp--preset--spacing--4);
	}
}

/* ---- Filters: بلوک «جزئیات» هسته دور «فیلترهای محصول» ووکامرس ---- */
.filters {
	border: var(--wp--custom--border-width) solid var(--wp--custom--color--border);
	border-radius: var(--wp--preset--border-radius--default);
	background: var(--wp--custom--color--surface);
}

.filters > summary {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--1);
	min-height: var(--wp--custom--size--control);
	padding: 0 var(--wp--preset--spacing--2);
	font-weight: var(--wp--custom--font-weight--bold);
	cursor: pointer;
	list-style: none;
}

.filters > summary::-webkit-details-marker {
	display: none;
}

/* آیکن قیف دمو */
.filters > summary::before {
	content: "";
	flex: none;
	width: var(--wp--custom--size--icon);
	height: var(--wp--custom--size--icon);
	background: var(--wp--preset--color--primary);
	-webkit-mask: var(--cn-icon-filter) center / contain no-repeat;
	mask: var(--cn-icon-filter) center / contain no-repeat;
}

/* فلش یک شکل چرخیده است، نه جهت متن */
.filters > summary::after {
	content: "";
	width: var(--wp--custom--size--chevron);
	height: var(--wp--custom--size--chevron);
	margin-inline-start: auto;
	border-right: var(--wp--custom--border-width-thick) solid currentColor;
	border-bottom: var(--wp--custom--border-width-thick) solid currentColor;
	transform: translateY(-25%) rotate(45deg);
}

.filters[open] > summary::after {
	transform: translateY(25%) rotate(-135deg);
}

.filters > .filters__form {
	display: block;
	margin: 0;
	padding: 0 var(--wp--preset--spacing--2) var(--wp--preset--spacing--2);
}

.filters__form .wc-block-product-filters__content {
	display: block;
}

.filters__form .filter-group {
	margin: 0;
	padding: var(--wp--preset--spacing--2) 0;
	border-top: var(--wp--custom--border-width) solid var(--wp--custom--color--border);
}

.filters__form .filter-group > * {
	margin-block: 0;
}

.filters__form .filter-group__title {
	margin-bottom: var(--wp--preset--spacing--1);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: var(--wp--custom--font-weight--bold);
	line-height: var(--wp--custom--line-height--body);
}

/* فهرست گزینه ها: چک باکس معمولی با رنگ اصلی، مثل .check دمو */
.filters__form .wc-block-product-filter-checkbox-list__label {
	display: flex;
	gap: var(--wp--preset--spacing--1);
	min-height: var(--wp--custom--size--tap);
	cursor: pointer;
}

.filters__form .wc-block-product-filter-checkbox-list__input-wrapper::before,
.filters__form svg.wc-block-product-filter-checkbox-list__mark {
	display: none;
}

.filters__form input[type="checkbox"].wc-block-product-filter-checkbox-list__input {
	appearance: auto;
	width: var(--wp--custom--size--icon);
	height: var(--wp--custom--size--icon);
	border: 0;
	accent-color: var(--wp--preset--color--primary);
}

.filters__form input[type="checkbox"].wc-block-product-filter-checkbox-list__input:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--custom--color--focus);
	outline-offset: var(--wp--custom--focus--offset);
}

.filters__form .wc-block-product-filter-checkbox-list__text-wrapper {
	font-size: var(--wp--preset--font-size--sm);
}

.filters__form .wc-block-product-filter-checkbox-list__show-more-button {
	min-height: var(--wp--custom--size--tap);
	color: var(--wp--preset--color--primary);
	font-size: var(--wp--preset--font-size--sm);
}

/* «پاک کردن»: فقط وقتی فیلتری فعال است (بلوک فیلترهای فعال ووکامرس) */
.filters__clear {
	padding-top: var(--wp--preset--spacing--2);
	border-top: var(--wp--custom--border-width) solid var(--wp--custom--color--border);
}

.filters__clear .wp-block-buttons {
	margin: 0;
}

.cn-btn--outline > .wp-block-button__link {
	background: var(--wp--custom--color--surface);
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
}

.cn-btn--outline > .wp-block-button__link:hover {
	background: var(--wp--preset--color--primary-soft);
	color: var(--wp--preset--color--primary-strong);
}

.cn-btn--sm > .wp-block-button__link {
	width: auto;
	min-height: var(--wp--custom--size--tap);
	padding: 0 var(--wp--preset--spacing--2);
	font-size: var(--wp--preset--font-size--sm);
}

/* ---- Toolbar: تیتر شبکه، شمارش و مرتب سازی ---- */
.catalog__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--1) var(--wp--preset--spacing--2);
	margin-bottom: var(--wp--preset--spacing--2);
}

.catalog__toolbar > *,
.catalog__toolbar > * > * {
	margin-block: 0;
}

.catalog .catalog__title {
	font-size: var(--wp--preset--font-size--lg);
}

.catalog__toolbar .catalog__count .woocommerce-result-count {
	margin: 0;
	color: var(--wp--custom--color--text-muted);
	font-size: var(--wp--preset--font-size--sm);
}

.catalog__toolbar .select {
	font-size: var(--wp--preset--font-size--sm);
}

.select .woocommerce-ordering {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--preset--spacing--1);
	margin: 0;
	font-size: var(--wp--preset--font-size--sm);
}

.select .woocommerce-ordering label {
	margin: 0;
}

.select select {
	font-size: inherit;
	min-height: var(--wp--custom--size--control);
	padding: 0 var(--wp--preset--spacing--2);
	border: var(--wp--custom--border-width-thick) solid var(--wp--custom--color--border-strong);
	border-radius: var(--wp--preset--border-radius--default);
	background-color: var(--wp--custom--color--surface);
}

.select select:focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--preset--color--primary-soft);
	outline-offset: 0;
	border-color: var(--wp--preset--color--primary);
}

/* شبکه کنار فیلتر: 3 ستون در lg و 4 ستون از 80em، مثل دمو */
@media (min-width: 64em) {
	.catalog .wc-block-product-template.product-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 80em) {
	.catalog .wc-block-product-template.product-grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}


/* ==========================================================================
   فیلدهای دسته، برند و برچسب (جلسه 11): جمله پرمصرف ها، محتوای آزاد، راهنمای خرید و
   دسته های مکمل. از category.html و subcategory.html دمو. نکته مغازه، سوال ها، جدول
   مقایسه (.table) و برچسب ها در components.css است.
   ========================================================================== */

/* جمله پرمصرف ها، زیر متن معرفی سر صفحه */
.page-head .page-head__popular {
	max-width: var(--wp--custom--size--lead);
	margin-block-start: var(--wp--preset--spacing--1);
	font-weight: var(--wp--custom--font-weight--bold);
}

/* محتوای آزاد: الگوی همگام. فاصله داخل خود الگو است. */
.term-content .container > :first-child {
	margin-block-start: 0;
}

.term-content .container > :last-child {
	margin-block-end: 0;
}

/* ---- راهنمای خرید (متن پایین): متن تمام عرض کادر (آیتم 19، جلسه 22) ---- */
.guide-box {
	padding: var(--wp--preset--spacing--3);
	border: var(--wp--custom--border-width) solid var(--wp--custom--color--border);
	border-inline-start: var(--wp--custom--accent-border-thick) solid var(--wp--preset--color--primary);
	border-radius: var(--wp--preset--border-radius--default);
	background: var(--wp--custom--color--surface);
}

.guide-box__body > *,
.guide-more__content > * {
	margin-block: 0 var(--wp--preset--spacing--2);
}

.guide-box__body > h2,
.guide-more__content > h2 {
	margin-block-start: var(--wp--preset--spacing--4);
}

.guide-box__body > h3,
.guide-more__content > h3 {
	margin-block-start: var(--wp--preset--spacing--3);
}

.guide-box__body > :first-child,
.guide-more__content > :first-child {
	margin-block-start: 0;
}

.guide-box__body > :last-child,
.guide-more__content > :last-child {
	margin-block-end: 0;
}

.guide-box__body li {
	margin-bottom: var(--wp--preset--spacing--half);
}

.guide-box__body .table-wrap {
	margin-block: var(--wp--preset--spacing--3);
}

.guide-more {
	margin-block: var(--wp--preset--spacing--2) var(--wp--preset--spacing--3);
}

.guide-more > summary {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--preset--spacing--1);
	min-height: var(--wp--custom--size--tap);
	padding: 0 var(--wp--preset--spacing--2);
	border: var(--wp--custom--border-width-thick) solid var(--wp--preset--color--primary);
	border-radius: var(--wp--preset--border-radius--default);
	color: var(--wp--preset--color--primary);
	font-weight: var(--wp--custom--font-weight--bold);
	cursor: pointer;
	list-style: none;
}

.guide-more > summary::-webkit-details-marker {
	display: none;
}

/* فلش مثل .faq، یک شکل چرخیده است نه جهت متن */
.guide-more > summary::after {
	content: "";
	width: var(--wp--custom--size--chevron);
	height: var(--wp--custom--size--chevron);
	border-right: var(--wp--custom--border-width-thick) solid currentColor;
	border-bottom: var(--wp--custom--border-width-thick) solid currentColor;
	transform: translateY(-25%) rotate(45deg);
}

.guide-more[open] > summary::after {
	transform: translateY(25%) rotate(-135deg);
}

.guide-more > summary:hover {
	background: var(--wp--preset--color--primary-soft);
}

.guide-more__close,
.guide-more[open] .guide-more__open {
	display: none;
}

.guide-more[open] .guide-more__close {
	display: inline;
}

.guide-more__content {
	margin-block-start: var(--wp--preset--spacing--3);
}

/* دسته های مکمل بعد از «راهنماهای مرتبط»: مثل دمو یک زمینه، بدون فاصله دوباره بین دو بخش */
.section--alt + .term-related {
	padding-block-start: 0;
}

@media (min-width: 64em) {
	.guide-box {
		padding: var(--wp--preset--spacing--4) var(--wp--preset--spacing--5);
	}
}
