.ff-filter__header {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin: 0 0 0.5em;
    font-weight: 600;
}

.ff-filter__header-icon {
    flex: 0 0 auto;
}

.ff-filter {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ff-filter li {
    margin: 0 0 0.5em;
}

.ff-filter--disabled {
    opacity: 0.5;
    pointer-events: none;
}

.ff-filter--checkbox li label,
.ff-filter--radio li label {
    display: inline-flex;
    align-items: center;
    padding: 0.25em 0.4em;
    border-radius: 4px;
    cursor: pointer;
}

.ff-filter--checkbox li label:hover,
.ff-filter--radio li label:hover,
.ff-filter--checkbox li label:has(input:focus-visible),
.ff-filter--radio li label:has(input:focus-visible) {
    background: #f0f0f1;
}

.ff-filter__input--icon-mode {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.ff-filter--icon .ff-filter__option {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    cursor: pointer;
}

.ff-filter--icon .ff-filter__option-icon {
    flex: 0 0 auto;
}

/*
 * The active/inactive icon are two different, independently configured icons
 * (not just a color swap), so which one shows can't be driven by a single CSS
 * variable -- both render always and :has(input:checked) toggles which is
 * visible. This also means the swap is instant on click, with no dependency
 * on a page reload (needed for Submit mode, where there is no reload until
 * commit).
 */
.ff-filter__option-icon-state {
    display: inline-flex;
}

.ff-filter__option-icon-state--active {
    display: none;
}

.ff-filter__option:has(input:checked) .ff-filter__option-icon-state--active {
    display: inline-flex;
}

.ff-filter__option:has(input:checked) .ff-filter__option-icon-state--inactive {
    display: none;
}

select.ff-filter--dropdown,
select.ff-orderby--dropdown {
    display: block;
    width: 100%;
    max-width: 100%;
}

.ff-filter--swatch {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
}

.ff-filter--swatch li {
    margin: 0;
}

.ff-filter--swatch label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5em;
    padding: 0 0.75em;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.ff-filter--swatch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.ff-filter--swatch label:has(input:checked) {
    border-color: #2271b1;
    background: #e7f1fa;
}

.ff-filter--toggle li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75em;
}

.ff-filter--toggle label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.75em;
    cursor: pointer;
}

.ff-filter--toggle input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex: 0 0 auto;
    width: 2.25em;
    height: 1.25em;
    margin: 0;
    border-radius: 999px;
    background: #ccc;
    cursor: pointer;
    outline: none;
    transition: background-color 0.15s ease;
}

.ff-filter--toggle input::before {
    content: "";
    position: absolute;
    top: 0.15em;
    left: 0.15em;
    width: 0.95em;
    height: 0.95em;
    border-radius: 50%;
    background: #fff;
    transition: left 0.15s ease;
}

.ff-filter--toggle input:checked {
    background: #2271b1;
}

.ff-filter--toggle input:checked::before {
    left: 1.15em;
}

.ff-price--buckets {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ff-price__bucket {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

.ff-price__bucket--active {
    font-weight: bold;
}

select.ff-price--buckets-dropdown {
    display: block;
    width: 100%;
    max-width: 100%;
}

.ff-price--input {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75em;
}

.ff-price--input label {
    display: block;
    font-size: 0.85em;
}

.ff-price__input {
    display: block;
    width: 6em;
    margin-top: 0.25em;
    padding: 0.5em 0.75em;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background: #fff;
}

.ff-price--slider {
    display: flex;
    flex-direction: column;
    gap: 0.6em;
}

.ff-price__slider-values {
    font-size: 0.9em;
    font-weight: 600;
}

.ff-price__slider-track {
    position: relative;
    height: 1.25em;
}

.ff-price__slider-track::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 0.25em;
    transform: translateY(-50%);
    border-radius: 999px;
    background: #dcdcde;
}

.ff-price__slider-range {
    position: absolute;
    top: 50%;
    height: 0.25em;
    transform: translateY(-50%);
    border-radius: 999px;
    background: #2271b1;
}

.ff-price__range {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1.25em;
    margin: 0;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.ff-price__range::-webkit-slider-runnable-track {
    -webkit-appearance: none;
    background: transparent;
}

.ff-price__range::-moz-range-track {
    background: transparent;
    border: none;
}

.ff-price__range::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: auto;
    width: 1.1em;
    height: 1.1em;
    border-radius: 50%;
    border: 1px solid #8c8f94;
    background: #ffffff;
    cursor: pointer;
}

.ff-price__range::-moz-range-thumb {
    pointer-events: auto;
    width: 1.1em;
    height: 1.1em;
    border-radius: 50%;
    border: 1px solid #8c8f94;
    background: #ffffff;
    cursor: pointer;
}

.ff-dropdown {
    position: relative;
}

.ff-dropdown__native {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Set synchronously in <head> (see FF_Plugin::print_early_js_class()) so the
   native select is hidden from the very first paint, before ff-dropdown.js
   (footer-enqueued) has a chance to run -- avoids a flash of the
   unenhanced select. Only applies when that early script actually ran, so
   the select stays visible/interactive as a fallback if JS is blocked. */
.ff-js select.ff-filter--dropdown,
.ff-js select.ff-price--buckets-dropdown,
.ff-js select.ff-orderby--dropdown {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Scoped under the .ff-dropdown ancestor (not just the bare class) so
   these reliably outrank generic theme button-reset stylesheets (e.g.
   `[type=button], button { display: inline-block; }`), which can tie or
   beat a single-class selector on specificity and win on source order. */
.ff-filter__clear:focus-visible,
.ff-price__clear:focus-visible,
.ff-price__apply:focus-visible,
.ff-dropdown .ff-dropdown__trigger:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.ff-dropdown .ff-dropdown__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5em;
    width: 100%;
    padding: 0.5em 0.75em;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}

.ff-dropdown .ff-dropdown__trigger-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ff-dropdown .ff-dropdown__trigger-caret {
    flex: 0 0 auto;
    font-size: 0.7em;
    line-height: 1;
    transition: transform 0.15s ease;
}

.ff-dropdown .ff-dropdown__trigger[aria-expanded="true"] .ff-dropdown__trigger-caret {
    transform: rotate(180deg);
}

.ff-dropdown .ff-dropdown__panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    margin: 0.25em 0 0;
    padding: 0.25em 0;
    list-style: none;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    overflow-y: auto;
    max-height: 16em;
}

.ff-dropdown .ff-dropdown__option {
    padding: 0.5em 0.75em;
    cursor: pointer;
}

.ff-dropdown .ff-dropdown__option--active {
    background: #f0f0f1;
}

.ff-dropdown .ff-dropdown__option[aria-selected="true"] {
    font-weight: 600;
}

.ff-filter__submit,
.ff-orderby__submit,
.ff-apply {
    margin-top: 0.5em;
}
