/*
 * Facets — sidebar form + active-filter pills + mobile drawer behaviour.
 * Uses theme tokens (--rm-red, --rm-light-gray, etc.) defined in
 * restomod theme's tokens.css.
 */

/* ===== Active-filter pills ============================================ */
.rm-facet-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 var(--rm-sp-4, 16px);
    margin-bottom: var(--rm-sp-3, 12px);
}
.rm-facet-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--rm-charcoal, #1A1A2E);
    color: var(--rm-white, #fff);
    padding: 6px 12px;
    border-radius: 999px;
    font-family: var(--rm-font-h, sans-serif);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-decoration: none;
    min-height: 32px;
    line-height: 1.2;
}
.rm-facet-pill:hover { background: var(--rm-red, #C62828); }
.rm-facet-pill__x { font-size: 1rem; line-height: 0.6; }

/* ===== Filter button (mobile trigger) ================================ */
.rm-facets-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--rm-charcoal, #1A1A2E);
    color: var(--rm-white, #fff);
    border: none;
    padding: 10px 16px;
    font-family: var(--rm-font-h, sans-serif);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    border-radius: var(--radius-sm, 6px);
    min-height: var(--tap, 44px);
    font-size: 0.85rem;
    cursor: pointer;
}
.rm-facets-trigger:hover { background: var(--rm-red, #C62828); }
.rm-facets-trigger__badge {
    background: var(--rm-red, #C62828);
    color: var(--rm-white, #fff);
    border-radius: 999px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ===== Drawer (mobile + tablet) ====================================== */
.rm-facets-drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}
.rm-facets-drawer-scrim.is-open { display: block; }

.rm-facets-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(360px, 90vw);
    background: var(--rm-white, #fff);
    z-index: 1000;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}
.rm-facets-drawer.is-open { transform: translateX(0); }

.rm-facets-drawer__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--rm-light-gray, #F4F5F7);
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

/* ===== Form ============================================================ */
.rm-facets {
    padding: var(--rm-sp-4, 16px);
    display: flex;
    flex-direction: column;
    gap: var(--rm-sp-4, 16px);
}
.rm-facets__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 48px var(--rm-sp-3, 12px) 0; /* leave space for absolute × close button (mobile drawer) */
    border-bottom: 2px solid var(--rm-red, #C62828);
    gap: var(--rm-sp-3, 12px);
}
.rm-facets__head h2 {
    margin: 0;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.rm-facets__clear {
    color: var(--rm-red, #C62828);
    font-family: var(--rm-font-h, sans-serif);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.78rem;
    text-decoration: none;
    white-space: nowrap;
}
@media (min-width: 1024px) {
    .rm-facets__head { padding-right: 0; } /* no close button on desktop */
}

/* ===== Facet group (one per axis) =================================== */
.rm-facet-group {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rm-facet-group legend {
    font-family: var(--rm-font-h, sans-serif);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
    color: var(--rm-charcoal, #1A1A2E);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--rm-border, #E2E4E8);
    width: 100%;
}
.rm-facet-search {
    border: 1px solid var(--rm-border, #E2E4E8);
    border-radius: var(--radius-sm, 6px);
    padding: 8px 10px;
    font-size: 0.85rem;
    width: 100%;
    min-height: 36px;
}
.rm-facet-options {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.rm-facet-options li { padding: 0; }
.rm-facet-options.rm-is-overflow { max-height: 280px; }
.rm-facet-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    cursor: pointer;
    min-height: 28px;
    line-height: 1.2;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.85rem;
}
/* Restore generous tap-target on actual touch devices only. Hover-capable
 * desktops/laptops get the compact rhythm Joe asked for. */
@media (hover: none) and (pointer: coarse) {
    .rm-facet-options label { min-height: var(--tap, 44px); padding: 8px 6px; }
}
.rm-facet-options label:hover { background: var(--rm-light-gray, #F4F5F7); }
.rm-facet-options input[type=checkbox],
.rm-facet-options input[type=radio] {
    width: 18px;
    height: 18px;
    accent-color: var(--rm-red, #C62828);
    flex-shrink: 0;
}
.rm-facet-name {
    flex: 1;
    font-size: 0.88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rm-facet-count {
    color: var(--rm-mid-gray, #444B53);
    font-size: 0.78rem;
    flex-shrink: 0;
}
.rm-facet-options li.rm-is-hidden { display: none; }

/* ===== Price range =================================================== */
.rm-facet-group--price .rm-facet-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.rm-facet-price-field {
    flex: 1;
}
.rm-facet-price-field input {
    width: 100%;
    border: 1px solid var(--rm-border, #E2E4E8);
    border-radius: var(--radius-sm, 6px);
    padding: 10px 12px;
    font-size: 0.95rem;
    min-height: 40px;
    -moz-appearance: textfield;
}
.rm-facet-price-field input::-webkit-outer-spin-button,
.rm-facet-price-field input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}

/* ===== Actions ======================================================== */
.rm-facets__actions {
    position: sticky;
    bottom: 0;
    background: var(--rm-white, #fff);
    padding: 12px 0 0;
    border-top: 1px solid var(--rm-border, #E2E4E8);
    margin-top: var(--rm-sp-3, 12px);
}
.rm-facets__apply {
    width: 100%;
    background: var(--rm-red, #C62828);
    color: var(--rm-white, #fff);
    border: none;
    padding: 14px 16px;
    font-family: var(--rm-font-h, sans-serif);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    border-radius: var(--radius-sm, 6px);
    min-height: var(--tap, 44px);
    cursor: pointer;
    font-size: 1rem;
}
.rm-facets__apply:hover { background: var(--rm-red-dark, #8E0000); }

/* ===== Desktop sidebar (>=1024px) — replaces the drawer ============== */
@media (min-width: 1024px) {
    .rm-facets-trigger { display: none; }
    .rm-facets-drawer-scrim { display: none !important; }

    .rm-facets-drawer {
        position: static;
        transform: none;
        width: 280px;
        box-shadow: none;
        overflow: visible;
        background: transparent;
    }
    .rm-facets-drawer__close { display: none; }

    .rm-facets {
        padding: 0;
        position: sticky;
        top: 90px;
        max-height: calc(100vh - 110px);
        overflow-y: auto;
    }

    /* The shop-grid layout: facets left, products right. archive-product.php
       wraps both in .rm-shop-with-facets at desktop to enable this grid. */
    .rm-has-facets.woocommerce .rm-shop-with-facets,
    .rm-has-facets .rm-shop-with-facets {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: var(--rm-sp-5, 24px);
        padding: 0 var(--rm-sp-5, 24px);
        max-width: var(--rm-container-max, 1240px);
        margin: 0 auto;
    }
}
