/*
 * BFH Filter Sidebar (filters.css)
 *
 * Styles the faceted sidebar rendered by templates/partials/filters.php and
 * filters-range.php. Kept apart from archive.css because the same sidebar is
 * also mounted standalone by the filter Elementor widget.
 */

.bfh-filters {
    display: flex;
    flex-direction: column;
    gap: var(--bfh-space-5);
    padding: var(--bfh-space-5);
    background-color: var(--bfh-surface);
    border: var(--bfh-border-width) solid var(--bfh-border);
    border-radius: var(--bfh-radius-lg);
}

.bfh-filters__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bfh-space-3);
    padding-bottom: var(--bfh-space-4);
    border-bottom: var(--bfh-border-width) solid var(--bfh-border);
}

.bfh-filters__title {
    margin: 0;
    font-size: var(--bfh-text-lg);
    font-weight: var(--bfh-font-weight-semibold);
    color: var(--bfh-text-primary);
}

.bfh-filters__clear {
    padding: 0;
    background: none;
    border: none;
    color: var(--bfh-color-primary);
    font-size: var(--bfh-text-sm);
    font-family: inherit;
    cursor: pointer;
    transition: color var(--bfh-anim-fast);
}

.bfh-filters__clear:hover {
    color: var(--bfh-color-primary-hover);
    text-decoration: underline;
}

/* Fieldsets carry a browser default border and inline padding that would
   otherwise box every facet. */
.bfh-filters__group {
    margin: 0;
    padding: 0;
    border: none;
    display: flex;
    flex-direction: column;
    gap: var(--bfh-space-3);
}

.bfh-filters__group + .bfh-filters__group {
    padding-top: var(--bfh-space-5);
    border-top: var(--bfh-border-width) solid var(--bfh-border);
}

.bfh-filters__label {
    padding: 0;
    font-size: var(--bfh-text-sm);
    font-weight: var(--bfh-font-weight-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--bfh-text-primary);
}

.bfh-filters__within {
    padding-block: var(--bfh-space-2);
    font-size: var(--bfh-text-sm);
}

/* -------------------- Facet lists -------------------- */
.bfh-facet {
    position: relative;
}

/* Numeric facets hold two inputs rather than a term list, so their rows stay
   short and the scrolling cap the list variants need would only clip them. */
.bfh-facet--year .bfh-facet__list,
.bfh-facet--price .bfh-facet__list {
    max-height: none;
    overflow: visible;
}

.bfh-facet__search {
    padding-block: var(--bfh-space-2);
    font-size: var(--bfh-text-sm);
}

.bfh-facet__list {
    display: flex;
    flex-direction: column;
    gap: var(--bfh-space-1);
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.bfh-facet__list::-webkit-scrollbar {
    width: 6px;
}

.bfh-facet__list::-webkit-scrollbar-thumb {
    background-color: var(--bfh-border);
    border-radius: var(--bfh-radius-pill);
}

.bfh-facet__item {
    margin: 0;
}

.bfh-facet__item[hidden] {
    display: none;
}

/* The native control is kept in the accessibility tree and focusable — only
   painted off-screen — so the label can carry the whole hit area. */
.bfh-facet__input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.bfh-facet__label {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--bfh-space-2);
    padding: var(--bfh-space-2) var(--bfh-space-2) var(--bfh-space-2) var(--bfh-space-6);
    border-radius: var(--bfh-radius-sm);
    font-size: var(--bfh-text-sm);
    color: var(--bfh-text-secondary);
    cursor: pointer;
    transition: background-color var(--bfh-anim-fast), color var(--bfh-anim-fast);
}

.bfh-facet__label::before {
    content: '';
    position: absolute;
    left: var(--bfh-space-2);
    width: 16px;
    height: 16px;
    border: var(--bfh-border-width) solid var(--bfh-border-hover);
    border-radius: var(--bfh-radius-sm);
    background-color: transparent;
    transition: all var(--bfh-anim-fast);
}

.bfh-facet--rating .bfh-facet__label::before {
    border-radius: var(--bfh-radius-round);
}

.bfh-facet__label:hover {
    background-color: var(--bfh-surface-hover);
    color: var(--bfh-text-primary);
}

.bfh-facet__input:checked + .bfh-facet__label {
    color: var(--bfh-text-primary);
    font-weight: var(--bfh-font-weight-medium);
}

.bfh-facet__input:checked + .bfh-facet__label::before {
    background-color: var(--bfh-color-primary);
    border-color: var(--bfh-color-primary);
}

/* Drawn rather than a glyph so the mark scales with the box and inherits no
   font metrics. */
.bfh-facet__input:checked + .bfh-facet__label::after {
    content: '';
    position: absolute;
    left: calc(var(--bfh-space-2) + 5px);
    top: 50%;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: translateY(-60%) rotate(45deg);
}

.bfh-facet--rating .bfh-facet__input:checked + .bfh-facet__label::after {
    left: calc(var(--bfh-space-2) + 5px);
    width: 6px;
    height: 6px;
    border: none;
    border-radius: var(--bfh-radius-round);
    background-color: #fff;
    transform: translateY(-50%);
}

.bfh-facet__input:focus-visible + .bfh-facet__label::before {
    outline: 2px solid var(--bfh-color-primary);
    outline-offset: 2px;
}

.bfh-facet__name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bfh-facet__count {
    flex: 0 0 auto;
    font-size: var(--bfh-text-xs);
    color: var(--bfh-text-muted);
    font-variant-numeric: tabular-nums;
}

.bfh-facet__swatch {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border-radius: var(--bfh-radius-round);
    /* No background here: the accord tint comes from the .bfh-accord-* class in
       components.css, and a colour at this weight would load later and win. */
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.bfh-facet__stars {
    flex: 0 0 auto;
    color: var(--bfh-rating-filled);
    letter-spacing: 1px;
}

.bfh-facet__more {
    align-self: flex-start;
    padding: 0;
    background: none;
    border: none;
    color: var(--bfh-color-primary);
    font-family: inherit;
    font-size: var(--bfh-text-sm);
    cursor: pointer;
    transition: color var(--bfh-anim-fast);
}

.bfh-facet__more:hover {
    color: var(--bfh-color-primary-hover);
    text-decoration: underline;
}

.bfh-facet__more[hidden] {
    display: none;
}

/* -------------------- Numeric ranges -------------------- */
.bfh-range {
    display: flex;
    align-items: center;
    gap: var(--bfh-space-2);
}

.bfh-range__field {
    flex: 1 1 0;
    min-width: 0;
    padding: var(--bfh-space-2) var(--bfh-space-3);
    font-size: var(--bfh-text-sm);
}

.bfh-range__sep {
    flex: 0 0 auto;
    color: var(--bfh-text-muted);
}

.bfh-range__apply {
    align-self: flex-start;
    padding: var(--bfh-space-2) var(--bfh-space-5);
}
