/**
 * Custom Product Filter Styles
 *
 * Дополнительно:
 * - стили облака тегов рядом с товарами;
 * - плавные появления карточек;
 * - более живые hover-эффекты;
 * - анимация раскрытия фильтров;
 * - поддержка prefers-reduced-motion.
 *
 * @package vigor
 */

.vigor-filter {
	position: sticky;
	top: 120px;
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 7.5rem);
	max-height: calc(100dvh - 7.5rem);
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	background: #fff;
	border: 1px solid var(--line, #e2e8f0);
	border-radius: var(--r-16, 16px);
	padding: var(--s-20, 20px);
	margin-bottom: var(--s-20, 20px);
	box-shadow: 0 8px 28px rgba(15, 23, 42, 0.04);
	transition:
		border-color 0.28s ease,
		box-shadow 0.28s ease,
		transform 0.28s ease;
}

.vigor-filter:hover {
	border-color: rgba(8, 37, 103, 0.18);
	box-shadow: 0 12px 32px rgba(15, 23, 42, 0.07);
}

.vigor-filter__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	position: sticky;
	top: 0;
	z-index: 2;
	margin-bottom: var(--s-20, 20px);
	padding-bottom: var(--s-16, 16px);
	border-bottom: 1px solid var(--line, #e2e8f0);
	background: #fff;
}

.vigor-filter__header-actions {
	display: flex;
	align-items: center;
	gap: var(--s-8, 8px);
}

.vigor-filter__close-drawer {
	display: none;
}

.vigor-filter__header-title {
	font-size: var(--fs-20, 20px);
	font-weight: 700;
	margin: 0;
	color: var(--ink-2, #1e293b);
}

.vigor-filter__header-reset {
	background: transparent;
	border: none;
	color: var(--brand-700, #082567);
	font-size: var(--fs-14, 14px);
	font-weight: 600;
	cursor: pointer;
	padding: var(--s-4, 4px) var(--s-8, 8px);
	text-decoration: underline;
	text-underline-offset: 3px;
	transition:
		color 0.2s ease,
		opacity 0.2s ease;
}

.vigor-filter__header-reset:hover {
	color: var(--brand-800, #051b4d);
	opacity: 0.78;
}

.vigor-filter__form {
	display: flex;
	flex-direction: column;
	gap: var(--s-12, 12px);
}

.vigor-filter__group {
	border-bottom: 1px solid var(--line, #e2e8f0);
	padding-bottom: var(--s-12, 12px);
	transition:
		border-color 0.2s ease,
		background-color 0.2s ease;
}

.vigor-filter__group:last-child {
	border-bottom: none;
	padding-bottom: 0;
}

.vigor-filter__group-toggle {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	background: transparent;
	border: 0;
	padding: 2px 0;
	cursor: pointer;
	text-align: left;
	border-radius: 8px;
	transition:
		color 0.2s ease,
		background-color 0.2s ease;
}

.vigor-filter__group-toggle:hover {
	color: var(--brand-700, #082567);
}

.vigor-filter__group-toggle::after {
	content: "";
	width: 10px;
	height: 10px;
	border-right: 2px solid var(--ink-3, #64748b);
	border-bottom: 2px solid var(--ink-3, #64748b);
	transform: rotate(45deg);
	transform-origin: center;
	transition:
		transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
		border-color 0.2s ease;
	flex: 0 0 auto;
	margin-top: -2px;
}

.vigor-filter__group-toggle:hover::after {
	border-color: var(--brand-700, #082567);
}

.vigor-filter__group.is-expanded .vigor-filter__group-toggle::after {
	transform: rotate(-135deg);
	margin-top: 0;
}

.vigor-filter__panel {
	margin-top: var(--s-12, 12px);
	transform-origin: top;
	animation: vigor-filter-panel-in 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes vigor-filter-panel-in {
	from {
		opacity: 0;
		transform: translateY(-5px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.vigor-filter__title {
	font-size: var(--fs-14, 14px);
	font-weight: 700;
	margin: 0 0 var(--s-12, 12px) 0;
	color: var(--ink-2, #1e293b);
}

.vigor-filter__group-toggle .vigor-filter__title {
	margin: 0;
}

.vigor-filter__options {
	display: flex;
	flex-direction: column;
	gap: var(--s-2, 2px);
	max-height: 250px;
	padding-right: var(--s-12, 12px);
	overflow-y: auto;
}

.vigor-filter__option {
	display: flex;
	align-items: center;
	gap: var(--s-8, 8px);
	cursor: pointer;
	padding: 6px 8px;
	margin-inline: -8px;
	border-radius: 8px;
	font-size: var(--fs-14, 14px);
	color: var(--ink-2, #1e293b);
	transition:
		background-color 0.18s ease,
		color 0.18s ease,
		transform 0.18s ease;
}

.vigor-filter__option:hover {
	background: var(--bg-2, #f1f3f9);
	color: var(--brand-700, #082567);
	transform: translateX(2px);
}

.vigor-filter__option input[type="checkbox"],
.vigor-filter__option input[type="radio"] {
	width: 18px;
	height: 18px;
	cursor: pointer;
	accent-color: var(--brand-600, #082567);
	flex-shrink: 0;
}

.vigor-filter__option span {
	flex: 1;
}

.vigor-filter__option small {
	color: var(--ink-3, #64748b);
	font-size: var(--fs-12, 12px);
}

.vigor-filter__price-range {
	display: flex;
	align-items: center;
	gap: var(--s-8, 8px);
}

.vigor-filter__price-input {
	width: 100%;
	height: 44px;
	padding: 0 var(--s-12, 12px);
	border: 1px solid var(--line, #e2e8f0);
	border-radius: var(--r-12, 12px);
	font-size: var(--fs-14, 14px);
	color: var(--ink-2, #1e293b);
	background: #fff;
	transition:
		border-color 0.2s ease,
		box-shadow 0.2s ease,
		transform 0.2s ease;
}

.vigor-filter__price-input:hover {
	border-color: rgba(8, 37, 103, 0.32);
}

.vigor-filter__price-input:focus {
	outline: none;
	border-color: var(--brand-600, #082567);
	box-shadow: 0 0 0 3px rgba(8, 37, 103, 0.1);
}

.vigor-filter__price-range span {
	color: var(--ink-3, #64748b);
	font-weight: 500;
}

/* ==========================================================================
 * Applied filters
 * ========================================================================== */

.applied__wrap {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s-8, 8px);
	align-items: center;
}

.applied__label {
	font-size: var(--fs-14, 14px);
	font-weight: 600;
	color: var(--ink-2, #1e293b);
}

.chip--applied {
	background: var(--brand-100, #eef2ff);
	color: var(--brand-700, #082567);
	border-color: var(--brand-300, #a5b4fc);
	cursor: pointer;
	transition:
		background-color 0.2s ease,
		border-color 0.2s ease,
		color 0.2s ease,
		transform 0.2s ease,
		box-shadow 0.2s ease;
}

.chip--applied:hover {
	background: var(--brand-200, #e0e7ff);
	transform: translateY(-1px);
	box-shadow: 0 5px 14px rgba(8, 37, 103, 0.1);
}

.applied__reset {
	background: transparent;
	border: none;
	color: var(--brand-700, #082567);
	font-size: var(--fs-14, 14px);
	font-weight: 600;
	cursor: pointer;
	padding: var(--s-4, 4px) var(--s-8, 8px);
	text-decoration: underline;
	text-underline-offset: 3px;
	transition:
		color 0.2s ease,
		opacity 0.2s ease;
}

.applied__reset:hover {
	color: var(--brand-800, #051b4d);
	opacity: 0.75;
}

/* ==========================================================================
 * Облако тегов около карточек товаров
 * ========================================================================== */

.catalog-tag-cloud {
	margin: 0 0 14px;
	padding: 14px 16px;
	background:
		linear-gradient(
			135deg,
			rgba(8, 37, 103, 0.035),
			rgba(201, 169, 91, 0.08)
		),
		#fff;
	border: 1px solid rgba(8, 37, 103, 0.1);
	border-radius: var(--r-16, 16px);
	box-shadow: 0 7px 22px rgba(15, 23, 42, 0.035);
	overflow: hidden;
	animation: vigor-catalog-fade-in 0.4s ease both;
}

.catalog-tag-cloud::before {
	content: "";
	position: absolute;
	top: -40px;
	right: -30px;
	width: 110px;
	height: 110px;
	border-radius: 50%;
	background: rgba(201, 169, 91, 0.08);
	pointer-events: none;
}

.catalog-tag-cloud__head {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
	color: var(--ink-2, #1e293b);
}

.catalog-tag-cloud__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	flex: 0 0 26px;
	border-radius: 8px;
	background: var(--brand-600, #082567);
	color: #fff;
	font-size: 14px;
	font-weight: 800;
	line-height: 1;
	box-shadow: 0 5px 12px rgba(8, 37, 103, 0.16);
}

.catalog-tag-cloud__title {
	font-size: var(--fs-14, 14px);
	font-weight: 700;
	line-height: 1.3;
}

.tag-cloud,
.tag-cloud--catalog {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 7px;
}

.tag-cloud__item {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	height: auto;
	padding: 7px 13px;
	border: 1px solid rgba(8, 37, 103, 0.13);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.88);
	color: var(--ink-2, #1e293b);
	box-shadow: none;
	font-size: var(--fs-13, 13px);
	font-weight: 600;
	line-height: 1.2;
	white-space: normal;
	text-align: center;
	text-decoration: none;
	transition:
		transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
		background-color 0.22s ease,
		border-color 0.22s ease,
		color 0.22s ease,
		box-shadow 0.22s ease;
}

.tag-cloud__item::before {
	content: "#";
	margin-right: 4px;
	color: var(--brand-600, #082567);
	font-weight: 800;
	opacity: 0.62;
	transition:
		color 0.22s ease,
		opacity 0.22s ease;
}

.tag-cloud__item:hover {
	transform: translateY(-2px);
	background: var(--brand-600, #082567);
	border-color: var(--brand-600, #082567);
	color: #fff;
	box-shadow: 0 8px 18px rgba(8, 37, 103, 0.16);
	text-decoration: none;
}

.tag-cloud__item:hover::before {
	color: #fff;
	opacity: 0.82;
}

.tag-cloud__item.is-active {
	background: var(--brand-600, #082567);
	border-color: var(--brand-600, #082567);
	color: #fff;
	box-shadow: 0 7px 18px rgba(8, 37, 103, 0.18);
}

.tag-cloud__item.is-active::before {
	color: #fff;
	opacity: 0.85;
}

/* ==========================================================================
 * Плавность каталога и карточек
 * ========================================================================== */

@keyframes vigor-catalog-fade-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.category .cat-head__row {
	animation: vigor-catalog-fade-in 0.36s ease both;
}

.category .subcats-block {
	animation: vigor-catalog-fade-in 0.4s 0.04s ease both;
}

.category .applied__wrap {
	animation: vigor-catalog-fade-in 0.4s 0.07s ease both;
}

.cat-products > .products-grid {
	transition:
		opacity 0.24s ease,
		transform 0.24s ease;
}

.products-grid > .product-card {
	animation: vigor-catalog-fade-in 0.38s ease both;
	will-change: transform;
	transition:
		transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
		box-shadow 0.3s ease,
		border-color 0.3s ease;
}

.products-grid > .product-card:nth-child(2) {
	animation-delay: 0.025s;
}

.products-grid > .product-card:nth-child(3) {
	animation-delay: 0.05s;
}

.products-grid > .product-card:nth-child(4) {
	animation-delay: 0.075s;
}

.products-grid > .product-card:nth-child(5) {
	animation-delay: 0.1s;
}

.products-grid > .product-card:nth-child(6) {
	animation-delay: 0.125s;
}

.products-grid > .product-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 14px 32px rgba(15, 23, 42, 0.11);
	border-color: rgba(8, 37, 103, 0.16);
}

.products-grid > .product-card .product-card__thumb img {
	transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.products-grid > .product-card:hover .product-card__thumb img {
	transform: scale(1.025);
}

.products-grid > .product-card .product-card__actions {
	transition: transform 0.26s ease;
}

.products-grid > .product-card:hover .product-card__actions {
	transform: translateY(-1px);
}

.subcat {
	transition:
		transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
		background-color 0.26s ease,
		border-color 0.26s ease,
		box-shadow 0.26s ease,
		color 0.26s ease;
}

.subcat:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 18px rgba(15, 23, 42, 0.07);
}

.subcat__img img {
	transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.subcat:hover .subcat__img img {
	transform: scale(1.05);
}

/* ==========================================================================
 * Loading spinner overlay
 * ========================================================================== */

.products-grid {
	position: relative;
}

.products-grid.loading {
	pointer-events: none;
	min-height: 220px;
}

.products-grid.loading::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.72);
	backdrop-filter: blur(2px);
	border-radius: var(--r-16, 16px);
	z-index: 5;
	animation: vigor-loading-overlay-in 0.18s ease both;
}

.products-grid.loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 38px;
	height: 38px;
	margin: -19px 0 0 -19px;
	border-radius: 50%;
	border: 3px solid var(--line, #e2e8f0);
	border-top-color: var(--brand-600, #082567);
	animation: vigor-spin 0.72s linear infinite;
	z-index: 6;
}

@keyframes vigor-loading-overlay-in {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

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

/* ==========================================================================
 * Responsive
 * ========================================================================== */

@media (max-width: 992px) {
	.vigor-filter {
		margin-bottom: var(--s-16, 16px);
		padding: var(--s-16, 16px);
		border-radius: 0;
	}

	.vigor-filter:hover {
		transform: none;
	}

	.vigor-filter__price-range {
		flex-direction: column;
		align-items: stretch;
	}

	.vigor-filter__price-range span {
		display: none;
	}

	.vigor-filter__close-drawer {
		display: flex;
		line-height: 38px;
		justify-content: center;
		align-items: flex-start;
	}

	.vigor-filter__options {
		max-height: 175px;
	}

	.catalog-tag-cloud {
		padding: 12px;
		margin-bottom: 12px;
		border-radius: var(--r-12, 12px);
	}

	.tag-cloud,
	.tag-cloud--catalog {
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		margin-inline: -12px;
		padding: 2px 12px 6px;
		scroll-snap-type: x proximity;
		overscroll-behavior-x: contain;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.tag-cloud::-webkit-scrollbar,
	.tag-cloud--catalog::-webkit-scrollbar {
		display: none;
	}

	.tag-cloud__item {
		flex: 0 0 auto;
		white-space: nowrap;
		scroll-snap-align: start;
	}
}

@media (max-width: 768px) {
	.applied__label {
		font-size: 12px;
	}

	.chip--applied {
		font-size: 12px;
		height: 30px;
		padding: 0 10px;
	}

	.applied__reset {
		font-size: 12px;
	}

	.catalog-tag-cloud__head {
		margin-bottom: 8px;
	}

	.catalog-tag-cloud__title {
		font-size: 13px;
	}

	.catalog-tag-cloud__icon {
		width: 24px;
		height: 24px;
		flex-basis: 24px;
		font-size: 13px;
	}

	.tag-cloud__item {
		min-height: 32px;
		padding: 6px 11px;
		font-size: 12px;
		border-radius: 9px;
	}

	.products-grid > .product-card:hover {
		transform: translateY(-2px);
	}
}

/* ==========================================================================
 * Ограничение движения для пользователей, отключивших анимацию
 * ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.vigor-filter,
	.vigor-filter__panel,
	.vigor-filter__option,
	.catalog-tag-cloud,
	.tag-cloud__item,
	.category .cat-head__row,
	.category .subcats-block,
	.category .applied__wrap,
	.products-grid > .product-card,
	.products-grid > .product-card .product-card__thumb img,
	.products-grid > .product-card .product-card__actions,
	.subcat,
	.subcat__img img {
		animation: none !important;
		transition: none !important;
		transform: none !important;
	}
}