/*
 * Catalog layout (body.pcm-catalog: shop + product archives). Presentation only.
 * Grid: 4 columns desktop / 3 tablet (768–1024) / 2 mobile (<768).
 */

/* ---------- Wide showcase: wider container, thin side fields (catalog pages only) ----------
 * Astra limits the shop to 1340px (.ast-container) and the white box adds ~107px padding per side.
 */
@media (min-width: 768px) {
	body.pcm-catalog #content > .ast-container {
		max-width: 1760px;
		padding-left: 24px;
		padding-right: 24px;
	}

	body.pcm-catalog .ast-woocommerce-container {
		padding-left: 40px;
		padding-right: 40px;
	}
}

@media (min-width: 768px) and (max-width: 1024px) {
	body.pcm-catalog #content > .ast-container {
		padding-left: 16px;
		padding-right: 16px;
	}

	body.pcm-catalog .ast-woocommerce-container {
		padding-left: 28px;
		padding-right: 28px;
	}
}

/* Solid white page behind the catalog (no grey frame around the white box). */
body.pcm-catalog,
body.pcm-catalog.ast-separate-container,
body.pcm-catalog #content {
	background-color: #fff;
}

/* ---------- Page frame: products use the whole content width ---------- */
body.pcm-catalog #primary {
	width: 100%;
	float: none;
	margin-left: 0;
	margin-right: 0;
	padding-left: 0;
	padding-right: 0;
	border: 0;
}

body.pcm-catalog .woocommerce-products-header {
	margin-bottom: 0;
}

body.pcm-catalog .woocommerce-products-header__title.page-title {
	margin-bottom: 24px;
}

/* ---------- Toolbar: [Фильтр] ........ [Сортировка] ---------- */
body.pcm-catalog .pcm-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 12px 16px;
	margin: 0 0 32px;
	padding: 0 0 20px;
	border-bottom: 1px solid #e6e6e6;
}

body.pcm-catalog .pcm-toolbar__filter,
body.pcm-catalog .pcm-toolbar__sort {
	display: flex;
	align-items: center;
	min-width: 0;
}

/* shared compact «button» look */
body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay,
body.pcm-catalog .pcm-toolbar__sort {
	height: 42px;
	border: 1px solid #1a1a1a;
	border-radius: 0;
	background: #fff;
	color: #1a1a1a;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	line-height: 1;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay {
	display: inline-flex !important;
	align-items: center;
	gap: 8px;
	padding: 0 18px 0 14px;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay:hover,
body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay:focus-visible {
	background: #1a1a1a;
	color: #fff;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay span {
	padding: 0;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay svg {
	width: 20px;
	height: 20px;
}

/* Sorting: native WooCommerce select, styled as a compact button (the option list opens natively). */
body.pcm-catalog .pcm-toolbar__sort {
	position: relative;
	padding: 0 0 0 16px;
	gap: 6px;
}

body.pcm-catalog .pcm-toolbar__sort-label {
	white-space: nowrap;
}

body.pcm-catalog .pcm-toolbar__sort .woocommerce-ordering {
	margin: 0;
	float: none;
}

body.pcm-catalog .pcm-toolbar__sort select.orderby {
	height: 40px;
	min-width: 0;
	margin: 0;
	padding: 0 38px 0 0;
	border: 0;
	border-radius: 0;
	background-color: transparent;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231a1a1a' stroke-width='1.6'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	color: #1a1a1a;
	font-size: 13px;
	font-weight: 400;
	letter-spacing: 0.02em;
	text-transform: none;
	cursor: pointer;
}

body.pcm-catalog .pcm-toolbar__sort select.orderby:focus {
	outline: none;
}

body.pcm-catalog .pcm-toolbar__sort:focus-within {
	outline: 2px solid #1a1a1a;
	outline-offset: 2px;
}

/* ---------- View switch: «вид каталога · [мозаика] [сетка]» ---------- */
body.pcm-catalog .pcm-toolbar .pcm-view-switch {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-left: auto; /* groups the switch with the sorting on the right */
	color: #1a1a1a;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

body.pcm-catalog .pcm-toolbar .pcm-view-switch__dot {
	margin: 0 2px;
}

body.pcm-catalog .pcm-toolbar .pcm-view-switch__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin: 0;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0;
	background: transparent !important;
	box-shadow: none !important;
	color: #bdbdbd !important;
	cursor: pointer;
	transition: color 0.2s ease;
}

body.pcm-catalog .pcm-toolbar .pcm-view-switch__btn:hover,
body.pcm-catalog .pcm-toolbar .pcm-view-switch__btn[aria-pressed="true"] {
	color: #1a1a1a !important;
}

body.pcm-catalog .pcm-toolbar .pcm-view-switch__btn svg {
	width: 20px;
	height: 20px;
	display: block;
}

/* ---------- Mosaic view: every 13 products = 8 regular + (4 regular around one 2x2 tile);
 * the large tile alternates right (26n+11) / left (26n+22). ---------- */
body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+11),
body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+22) {
	grid-column: span 2;
	grid-row: span 2;
}

/* the photo area of the large tile fills both rows (minus its own title/price) */
body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+11) .astra-shop-thumbnail-wrap,
body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+22) .astra-shop-thumbnail-wrap {
	aspect-ratio: auto;
	flex: 1 1 0;
	min-height: 0;
}

body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+11) .astra-shop-thumbnail-wrap > a.woocommerce-LoopProduct-link,
body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+22) .astra-shop-thumbnail-wrap > a.woocommerce-LoopProduct-link {
	position: absolute;
	inset: 0;
}

body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+11) .astra-shop-thumbnail-wrap img,
body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+22) .astra-shop-thumbnail-wrap img {
	padding: 10%;
}

/* Accent photo (the product's 2nd photo) in a large tile — switched on by catalog-view.js (li.pcm-alt-on). */
body.pcm-catalog ul.products li.product .astra-shop-thumbnail-wrap img.pcm-alt-img,
body.pcm-catalog ul.products li.product.pcm-alt-on .astra-shop-thumbnail-wrap img:not(.pcm-alt-img) {
	display: none;
}

body.pcm-catalog ul.products li.product.pcm-alt-on .astra-shop-thumbnail-wrap img.pcm-alt-img {
	display: block;
}

/* lifestyle photo: fills the whole tile */
body.pcm-catalog.pcm-view-mosaic ul.products li.product.pcm-alt-on .astra-shop-thumbnail-wrap img.pcm-alt-img--cover {
	padding: 0;
	object-fit: cover;
	mix-blend-mode: normal;
}

/* ---------- Filters drawer (Product Filters block overlay, on every screen width) ---------- */
body.pcm-catalog .pcm-toolbar .wc-block-product-filters {
	display: block;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay {
	position: fixed !important;
	inset: 0 !important;
	z-index: 99999;
	background: transparent !important;
	pointer-events: none !important;
	transition: background-color 0.3s ease !important;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters.is-overlay-opened .wc-block-product-filters__overlay {
	background: rgba(0, 0, 0, 0.45) !important;
	pointer-events: auto !important;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-wrapper {
	position: relative;
	width: 100% !important;
	height: 100% !important;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-dialog {
	position: absolute !important;
	top: 0 !important;
	bottom: 0 !important;
	left: 0 !important;
	right: auto !important;
	width: min(420px, 100%) !important;
	max-height: 100%;
	display: flex !important;
	flex-direction: column;
	background: #fff !important;
	color: #1a1a1a !important;
	box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
	transform: translateX(-105%) !important;
	transition: transform 0.35s ease !important;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters.is-overlay-opened .wc-block-product-filters__overlay-dialog {
	transform: translateX(0) !important;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-header {
	display: flex !important;
	justify-content: flex-end;
	padding: 16px 20px 0;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__close-overlay {
	display: flex !important;
	align-items: center;
	background: transparent;
	border: 0;
	color: #1a1a1a;
	font-size: 13px;
	cursor: pointer;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-content {
	flex: 1 1 auto;
	overflow-y: auto !important;
	padding: 8px 28px 24px !important;
	gap: 28px;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-content > h2 {
	font-size: 20px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-content h3 {
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* price inputs: room for values like «1 050 000 ₽» */
body.pcm-catalog .pcm-toolbar .wc-block-product-filter-price-slider__left,
body.pcm-catalog .pcm-toolbar .wc-block-product-filter-price-slider__right {
	width: auto;
	min-width: 0;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filter-price-slider__left input,
body.pcm-catalog .pcm-toolbar .wc-block-product-filter-price-slider__right input {
	width: 130px;
	max-width: 100%;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-footer {
	display: flex !important;
	padding: 16px 28px 24px;
	border-top: 1px solid #eee;
}

body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__apply {
	width: 100%;
	height: 46px;
	border: 0;
	border-radius: 0;
	background: #1a1a1a;
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	cursor: pointer;
}

/* ---------- Product grid ---------- */
body.pcm-catalog ul.products {
	display: grid !important;
	grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
	column-gap: 20px !important;
	row-gap: 40px !important;
	margin: 0 !important;
	padding: 0;
}

body.pcm-catalog ul.products::before,
body.pcm-catalog ul.products::after {
	display: none !important;
}

body.pcm-catalog ul.products li.product {
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	clear: none !important;
	display: flex;
	flex-direction: column;
}

/* equal portrait (3:4) image area, whole image visible (no cropping) */
body.pcm-catalog ul.products li.product .astra-shop-thumbnail-wrap {
	position: relative;
	margin: 0 0 14px;
	background: #f4f4f4;
	aspect-ratio: 3 / 4;
	overflow: hidden;
}

body.pcm-catalog ul.products li.product .astra-shop-thumbnail-wrap > a.woocommerce-LoopProduct-link {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

body.pcm-catalog ul.products li.product .astra-shop-thumbnail-wrap img {
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 8%;
	box-sizing: border-box;
	object-fit: contain;
	mix-blend-mode: multiply; /* white photo backgrounds merge into the tile */
	transition: transform 0.35s ease;
}

body.pcm-catalog ul.products li.product:hover .astra-shop-thumbnail-wrap img {
	transform: scale(1.03);
}

/* card text */
body.pcm-catalog ul.products li.product .astra-shop-summary-wrap {
	padding: 0;
	text-align: left;
}

body.pcm-catalog ul.products li.product .woocommerce-loop-product__title {
	margin: 0 0 4px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
	letter-spacing: 0.02em;
}

body.pcm-catalog ul.products li.product .pcm-loop-collection {
	margin: 0 0 6px;
	font-size: 12px;
}

body.pcm-catalog ul.products li.product .price {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
}

body.pcm-catalog ul.products li.product .pcm-stock {
	font-size: 12px;
}

/* «Показать ещё» (above the regular pagination) */
body.pcm-catalog .pcm-load-more {
	display: flex;
	justify-content: center;
	margin: 56px 0 0;
}

body.pcm-catalog .pcm-load-more__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 240px;
	height: 48px;
	padding: 0 32px;
	border: 1px solid #1a1a1a;
	background: #fff;
	color: #1a1a1a;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

body.pcm-catalog .pcm-load-more__btn:hover,
body.pcm-catalog .pcm-load-more__btn:focus-visible {
	background: #1a1a1a;
	color: #fff;
}

body.pcm-catalog .pcm-load-more__btn.is-loading {
	opacity: 0.6;
	pointer-events: none;
}

/* pagination */
body.pcm-catalog .woocommerce-pagination {
	margin-top: 32px;
}

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
	/* mosaic below desktop: the large product takes a whole row */
	body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+11),
	body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+22) {
		grid-column: 1 / -1;
		grid-row: auto;
	}

	body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+11) .astra-shop-thumbnail-wrap,
	body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+22) .astra-shop-thumbnail-wrap {
		aspect-ratio: 4 / 3;
		flex: none;
	}

	body.pcm-catalog ul.products {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
		column-gap: 20px !important;
		row-gap: 36px !important;
	}
}

/* ---------- Mobile: exactly 2 per row ---------- */
@media (max-width: 767px) {
	/* long category names («Шариковые ручки», «Перьевые ручки») must fit the screen */
	body.pcm-catalog .woocommerce-products-header__title.page-title {
		margin-bottom: 16px;
		font-size: clamp(30px, 9.5vw, 44px);
		line-height: 1.1;
		overflow-wrap: anywhere;
	}

	body.pcm-catalog .pcm-toolbar {
		flex-wrap: wrap;
		gap: 10px;
		margin-bottom: 20px;
		padding-bottom: 12px;
	}

	body.pcm-catalog .pcm-toolbar__filter,
	body.pcm-catalog .pcm-toolbar__sort {
		flex: 1 1 calc(50% - 5px);
	}

	body.pcm-catalog .pcm-toolbar__filter {
		order: 1;
	}

	body.pcm-catalog .pcm-toolbar__sort {
		order: 2;
	}

	/* view switch: own line under Filter / Sort, right-aligned */
	body.pcm-catalog .pcm-toolbar .pcm-view-switch {
		order: 3;
		flex: 1 1 100%;
		justify-content: flex-end;
		margin-left: 0;
	}

	body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+11) .astra-shop-thumbnail-wrap,
	body.pcm-catalog.pcm-view-mosaic ul.products > li:nth-child(26n+22) .astra-shop-thumbnail-wrap {
		aspect-ratio: 1 / 1;
	}

	body.pcm-catalog .pcm-toolbar .wc-block-product-filters,
	body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay {
		width: 100%;
	}

	body.pcm-catalog .pcm-toolbar .wc-block-product-filters__open-overlay {
		justify-content: center;
		padding: 0 10px;
	}

	body.pcm-catalog .pcm-toolbar__sort {
		padding-left: 10px;
	}

	body.pcm-catalog .pcm-toolbar__sort-label {
		display: none;
	}

	body.pcm-catalog .pcm-toolbar__sort .woocommerce-ordering {
		width: 100%;
	}

	body.pcm-catalog .pcm-toolbar__sort select.orderby {
		width: 100%;
		padding-right: 28px;
		background-position: right 10px center;
		font-size: 12px;
		text-overflow: ellipsis;
	}

	body.pcm-catalog .pcm-toolbar .wc-block-product-filters .wc-block-product-filters__overlay-dialog {
		width: 100% !important;
	}

	body.pcm-catalog ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
		column-gap: 12px !important;
		row-gap: 28px !important;
	}

	body.pcm-catalog ul.products li.product .astra-shop-thumbnail-wrap {
		margin-bottom: 10px;
	}

	body.pcm-catalog ul.products li.product .woocommerce-loop-product__title {
		font-size: 13px;
	}

	body.pcm-catalog ul.products li.product .price {
		font-size: 14px;
	}
}
