/* ── Shop toolbar ───────────────────────────────────────────
   Figma: desktop 3033:94075 (open filter 3033:93581, pills
   3033:94092), tablet 3033:94864, mobile 3033:94493.
   ─────────────────────────────────────────────────────────── */

.shop-toolbar {
    padding: 40px var(--pad-x) 0;
}

.shop-toolbar__inner {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: var(--site-max-w);
    margin: 0 auto;
}

.shop-toolbar__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

/* The search results' heading, with "24 products found" under it */
div.shop-toolbar__title {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shop-toolbar__count {
    line-height: 20.8px;
}

.shop-toolbar__controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Sort By */
.shop-toolbar__sort {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shop-toolbar__sort-label {
    font-weight: 700;
    line-height: 20.8px;
    white-space: nowrap;
}

.shop-toolbar__select {
    position: relative;
    display: flex;
}

/* The button looks like the Filter button; its menu like the Filter panel */
.shop-toolbar__select-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-width: 180px;
    height: 46px;
    padding: 10px 20px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-white);
    box-shadow: 0 0 6px rgb(0 0 0 / 0.12);
    color: var(--color-text);
    font: inherit;
    line-height: 20.8px;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.shop-toolbar__select-toggle[aria-expanded="true"] {
    border-radius: 4px 4px 0 0;
}

.shop-toolbar__chevron {
    flex: none;
    width: 20px;
    height: 20px;
    transition: rotate var(--transition);
}

/* "rotate" on top of the icon's own inline turn: points up while open */
.shop-toolbar__select-toggle[aria-expanded="true"] .shop-toolbar__chevron {
    rotate: 180deg;
}

.shop-toolbar__menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: var(--color-white);
    box-shadow: 0 6px 6px rgb(0 0 0 / 0.12);
}

.shop-toolbar__menu[hidden] {
    display: none;
}

.shop-toolbar__choice {
    position: relative;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 20.8px;
    white-space: nowrap;
    cursor: pointer;
}

.shop-toolbar__choice:hover,
.shop-toolbar__choice:has(input:focus-visible) {
    background: var(--color-grey-hover);
}

/* The radio itself stays for the keyboard and screen readers, unseen. */
.shop-toolbar__choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.shop-toolbar__choice:has(input:checked) {
    color: var(--color-primary);
    font-weight: 700;
}

/* Filter: the toggle, and the panel that drops from it */
.shop-toolbar__filter {
    position: relative;
    width: 320px;
}

.shop-toolbar__filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 46px;
    padding: 10px 20px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-white);
    box-shadow: 0 0 6px rgb(0 0 0 / 0.12);
    color: var(--color-text);
    font: inherit;
    line-height: 20.8px;
    cursor: pointer;
}

.shop-toolbar__filter-toggle[aria-expanded="true"] {
    border-radius: 4px 4px 0 0;
}

.shop-toolbar__filter-icon {
    width: 20px;
    height: 20px;
}

.shop-toolbar__panel {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    padding: 0 16px 20px;
    overflow-x: hidden; /* scrolls up and down only */
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: var(--color-white);
    box-shadow: 0 6px 6px rgb(0 0 0 / 0.12);
}

.shop-toolbar__panel[hidden] {
    display: none;
}

.shop-toolbar__group {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.shop-toolbar__group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 0;
    border: 0;
    background: none;
    color: var(--color-text);
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 500;
    line-height: 20px;
    text-align: left;
    cursor: pointer;
}

.shop-toolbar__group-chevron {
    width: 16px;
    height: 16px;
    transform: rotate(-90deg);
    transition: transform var(--transition);
}

.shop-toolbar__group-toggle[aria-expanded="false"] .shop-toolbar__group-chevron {
    transform: rotate(180deg);
}

.shop-toolbar__group-toggle[aria-expanded="false"] + .shop-toolbar__options {
    display: none;
}

.shop-toolbar__options {
    display: flex;
    flex-direction: column;
}

.shop-toolbar__option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 16px 4px 8px;
    border-radius: 4px;
    line-height: 20.8px;
    cursor: pointer;
}

.shop-toolbar__option:hover {
    background: var(--color-grey-hover);
}

.shop-toolbar__option input {
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 2px solid var(--color-primary);
    border-radius: 4px;
    background: var(--color-white) center / 20px no-repeat;
    cursor: pointer;
    appearance: none;
}

.shop-toolbar__option input:checked {
    background-color: var(--color-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.5' d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

.shop-toolbar__option input:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

/* A pill for each ticked filter */
.shop-toolbar__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.shop-toolbar__pills:not(:has(*)) {
    display: none;
}

/* A pill: its name and its × are separate controls */
.shop-toolbar__pill {
    cursor: default;
}

.shop-toolbar__pill-open {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.shop-toolbar__pill-remove {
    position: relative;
    color: inherit;
    text-decoration: none;
}

/* A bigger tap area than the × itself */
.shop-toolbar__pill-remove::after {
    content: "";
    position: absolute;
    inset: -8px -10px;
}

/* ── Tablet: Filter is an icon button ───────────────────────── */
@media (max-width: 1024px) {
    .shop-toolbar {
        padding-top: 32px;
    }

    .shop-toolbar__head {
        align-items: center;
    }

    .shop-toolbar__select-toggle {
        min-width: 212px;
    }

    .shop-toolbar__filter {
        position: static;
        width: 46px;
    }

    .shop-toolbar__filter-toggle {
        position: relative;
        z-index: 21; /* over the panel */
        justify-content: center;
        padding: 0;
    }

    .shop-toolbar__filter-toggle[aria-expanded="true"] {
        border-color: transparent;
        border-radius: 4px;
        background: transparent;
        box-shadow: none;
    }

    .shop-toolbar__filter-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    /* The Filter panel opens over the whole of Sort By and Filter, from the
       filter button's corner: "Filter" on the left, the button staying top
       right (tap it again to close). Shorter, as a share of the screen's
       height; scrolling inside it doesn't scroll the page. */
    .shop-toolbar__controls {
        position: relative;
    }

    .shop-toolbar__panel {
        top: 0;
        left: 0;
        width: auto;
        border-top: 1px solid var(--color-border);
        border-radius: 12px;
        max-height: 50vh;
        max-height: 50dvh;
        overscroll-behavior: contain;
        box-shadow: 0 0 12px rgb(0 0 0 / 0.2);
        transform-origin: top right;
        animation: shop-toolbar-panel-open 200ms ease-out;
    }

    /* Stays at the top while the options scroll, level with the button */
    .shop-toolbar__panel::before {
        content: "Filter";
        position: sticky;
        top: 0;
        z-index: 1;
        flex-shrink: 0;
        margin-inline: -16px;
        padding-inline: 16px;
        background: var(--color-white);
        line-height: 46px;
    }
}

/* ── Mobile: title, then the controls, then the pills ──────── */
@media (max-width: 767px) {
    .shop-toolbar {
        padding-top: 40px;
    }

    .shop-toolbar__inner {
        gap: 25px;
    }

    .shop-toolbar__form,
    .shop-toolbar__head {
        display: contents;
    }

    .shop-toolbar__title {
        order: 1;
    }

    /* The pills under the controls, as on desktop */
    .shop-toolbar__controls {
        order: 2;
        justify-content: space-between;
    }

    .shop-toolbar__pills {
        order: 3;
    }

    .shop-toolbar__sort {
        flex: 1;
        min-width: 0;
    }

    .shop-toolbar__select {
        flex: 1;
        min-width: 0;
    }

    .shop-toolbar__select-toggle {
        min-width: 0;
    }
}

/* The page behind the open Filter panel doesn't scroll (tablet and mobile; shop-toolbar.js). */
.has-filter-open {
    overflow: hidden;
}

@keyframes shop-toolbar-panel-open {
    from {
        opacity: 0;
        transform: scale(0.15);
    }
}
