/**
 * Shop archive: toolbar, filters and category tiles.
 *
 * The product card is a component and lives in `components/product-card.css`,
 * which is always loaded — it is rendered on the homepage and the product page
 * too, neither of which loads this file.
 * ==========================================================================
 *
 * @package Cropped
 * @since   1.0.0
 * ========================================================================== */

/* --------------------------------------------------------------------------
 * Toolbar
 * -------------------------------------------------------------------------- */

.cr-shop-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var( --cr-space-sm ) var( --cr-space-md );
	padding-block-end: var( --cr-space-md );
	margin-block-end: var( --cr-space-lg );
	border-block-end: 1px solid var( --cr-border );
}

.cr-shop-toolbar__count {
	margin: 0;
	font-size: var( --cr-text-xs );
	letter-spacing: var( --cr-tracking-wide );
	text-transform: uppercase;
	color: var( --cr-text-muted );
	font-variant-numeric: tabular-nums;
}

.cr-shop-toolbar__actions {
	display: flex;
	align-items: center;
	gap: var( --cr-space-sm );
	margin-inline-start: auto;
}

/* The filter trigger is only for the sheet, which only exists on a phone. */
@media ( min-width: 64rem ) {
	.cr-shop-toolbar__filter {
		display: none;
	}
}

.cr-filter-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-inline-size: 1.25rem;
	block-size: 1.25rem;
	padding-inline: 0.3em;
	margin-inline-start: var( --cr-space-3xs );
	background-color: var( --cr-clay-700 );
	color: #fff; /* 7.06:1 on clay-700 — audited */
	border-radius: var( --cr-radius-full );
	font-size: 0.65rem;
	font-variant-numeric: tabular-nums;
}

/* The sort select, without the full input chrome. */
.cr-select--bare {
	min-block-size: 2.25rem;
	padding-block: var( --cr-space-2xs );
	padding-inline: var( --cr-space-sm ) var( --cr-space-xl );
	border-color: var( --cr-border );
	font-size: var( --cr-text-xs );
	letter-spacing: var( --cr-tracking-wide );
	text-transform: uppercase;
	background-position: right var( --cr-space-sm ) center;
	background-size: 0.6rem;
}

/* A finger needs the full 44 px; a mouse does not. See `.cr-btn--sm`. */
@media ( pointer: coarse ) {
	.cr-select--bare {
		min-block-size: var( --cr-tap-target );
	}
}

.cr-shop-toolbar__sort {
	display: flex;
	align-items: center;
	gap: var( --cr-space-xs );
}

/* --------------------------------------------------------------------------
 * Active filter chips
 * -------------------------------------------------------------------------- */

.cr-active-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var( --cr-space-xs ) var( --cr-space-md );
	margin-block-end: var( --cr-space-lg );
}

.cr-active-filters__list {
	display: flex;
	flex-wrap: wrap;
	gap: var( --cr-space-xs );
	margin: 0;
	padding: 0;
	list-style: none;
}

.cr-chip {
	display: inline-flex;
	align-items: center;
	gap: var( --cr-space-2xs );
	min-block-size: 2rem;
	padding: var( --cr-space-2xs ) var( --cr-space-sm );
	border: 1px solid var( --cr-border-strong );
	border-radius: var( --cr-radius-full );
	background-color: var( --cr-surface );
	color: var( --cr-text );
	font-size: var( --cr-text-xs );
	text-decoration: none;
	transition: background-color var( --cr-duration ) var( --cr-ease );
}

.cr-chip:hover {
	background-color: var( --cr-surface-sunken );
}

.cr-chip__icon {
	inline-size: 0.7em;
	block-size: 0.7em;
	color: var( --cr-text-muted );
}

.cr-active-filters__clear {
	font-size: var( --cr-text-xs );
}

/* --------------------------------------------------------------------------
 * Filter panel
 *
 * One element, two presentations. Below 64rem it is the bottom sheet defined
 * in `components/drawer.css`; at and above it, it becomes a static sidebar.
 * It is never duplicated — two copies would repeat every id and every filter
 * link in the accessibility tree.
 * -------------------------------------------------------------------------- */

@media ( min-width: 64rem ) {
	/*
	 * `[hidden]` is normally `display: none !important` (see reset.css). Here it
	 * is deliberately overridden: the attribute is the *sheet's* closed state,
	 * and there is no sheet at this width. Two `!important` declarations, so
	 * specificity decides — `.cr-shop__filters[hidden]` (0,2,0) beats the
	 * reset's `[hidden]` (0,1,0). The element is rendered, and therefore also
	 * exposed to assistive technology, which is what we want here.
	 */
	.cr-shop__filters,
	.cr-shop__filters[hidden] {
		display: block !important;
		position: static;
		inline-size: auto;
		max-block-size: none;
		transform: none;
		opacity: 1;
		background-color: transparent;
		box-shadow: none;
		border-radius: 0;
	}

	/* The sheet's chrome has no meaning as a sidebar. */
	.cr-shop__filters .cr-drawer__head,
	.cr-shop__filters .cr-drawer__foot {
		display: none;
	}

	.cr-shop__filters .cr-drawer__body {
		overflow: visible;
		padding: 0;
	}
}

.cr-filters .cr-disclosure:first-child {
	border-block-start: 1px solid var( --cr-border );
}

.cr-filter-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.cr-filter-list__link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var( --cr-space-sm );
	min-block-size: var( --cr-tap-target );
	padding-block: var( --cr-space-2xs );
	color: var( --cr-text-secondary );
	font-size: var( --cr-text-sm );
	text-decoration: none;
}

.cr-filter-list__link:hover {
	color: var( --cr-text-accent );
}

/*
 * The applied state is carried by weight and a leading rule, not by colour
 * alone, and `aria-current` carries it to assistive technology.
 */
.cr-filter-list__link[aria-current] {
	color: var( --cr-text );
	font-weight: var( --cr-weight-semibold );
}

.cr-filter-list__count {
	color: var( --cr-text-muted );
	font-size: var( --cr-text-xs );
	font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
 * Size swatches in the filter panel
 * -------------------------------------------------------------------------- */

.cr-filter-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: var( --cr-space-xs );
	margin: 0;
	padding: 0;
	list-style: none;
}

.cr-swatch {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-inline-size: var( --cr-tap-target );
	min-block-size: var( --cr-tap-target );
	padding-inline: var( --cr-space-xs );
	border: 1px solid var( --cr-border-strong );
	border-radius: var( --cr-radius-sm );
	background-color: var( --cr-surface );
	color: var( --cr-text );
	font-size: var( --cr-text-sm );
	letter-spacing: var( --cr-tracking-wide );
	text-transform: uppercase;
	text-decoration: none;
	transition: background-color var( --cr-duration ) var( --cr-ease ), border-color var( --cr-duration ) var( --cr-ease );
}

.cr-swatch:hover {
	border-color: var( --cr-text );
}

.cr-swatch.is-active {
	background-color: var( --cr-action );
	border-color: var( --cr-action );
	color: var( --cr-action-text );
}

/* --------------------------------------------------------------------------
 * Price filter
 * -------------------------------------------------------------------------- */

.cr-filter-price__row {
	display: flex;
	align-items: center;
	gap: var( --cr-space-xs );
	margin-block-end: var( --cr-space-sm );
}

.cr-filter-price__row .cr-input {
	min-inline-size: 0;
	text-align: center;
}

/* --------------------------------------------------------------------------
 * Category tiles above the grid
 * -------------------------------------------------------------------------- */

.woocommerce .products > .product-category {
	list-style: none;
}

.product-category a {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: var( --cr-radius-sm );
	color: var( --cr-text );
	text-decoration: none;
}

.product-category img {
	inline-size: 100%;
	aspect-ratio: var( --cr-ratio-product );
	object-fit: cover;
}

.product-category h2 {
	margin-block-start: var( --cr-space-sm );
	font-size: var( --cr-text-lg );
}

.product-category mark.count {
	background: none;
	color: var( --cr-text-muted );
	font-size: var( --cr-text-sm );
}
