/*
 * Open Catalog for Woo
 *
 * Product cards: everything is scoped to `ul.products.ocfw-grid` and built on
 *                WooCommerce classes plus the plugin's own boxes.
 * Filter panel:  everything is scoped to `body.ocfw-filters` and built on the
 *                WooCommerce "Product Filters" block.
 * Colours: theme palette when there is one (Kadence --global-paletteN), with
 * neutral fallbacks for any other theme.
 * No !important: this file loads after the theme's WooCommerce styles.
 */

/* ---------------------------------------------------------------------------
 * Design tokens
 * ------------------------------------------------------------------------ */
.ocfw-grid,
.ocfw-filters {
	--ocfw-radius: 16px;
	--ocfw-radius-small: 10px;
	--ocfw-card: var(--global-palette9, #fff);
	--ocfw-line: var(--global-palette7, #e8e4e0);
	--ocfw-soft: color-mix(in srgb, var(--global-palette8, #f6f3ef) 70%, var(--global-palette9, #fff));
	/* Image background ("Choose colour" setting). A fixed colour, not taken from
	 * the theme; the colour picked in the settings replaces it. */
	--ocfw-image-bg: #f9f6f4;
	--ocfw-text: var(--global-palette3, #1f1a1d);
	--ocfw-muted: var(--global-palette5, #5c5558);
	--ocfw-accent: var(--global-palette-btn-bg, var(--global-palette1, #2b2b2b));
	--ocfw-accent-hover: var(--global-palette-btn-bg-hover, var(--global-palette2, #000));
	--ocfw-on-accent: var(--global-palette-btn, #fff);
	--ocfw-on-accent-hover: var(--global-palette-btn-hover, #fff);
	--ocfw-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---------------------------------------------------------------------------
 * Product card
 * Built on WooCommerce classes (li.product, .price, .button, .onsale,
 * .woocommerce-loop-product__title) and the plugin's own boxes:
 * .ocfw-card-media (image), .ocfw-card-body (text), .ocfw-card-actions (price + button).
 * ------------------------------------------------------------------------ */
.woocommerce ul.products.ocfw-grid {
	--ocfw-pad-x: 1.1rem;
	--ocfw-pad-y: 1rem;
	--ocfw-icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
	--ocfw-icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
	--ocfw-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

.woocommerce ul.products.ocfw-grid li.product {
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	overflow: hidden;
	padding: 0;
	text-align: start;
	background: var(--ocfw-card);
	border: 1px solid var(--ocfw-line);
	border-radius: var(--ocfw-radius);
	box-shadow: none;
	transition: box-shadow 0.25s ease, transform 0.25s var(--ocfw-ease), border-color 0.25s ease;
}

@media (hover: hover) {
	.woocommerce ul.products.ocfw-grid li.product:hover {
		border-color: transparent;
		box-shadow: 0 14px 32px -14px rgba(0, 0, 0, 0.22);
		transform: translateY(-3px);
	}
}

.woocommerce ul.products.ocfw-grid li.product > a {
	display: block;
	color: inherit;
	text-decoration: none;
}

/* Image: square, fills its box (product thumbnails are square in WooCommerce by default). */
.woocommerce ul.products.ocfw-grid li.product .ocfw-card-media {
	position: relative;
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

/* "No background": nothing is painted, the card shows behind the photo. */
.woocommerce ul.products.ocfw-grid.ocfw-img-color li.product .ocfw-card-media {
	background: var(--ocfw-image-bg);
}

.woocommerce ul.products.ocfw-grid li.product .ocfw-card-media img {
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	object-fit: cover;
	box-shadow: none;
}

/* White photo backgrounds melt into the chosen colour. */
.woocommerce ul.products.ocfw-grid.ocfw-img-color li.product .ocfw-card-media img {
	mix-blend-mode: multiply;
}

.woocommerce ul.products.ocfw-grid li.product.outofstock .ocfw-card-media img {
	opacity: 0.85;
}

/* Badges: sale (WooCommerce) and sold out (Open Catalog). */
.woocommerce ul.products.ocfw-grid li.product .onsale,
.woocommerce ul.products.ocfw-grid li.product .ocfw-badge {
	position: absolute;
	top: 0.75rem;
	z-index: 2;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0.35em 0.8em;
	border-radius: 999px;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.2;
}

.woocommerce ul.products.ocfw-grid li.product .onsale {
	left: 0.75rem;
	right: auto;
	background: var(--ocfw-accent);
	color: var(--ocfw-on-accent);
}

.woocommerce ul.products.ocfw-grid li.product .ocfw-badge {
	right: 0.75rem;
	background: var(--ocfw-text);
	color: var(--ocfw-card);
}

/* Text: brand, name, size, rating. */
.woocommerce ul.products.ocfw-grid li.product .ocfw-card-body {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	padding: var(--ocfw-pad-y) var(--ocfw-pad-x) 0.6rem;
}

.woocommerce ul.products.ocfw-grid li.product .ocfw-brand {
	margin: 0;
	font-size: 0.72em;
	font-weight: 600;
	line-height: 1.3;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--ocfw-muted);
}

/* Name: size, weight and colour come from the theme (Kadence: Customizer >
 * WooCommerce > Product Catalog > title font). Only the two-line layout is set here. */
.woocommerce ul.products.ocfw-grid li.product .woocommerce-loop-product__title {
	display: -webkit-box;
	overflow: hidden;
	margin: 0;
	padding: 0;
	min-height: calc(2em * 1.4); /* fallback for browsers without the lh unit */
	min-height: 2lh; /* two lines of the theme's own title font */
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.woocommerce ul.products.ocfw-grid li.product .woocommerce-loop-product__title a {
	color: inherit;
	text-decoration: none;
}

.woocommerce ul.products.ocfw-grid li.product .ocfw-size {
	margin: 0;
	font-size: 0.85em;
	line-height: 1.4;
	color: var(--ocfw-muted);
}

.woocommerce ul.products.ocfw-grid li.product .star-rating {
	margin: 0.15rem 0 0;
}

/* Price + button, pinned to the bottom of the card. */
.woocommerce ul.products.ocfw-grid li.product .ocfw-card-actions {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 0.7rem;
	margin-top: auto;
	padding: 0 var(--ocfw-pad-x) var(--ocfw-pad-y);
}

.woocommerce ul.products.ocfw-grid li.product .ocfw-card-actions .price {
	display: block;
	margin: 0;
	padding: 0;
}

.woocommerce ul.products.ocfw-grid li.product .price del {
	margin-right: 0.3em;
	opacity: 0.55;
}

.woocommerce ul.products.ocfw-grid li.product .price ins {
	text-decoration: none;
}

.woocommerce ul.products.ocfw-grid li.product .price .woocommerce-price-suffix {
	margin-left: 0.25em;
	color: var(--ocfw-muted);
}

/* Button, text style (default). */
.woocommerce ul.products.ocfw-grid li.product .button,
.woocommerce ul.products.ocfw-grid li.product .button.added {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	height: auto;
	min-height: 44px;
	margin: 0;
	padding: 0.65em 1.2em;
	overflow: visible;
	border: 0;
	border-radius: 999px;
	background: var(--ocfw-accent);
	color: var(--ocfw-on-accent);
	text-align: center;
	text-decoration: none;
	text-transform: none; /* "Añadir al carrito", not all caps */
	box-shadow: none;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.woocommerce ul.products.ocfw-grid li.product .button:hover,
.woocommerce ul.products.ocfw-grid li.product .button:focus-visible {
	background: var(--ocfw-accent-hover);
	color: var(--ocfw-on-accent-hover);
}

.woocommerce ul.products.ocfw-grid li.product .button:active {
	transform: scale(0.98);
}

.woocommerce ul.products.ocfw-grid li.product .button.loading {
	opacity: 0.6;
}

/* Out of stock: the button only leads to the product page, so it is quieter. */
.woocommerce ul.products.ocfw-grid li.product.outofstock .button {
	background: transparent;
	color: var(--ocfw-text);
	box-shadow: inset 0 0 0 1px var(--ocfw-line);
}

.woocommerce ul.products.ocfw-grid li.product.outofstock .button:hover,
.woocommerce ul.products.ocfw-grid li.product.outofstock .button:focus-visible {
	background: var(--ocfw-soft);
	color: var(--ocfw-text);
}

/* "View cart" link that WooCommerce adds after the button: a plain, discreet
 * link on its own line, centred under the button. Its text comes from WooCommerce. */
.woocommerce ul.products.ocfw-grid li.product .ocfw-card-actions .added_to_cart {
	display: flex;
	justify-content: center;
	width: 100%;
	margin: 0;
	padding: 0.25em 0 0;
	background: none;
	color: var(--ocfw-muted);
	font-size: 0.875em;
	font-weight: normal;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.woocommerce ul.products.ocfw-grid li.product .ocfw-card-actions .added_to_cart:hover,
.woocommerce ul.products.ocfw-grid li.product .ocfw-card-actions .added_to_cart:focus-visible {
	color: var(--ocfw-text);
}

/* "View cart" link hidden (setting): the button's own "added" state is enough. */
.woocommerce ul.products.ocfw-grid.ocfw-cart-link-hidden li.product .added_to_cart {
	display: none;
}

/* Button, round style: only an icon, drawn by the plugin, next to the price. */
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .ocfw-card-actions {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
}

/* With the link hidden, price and button always share one line. */
.woocommerce ul.products.ocfw-grid.ocfw-btn-round.ocfw-cart-link-hidden li.product .ocfw-card-actions {
	flex-wrap: nowrap;
}

.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .ocfw-card-actions .price {
	flex: 1 1 auto;
	min-width: 0;
}

.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button,
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button.added {
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	min-height: 0;
	padding: 0;
	border-radius: 50%;
	font-size: 0;
}

/* Icons added by the theme or by WooCommerce are hidden; the plugin draws its own. */
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button > :not(.ocfw-btn-label),
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button::after {
	display: none;
}

/* Arrow by default (view options, read more, view products...). */
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button::before {
	content: "";
	display: block;
	width: 18px;
	height: 18px;
	background: currentColor;
	-webkit-mask: var(--ocfw-icon-arrow) center / contain no-repeat;
	mask: var(--ocfw-icon-arrow) center / contain no-repeat;
}

/* "+" when the button adds straight to the cart. */
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button.ajax_add_to_cart::before {
	-webkit-mask-image: var(--ocfw-icon-plus);
	mask-image: var(--ocfw-icon-plus);
}

/* Adding: a small spinner. */
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button.loading {
	opacity: 1;
}

.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button.loading::before {
	width: 16px;
	height: 16px;
	box-sizing: border-box;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	background: none;
	-webkit-mask: none;
	mask: none;
	animation: ocfw-spin 0.7s linear infinite;
}

/* Added: a check. */
.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button.added::before {
	-webkit-mask-image: var(--ocfw-icon-check);
	mask-image: var(--ocfw-icon-check);
}

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

.woocommerce ul.products.ocfw-grid li.product .ocfw-btn-label {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Keyboard focus. */
.woocommerce ul.products.ocfw-grid li.product a:focus-visible,
.woocommerce ul.products.ocfw-grid li.product .button:focus-visible {
	outline: 2px solid var(--ocfw-accent);
	outline-offset: 3px;
}

.woocommerce ul.products.ocfw-grid li.product > a:focus-visible,
.woocommerce ul.products.ocfw-grid li.product a:has(> .ocfw-card-media):focus-visible {
	outline-offset: -4px;
}

/* Category cards: natural height. */
.woocommerce ul.products.ocfw-grid li.product-category {
	align-self: start;
}

/* WooCommerce prints subcategories and products in the same list: the first
 * product after them always starts a new row, so categories stay on top and
 * products below, whatever the number of categories. */
.woocommerce ul.products.ocfw-grid li.product-category + li.product:not(.product-category) {
	grid-column-start: 1;
	clear: both;
}

.woocommerce ul.products.ocfw-grid li.product-category > a {
	display: flex;
	flex-direction: column;
	height: 100%;
	color: var(--ocfw-text);
	text-decoration: none;
}

.woocommerce ul.products.ocfw-grid li.product-category .woocommerce-loop-category__title {
	margin: 0;
	padding: 1rem 1.1rem;
}

.woocommerce ul.products.ocfw-grid li.product-category .count,
.woocommerce ul.products.ocfw-grid.ocfw-cat-no-image li.product-category img {
	display: none;
}

/* Small screens. */
@media (max-width: 767px) {
	.woocommerce ul.products.ocfw-grid {
		--ocfw-pad-x: 0.85rem;
		--ocfw-pad-y: 0.8rem;
	}

	.woocommerce ul.products.ocfw-grid.ocfw-btn-text li.product .button,
	.woocommerce ul.products.ocfw-grid.ocfw-btn-text li.product .button.added {
		padding: 0.6em 0.5em;
	}

	/* Narrow cards: text only, icons added by the theme do not fit. */
	.woocommerce ul.products.ocfw-grid.ocfw-btn-text li.product .button:not(.added):not(.loading) svg {
		display: none;
	}

	.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button,
	.woocommerce ul.products.ocfw-grid.ocfw-btn-round li.product .button.added {
		width: 40px;
		height: 40px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.woocommerce ul.products.ocfw-grid li.product {
		transition: none;
	}

	.woocommerce ul.products.ocfw-grid li.product:hover {
		transform: none;
	}
}

/* ---------------------------------------------------------------------------
 * Card style: Glass
 * The text box and the price + button box form one translucent panel that
 * slightly overlaps the image. Two boxes (not one) so the same markup works
 * with any theme; they share background and border, so they read as one panel.
 * ------------------------------------------------------------------------ */
.woocommerce ul.products.ocfw-grid.ocfw-style-glass {
	--ocfw-glass: color-mix(in srgb, var(--ocfw-card) 75%, transparent);
	--ocfw-glass-edge: color-mix(in srgb, var(--ocfw-card) 90%, transparent);
	--ocfw-glass-inset: 0.75rem;
	--ocfw-glass-overlap: 2rem;
	--ocfw-glass-radius: 12px;
}

/* The text box grows, so the panel is one piece down to the button. */
.woocommerce ul.products.ocfw-grid.ocfw-style-glass li.product > a:has(> .ocfw-card-body) {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
}

.woocommerce ul.products.ocfw-grid.ocfw-style-glass li.product .ocfw-card-body {
	position: relative;
	z-index: 1;
	flex: 1 1 auto;
	margin: calc(-1 * var(--ocfw-glass-overlap)) var(--ocfw-glass-inset) 0;
	padding: 0.85rem 1rem 0.5rem;
	border: 1px solid var(--ocfw-glass-edge);
	border-bottom: 0;
	border-radius: var(--ocfw-glass-radius) var(--ocfw-glass-radius) 0 0;
	background: var(--ocfw-glass);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	box-shadow: 0 -8px 18px -10px rgba(0, 0, 0, 0.18);
}

.woocommerce ul.products.ocfw-grid.ocfw-style-glass li.product .ocfw-card-actions {
	margin: 0 var(--ocfw-glass-inset) var(--ocfw-glass-inset);
	padding: 0.4rem 1rem 1rem;
	border: 1px solid var(--ocfw-glass-edge);
	border-top: 0;
	border-radius: 0 0 var(--ocfw-glass-radius) var(--ocfw-glass-radius);
	background: var(--ocfw-glass);
	box-shadow: 0 10px 18px -12px rgba(0, 0, 0, 0.18);
}

/* Kadence keeps the button box at the bottom; here the panel is continuous. */
.woocommerce ul.products.ocfw-grid.ocfw-style-glass li.product .product-action-wrap {
	margin-top: 0;
}

@media (max-width: 767px) {
	.woocommerce ul.products.ocfw-grid.ocfw-style-glass {
		--ocfw-glass-inset: 0.5rem;
		--ocfw-glass-overlap: 1.5rem;
	}

	.woocommerce ul.products.ocfw-grid.ocfw-style-glass li.product .ocfw-card-body {
		padding: 0.7rem 0.75rem 0.4rem;
	}

	.woocommerce ul.products.ocfw-grid.ocfw-style-glass li.product .ocfw-card-actions {
		padding: 0.35rem 0.75rem 0.8rem;
	}
}

/* ---------------------------------------------------------------------------
 * Kadence compatibility
 * Kadence adds its own boxes to the card (.entry-content-wrap, .product-action-wrap)
 * with padding, margins and a hover animation. These rules only neutralise them so
 * the plugin's boxes above decide the layout. With other themes they do nothing.
 * ------------------------------------------------------------------------ */

/* Kadence's text box becomes a plain column that fills the card. Its padding
 * rules use up to nine classes in some layouts (unboxed archives, related
 * products); repeating the plugin's class keeps this above them without !important. */
.woocommerce ul.products.ocfw-grid.ocfw-grid.ocfw-grid.ocfw-grid li.product.product .entry-content-wrap.entry-content-wrap {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	margin: 0;
	padding: 0;
	border-radius: 0;
	background: transparent;
	transform: none;
}

/* Kadence's button box: always visible, at the bottom, no slide-up. */
.woocommerce ul.products.ocfw-grid li.product .product-action-wrap,
.woocommerce ul.products.ocfw-grid li.product:hover .product-action-wrap,
.woocommerce ul.products.ocfw-grid li.product:focus-within .product-action-wrap {
	position: static;
	width: auto;
	margin-top: auto;
	padding: 0;
	opacity: 1;
	transition: none;
}

/* Kadence "text with arrow" button: a little room before the arrow. */
.woocommerce ul.products.ocfw-grid.ocfw-btn-text li.product .button .kadence-svg-iconset svg {
	margin-left: 0;
}

.woocommerce ul.products.ocfw-grid.ocfw-btn-text li.product .button:not(.added) .kadence-svg-iconset:has(.kadence-arrow-right-alt-svg),
.woocommerce ul.products.ocfw-grid.ocfw-btn-text li.product .button.added .kadence-svg-iconset:has(.kadence-check-svg) {
	margin-left: 0.45em;
}

@media (max-width: 767px) {
	.woocommerce ul.products.ocfw-grid.ocfw-btn-text li.product .button:not(.added) .kadence-svg-iconset:has(.kadence-arrow-right-alt-svg) {
		display: none;
	}
}

/* Kadence list view: image left, text right. */
.woocommerce ul.products.ocfw-grid.products-list-view li.product {
	flex-direction: row;
}

.woocommerce ul.products.ocfw-grid.products-list-view li.product > a:has(.ocfw-card-media) {
	flex: 0 0 min(34%, 260px);
}

.woocommerce ul.products.ocfw-grid.products-list-view li.product .button {
	width: auto;
	align-self: flex-start;
}

/* ---------------------------------------------------------------------------
 * Filters (WooCommerce "Product Filters" block)
 * The block's own styles use :where(), so a single class is enough here.
 * ------------------------------------------------------------------------ */
.ocfw-filters .wc-block-product-filters {
	--wc-product-filter-price-slider: var(--ocfw-accent);
	--wc-product-filter-price-slider-handle-border: var(--ocfw-accent);
	--wc-product-filter-chips-selected-background: var(--ocfw-accent);
	--wc-product-filter-chips-selected-border: var(--ocfw-accent);
	--wc-product-filter-chips-selected-text: var(--ocfw-on-accent);
	width: 100%;
	min-width: 0;
}

/* Headings: their size is set in the block editor (or by the theme). */
.ocfw-filters .wc-block-product-filters h2.wp-block-heading {
	margin: 0;
}

.ocfw-filters .wc-block-product-filters h3.wp-block-heading {
	margin: 0 0 0.75rem;
}

/* Each filter separated by a thin line. */
.ocfw-filters .wc-block-product-filters [class*="wp-block-woocommerce-product-filter-"]:not(.wp-block-woocommerce-product-filter-active):not(.wp-block-woocommerce-product-filter-price-slider):not(.wp-block-woocommerce-product-filter-chips):not(.wp-block-woocommerce-product-filter-checkbox-list):not(.wp-block-woocommerce-product-filter-removable-chips):not(.wp-block-woocommerce-product-filter-clear-button) {
	padding-top: 1.1rem;
	border-top: 1px solid var(--ocfw-line);
}

/* Price: two boxes that fit the sidebar. */
.ocfw-filters .wc-block-product-filter-price-slider__content {
	grid-template-columns: minmax(0, 1fr) 0 minmax(0, 1fr);
	row-gap: 0.9rem;
}

.ocfw-filters .wc-block-product-filter-price-slider__content .text input[type="text"] {
	width: 100%;
	max-width: none;
	padding: 0.55em 0.75em;
	border: 1px solid var(--ocfw-line);
	border-radius: var(--ocfw-radius-small);
	background: var(--ocfw-card);
}

/* Chips (sizes, etc.). */
.ocfw-filters .wc-block-product-filter-chips__items {
	gap: 0.45rem;
}

.ocfw-filters .wc-block-product-filter-chips__item,
.ocfw-filters .wc-block-product-filter-chips__item:hover {
	min-height: 36px;
	padding: 0.45em 0.95em;
	border: 1px solid var(--ocfw-line);
	border-radius: 999px;
	background: var(--ocfw-card);
	color: var(--ocfw-text);
	transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.ocfw-filters .wc-block-product-filter-chips__item:hover {
	border-color: var(--ocfw-accent);
}

/* Selected chip (themes give every button a hover colour, so each state is set). */
.ocfw-filters .wc-block-product-filter-chips__item[aria-checked="true"],
.ocfw-filters .wc-block-product-filter-chips__item[aria-checked="true"]:hover {
	border-color: var(--ocfw-accent);
	background: var(--ocfw-accent);
	color: var(--ocfw-on-accent);
}

.ocfw-filters .wc-block-product-filter-chips__item:focus-visible {
	outline: 2px solid var(--ocfw-accent);
	outline-offset: 2px;
}

/* Checkbox lists (no box around them). */
.ocfw-filters .wp-block-woocommerce-product-filter-checkbox-list fieldset,
.ocfw-filters .wc-block-product-filter-checkbox-list fieldset {
	display: contents;
	margin: 0;
	padding: 0;
	border: 0;
}

.ocfw-filters .wc-block-product-filter-checkbox-list__items {
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
}

.ocfw-filters .wc-block-product-filters {
	--wc-product-filter-checkbox-list-option-element-selected: var(--ocfw-on-accent);
}

.ocfw-filters .wc-block-product-filter-checkbox-list__input-wrapper::before {
	display: none;
}

.ocfw-filters input[type="checkbox"].wc-block-product-filter-checkbox-list__input {
	border: 1.5px solid color-mix(in srgb, var(--ocfw-text) 30%, transparent);
	border-radius: 5px;
	background: var(--ocfw-card);
	cursor: pointer;
}

.ocfw-filters input[type="checkbox"].wc-block-product-filter-checkbox-list__input:checked {
	border-color: var(--ocfw-accent);
	background: var(--ocfw-accent);
}

.ocfw-filters input[type="checkbox"].wc-block-product-filter-checkbox-list__input:focus-visible {
	outline: 2px solid var(--ocfw-accent);
	outline-offset: 2px;
}

/* Text buttons of the block ("Show more", remove an active filter): themes give
 * every button a hover background, these stay plain text. */
.ocfw-filters .wc-block-product-filter-chips__show-more,
.ocfw-filters .wc-block-product-filter-chips__show-more:hover,
.ocfw-filters .wc-block-product-filter-checkbox-list__show-more-button,
.ocfw-filters .wc-block-product-filter-checkbox-list__show-more-button:hover,
.ocfw-filters .wc-block-product-filter__show-more,
.ocfw-filters .wc-block-product-filter__show-more:hover,
.ocfw-filters .wc-block-product-filter-removable-chips__remove,
.ocfw-filters .wc-block-product-filter-removable-chips__remove:hover {
	background: transparent;
	color: var(--ocfw-text);
}

/* Active filters: removable chips and "Clear filters". */
.ocfw-filters .wc-block-product-filter-removable-chips__items {
	margin: 0;
	padding: 0;
}

.ocfw-filters .wc-block-product-filter-removable-chips__item {
	border-radius: 999px;
}

.ocfw-filters .wc-block-product-filter-clear-button .wp-block-button__link {
	padding: 0.4em 1em;
	border: 1px solid var(--ocfw-line);
	border-radius: 999px;
	background: transparent;
	color: var(--ocfw-text);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.ocfw-filters .wc-block-product-filter-clear-button .wp-block-button__link:hover,
.ocfw-filters .wc-block-product-filter-clear-button .wp-block-button__link:focus-visible {
	border-color: var(--ocfw-accent);
	color: var(--ocfw-accent);
}

/* ---- Mobile and tablet: floating "Filter products" button, bottom panel ----
 * The button is WooCommerce's own; it is only placed at the bottom of the
 * screen, so it does not matter where the theme puts the sidebar. */
@media (max-width: 1024px) {

	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__open-overlay {
		position: fixed;
		left: 50%;
		bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
		z-index: 9990;
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 0.4rem;
		min-height: 48px;
		padding: 0.7rem 1.4rem;
		border: 0;
		border-radius: 999px;
		background: var(--ocfw-accent);
		color: var(--ocfw-on-accent);
		white-space: nowrap;
		box-shadow: 0 10px 28px -6px rgba(0, 0, 0, 0.35);
		transform: translateX(-50%);
		cursor: pointer;
		transition: background-color 0.2s ease, opacity 0.2s ease;
	}

	.ocfw-filters .wc-block-product-filters__open-overlay:hover,
	.ocfw-filters .wc-block-product-filters__open-overlay:focus-visible {
		background: var(--ocfw-accent-hover);
		color: var(--ocfw-on-accent-hover);
	}

	.ocfw-filters .wc-block-product-filters__open-overlay:focus-visible {
		outline: 2px solid var(--ocfw-accent);
		outline-offset: 3px;
	}

	/* While the panel is open the button steps aside. */
	.ocfw-filters .wc-block-product-filters.is-overlay-opened .wc-block-product-filters__open-overlay {
		opacity: 0;
		pointer-events: none;
	}

	/* Overlay behaviour on tablet too (WooCommerce only does it up to 600px). */
	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__overlay {
		position: fixed;
		inset: 0;
		top: var(--top-padding, 0);
		flex-grow: 0;
		pointer-events: none;
		background-color: transparent;
		transition: background-color 0.35s ease;
	}

	.ocfw-filters .wc-block-product-filters.is-overlay-opened .wc-block-product-filters__overlay {
		z-index: 9999;
		pointer-events: auto;
		background-color: rgba(20, 16, 18, 0.45);
	}

	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__overlay-wrapper {
		position: relative;
		width: 100%;
		height: 100%;
	}

	/* The panel: from the bottom, rounded top, never taller than the screen. */
	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__overlay-dialog {
		position: absolute;
		inset: auto 0 0 0;
		display: flex;
		flex-direction: column;
		max-height: min(88vh, calc(100% - 1.5rem));
		overflow: hidden;
		border-radius: 22px 22px 0 0;
		background: var(--wc-product-filters-overlay-background-color, var(--ocfw-card));
		color: var(--wc-product-filters-overlay-text-color, var(--ocfw-text));
		box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.18);
		transform: translateY(105%);
		visibility: hidden;
		transition: transform 0.4s var(--ocfw-ease), visibility 0s linear 0.4s;
	}

	/* Open. While closed it is also hidden, so it cannot be reached with the keyboard. */
	.ocfw-filters .wc-block-product-filters.is-overlay-opened .wc-block-product-filters__overlay-dialog {
		transform: translateY(0);
		visibility: visible;
		transition: transform 0.4s var(--ocfw-ease), visibility 0s;
	}

	/* Handle. */
	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__overlay-dialog::before {
		content: "";
		flex: 0 0 auto;
		width: 44px;
		height: 5px;
		margin: 10px auto 0;
		border-radius: 3px;
		background: var(--ocfw-line);
	}

	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__overlay-header {
		display: flex;
		flex-flow: row-reverse;
		padding: 0.25rem 1rem 0;
	}

	.ocfw-filters .wc-block-product-filters__close-overlay,
	.ocfw-filters .wc-block-product-filters__close-overlay:hover {
		min-height: 44px;
		padding: 0 0.25rem;
		background: transparent;
		color: var(--ocfw-text);
		cursor: pointer;
	}

	.ocfw-filters .wc-block-product-filters__close-overlay:hover {
		opacity: 0.7;
	}

	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__overlay-content {
		flex: 1 1 auto;
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 0 1.25rem 1.25rem;
	}

	.ocfw-filters .wc-block-product-filters:not(.is-filter-drawer-disabled) .wc-block-product-filters__overlay-footer {
		display: flex;
		padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
		border-top: 1px solid var(--ocfw-line);
		box-shadow: none;
	}

	.ocfw-filters .wc-block-product-filters__apply {
		width: 100%;
		min-height: 48px;
		border: 0;
		border-radius: 999px;
		background: var(--ocfw-accent);
		color: var(--ocfw-on-accent);
		cursor: pointer;
	}

	.ocfw-filters .wc-block-product-filters__apply:hover,
	.ocfw-filters .wc-block-product-filters__apply:focus-visible {
		background: var(--ocfw-accent-hover);
		color: var(--ocfw-on-accent-hover);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ocfw-filters .wc-block-product-filters .wc-block-product-filters__overlay,
	.ocfw-filters .wc-block-product-filters .wc-block-product-filters__overlay-dialog {
		transition: none;
	}
}
