/* ==========================================================================
   Product Card
   ========================================================================== */

/* Grid - uses --columns CSS variable from WooCommerce settings */
.products-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 1rem;
}

@media (min-width: 600px) {
	.products-grid {
		grid-template-columns: repeat(min(var(--columns, 4), 3), 1fr);
		gap: 1.25rem;
	}
}

@media (min-width: 1024px) {
	.products-grid {
		grid-template-columns: repeat(var(--columns, 4), 1fr);
		gap: 1.5rem;
	}
}

/* Card */
.product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--kw-radius-lg);
	overflow: hidden;
	box-shadow: var(--kw-shadow-xs);
	transition: box-shadow 0.3s var(--kw-ease), border-color 0.3s var(--kw-ease), transform 0.3s var(--kw-ease);
	cursor: pointer;
}

.product-card:hover {
	box-shadow: var(--kw-shadow-lg);
	border-color: transparent;
	transform: translateY(-3px);
}

.product-card--out-of-stock {
	opacity: 0.7;
}

.product-card__link {
	display: flex;
	flex-direction: column;
	flex: 1;
	color: inherit;
}

.product-card__link:hover {
	color: inherit;
}

/* Image */
.product-card__image-wrapper {
	position: relative;
	aspect-ratio: 1;
	overflow: hidden;
	background-color: var(--wp--preset--color--surface-alt);
}

.product-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

.product-card:hover .product-card__image {
	transform: scale(1.06);
}

.product-card__image--placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, var(--wp--preset--color--surface-alt) 0%, var(--wp--preset--color--border) 100%);
	color: var(--wp--preset--color--text-light);
}

/* Badges */
.product-card__badges {
	position: absolute;
	top: 0.625rem;
	left: 0.625rem;
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
	z-index: 2;
	transition: opacity 0.2s;
}

.product-card:hover .product-card__badges {
	opacity: 0;
	pointer-events: none;
}

.product-card__badge {
	display: inline-flex;
	padding: 0.1875rem 0.5rem;
	font-size: 0.6875rem;
	box-shadow: var(--kw-shadow-sm);
	font-weight: 700;
	letter-spacing: 0.02em;
	border-radius: 4px;
	line-height: 1.5;
	width: fit-content;
}

.product-card__badge--sale {
	background-color: var(--wp--preset--color--highlight);
	color: var(--wp--preset--color--surface);
}

.product-card__badge--out {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
}

/* Info */
.product-card__info {
	display: flex;
	flex-direction: column;
	gap: 0.375rem;
	padding: 0.875rem;
	flex: 1;
}

.product-card__title {
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.4;
	color: var(--wp--preset--color--text);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 0;
}

/* Rating */
.product-card__rating {
	display: flex;
	align-items: center;
	gap: 0.375rem;
}

.product-card__stars {
	display: inline-block;
	width: 5em;
	height: 1em;
	font-size: 0.75rem;
	background: linear-gradient(
		90deg,
		var(--wp--preset--color--warning) calc(var(--rating) / 5 * 100%),
		var(--wp--preset--color--border) calc(var(--rating) / 5 * 100%)
	);
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 24'%3E%3Cpath d='M12 .587l3.668 7.431L24 9.168l-6 5.848L19.335 24 12 20.013 4.665 24 6 15.016 0 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M36 .587l3.668 7.431L48 9.168l-6 5.848L43.335 24 36 20.013 28.665 24 30 15.016 24 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M60 .587l3.668 7.431L72 9.168l-6 5.848L67.335 24 60 20.013 52.665 24 54 15.016 48 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M84 .587l3.668 7.431L96 9.168l-6 5.848L91.335 24 84 20.013 76.665 24 78 15.016 72 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M108 .587l3.668 7.431L120 9.168l-6 5.848L115.335 24 108 20.013 100.665 24 102 15.016 96 9.168l8.332-1.15z' fill='black'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 24'%3E%3Cpath d='M12 .587l3.668 7.431L24 9.168l-6 5.848L19.335 24 12 20.013 4.665 24 6 15.016 0 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M36 .587l3.668 7.431L48 9.168l-6 5.848L43.335 24 36 20.013 28.665 24 30 15.016 24 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M60 .587l3.668 7.431L72 9.168l-6 5.848L67.335 24 60 20.013 52.665 24 54 15.016 48 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M84 .587l3.668 7.431L96 9.168l-6 5.848L91.335 24 84 20.013 76.665 24 78 15.016 72 9.168l8.332-1.15z' fill='black'/%3E%3Cpath d='M108 .587l3.668 7.431L120 9.168l-6 5.848L115.335 24 108 20.013 100.665 24 102 15.016 96 9.168l8.332-1.15z' fill='black'/%3E%3C/svg%3E");
}

.product-card__review-count {
	font-size: 0.6875rem;
	color: var(--wp--preset--color--text-light);
}

/* Price */
.product-card__price {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	font-size: 0.9375rem;
	font-weight: 700;
	color: var(--wp--preset--color--primary);
	margin-top: auto;
}

.product-card__price-old {
	font-size: 0.8125rem;
	font-weight: 400;
	color: var(--wp--preset--color--text-light);
}

.product-card__price-from {
	font-size: 0.75rem;
	font-weight: 400;
	color: var(--wp--preset--color--text-light);
}

/* Actions */
.product-card__actions {
	padding: 0 0.875rem 0.875rem;
}

.product-card__btn {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.5rem 0.75rem;
	font-size: 0.8125rem;
	font-weight: 600;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 6px;
	background: var(--wp--preset--color--surface-alt);
	color: var(--wp--preset--color--text);
	cursor: pointer;
	transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.product-card__btn:hover {
	background-color: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
}

.product-card__btn--in-cart {
	background-color: var(--wp--preset--color--success);
	border-color: var(--wp--preset--color--success);
	color: var(--wp--preset--color--surface);
	cursor: default;
	pointer-events: none;
}

.product-card__btn svg {
	flex-shrink: 0;
}

/* Category Grid */
.category-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 1rem;
	margin-bottom: 2.5rem;
}

@media (min-width: 600px) {
	.category-grid {
		grid-template-columns: repeat(min(var(--columns, 4), 3), 1fr);
		gap: 1.25rem;
	}
}

@media (min-width: 1024px) {
	.category-grid {
		grid-template-columns: repeat(var(--columns, 4), 1fr);
		gap: 1.5rem;
	}
}

.category-card {
	display: block;
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 8px;
	overflow: hidden;
	color: inherit;
	transition: box-shadow 0.25s ease, border-color 0.25s ease;
	cursor: pointer;
}

.category-card:hover {
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
	border-color: transparent;
	color: inherit;
}

.category-card__image-wrapper {
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background-color: var(--wp--preset--color--surface-alt);
}

.category-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.4s ease;
}

.category-card:hover .category-card__image {
	transform: scale(1.06);
}

.category-card__image--placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--wp--preset--color--text-light);
}

.category-card__info {
	padding: 0.875rem;
	text-align: center;
}

.category-card__name {
	font-size: 0.9375rem;
	font-weight: 600;
	margin: 0 0 0.125rem;
	color: var(--wp--preset--color--text);
}

.category-card__count {
	font-size: 0.75rem;
	color: var(--wp--preset--color--text-light);
}

/* No Products - Empty State */
.no-products {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 4rem 2rem;
}

.no-products__icon {
	color: var(--wp--preset--color--border);
	margin-bottom: 1.5rem;
}

.no-products__title {
	font-size: 1.25rem;
	margin-bottom: 0.5rem;
}

.no-products__text {
	color: var(--wp--preset--color--text-light);
	margin-bottom: 1.5rem;
	max-width: 360px;
}

/* Archive Header */
.archive-header {
	margin-bottom: 1.5rem;
}

.archive-header .page-title {
	font-size: var(--wp--preset--font-size--x-large);
	margin-bottom: 0.25rem;
}

.archive-header .archive-description {
	color: var(--wp--preset--color--text-light);
	font-size: 0.9375rem;
	max-width: 600px;
}

.archive-header__inner {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.archive-header__image {
	flex-shrink: 0;
	width: 64px;
	height: 64px;
	object-fit: cover;
	border-radius: var(--kw-radius-md, 10px);
	border: 1px solid var(--wp--preset--color--border);
}

.archive-header__text {
	min-width: 0;
}

/* Archive Search Bar */
.archive-search {
	margin-top: 0.75rem;
	max-width: 540px;
}

.archive-search__field {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.375rem 0.375rem 0.375rem 1rem;
	background: var(--wp--preset--color--surface-alt);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 12px;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.archive-search__field:focus-within {
	border-color: var(--wp--preset--color--accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wp--preset--color--accent) 10%, transparent);
	background: var(--wp--preset--color--surface);
}

.archive-search__icon {
	flex-shrink: 0;
	color: var(--wp--preset--color--text-light);
}

.archive-search__input {
	flex: 1;
	min-width: 0;
	border: none;
	background: transparent;
	padding: 0.375rem 0;
	font-size: 0.9375rem;
	color: var(--wp--preset--color--text);
	outline: none;
}

.archive-search__input::placeholder {
	color: var(--wp--preset--color--text-light);
}

.archive-search__btn {
	flex-shrink: 0;
	padding: 0.5rem 1.25rem;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--wp--preset--color--surface);
	background-color: var(--wp--preset--color--primary);
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: opacity 0.2s;
}

.archive-search__btn:hover {
	opacity: 0.85;
}

/* Loading state */
.shop-layout__products.is-loading .products-grid {
	opacity: 0.5;
	pointer-events: none;
	filter: saturate(0.7);
	transition: opacity 0.25s var(--kw-ease), filter 0.25s var(--kw-ease);
}

/* Pagination */
.shop-pagination {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 0.375rem;
	margin-top: 2.5rem;
	padding-top: 2rem;
	border-top: 1px solid var(--wp--preset--color--border);
}

.shop-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.25rem;
	height: 2.25rem;
	padding: 0.25rem 0.5rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--kw-radius-sm);
	font-size: 0.8125rem;
	font-weight: 500;
	color: var(--wp--preset--color--text);
	transition: all 0.2s var(--kw-ease);
	cursor: pointer;
}

.shop-pagination .page-numbers:hover:not(.current):not(.dots) {
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
	background-color: var(--wp--preset--color--surface-alt);
}

.shop-pagination .page-numbers.current {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
	border-color: var(--wp--preset--color--primary);
}

.shop-pagination .page-numbers.dots {
	border-color: transparent;
	cursor: default;
}

.shop-pagination .page-numbers.dots:hover {
	color: var(--wp--preset--color--text-light);
}

.shop-pagination .prev,
.shop-pagination .next {
	padding: 0.25rem;
}

.shop-pagination .prev svg,
.shop-pagination .next svg {
	display: block;
}

@media (prefers-reduced-motion: reduce) {
	.product-card,
	.product-card__image,
	.product-card__btn,
	.category-card,
	.category-card__image {
		transition: none;
	}

	.product-card:hover .product-card__image,
	.category-card:hover .category-card__image {
		transform: none;
	}
}

/* ==========================================================================
   List View
   ========================================================================== */

.product-card__description {
	display: none;
	font-size: 0.8125rem;
	line-height: 1.5;
	color: var(--wp--preset--color--text-light);
	margin-bottom: 0.375rem;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Hidden by default in grid view */
.products-grid:not(.products-grid--list) .product-card__description {
	display: none;
}

/* List layout */
.products-grid--list {
	grid-template-columns: 1fr !important;
	gap: 0.75rem;
}

.products-grid--list .product-card {
	display: grid;
	grid-template-columns: 180px 1fr auto;
	gap: 1rem;
	align-items: center;
}

.products-grid--list .product-card__link {
	display: contents;
}

.products-grid--list .product-card__image-wrapper {
	aspect-ratio: 1;
	border-radius: 10px;
}

.products-grid--list .product-card__info {
	padding: 0.5rem 0;
}

.products-grid--list .product-card__description {
	display: -webkit-box;
}

.products-grid--list .product-card__actions {
	padding: 0 1rem 0 0;
}

@media (max-width: 599px) {
	.products-grid--list .product-card {
		grid-template-columns: 100px 1fr;
	}

	.products-grid--list .product-card__actions {
		grid-column: 1 / -1;
		padding: 0 0.75rem 0.75rem;
	}
}

/* ==========================================================================
   Subcategory Chips
   ========================================================================== */

.subcategory-chips {
	margin-bottom: 1.25rem;
	overflow: hidden;
}

.subcategory-chips__track {
	display: flex;
	gap: 0.5rem;
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 2px;
}

.subcategory-chips__track::-webkit-scrollbar {
	display: none;
}

.subcategory-chips__chip {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.375rem 0.875rem;
	border-radius: 999px;
	font-size: 0.8125rem;
	font-weight: 500;
	white-space: nowrap;
	border: 1px solid var(--wp--preset--color--border);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--text);
	transition: all 0.2s;
	text-decoration: none;
}

.subcategory-chips__chip:hover {
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--primary);
}

.subcategory-chips__chip.is-active {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
	border-color: var(--wp--preset--color--primary);
}

.subcategory-chips__count {
	font-size: 0.6875rem;
	opacity: 0.7;
}

/* ==========================================================================
   Sorting Bar — Per-page & View Toggle
   ========================================================================== */

.product-sorting__per-page {
	display: none;
}

@media (min-width: 768px) {
	.product-sorting__per-page {
		display: flex;
		align-items: center;
		gap: 0.375rem;
	}

	.product-sorting__per-page-label {
		font-size: 0.8125rem;
		color: var(--wp--preset--color--text-light);
		white-space: nowrap;
	}
}

.product-sorting__view-toggle {
	display: none;
}

@media (min-width: 768px) {
	.product-sorting__view-toggle {
		display: flex;
		align-items: center;
		gap: 2px;
		border: 1px solid var(--wp--preset--color--border);
		border-radius: 8px;
		overflow: hidden;
	}
}

.product-sorting__view-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	background: none;
	border: none;
	color: var(--wp--preset--color--text-light);
	cursor: pointer;
	transition: background-color 0.15s, color 0.15s;
}

.product-sorting__view-btn:hover {
	color: var(--wp--preset--color--text);
}

.product-sorting__view-btn.is-active {
	background-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
}

/* ==========================================================================
   Sticky Mobile Filter Bar
   ========================================================================== */

.sticky-filter-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 90;
	background: var(--wp--preset--color--surface);
	border-top: 1px solid var(--wp--preset--color--border);
	box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
	transform: translateY(100%);
	transition: transform 0.3s ease;
	padding: 0.625rem 0;
}

.sticky-filter-bar.is-visible {
	transform: translateY(0);
}

@media (min-width: 1024px) {
	.sticky-filter-bar {
		display: none;
	}
}

.sticky-filter-bar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.sticky-filter-bar__btn {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 1rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--wp--preset--color--text);
	background: var(--wp--preset--color--surface-alt);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 8px;
	cursor: pointer;
}

.sticky-filter-bar__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	font-size: 0.6875rem;
	font-weight: 700;
	color: var(--wp--preset--color--surface);
	background-color: var(--wp--preset--color--highlight);
	border-radius: 10px;
}

.sticky-filter-bar__sort {
	font-size: 0.8125rem;
	color: var(--wp--preset--color--text-light);
}

/* ==========================================================================
   Pagination — Hidden for infinite scroll
   ========================================================================== */

.shop-pagination--hidden {
	display: none;
}

/* Infinite scroll spinner */
.infinite-scroll-spinner {
	display: flex;
	justify-content: center;
	padding: 2rem 0;
}

.infinite-scroll-spinner::after {
	content: '';
	width: 28px;
	height: 28px;
	border: 3px solid var(--wp--preset--color--border);
	border-top-color: var(--wp--preset--color--primary);
	border-radius: 50%;
	animation: kw-spin 0.6s linear infinite;
}

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