/*
 * Daygas product filters: the panel of the shop page and the category pages (inc/filters.php).
 * Loaded after archive.css (handle daygas-filters). Colours come from the --dg-* tokens only.
 *
 * From 1000 px: a column to the left of the product grid.
 * Below: a "Filters" button and a panel that slides in from the left (native popover, no script).
 * Without the popover API the panel simply stays open above the grid.
 */

/* 1. Frame ------------------------------------------------------------------ */

.dg-shop--filters {
	display: block;
}

.dg-shop__main {
	min-width: 0;
}

.dg-filters {
	margin-bottom: var(--dg-space-5);
}

/* Only where the popover API exists and the column is not shown. */
.dg-filters__toggle,
.dg-filters__head {
	display: none;
}

/* 2. Chosen filters --------------------------------------------------------- */

.dg-filters__active {
	margin-bottom: var(--dg-space-4);
}

.dg-filters__label {
	margin: 0 0 var(--dg-space-2);
	color: var(--dg-muted);
	font-size: var(--dg-fs-xs);
	font-weight: 600;
}

.dg-filters__active ul {
	display: flex;
	flex-wrap: wrap;
	gap: var(--dg-space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.dg-filters__active li {
	margin: 0;
}

.dg-filters__active li a {
	display: inline-flex;
	align-items: center;
	gap: var(--dg-space-2);
	box-sizing: border-box;
	min-height: 44px;
	padding: 0 var(--dg-space-3) 0 var(--dg-space-4);
	border: 1.5px solid var(--dg-accent);
	border-radius: 999px;
	background: color-mix(in srgb, var(--dg-accent) 14%, var(--dg-white));
	color: var(--dg-ink);
	font-size: var(--dg-fs-xs);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	transition: border-color 140ms var(--dg-ease);
}

.dg-filters__active li a::after {
	content: "\00d7";
	font-size: 1.35em;
	line-height: 1;
}

.dg-filters__active li a:hover {
	border-color: var(--dg-ink);
}

.dg-filters__active li a:focus-visible {
	outline: none;
	box-shadow: var(--dg-focus);
}

.dg-filters__clear {
	display: inline-block;
	margin-top: var(--dg-space-3);
	color: var(--dg-ink);
	font-size: var(--dg-fs-sm);
	font-weight: 600;
	text-decoration: underline;
}

.dg-filters__clear:focus-visible {
	outline: none;
	border-radius: var(--dg-radius);
	box-shadow: var(--dg-focus);
}

/* 3. Panel and groups ------------------------------------------------------- */

.dg-filters__panel {
	box-sizing: border-box;
	padding: 0 var(--dg-space-4);
	border: 1px solid var(--dg-line);
	border-radius: var(--dg-radius-lg);
	background: var(--dg-white);
}

.dg-filters__group {
	padding: var(--dg-space-3) 0;
	border-bottom: 1px solid var(--dg-line);
}

.dg-filters__group:last-child {
	border-bottom: 0;
}

.dg-filters__summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--dg-space-3);
	min-height: 44px;
	color: var(--dg-ink);
	font-size: var(--dg-fs-md);
	font-weight: 700;
	list-style: none;
	cursor: pointer;
}

.dg-filters__summary::-webkit-details-marker {
	display: none;
}

.dg-filters__summary:focus-visible {
	outline: none;
	border-radius: var(--dg-radius);
	box-shadow: var(--dg-focus);
}

.dg-filters__summary .dg-icon {
	flex: none;
	transition: transform 160ms var(--dg-ease);
}

.dg-filters__group:not([open]) .dg-filters__summary .dg-icon {
	transform: rotate(-90deg);
}

.dg-filters__body ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.dg-filters__body li {
	display: flex;
	align-items: center;
	gap: var(--dg-space-2);
	margin: 0;
	padding: 0;
}

/* The option: the link (or the plain text of an option that cannot be chosen) fills the row, the counter sits at the end. */
.dg-filters__body li > :is(a, span):first-child {
	position: relative;
	display: flex;
	flex: 1;
	align-items: center;
	gap: var(--dg-space-3);
	box-sizing: border-box;
	min-height: 44px;
	color: var(--dg-ink);
	font-size: var(--dg-fs-sm);
	line-height: 1.3;
	text-decoration: none;
}

.dg-filters__body li > a:hover {
	color: var(--dg-accent-text);
}

.dg-filters__body li > a:focus-visible {
	outline: none;
	border-radius: var(--dg-radius);
	box-shadow: var(--dg-focus);
}

/* The box in front of the option: a square for the attribute groups, a circle for the type of appliance. */
.dg-filters__body li > a::before {
	content: "";
	flex: none;
	box-sizing: border-box;
	width: 20px;
	height: 20px;
	border: 1.5px solid var(--dg-muted);
	border-radius: 5px;
	background: var(--dg-white);
	transition: border-color 140ms var(--dg-ease), background-color 140ms var(--dg-ease);
}

.dg-filters__body li > a:hover::before {
	border-color: var(--dg-ink);
}

.dg-filters__body li.chosen > a,
.dg-filters__body li.is-current > a {
	font-weight: 600;
}

.dg-filters__body li.chosen > a::before,
.dg-filters__body li.is-current > a::before {
	border-color: var(--dg-accent);
	background: var(--dg-accent);
}

.dg-filters__body li.chosen > a::after {
	content: "";
	position: absolute;
	top: calc(50% - 7px);
	left: 7px;
	width: 5px;
	height: 10px;
	border: solid var(--dg-ink);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.dg-filters__group--types li > a::before {
	border-radius: 50%;
}

.dg-filters__group--types li.is-current > a::before {
	box-shadow: inset 0 0 0 4px var(--dg-white);
}

.dg-filters__body .count {
	flex: none;
	color: var(--dg-muted);
	font-size: var(--dg-fs-xs);
}

/* 4. Phones and tablets: button and sliding panel --------------------------- */

.dg-filters__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--dg-accent);
	color: var(--dg-ink);
	font-size: var(--dg-fs-xs);
	font-weight: 700;
}

@supports selector(:popover-open) {
	@media (max-width: 999.98px) {
		.dg-filters__toggle {
			display: inline-flex;
			margin-bottom: var(--dg-space-4);
		}

		.dg-filters__head {
			position: sticky;
			top: 0;
			z-index: 1;
			display: flex;
			align-items: center;
			justify-content: space-between;
			gap: var(--dg-space-3);
			min-height: 64px;
			border-bottom: 1px solid var(--dg-line);
			background: var(--dg-white);
		}

		.dg-filters__title {
			margin: 0;
			color: var(--dg-ink);
			font-size: var(--dg-fs-h3);
			font-weight: 700;
			line-height: 1.2;
		}

		.dg-filters__close {
			padding: 0 var(--dg-space-4);
			font-size: var(--dg-fs-sm);
		}

		.dg-filters__panel {
			position: fixed;
			inset: 0 auto 0 0;
			width: min(88vw, 380px);
			height: 100%;
			max-height: none;
			margin: 0;
			padding: 0 var(--dg-space-4) var(--dg-space-6);
			overflow-y: auto;
			overscroll-behavior: contain;
			border: 0;
			border-radius: 0;
			box-shadow: var(--dg-shadow);
			color: var(--dg-text);
			transform: translateX(-100%);
			transition: transform 240ms var(--dg-ease), overlay 240ms allow-discrete, display 240ms allow-discrete;
		}

		.dg-filters__panel:popover-open {
			transform: none;
		}

		@starting-style {
			.dg-filters__panel:popover-open {
				transform: translateX(-100%);
			}
		}

		.dg-filters__panel::backdrop {
			background: color-mix(in srgb, var(--dg-ink) 55%, transparent);
		}

		html:has(.dg-filters__panel:popover-open) {
			overflow: hidden;
		}
	}
}

@media (max-width: 689.98px) {
	.dg-filters__toggle {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.dg-filters__panel {
		transition: none;
	}
}

/* 5. Desktop: the column next to the grid ---------------------------------- */

@media (min-width: 1000px) {
	.dg-shop--filters {
		display: grid;
		grid-template-columns: clamp(240px, 22vw, 280px) minmax(0, 1fr);
		gap: var(--dg-space-6);
		align-items: start;
	}

	.dg-filters {
		margin-bottom: 0;
	}

	/* The panel is a popover only on narrow screens; a closed popover is display: none by default. */
	.dg-filters__panel[popover] {
		position: static;
		inset: auto;
		display: block;
		width: auto;
		height: auto;
		max-height: none;
		margin: 0;
		padding: 0 var(--dg-space-4);
		overflow: visible;
		border: 1px solid var(--dg-line);
		border-radius: var(--dg-radius-lg);
		color: var(--dg-text);
		background: var(--dg-white);
		box-shadow: none;
		transform: none;
	}

	/* Three product columns beside the filters; four on a wide screen. */
	.dg-shop--filters ul.products.dg-products,
	.dg-shop--filters ul.products.dg-products.dg-products--c4 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--dg-space-4);
	}
}

@media (min-width: 1400px) {
	.dg-shop--filters ul.products.dg-products,
	.dg-shop--filters ul.products.dg-products.dg-products--c4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: var(--dg-space-5);
	}
}
