.cpf-sort {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2);
	min-width: 0;
	max-width: 100%;
	margin: 0;
}

.cpf-sort__field {
	position: relative;
	width: 230px;
	max-width: 100%;
	min-width: 0;
	border: var(--border-width) solid var(--theme-palette-color-6);
	border-radius: var(--radius-md);
	background: var(--theme-palette-color-8);
	outline: none;
	box-shadow: none;
	transition: border-color var(--transition-fast);
}

.cpf-sort__field:hover,
.cpf-sort__field:active,
.cpf-sort__field:focus-within {
	border-color: var(--theme-palette-color-2);
}

.cpf-sort .cpf-sort__trigger {
	display: flex;
	align-items: center;
	position: relative;
	list-style: none;
	text-align: left;
	text-transform: none;
	letter-spacing: normal;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	min-height: var(--control-touch, 44px);
	margin: 0;
	padding: 0 40px;
	border: 0;
	border-radius: inherit;
	background: transparent;
	color: var(--theme-palette-color-4);
	font-family: inherit;
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	line-height: var(--lh-normal);
	outline: none;
	box-shadow: none;
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
}

.cpf-sort__icon,
.cpf-sort__chevron {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

.cpf-sort__icon {
	width: 20px;
	height: 20px;
	left: var(--space-3);
	color: var(--theme-palette-color-2);
}

/* The shared SVG asset uses a white stroke; inherit this control's color. */
.cpf-sort__icon svg,
.cpf-sort__chevron svg {
	display: block;
	width: 100%;
	height: 100%;
	stroke: currentColor;
}

/* A single border indicates mouse, touch and keyboard focus. */
.cpf-sort .cpf-sort__trigger:focus,
.cpf-sort .cpf-sort__trigger:focus-visible {
	outline: none;
	box-shadow: none;
	border: 0;
	background: transparent;
}

.cpf-sort__chevron {
	width: 16px;
	height: 16px;
	right: var(--space-3);
	color: var(--theme-palette-color-3);
}

.cpf-sort__trigger::-webkit-details-marker {
	display: none;
}
.cpf-sort__trigger::marker {
	content: '';
}
.cpf-sort__field[open] {
	border-color: var(--theme-palette-color-2);
	z-index: 40;
}
.cpf-sort__field[open] .cpf-sort__chevron {
	transform: translateY(-50%) rotate(180deg);
}
.cpf-sort .cpf-sort__menu {
	position: absolute;
	z-index: 40;
	top: calc(100% + 8px);
	right: 0;
	width: max(100%, 250px);
	max-width: calc(100vw - 32px);
	max-height: var(--cpf-sort-room, min(300px, 60vh));
	overflow-y: auto;
	overscroll-behavior: contain;
	margin: 0;
	padding: 4px;
	list-style: none;
	border: var(--border-width) solid var(--theme-palette-color-6);
	border-radius: var(--radius-md);
	background: var(--theme-palette-color-8);
	box-shadow: 0 8px 24px rgb(21 25 23 / 10%);
}
.cpf-sort__field[data-cpf-sort-up] .cpf-sort__menu {
	top: auto;
	bottom: calc(100% + 8px);
}
.cpf-sort .cpf-sort__menu > li {
	margin: 0;
	padding: 0;
	list-style: none;
}
.cpf-sort .cpf-sort__menu > li::before {
	content: none;
}
.cpf-sort .cpf-sort__option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 44px;
	padding: 10px 12px;
	border: 0;
	border-radius: max(2px, calc(var(--radius-md) - 4px));
	color: var(--theme-palette-color-4);
	background: transparent;
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	line-height: var(--lh-normal);
	text-decoration: none;
	outline: none;
	box-shadow: none;
	touch-action: manipulation;
}
.cpf-sort .cpf-sort__option[aria-checked='true'],
.cpf-sort .cpf-sort__option:focus-visible {
	color: var(--theme-palette-color-2);
	background: color-mix(in srgb, var(--theme-palette-color-2) 9%, var(--theme-palette-color-8));
}
.cpf-sort .cpf-sort__option:focus-visible {
	outline: 1px solid var(--theme-palette-color-2);
	outline-offset: -1px;
}
@media (hover: hover) {
	.cpf-sort .cpf-sort__option:hover {
		color: var(--theme-palette-color-2);
		background: color-mix(in srgb, var(--theme-palette-color-2) 7%, var(--theme-palette-color-8));
	}
}
.cpf-sort__check {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 18px;
	visibility: hidden;
}
.cpf-sort__check svg {
	display: block;
	width: 18px;
	height: 18px;
	stroke: currentColor;
}
.cpf-sort__option[aria-checked='true'] .cpf-sort__check {
	visibility: visible;
}
@media (max-width: 689.98px) {
	.cpf-sort,
	.cpf-sort__field {
		width: 100%;
	}

	.cpf-sort .cpf-sort__menu {
		width: 100%;
	}
}
@media (max-width: 999px) {
	.cpf-sort .cpf-sort__trigger,
	.cpf-sort .cpf-sort__option {
		font-size: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cpf-sort__field {
		transition: none;
	}
}
