/* Serefni Filters – front-end (Cole & Son style horizontal filter bar). */

.serefni-filters {
	margin: 0 0 1.5em;
	padding: 0;
	border: 0;
}

.serefni-filters__groups {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	align-items: center;
}

/* Inline placement: JS moves the bar into the theme's sorting toolbar so the
   filters sit on the left of the "Sjálfgefin röðun" dropdown, sharing one row.
   The result count ("Showing 1–50 of X results") is tucked tightly onto its
   own line just below. Scoped to .has-serefni-filters so categories WITHOUT
   filters keep the theme's default toolbar layout untouched. */
.woostify-sorting.has-serefni-filters {
	row-gap: 0.5em;
	align-items: flex-start;
}

.woostify-sorting.has-serefni-filters .serefni-filters {
	order: 1;
	margin: 0;
	flex: 0 1 auto;
}

.woostify-sorting.has-serefni-filters .woocommerce-ordering {
	order: 2;
	margin-left: auto;
	/* The theme gives this form a large bottom margin; it would stretch the
	   flex row and push the result count far down — zero it here. */
	margin-top: 0;
	margin-bottom: 0;
}

.woostify-sorting.has-serefni-filters .woostify-toolbar-left {
	order: 3;
	flex: 0 0 100%;
	margin: 0 0 1em;
}

.serefni-filter-group {
	position: relative;
}

/* Matches the WooCommerce "Sjálfgefin röðun" dropdown: transparent bg,
   1px #ddd border, 2px radius, muted #545b5c text, granville serif (inherited). */
.serefni-filter-group__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	background: transparent;
	border: 1px solid #ddd;
	border-radius: 2px;
	padding: 0.4em 0.85em;
	font: inherit;
	line-height: 1.2;
	cursor: pointer;
	color: #545b5c;
	transition: border-color 0.15s ease;
}

.serefni-filter-group__toggle:hover,
.serefni-filter-group__toggle[aria-expanded="true"] {
	border-color: #545b5c;
}

.serefni-filter-group__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.5em;
	height: 1.5em;
	padding: 0 0.4em;
	border-radius: 1em;
	background: #545b5c;
	color: #fff;
	font-size: 0.78em;
	font-weight: 600;
}

/* The class rule above sets display, which overrides the UA [hidden] rule;
   restore hiding so the count badge disappears when nothing is selected. */
.serefni-filter-group__badge[hidden] {
	display: none;
}

.serefni-filter-group__caret {
	width: 0;
	height: 0;
	border-left: 0.32em solid transparent;
	border-right: 0.32em solid transparent;
	border-top: 0.38em solid currentColor;
	transition: transform 0.15s ease;
}

.serefni-filter-group__toggle[aria-expanded="true"] .serefni-filter-group__caret {
	transform: rotate(180deg);
}

.serefni-filter-group__panel {
	position: absolute;
	z-index: 50;
	top: calc(100% + 0.35em);
	left: 0;
	min-width: 230px;
	max-height: 340px;
	overflow-y: auto;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 2px;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
	padding: 0.5em 0;
}

.serefni-filter-group__panel[hidden] {
	display: none;
}

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

.serefni-filter-option {
	margin: 0;
}

/* Excluded option (0 results in the current context): greyed out, still visible,
   shows "(0)" and is not selectable. */
.serefni-filter-option--empty {
	opacity: 0.4;
}

.serefni-filter-option--empty label {
	cursor: default;
}

.serefni-filter-option--empty label:hover {
	background: none;
}

.serefni-filter-option--empty input {
	cursor: default;
}

.serefni-filter-option label {
	display: flex;
	align-items: center;
	gap: 0.55em;
	padding: 0.4em 1em;
	cursor: pointer;
	font-size: 0.95em;
}

.serefni-filter-option label:hover {
	background: #f5f5f5;
}

.serefni-filter-option input {
	margin: 0;
	flex: 0 0 auto;
}

.serefni-filter-option__name {
	flex: 1 1 auto;
}

.serefni-filter-option__count {
	color: #888;
	font-size: 0.85em;
	flex: 0 0 auto;
}

.serefni-filters__actions {
	margin-top: 0.6em;
}

.serefni-filters__clear {
	background: none;
	border: 0;
	padding: 0;
	font: inherit;
	color: #666;
	text-decoration: underline;
	cursor: pointer;
}

.serefni-filters__clear:hover {
	color: #222;
}

.serefni-filters__clear[hidden] {
	display: none;
}

/* Subtle loading state on the results while fetching. */
.serefni-filters.is-loading {
	cursor: progress;
}

.serefni-filters.is-loading ~ ul.products,
.serefni-filters.is-loading ~ * ul.products,
.woostify-sorting:has( .serefni-filters.is-loading ) ~ ul.products {
	opacity: 0.55;
	transition: opacity 0.15s ease;
	pointer-events: none;
}

/* Hide the no-JS submit when JS has enhanced the form. */
.serefni-filters.is-enhanced .serefni-filters__submit {
	display: none;
}

@media (max-width: 600px) {
	.serefni-filter-group,
	.serefni-filter-group__toggle {
		width: 100%;
	}
	.serefni-filter-group__toggle {
		justify-content: space-between;
	}
	.serefni-filter-group__panel {
		position: static;
		box-shadow: none;
		min-width: 0;
		border-top: 0;
	}
}
