/*
 * Filter pill bar. All selectors carry the le-fb- prefix and win over the
 * template CSS through structure, not through !important.
 *
 * Design tokens live here once and are referenced everywhere else. A hard-coded
 * colour inside a component is the start of the drift this file exists to stop.
 */
/*
 * Two tokens sit above the component: the loading state styles #product-list,
 * which is the template's node and never a descendant of .le-fb, so it cannot
 * inherit from there. They are declared once here rather than repeated as a
 * literal in the busy rule - that repetition is the drift this file avoids.
 * Nothing is styled at :root, only named.
 */
:root {
    --le-fb-brand: #8fad07;
    --le-fb-track: #e5e5e5;
}

.le-fb {
    --le-fb-ink: #1d1d1b;
    --le-fb-muted: #6b6b66;
    --le-fb-border: #d8d8d2;
    --le-fb-surface: #fff;
    --le-fb-box: 18px;
    --le-fb-icon: 12px;
    --le-fb-icon-lg: 18px;
    --le-fb-radius: 999px;
    --le-fb-radius-panel: 8px;
    --le-fb-gap: 8px;
    --le-fb-pad-y: 8px;
    --le-fb-pad-x: 14px;
    --le-fb-font: "Lato", -apple-system, "Segoe UI", sans-serif;
    --le-fb-max: 1260px;

    max-width: var(--le-fb-max);
    margin: 0 auto 12px;
    font-family: var(--le-fb-font);
    color: var(--le-fb-ink);
}

/*
 * Soft launch: with hide-toolbar = 0 both the stock toolbar and the template's
 * active-filter block stay visible; the bar is then purely additive.
 *
 * The state is read from an attribute the plugin puts on body, NOT from where
 * our bar sits. The earlier rules used a sibling combinator and `:has(> …)`, so
 * they described a position rather than a setting - and the AJAX layer moves
 * positions. A re-inserted region landed outside the relation and the setting
 * stopped applying without anything reporting it. An attribute survives every
 * node move.
 *
 * Consequence to know: this hides EVERY toolbar and chip row on the page, where
 * the sibling rule only ever hid the one next to the bar. On a listing with a
 * second toolbar below the grid that is the intended reading of the setting.
 */
body[data-le-fb-hide-toolbar="1"] .result-options,
body[data-le-fb-hide-toolbar="1"] .active-filters {
    display: none;
}

.le-fb__row {
    display: flex;
    align-items: center;
    gap: var(--le-fb-gap);
}

.le-fb__left {
    display: flex;
    align-items: center;
    gap: var(--le-fb-gap);
}

.le-fb__right {
    display: flex;
    align-items: center;
    gap: var(--le-fb-gap);
    margin-left: auto;
}

.le-fb__pill-wrap {
    position: relative;
}

.le-fb__pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--le-fb-pad-y) var(--le-fb-pad-x);
    border: 1px solid var(--le-fb-border);
    border-radius: var(--le-fb-radius);
    background: var(--le-fb-surface);
    color: inherit;
    font: inherit;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.le-fb__pill:hover {
    border-color: var(--le-fb-muted);
}

.le-fb__pill.is-active {
    border-color: var(--le-fb-brand);
    box-shadow: inset 0 0 0 1px var(--le-fb-brand);
}

.le-fb__badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--le-fb-radius);
    background: var(--le-fb-brand);
    color: #fff;
    font-size: 12px;
    text-align: center;
}

.le-fb__dropdown {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    right: 0;
    min-width: 260px;
    max-width: 340px;
    padding: 12px;
    border: 1px solid var(--le-fb-border);
    border-radius: var(--le-fb-radius-panel);
    background: var(--le-fb-surface);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
}

.le-fb__dropdown[hidden] {
    display: none;
}

.le-fb__dropdown-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
}

.le-fb__dropdown-title {
    font-weight: 700;
}

.le-fb__reset,
.le-fb__apply {
    border: 0;
    background: none;
    color: var(--le-fb-muted);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.le-fb__apply {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--le-fb-radius-panel);
    background: var(--le-fb-brand);
    color: #fff;
    text-decoration: none;
}

.le-fb__search {
    width: 100%;
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid var(--le-fb-border);
    border-radius: var(--le-fb-radius-panel);
    font: inherit;
}

.le-fb__list {
    max-height: 260px;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.le-fb__item[hidden] {
    display: none;
}

.le-fb__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 2px;
    color: inherit;
    text-decoration: none;
}

/*
 * Checkbox and its tick. The tick is a rotated two-sided border, the same shape
 * the approved mockup uses — drawn rather than shipped as an icon font or SVG so
 * it inherits the brand colour token and needs no second asset.
 */
.le-fb__check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--le-fb-box);
    height: var(--le-fb-box);
    border: 2px solid var(--le-fb-border);
    border-radius: 3px;
    flex: 0 0 auto;
}

.le-fb__option[data-le-fb-selected="1"] .le-fb__check {
    border-color: var(--le-fb-brand);
    background: var(--le-fb-brand);
}

/* content:'' — an empty string, not `none`: `none` suppresses the box entirely. */
.le-fb__option[data-le-fb-selected="1"] .le-fb__check::after {
    content: "";
    width: 4px;
    height: 9px;
    margin-top: -2px;
    border: solid var(--le-fb-surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Sorting is single choice, so its control is a radio, not a checkbox. */
.le-fb__option--radio .le-fb__check {
    border-radius: 50%;
}

.le-fb__option--radio[data-le-fb-selected="1"] .le-fb__check::after {
    width: 3px;
    height: 7px;
    border-width: 0 2px 2px 0;
}

.le-fb__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.le-fb__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--le-fb-border);
    border-radius: var(--le-fb-radius);
    color: inherit;
    font-size: 14px;
    text-decoration: none;
}

.le-fb__clear {
    border: 0;
    padding: 4px 6px;
    background: none;
    color: var(--le-fb-muted);
    font: inherit;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
}

/*
 * Mobile hybrid. The sheet, its scrim and the drag handle are laid out here but
 * only revealed below the breakpoint - the desktop bar never shows them.
 */
.le-fb__pill--sheet,
.le-fb__handle,
.le-fb__sheet,
.le-fb__scrim {
    display: none;
}

.le-fb__acc {
    border-bottom: 1px solid var(--le-fb-border);
}

.le-fb__acc-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px 2px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.le-fb__acc-name {
    font-weight: 700;
}

.le-fb__acc-value {
    flex: 1 1 auto;
    overflow: hidden;
    color: var(--le-fb-muted);
    font-size: 14px;
    text-align: right;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.le-fb__acc-body[hidden] {
    display: none;
}

.le-fb__acc-body {
    padding-bottom: 10px;
}

/*
 * Inline SVG icons. They inherit currentColor, so a pill that changes colour
 * takes its icon with it and no second asset is requested. The chevron flips on
 * aria-expanded rather than on a JS-set class: the attribute is already the
 * source of truth for screen readers, so there is only one state to keep right.
 */
.le-fb__chevron,
.le-fb__sliders {
    stroke: currentColor;
    fill: none;
    flex: 0 0 auto;
}

.le-fb__chevron {
    width: var(--le-fb-icon);
    height: var(--le-fb-icon);
    stroke-width: 2.2;
    transition: transform .15s;
}

.le-fb__sliders {
    width: var(--le-fb-icon-lg);
    height: var(--le-fb-icon-lg);
    stroke-width: 2;
}

[aria-expanded="true"] > .le-fb__chevron {
    transform: rotate(180deg);
}

/*
 * "More filters" is a text action in the mockup, not a pill: no border, bold,
 * icon leading. It keeps the pill class for layout and overrides the skin.
 */
.le-fb__more {
    border-color: transparent;
    background: none;
    padding-left: 8px;
    padding-right: 0;
    font-weight: 700;
}

.le-fb__more:hover {
    border-color: transparent;
    text-decoration: underline;
}

.le-fb__option--radio .le-fb__check {
    border-radius: 50%;
}

/*
 * Availability pill. It used to carry the admorris avf classes so the template
 * SCSS would style it - measured on 20.09.2026 that SCSS made it uppercase, 47px
 * tall and gave it a foreign box. It is a plugin pill now and is styled here;
 * only the data-le-avf attribute stays, because the admorris element keys on it.
 * (The old class names are deliberately not spelled out: a gate greps for them.)
 */
.le-fb__avf {
    text-transform: none;
}

.le-fb__avf-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--le-fb-box);
    height: var(--le-fb-box);
    border: 2px solid var(--le-fb-border);
    border-radius: 3px;
    flex: 0 0 auto;
}

.le-fb__avf.is-active .le-fb__avf-box {
    border-color: var(--le-fb-brand);
    background: var(--le-fb-brand);
}

.le-fb__avf.is-active .le-fb__avf-box::after {
    content: "";
    width: 4px;
    height: 8px;
    margin-top: -2px;
    border: solid var(--le-fb-surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.le-fb__switch {
    position: relative;
    width: 38px;
    height: 22px;
    margin-left: auto;
    border-radius: var(--le-fb-radius);
    background: var(--le-fb-border);
    flex: 0 0 auto;
}

.le-fb__switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--le-fb-surface);
    transition: left .15s;
}

.le-fb__acc-head[data-le-fb-selected="1"] .le-fb__switch {
    background: var(--le-fb-brand);
}

.le-fb__acc-head[data-le-fb-selected="1"] .le-fb__switch::after {
    left: 18px;
}

/* Mobile: one horizontally scrolling row. Breakpoint is a single named value. */
@media (max-width: 767px) {
    .le-fb__row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .le-fb__row::-webkit-scrollbar {
        display: none;
    }

    .le-fb__right {
        margin-left: 0;
    }

    .le-fb__sort,
    .le-fb__more {
        display: none;
    }

    /* Single pill becomes a bottom sheet: scrim, handle, list, apply. */
    .le-fb__dropdown {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        top: auto;
        z-index: 1052;
        max-width: none;
        max-height: 70vh;
        overflow-y: auto;
        border-radius: var(--le-fb-radius-panel) var(--le-fb-radius-panel) 0 0;
    }

    .le-fb__handle {
        display: block;
        width: 40px;
        height: 4px;
        margin: 0 auto 10px;
        border-radius: var(--le-fb-radius);
        background: var(--le-fb-border);
    }

    .le-fb__pill--sheet {
        display: inline-flex;
        order: -1;
        border-color: var(--le-fb-ink);
    }

    .le-fb__scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(0, 0, 0, .45);
    }

    .le-fb__scrim[hidden] {
        display: none;
    }

    /* Full-screen sheet: header, scrolling accordion body, sticky footer. */
    .le-fb__sheet {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 1055;
        flex-direction: column;
        background: var(--le-fb-surface);
    }

    .le-fb__sheet[hidden] {
        display: none;
    }

    .le-fb__sheet-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        border-bottom: 1px solid var(--le-fb-border);
        font-weight: 700;
    }

    .le-fb__sheet-close {
        border: 0;
        background: none;
        color: inherit;
        font-size: 24px;
        line-height: 1;
        cursor: pointer;
    }

    .le-fb__sheet-body {
        flex: 1 1 auto;
        padding: 0 16px;
        overflow-y: auto;
    }

    .le-fb__sheet-body .le-fb__list {
        max-height: none;
    }

    .le-fb__sheet-foot {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        border-top: 1px solid var(--le-fb-border);
    }

    .le-fb__sheet-reset {
        border: 1px solid var(--le-fb-border);
        border-radius: var(--le-fb-radius-panel);
        padding: 12px 16px;
        background: none;
        color: inherit;
        font: inherit;
        cursor: pointer;
    }

    .le-fb__sheet-apply {
        flex: 1 1 auto;
        border: 0;
        border-radius: var(--le-fb-radius-panel);
        padding: 12px 16px;
        background: var(--le-fb-brand);
        color: #fff;
        font: inherit;
        cursor: pointer;
    }
}

/* Set while a sheet is open so the page behind it cannot scroll away. */
body.le-fb-locked {
    overflow: hidden;
}

/*
 * Loading state of an in-place filter change (phase 2).
 *
 * The class sits on body, not on the grid: the grid node is replaced during the
 * swap, so a state stored on it would be carried away half-way through and the
 * clean-up would have nothing left to clear. Values taken from the approved
 * mockup (opacity .35, 38 px ring, brand arc on a grey track).
 */
body.le-fb-busy {
    --le-fb-spinner: 38px;
    --le-fb-spinner-top: 120px;
}

body.le-fb-busy #product-list {
    position: relative;
    opacity: .35;
    pointer-events: none;
    transition: opacity .15s;
}

body.le-fb-busy #product-list::after {
    content: "";
    position: absolute;
    z-index: 5;
    top: var(--le-fb-spinner-top);
    left: 50%;
    width: var(--le-fb-spinner);
    height: var(--le-fb-spinner);
    margin-left: calc(var(--le-fb-spinner) / -2);
    border: 4px solid var(--le-fb-track);
    border-top-color: var(--le-fb-brand);
    border-radius: 50%;
    animation: le-fb-spin .7s linear infinite;
}

@keyframes le-fb-spin {
    to { transform: rotate(360deg); }
}

/* A spinner that cannot spin still has to read as "busy", hence the dimming. */
@media (prefers-reduced-motion: reduce) {
    body.le-fb-busy #product-list::after {
        animation: none;
    }
}
