/*
 * IO-31583 Modern product filter layout.
 *
 * Authored mobile-first: the unprefixed rules below describe the phone layout
 * (a slide-out drawer), and the min-width blocks progressively promote it to a
 * sticky desktop sidebar. There are deliberately no max-width queries here.
 *
 * Everything is namespaced under .io-filter so this file is inert on sites
 * still using the classic layout.
 */

.io-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.io-filter {
    /* Sticky is silently inert if an ancestor clips overflow. We can at least
       guarantee our own wrapper does not. */
    overflow: visible;
    font-family: var(--e-global-typography-text-font-family), sans-serif;
}

/* ---------- drawer trigger (phones only) ---------- */

.io-filter-open {
    position: sticky;
    top: 0;
    z-index: 9300;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    background: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.io-filter-count {
    display: inline-block;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--e-global-color-accent, green);
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
}

.io-filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9400;
    background: rgba(0, 0, 0, 0.45);
}

.io-filter-backdrop[hidden] {
    display: none;
}

/* ---------- panel ---------- */

.io-filter-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 9500;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: min(90vw, 360px);
    background: #fff;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

.io-filter.is-open .io-filter-panel {
    transform: translateX(0);
}

.io-filter-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.io-filter-heading {
    margin: 0;
    font-size: 18px;
}

.io-filter-close {
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

/* Keep the page scroll position while the drawer owns the viewport. iOS
   Safari ignores overflow:hidden on body, hence the position:fixed approach
   applied by the script. */
.io-filter-locked {
    overflow: hidden;
}

/* ---------- active filter chips ---------- */

.io-filter-active {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}

.io-filter-active[hidden] {
    display: none;
}

.io-filter-active-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
}

.io-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 4px 10px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 14px;
    background: #f5f5f5;
    font-size: 13px;
}

.io-filter-chip button {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.io-filter-chip button::before {
    content: "\00d7";
}

.io-filter-chip button:hover,
.io-filter-chip button:focus-visible {
    background: rgba(0, 0, 0, 0.12);
}

.io-filter-clear {
    padding: 0;
    border: 0;
    background: none;
    color: var(--e-global-color-accent, green);
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- facet groups ---------- */

.io-filter-form {
    flex: 1 1 auto;
    padding: 0 16px;
}

.io-filter-group {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.io-filter-group-title {
    margin: 0;
    font-size: inherit;
}

.io-filter-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    /* The caret is rotated 45deg, which widens its bounding box past the
       nominal 8px and would otherwise poke through the panel's right edge
       and raise a horizontal scrollbar. */
    padding: 12px 4px 12px 0;
    border: 0;
    background: none;
    color: #3c3c3c;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    cursor: pointer;
}

.io-filter-group-caret {
    width: 8px;
    height: 8px;
    margin-left: 10px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.io-filter-group-toggle[aria-expanded="false"] .io-filter-group-caret {
    transform: rotate(-45deg);
}

.io-filter-group-body {
    padding-bottom: 12px;
}

.io-filter-group-body[hidden] {
    display: none;
}

.io-filter-options {
    display: grid;
    /* The operator's column width becomes a minimum on small screens so the
       grid can still reflow, rather than a fixed track that overflows. */
    grid-template-columns: repeat(auto-fill, minmax(var(--io-filter-col-w, 120px), 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.io-filter-option {
    margin: 0;
}

.io-filter-choice {
    display: block;
    cursor: pointer;
}

.io-filter-choice:hover .io-filter-choice-inner {
    border-color: rgba(0, 0, 0, 0.22);
}

/* Visually hidden but still focusable and still in the tab order - display:none
   would remove it from both. */
.io-filter-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.io-filter-choice-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 6px 8px;
    /* border-box so the 1px border cannot push a grid item past its track */
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
}

/* Options without artwork need a visible control - the real checkbox is
   clipped for the swatch layout, so a text-only row would otherwise look
   like inert copy. */
.io-filter-option:not(.has-image) .io-filter-choice-inner::before {
    content: "";
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 18px;
    height: 18px;
    border: 1px solid rgba(0, 0, 0, 0.45);
    border-radius: 3px;
    background: #fff;
}

.io-filter-option:not(.has-image) .io-filter-input:checked + .io-filter-choice-inner::before {
    border-color: var(--e-global-color-accent, green);
    background: var(--e-global-color-accent, green);
    box-shadow: inset 0 0 0 2px #fff;
}

.io-filter-option.has-image .io-filter-choice-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    text-align: center;
}

.io-filter-input:checked + .io-filter-choice-inner {
    border-color: var(--e-global-color-accent, green);
    background: rgba(0, 0, 0, 0.04);
    font-weight: 600;
}

.io-filter-input:focus-visible + .io-filter-choice-inner {
    outline: 2px solid var(--e-global-color-accent, green);
    outline-offset: 2px;
}

.io-filter-swatch {
    display: block;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    /* A fixed height letterboxes badly when the tile is wide; a ratio keeps
       the artwork in proportion at any panel width. */
    height: auto;
    aspect-ratio: 3 / 2;
    min-height: 70px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    background-color: #eee;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

/* Selected artwork gets an explicit check badge - an outline alone is easy
   to miss on busy product photos. */
.io-filter-input:checked + .io-filter-choice-inner .io-filter-swatch::after {
    content: "\2713";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--e-global-color-accent, green);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 13px;
    line-height: 22px;
    text-align: center;
}

/* Categories with no artwork get a same-sized initial tile, so a missing image
   never breaks the grid rhythm. */
.io-filter-swatch[data-io-initial]:not([style*="url"])::before {
    content: attr(data-io-initial);
    display: grid;
    place-items: center;
    height: 100%;
    border-radius: 3px;
    background: var(--e-global-color-secondary, #444);
    color: #fff;
    font-size: 26px;
    text-transform: uppercase;
}

/* ---------- price / size rows ---------- */

.io-filter-range-row {
    margin: 10px 0;
}

.io-filter-range-legend {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}

.io-filter-range-pair {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.io-filter-range-pair label {
    font-size: 13px;
}

.io-filter-range-pair input[type="number"] {
    flex: 1 1 70px;
    min-width: 0;
    /* Never balloon to fill a wide row - these are two-to-four digit numbers. */
    max-width: 140px;
    min-height: 40px;
    padding: 4px 8px;
    border: 1px solid #c9c9c9;
    border-radius: 6px;
    background: #fff;
}

/* The shared stylesheet caps range inputs at 400px; inside the panel they need
   to track the container instead. */
.io-filter input[type="range"] {
    width: 100%;
    max-width: 100%;
}

.io-filter .multi-range {
    display: block;
    position: relative;
    width: 100%;
    margin-top: 8px;
}

.io-filter-size-container[hidden] {
    display: none;
}

.io-filter-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--e-global-color-accent, green);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- footer ---------- */

.io-filter-panel-foot {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 8px;
    padding: 12px 0;
    background: #fff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.io-filter-panel-foot button {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 15px;
    cursor: pointer;
}

.io-filter-reset {
    border: 1px solid rgba(0, 0, 0, 0.25);
    background: #fff;
}

.io-filter-apply-close {
    border: 0;
    background: var(--e-global-color-accent, green);
    color: #fff;
    font-weight: 600;
}

/* ---------- processing indicator ---------- */

/* The ring itself is styled in io_styles_v6.css, whose selector list this
   class was added to - only the box is declared here. z-index sits below the
   cart's own overlay (10000) so the two never fight. */
.io-filter-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 9000;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
}

.io-filter-overlay.is-visible {
    display: flex;
}

.io-filter-results-busy {
    min-height: 240px;
}

.io-filter-error {
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid #e0b4b4;
    border-radius: 4px;
    background: #fff6f6;
    color: #8a1f11;
    font-size: 14px;
}

.io-filter-retry {
    margin-left: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.io-filter.is-busy .io-filter-panel {
    opacity: 0.7;
}

/* ---------- desktop: promote the drawer to a sidebar ---------- */

@media (min-width: 769px) {
    .io-filter-open,
    .io-filter-close,
    .io-filter-backdrop,
    .io-filter-apply-close {
        display: none;
    }

    .io-filter-panel {
        position: static;
        width: auto;
        /* This is a sidebar layout. Dropped into a full-width container it
           would otherwise stretch edge to edge and letterbox the swatches, so
           cap it at roughly the reference site's 400px. Override
           --io-filter-panel-max to widen it. */
        max-width: var(--io-filter-panel-max, 420px);
        padding: 2px 18px 14px;
        border: 1px solid rgba(0, 0, 0, 0.1);
        border-radius: 10px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
        transform: none;
        overflow: visible;
    }

    .io-filter-panel-head {
        padding: 12px 0 10px;
    }

    .io-filter-active {
        padding: 10px 0;
    }

    .io-filter.is-sticky .io-filter-panel {
        position: sticky;
        top: var(--io-filter-top, 20px);
        max-height: calc(100vh - var(--io-filter-top, 20px) - 20px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .io-filter-form {
        padding: 0;
    }

    .io-filter-options {
        grid-template-columns: repeat(var(--io-filter-cols, 2), minmax(0, 1fr));
    }

    .io-filter-panel-foot {
        position: static;
        box-shadow: none;
    }
}

/* WordPress core pins the admin bar at 783px and above; below that it scrolls
   with the page and needs no compensation. */
@media (min-width: 783px) {
    body.admin-bar .io-filter.is-sticky .io-filter-panel {
        top: calc(var(--io-filter-top, 20px) + 32px);
        max-height: calc(100vh - var(--io-filter-top, 20px) - 52px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .io-filter-panel,
    .io-filter-group-caret {
        transition: none;
    }

    /* A frozen ring communicates nothing, so say it in words instead. */
    .io-filter-overlay .io-spinner {
        animation: none;
        border-top-color: transparent;
    }

    /* ASCII only: a .css file has no charset of its own and falls back to the
       referring document's encoding, so a literal ellipsis can arrive mojibaked. */
    .io-filter-overlay::after {
        content: "Updating results...";
        font-size: 14px;
    }
}
