/* Shop and category archives: filter sidebar and subcategory navigation. */

/* ========================================
   Sticky sidebar
======================================== */

@media (min-width: 768px) {
	.filters-wrapper,
	.filters-rail {
		position: sticky;
		top: 10px;
	}

	.admin-bar .filters-wrapper,
	.admin-bar .filters-rail {
		top: 42px;
	}
}

/* ========================================
   Hiding the column (desktop) and the drawer (phones)
   State lives on .shop-wrapper: is-filters-hidden, is-filters-open (bc-shop-filters.js).
======================================== */

/* Without JS nothing can toggle, so the controls stay out and the filters stay in place. */
html:not(.has-js) :is(.filters-toggle, .filters-open, .filters-hide, .filters-rail, .filters-apply, .filters-overlay) {
	display: none;
}

.filters-overlay,
.filters-rail,
.filters-apply {
	display: none;
}

/* Text toggle beside the sort dropdown; both float right, so it lands to its left. */
.woocommerce .filters-toggle {
	float: right;
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	margin: 0 var(--space-6) var(--space-6) 0; /* Same bottom margin as the count and the sort, so the row sits clear of the cards. */
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-size: var(--text-body-s);
	line-height: var(--leading-short);
	cursor: pointer;
}

.filters-toggle:hover .filters-toggle__label {
	text-decoration: underline;
}

.filters-toggle__label--show,
.shop-wrapper.is-filters-hidden .filters-toggle__label--hide {
	display: none;
}

.shop-wrapper.is-filters-hidden .filters-toggle__label--show {
	display: inline;
}

.filters-toggle__count:empty {
	display: none;
}

/* Icon button at the end of the "Filtriranje" row: an arrow on desktop, a close on phones. */
.filters-hide {
	display: inline-flex;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}

.filter-facets__label {
	margin-inline-end: auto;
}

.filters-hide .filters-hide__mobile {
	display: none;
}

.filters-toggle:focus-visible,
.filters-hide:focus-visible,
.filters-rail:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

@media (min-width: 768px) {
	.woocommerce .filters-open {
		display: none;
	}

	.shop-wrapper #secondary {
		min-width: 0; /* The width snaps; bc-shop-filters.js animates the cards instead. */
	}

	.filters-wrapper {
		transition: opacity var(--duration) var(--ease-in-out);
	}

	/* Hidden: the column narrows to a rail that holds one button to bring it back. */
	.shop-wrapper.is-filters-hidden #secondary {
		flex-basis: var(--space-10);
		max-width: var(--space-10);
		margin-right: 0;
	}

	/* Fixed width while hidden, so the text never rewraps as the column narrows under it. */
	.shop-wrapper.is-filters-hidden .filters-wrapper {
		width: 250px;
		opacity: 0;
		visibility: hidden;
		transition: opacity var(--duration) var(--ease-in-out), visibility 0s linear var(--duration);
	}

	.shop-wrapper.is-filters-hidden .filters-rail {
		display: flex;
		align-items: center;
		justify-content: center;
		width: var(--space-10);
		height: var(--space-10);
		padding: 0;
		border: 1px solid var(--color-border-strong);
		border-radius: var(--radius-s);
		background: none;
		color: inherit;
		cursor: pointer;
		transition: background-color var(--duration) var(--ease);
	}

	.filters-rail:hover {
		background-color: var(--color-surface-hover);
	}
}

@media (max-width: 767px) {
	.woocommerce .filters-toggle {
		display: none;
	}

	.woocommerce .filters-open {
		clear: both;
		display: flex;
		width: 100%;
		margin-bottom: var(--space-5);
	}

	.filters-hide .filters-hide__desktop {
		display: none;
	}

	.filters-hide .filters-hide__mobile {
		display: inline-block;
	}

	/* The drawer slides in from the left, the side the column sits on at desktop, over a scrim. */
	html.has-js .shop-wrapper #secondary {
		position: fixed;
		inset-block: 0;
		inset-inline-start: 0;
		z-index: var(--z-drawer);
		width: min(24rem, 100vw - var(--space-10));
		max-width: none;
		margin: 0;
		padding: var(--space-5) var(--space-5) 0;
		overflow-y: auto;
		overscroll-behavior: contain;
		background: var(--color-surface);
		box-shadow: var(--shadow-l);
		transform: translateX(-100%);
		visibility: hidden;
		transition: transform var(--duration) var(--ease-in-out), visibility 0s linear var(--duration);
	}

	html.has-js .shop-wrapper.is-filters-open #secondary {
		transform: none;
		visibility: visible;
		transition: transform var(--duration) var(--ease-in-out);
	}

	html.has-js .filters-overlay {
		display: block;
		position: fixed;
		inset: 0;
		z-index: var(--z-drawer);
		background: var(--color-scrim);
		opacity: 0;
		visibility: hidden;
		transition: opacity var(--duration) var(--ease-in-out), visibility 0s linear var(--duration);
	}

	html.has-js .shop-wrapper.is-filters-open .filters-overlay {
		opacity: 1;
		visibility: visible;
		transition: opacity var(--duration) var(--ease-in-out);
	}

	html.has-filters-open {
		overflow: hidden;
	}

	/* "Prikaži rezultate" stays at the bottom of the drawer; FacetWP has already filtered behind it. */
	html.has-js .filters-apply {
		display: block;
		position: sticky;
		bottom: 0;
		margin-inline: calc(var(--space-5) * -1);
		padding: var(--space-4) var(--space-5);
		border-top: 1px solid var(--color-separator);
		background: var(--color-surface);
	}

	.filters-apply__button {
		width: 100%;
	}
}

/* ========================================
   FacetWP filters
======================================== */

.facetwp-facet .facetwp-checkbox {
	background: none !important;
	display: flex;
	align-items: center;
	margin-bottom: 10px;
	padding-left: 0;
	padding-top: 2px;
	padding-bottom: 2px;
	cursor: pointer;
	position: relative;
}

.facetwp-facet .facetwp-checkbox:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

.facetwp-display-value {
	margin-right: auto;
}

.facetwp-counter {
	margin-left: auto;
	transition: color 0.2s ease;
}

.facetwp-facet .facetwp-checkbox:hover .facetwp-counter,
.facetwp-facet .facetwp-checkbox.checked .facetwp-counter {
	color: var(--color-text);
}

/* "Prikaži još" is an <a> without href, which browsers leave unstyled. */
.facetwp-facet .facetwp-toggle {
	text-decoration: underline;
}

.facetwp-facet .facetwp-toggle:hover {
	text-decoration: none;
}

.facetwp-facet .facetwp-checkbox::before {
	content: "";
	display: block;
	width: 20px;
	height: 20px;
	margin-right: 10px;
	background-color: var(--color-surface-raised);
	border: 1px solid var(--color-border);
	border-radius: 4px;
	box-sizing: border-box;
	flex-shrink: 0;
}

.facetwp-facet .facetwp-checkbox::after {
	content: "";
	display: block;
	width: 20px;
	height: 20px;
	position: absolute;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	opacity: 0;
	background-image: url("../../../images/icons/checkmark.svg");
	background-size: contain;
	background-repeat: no-repeat;
	transition: opacity 0.3s ease, filter 0.3s ease;
}

.facetwp-facet .facetwp-checkbox:not(.checked):hover::after {
	opacity: 0.75;
	filter: grayscale(1);
}

.facetwp-facet .facetwp-checkbox.checked::after {
	opacity: 1;
}

.facetwp-facet .facetwp-checkbox.disabled {
	pointer-events: none;
	opacity: 0.55;
}

.facetwp-checkbox .facetwp-expand {
	margin-left: 5px;
}

/* ========================================
   Filter header / reset
======================================== */

.filter-facets {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px 20px;
	position: relative;
	line-height: var(--leading-short);
	margin-bottom: .425em;
}

.facetwp-facet.facetwp-facet-reset:not(.facetwp-hidden) {
	display: flex;
	align-items: center;
	margin-bottom: 0;
}

.filter-facets__label {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: var(--font-bold);
}

.filter-icon {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
}

.facetwp-reset {
	font-size: var(--text-meta);
	line-height: var(--leading-flat);
}

.facetwp-reset:hover {
	text-decoration: none;
}

/* ========================================
   Facet labels and category tree
======================================== */

.facet-label,
.cat-item--top-link {
	display: block;
	margin-bottom: 1em;
	font-weight: var(--font-bold);
}

.facet-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-2);
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	font-weight: var(--font-bold);
	text-align: start;
	cursor: pointer;
	transition: margin-bottom var(--duration) var(--ease-in-out);
}

.facet-toggle:focus-visible {
	outline: 2px solid var(--color-focus);
	outline-offset: 2px;
}

/* Folded: the title alone, with the same space below it as above. */
.facet-toggle[aria-expanded="false"] {
	margin-bottom: var(--space-5);
}

/* Same chevron as the main navigation's submenu toggle: down when folded, up when open. */
.facet-toggle__icon {
	display: inline-flex;
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	transition: transform var(--duration) var(--ease-in-out);
}

.facet-toggle__icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

.facet-toggle[aria-expanded="true"] .facet-toggle__icon {
	transform: rotate(180deg);
}

/* Height animates through the grid row (0fr to 1fr), which needs no measured height. */
.facet-block__body {
	display: grid;
	grid-template-rows: 1fr;
	transition: grid-template-rows var(--duration) var(--ease-in-out);
}

/* The padding, cancelled by the margin, keeps the checkboxes' focus ring out of the clip. */
.facet-block__inner {
	min-height: 0;
	overflow: hidden;
	margin: -4px -4px 0;
	padding: 4px 4px 0;
}

/* visibility waits for the fold to finish, then takes the checkboxes out of the tab order. */
.facet-toggle[aria-expanded="false"] + .facet-block__body {
	grid-template-rows: 0fr;
	visibility: hidden;
	transition: grid-template-rows var(--duration) var(--ease-in-out), visibility 0s linear var(--duration);
}

.product-cat-tree-wrapper {
	margin-bottom: 1.5rem;
	font-size: var(--text-ui);
}

.cat-item--top-link {
	text-decoration: none;
	line-height: var(--leading-flat);
}

.product-cat-tree {
	border-bottom: 1px solid var(--color-separator);
	list-style: none;
	padding-left: 0;
	padding-bottom: 10px;

}

.product-cat-tree .cat-item {
	padding-bottom: 10px;
}

.cat-item--link {
	text-decoration: none;
}

.cat-item--link:hover,
.current-cat .cat-item--link {
	text-decoration: underline;
}

.product-cat-tree ul {
	list-style: none;
	padding-left: 0;
}

/* ========================================
   Active selections
======================================== */

.user-selections-wrapper {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: var(--space-4);
	border-top: 1px solid var(--color-separator);
}

.user-selections-label {
	display: none;
	flex: 1 1 auto;
	font-size: var(--text-ui);
	order: 0;
	padding-top: 10px;
	padding-bottom: 10px;
}

.user-selections-wrapper .facetwp-selections:not(:empty) + .user-selections-label {
	display: block;
}

.facetwp-selections {
	order: 2;
	flex-basis: 100%;
}

.user-selections-wrapper .facetwp-selections:not(:empty) {
	padding-bottom: var(--space-2);
	border-bottom: 1px solid var(--color-separator);
}

#secondary .facetwp-selections ul {
	margin: 0;
	padding-left: 0;
}

/* "Poništi filtere" on the "Odabrani filteri" line, right-aligned; both only show while something is selected. */
.user-selections-wrapper .facetwp-facet-reset:not(.facetwp-hidden) {
	order: 1;
}

.facetwp-selection-label {
	clip: rect(1px, 1px, 1px, 1px);
	height: 1px;
	overflow: hidden;
	position: absolute !important;
	width: 1px;
	word-wrap: normal !important;
}

#secondary .facetwp-selections .facetwp-selection-value {
	display: inline-block;
	position: relative;
	margin-right: 6px;
	margin-bottom: 6px;
	padding-top: 5px;
	padding-right: 24px;
	padding-bottom: 5px;
	padding-left: 8px;
	font-size: 0.9375rem;
	line-height: var(--leading-slim);
	cursor: pointer;
	background-color: var(--color-surface-warm);
	background-image: none;
	border-radius: 30px;
	transition: opacity .1s ease-in-out;
}

#secondary .facetwp-selections .facetwp-selection-value:hover {
	opacity: .8;
}

.facetwp-selections .facetwp-selection-value::after {
	content: "";
	display: inline-block;
	position: absolute;
	top: 0;
	right: 5px;
	bottom: 0;
	margin-top: auto;
	margin-bottom: auto;
	width: 18px;
	height: 18px;
	background-image: url("../../../images/icons/close-small.svg");
	background-size: contain;
	background-position: center;
	background-repeat: no-repeat;
	transition: transform .1s ease-in-out;
}

.facetwp-selections .facetwp-selection-value:hover::after {
	transform: scale(1.2);
}

/* ========================================
   Facet blocks
======================================== */

.facet-block {
	padding-top: 20px;
	border-bottom: 1px solid var(--color-separator);
	font-size: var(--text-ui);
}

.facet-block:last-of-type {
	border-bottom: none;
}

.facet-block .facetwp-facet {
	margin-bottom: 20px;
}

/* ========================================
   Subcategory navigation
======================================== */

.subcat-nav {
	width: 100%;
}

.subcat-nav-list {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 15px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.subcat-item {
	width: 100px;
}

.subcat-item__link {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	text-decoration: none;
	color: inherit;
}

/* Category image */
.subcat-item__thumb {
	display: block;
	width: 80px;
	height: 80px;
	margin-bottom: 10px;
	border: 4px solid #fff;
	border-radius: 50%;
	background: #fff;
	box-shadow: 5px 15px 25px rgba(89, 89, 89, 0.14);
	object-fit: cover;
	transition: border-color 0.3s ease, transform 0.3s ease;
	-webkit-backface-visibility: hidden;
	-webkit-tap-highlight-color: transparent;
}

/* Category name */
.subcat-item__name {

}

/* Hover and focus state */
.subcat-item__link:hover .subcat-item__thumb,
.subcat-item__link:focus-visible .subcat-item__thumb {
	border-color: var(--color-link);
	transform: translateY(-2px);
}

/* Active state */
.subcat-item--active .subcat-item__thumb,
.subcat-item__link[aria-current="page"] .subcat-item__thumb,
.current-subcat-item--ancestor .subcat-item__thumb {
	border-color: red;
}

.subcat-item--active .subcat-item__name,
.subcat-item__link[aria-current="page"] .subcat-item__name,
.current-subcat-item--ancestor .subcat-item__name {
	font-weight: var(--font-mild);
}
