/**
 * AFB Shop — Mobile Filter Drawer + Sticky Bar
 * Add to bottom of shop.css or enqueue separately
 */

@media ( max-width: 768px ) {

    /* -----------------------------------------------------------------------
       Hide sidebar on mobile — JS replaces with drawer
       ----------------------------------------------------------------------- */

    .afb-sidebar-hidden-mobile {
        display: none !important;
    }

    /* -----------------------------------------------------------------------
       Sticky filter bar
       ----------------------------------------------------------------------- */

    #afb-filter-bar {
        position: sticky;
        top: 0;
        z-index: 100;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
        padding: 0.625rem 1rem;
        background: var( --global-palette9, #fff );
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.06 );
    }

    /* Filter trigger button */
    .afb-filter-trigger {
        display: inline-flex;
        align-items: center;
        gap: 0.375rem;
        padding: 0.375rem 0.875rem;
        background: #2d3748;
        color: #fff;
        border: none;
        border-radius: 2rem;
        font-size: 0.875rem;
        font-weight: 600;
        cursor: pointer;
        white-space: nowrap;
        flex-shrink: 0;
        transition: background 0.15s ease;
    }

    .afb-filter-trigger:hover {
        background: #1a202c;
    }

    .afb-filter-trigger--active {
        background: var( --global-palette1, #2872fa );
    }

    .afb-filter-trigger--active:hover {
        background: var( --global-palette2, #1a5fd4 );
    }

    .afb-filter-trigger:focus-visible {
        outline: 2px solid var( --global-palette1, #2872fa );
        outline-offset: 2px;
    }

    /* -----------------------------------------------------------------------
       Active filter chips
       ----------------------------------------------------------------------- */

    .afb-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 0.375rem;
        align-items: center;
    }

    .afb-chip {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        padding: 0.25rem 0.5rem 0.25rem 0.625rem;
        background: #edf2f7;
        color: #2d3748;
        border-radius: 2rem;
        font-size: 0.8125rem;
        font-weight: 500;
        line-height: 1;
    }

    .afb-chip--clear {
        background: transparent;
        color: #4a5568;
        border: 1px solid #cbd5e0;
        cursor: pointer;
        padding: 0.25rem 0.625rem;
        font-size: 0.8125rem;
        font-weight: 500;
        border-radius: 2rem;
        transition: background 0.15s ease;
    }

    .afb-chip--clear:hover {
        background: #edf2f7;
        color: #2d3748;
    }

    .afb-chip--clear:focus-visible {
        outline: 2px solid var( --global-palette1, #2872fa );
        outline-offset: 2px;
    }

    .afb-chip-remove {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1rem;
        height: 1rem;
        background: #cbd5e0;
        color: #2d3748;
        border: none;
        border-radius: 50%;
        font-size: 0.75rem;
        line-height: 1;
        cursor: pointer;
        padding: 0;
        transition: background 0.15s ease;
    }

    .afb-chip-remove:hover {
        background: #a0aec0;
    }

    .afb-chip-remove:focus-visible {
        outline: 2px solid var( --global-palette1, #2872fa );
        outline-offset: 2px;
    }

    /* -----------------------------------------------------------------------
       Backdrop
       ----------------------------------------------------------------------- */

    #afb-drawer-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba( 0, 0, 0, 0.5 );
        z-index: 200;
    }

    .afb-drawer-open #afb-drawer-backdrop {
        display: block;
    }

    /* -----------------------------------------------------------------------
       Drawer
       ----------------------------------------------------------------------- */

    #afb-filter-drawer {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min( 320px, 85vw );
        background: var( --global-palette9, #fff );
        z-index: 300;
        display: flex;
        flex-direction: column;
        transform: translateX( 100% );
        transition: transform 0.3s cubic-bezier( 0.4, 0, 0.2, 1 );
        overflow: hidden;
    }

    #afb-filter-drawer:not([hidden]) {
        transform: translateX( 0 );
    }

    /* Drawer header */
    .afb-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid #e2e8f0;
        flex-shrink: 0;
    }

    .afb-drawer-title {
        font-size: 1.125rem;
        font-weight: 600;
        margin: 0;
        color: #2d3748;
    }

    .afb-drawer-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        background: transparent;
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        color: #4a5568;
        cursor: pointer;
        transition: background 0.15s ease;
    }

    .afb-drawer-close:hover {
        background: #edf2f7;
        color: #2d3748;
    }

    .afb-drawer-close:focus-visible {
        outline: 2px solid var( --global-palette1, #2872fa );
        outline-offset: 2px;
    }

    /* Drawer body — scrollable */
    .afb-drawer-body {
        flex: 1;
        overflow-y: auto;
        padding: 1.25rem;
        -webkit-overflow-scrolling: touch;
    }

    /* Drawer body inherits sidebar widget styles */
    .afb-drawer-body .facetwp-facet {
        margin-bottom: 1.5rem;
    }

    .afb-drawer-body .widget-title,
    .afb-drawer-body .afb-facet-label {
        font-size: 0.8125rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #4a5568;
        margin: 0 0 0.75rem;
    }

    /* -----------------------------------------------------------------------
       Prevent body scroll when drawer is open
       ----------------------------------------------------------------------- */

    .afb-drawer-open {
        overflow: hidden;
    }

    /* -----------------------------------------------------------------------
       Grid adjustment — account for sticky bar height
       ----------------------------------------------------------------------- */

    .afb-downloads-grid {
        grid-template-columns: repeat( 2, 1fr );
    }

}