/* Custom facets styling */

/* Make color swatches larger and add gray border */
.facet-checkbox--color {
    width: 4.5rem !important;
    height: 4.5rem !important;
    border: 0.25px solid var(--border-color) !important;
    position: relative !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    transition: outline 0.2s ease !important;
}

/* Theme scheme adjustments (matches project convention) */
body[data-scheme="light"] #FacetFiltersForm {
    --facet-swatch-outline-hover: rgba(0, 0, 0, 0.20);
    --facet-swatch-outline-selected: rgba(0, 0, 0, 0.35);
    --facet-swatch-inner-ring: rgba(255, 255, 255, 0.85);
}

body[data-scheme="dark"] #FacetFiltersForm {
    /* Make selection readable on dark backgrounds */
    --text-color: rgba(255, 255, 255, 0.70);
    --text-selected-color: rgba(255, 255, 255, 0.95);
    --border-color: rgba(255, 255, 255, 0.22);

    --facet-swatch-outline-hover: rgba(255, 255, 255, 0.22);
    --facet-swatch-outline-selected: rgba(255, 255, 255, 0.40);
    /* Inner ring flips darker so it still reads on very light swatches */
    --facet-swatch-inner-ring: rgba(0, 0, 0, 0.35);
}

.facet-checkbox--color:hover {
    outline: 2px solid var(--facet-swatch-outline-hover, #ccc) !important;
    outline-offset: 2px !important;
}


/* Selected state for color swatches */
/* Prefer class-based "active" state for broad browser support (Liquid adds it). */
.facets__item--active .facet-checkbox--color,
.facet-checkbox--color.facet-checkbox--active,
/* Fallback: if markup changes, still support :has() capable browsers. */
.facet-checkbox--color:has(.facets-checkbox__hide:checked),
.facets__list--color .facet-checkbox--color:has(.facets-checkbox__hide:checked) {
    outline: 2px solid var(--facet-swatch-outline-selected, rgba(0, 0, 0, 0.35)) !important;
    outline-offset: 2px !important;
}

/* Add a subtle inner ring so the state reads on dark colors */
.facets__item--active .facet-checkbox--color::before,
.facet-checkbox--color.facet-checkbox--active::before,
.facet-checkbox--color:has(.facets-checkbox__hide:checked)::before {
    box-shadow: inset 0 0 0 1px var(--facet-swatch-inner-ring, rgba(255, 255, 255, 0.85)) !important;
}

/* Make the selected label text slightly stronger too (subtle) */
.facets__item--active .facets-checkbox__label {
    color: var(--text-selected-color) !important;
    font-weight: 500 !important;
}

.facet-checkbox--color::before {
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    border-radius: 50% !important;
}

/* Style color swatch labels - now targeting sibling element */
.facets__list--color li .facets-checkbox__label {
    font-size: 1.2rem !important;
    text-transform: none !important;
    text-align: center !important;
    display: block !important;
    margin-top: 0.5rem !important;
    line-height: 1.2 !important;
    white-space: normal !important;
    width: fit-content !important;
    max-width: 10rem !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
}

/* Fix the list item layout to stack vertically with equal spacing */
.facets__list--color li {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    margin-bottom: 1rem !important;
    width: 4.5rem !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

/* Override any capitalize transforms */
.facets__list--color li .facets-checkbox__label {
    text-transform: lowercase !important;
}

.facets__list--color li .facets-checkbox__label::first-letter {
    text-transform: uppercase !important;
}

/* Ensure the list has proper grid layout with fixed column width - override flexbox */
.facets__list--color {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, 4.5rem) !important;
    gap: 1rem 3rem !important;
    justify-content: start !important;
    width: auto !important;
    max-width: none !important;
    flex-direction: unset !important;
    flex-wrap: unset !important;
}

/* Hide items filtered out by custom-filters.js */
.facets__item--hidden-by-custom {
    display: none !important;
}

/* Same layout on desktop and mobile -- grey border stuff */
#FacetFiltersForm {
    --text-color: #ADADAD;
    --text-selected-color: #5C5C5C;
    --border-color: #E7E7E7;
}

div.facets .fullscreen-container {
    padding: 0 1rem;
    border-top: 0.25px solid var(--border-color) !important;
    border-bottom: 0.25px solid var(--border-color) !important;
}



.facets__wrapper {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    justify-content: center !important;
    align-items: center !important;
    gap: 0 !important;
}

span#ProductCount {
    display: none !important;
}

.button.open_filters {
    display: flex !important;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-color) !important;
    padding: 0 4.5rem;
}

.button.open_filters:hover {
    color: var(--text-selected-color) !important;
}


.border-r {
    border-right: 0.25px solid var(--border-color) !important;
}

@media (min-width: 800px) {
    .border-l {
        border-left: 0.25px solid var(--border-color);
    }
}



/* Sort by */
.facets__sort-by {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    color: var(--text-color) !important;
    padding: 0 4.5rem !important;
    gap: 0 !important;
    position: relative;
}

button.open_sort {
    all: unset !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 1.2rem !important;
    cursor: pointer !important;
    color: var(--text-color) !important;
    font-size: 1.4rem;
    font-weight: 400;
    line-height: 1.2;
    padding: 0.4rem 0 !important;
}

button.open_sort:hover {
    color: var(--text-selected-color) !important;
}

.sort-button__label {
    white-space: nowrap;
    text-transform: none !important;
}

.sort-button__chevron {
    /* display: none; */
    margin: auto 0;
    width: 1.2rem;
    height: 0.8rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

button.open_sort[aria-expanded="true"] .sort-button__chevron {
    transform: rotate(180deg);
}

/* Desktop: Custom dropdown */
@media (min-width: 750px) {
    .sort-dropdown {
        position: absolute;
        top: 100%;
        left: 0rem;
        margin-top: 0;
        background: #fff;
        border: 0.25px solid var(--color-border);
        border-radius: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-0.8rem);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
        z-index: 100;
        width: fit-content;
        min-width: 20rem;
        white-space: nowrap;
    }

    .facets__sort-by-container:has(button.open_sort[aria-expanded="true"]) .sort-dropdown,
    .sort-dropdown.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }

    .sort-dropdown__list {
        list-style: none;
        margin: 0;
        padding: 1rem 0;
    }

    .sort-dropdown__item {
        margin: 0;
        padding: 0;
    }

    .sort-dropdown__option {
        width: 100%;
        display: block;
        padding: 1.2rem 2rem;
        background: none;
        border: none;
        text-align: left;
        cursor: pointer;
        color: var(--text-color);
        font-size: 1.4rem;
        font-weight: 400;
        transition: background-color 0.15s ease;
    }

    .sort-dropdown__option:hover {
        background: rgba(0, 0, 0, 0.03);
    }

    .sort-dropdown__option--active {
        background: rgba(0, 0, 0, 0.05);
        color: var(--text-selected-color);
        font-weight: 500;
    }

    .sort-menu {
        display: none !important;
    }
}

/* Mobile: Bottom drawer */
@media (max-width: 749px) {
    .sort-dropdown {
        display: none !important;
    }
}

/* Allow grid items to shrink within their tracks */
.facets__wrapper>* {
    min-width: 0 !important;
}

/* Grid column control overrides */
.collection-product-list.cols-1 {
    grid-template-columns: repeat(1, 1fr) !important;
}

.collection-product-list.cols-2 {
    grid-template-columns: repeat(2, 1fr) !important;
}

.collection-product-list.cols-3 {
    grid-template-columns: repeat(3, 1fr) !important;
}

.collection-product-list.cols-4 {
    grid-template-columns: repeat(4, 1fr) !important;
}

.collection-product-list.cols-auto {
    grid-template-columns: repeat(auto-fit, minmax(var(--auto-col-min, 240px), 1fr)) !important;
}

/* Bottom Sort Drawer - Mobile only */
@media (min-width: 750px) {
    .sort-menu {
        display: none !important;
    }
}

.sort-menu {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    transition: opacity .25s ease-in-out;
    pointer-events: none;
}

.sort-menu.show_menu {
    opacity: 1;
    pointer-events: auto;
}

.sort-menu .form-menu__mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(2px);
    z-index: 1;
}

.sort-menu__sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgb(243, 243, 243);
    border-radius: 0;
    max-height: 70vh;
    overflow: auto;

    z-index: 2;
    transform: translateY(100%);
    transition: transform .25s ease-in-out;
    will-change: transform;
}

.sort-menu.show_menu .sort-menu__sheet {
    transform: translateY(0);
}

.sort-menu__header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.6rem 0;
    border-bottom: 0.25px solid var(--text-color);
    color: var(--text-selected-color);
}

.sort-menu__close {
    position: absolute;
    right: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    height: fit-content;
    color: inherit;
}

.sort-menu__close svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
    color: inherit;
    fill: currentColor;
    stroke: currentColor;
    transition: transform .2s ease-in-out;
    will-change: transform;
    margin: 0;
}

.sort-menu__close:hover svg {
    transform: rotate(90deg);
}

/* Apply the same hover animation to the filters drawer close button */
.facets-menu__close svg {
    transition: transform .2s ease-in-out;
    will-change: transform;
}

.facets-menu__close:hover svg {
    transform: rotate(90deg);
}

.sort-menu__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.2rem;
    height: 3.2rem;
}

.sort-menu__title {
    margin: 0;
    width: 100%;
    text-align: center;
    font-size: 2rem;
    font-weight: normal !important;
}

.sort-menu__list {
    list-style: none;
    margin: 0;
    padding: 1.5rem 0 1.5rem 0;
}

.sort-menu__item {
    margin: 0;
    padding: 0;
}

.sort-menu__option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 2rem;
    cursor: pointer;
}

.sort-menu__option:hover {
    color: var(--text-selected-color);
}


.sort-menu__option-label {
    font-size: 1.05rem;
}

.sort-menu__option:has(.sort-menu__radio:checked) .sort-menu__option-label {
    color: var(--text-selected-color);
    font-weight: 500;
}

.facets__column-controls {
    gap: 1.5rem !important;
    padding: 0 4.5rem !important;
}

/* Improving the look of the filtering button & text to be like BabyBoo */

@media (max-width: 800px) {

    .open_filters,
    .facets__sort-by,
    .facets__column-controls {
        padding: 0 2rem !important;
    }

    .facets__sort-by {
        min-height: 4.5rem !important;
    }

    .facets__wrapper {
        grid-template-columns: 1fr 1fr auto !important;
    }

    div.facets .fullscreen-container {
        padding: 0 !important;

        svg.icon-button-arrow {
            margin-right: 0 !important;
        }
    }
}


/* Sticky facets */
.collection-grid-section {
    position: relative;
}

.sticky-facets {
    position: fixed;
    background-color: white !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 0 !important;
}

.sticky-facets .facets {
    margin-top: 0 !important;
}