/* =============================================================================
   CATALOG FILTER BAR — one slim row above the grid.
   The catalogue is the posters; the controls are how you narrow them down, so
   they get a single line and no more: «مرتب‌سازی» always visible because it is
   used constantly, and everything else folded behind one «فیلترها» button that
   says how many are active. Nothing is removed — it is put away.
   ========================================================================== */

.fp-cat-bar {
    /* the panel hangs from the BAR, not from the button, so it can use the
       full width of the row instead of half of it */
    position: relative;
    /* grid, not flex: two exactly equal columns whatever the sort label says —
       with flex the longer option text quietly stole width from the button. */
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 8px;
    max-width: 640px;
    margin: 0 auto 14px;
    padding: 0 2px;
}

/* both controls are the same pill so the row reads as one object */
.fp-cat-pill {
    position: relative;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 13px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .055);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
    color: #EDF1F8;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .18s, border-color .18s;
}

.fp-cat-pill:hover {
    background: rgba(255, 255, 255, .085);
    border-color: rgba(255, 255, 255, .18);
}

.fp-cat-pill > svg {
    flex: none;
    width: 17px;
    height: 17px;
    opacity: .75;
}

/* ── sort: a real select, dressed as the pill ───────────────────────────── */
.fp-cat-sort select {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    text-overflow: ellipsis;
}

.fp-cat-sort select:focus-visible {
    outline: 2px solid #9CC2FF;
    outline-offset: 3px;
    border-radius: 8px;
}

.fp-cat-sort select option {
    background: #12161D;
    color: #EDF1F8;
}

/* the caret: drawn tight to the text so the pill reads as one control */
.fp-cat-sort::after {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-inline-start: 2px;
    border-inline-start: 1.7px solid rgba(255, 255, 255, .55);
    border-bottom: 1.7px solid rgba(255, 255, 255, .55);
    transform: rotate(-45deg) translate(1px, -1px);
}

/* ── filters: a <details> so it works with JavaScript off ───────────────── */
.fp-cat-filters {
    padding: 0;
    display: block;
    min-width: 0;
    height: auto;
    background: none;
    border: 0;
    box-shadow: none;
}

.fp-cat-filters > summary {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 13px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .055);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
    list-style: none;
    cursor: pointer;
    transition: background .18s, border-color .18s;
}

.fp-cat-filters > summary::-webkit-details-marker { display: none; }
.fp-cat-filters > summary:hover { background: rgba(255, 255, 255, .085); border-color: rgba(255, 255, 255, .18); }
.fp-cat-filters[open] > summary { background: rgba(253, 116, 23, .12); border-color: rgba(253, 116, 23, .42) }
.fp-cat-filters > summary svg { flex: none; width: 17px; height: 17px; opacity: .75 }
.fp-cat-filters > summary b { font-weight: 700 }

/* how many filters are on — the reason it is safe to hide them */
.fp-cat-count {
    flex: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: .68rem;
    font-weight: 800;
    color: #22100A;
    background: linear-gradient(135deg, #FDAB01, #FA363C);
}

/* ── the panel ──────────────────────────────────────────────────────────── */
.fp-cat-panel {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 8px);
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 8px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(16, 19, 26, .96);
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 22px 50px rgba(0, 0, 0, .55);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
    animation: fpCatPanelIn .18s cubic-bezier(.22, 1, .36, 1) both;
}

@keyframes fpCatPanelIn {
    from { opacity: 0; transform: translateY(-6px) }
    to   { opacity: 1; transform: none }
}

.fp-cat-panel .filter-input { margin: 0; min-width: 0 }
.fp-cat-panel .filter-input.wide { grid-column: 1 / -1 }

.fp-cat-panel label {
    display: block;
    margin: 0 2px 5px;
    font-size: .68rem;
    font-weight: 700;
    color: rgba(255, 255, 255, .5);
}

.fp-cat-panel input,
.fp-cat-panel select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: .85rem;
    font-family: inherit;
    color: #f3f4f6;
    border-radius: 12px;
    background: rgba(2, 6, 16, .42);
    border: 1px solid rgba(255, 255, 255, .12);
}

.fp-cat-panel .catalog-filter-btn {
    grid-column: 1 / -1;
    border: 0;
    border-radius: 13px;
    padding: 12px;
    font-family: inherit;
    font-size: .88rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    background: linear-gradient(105deg, #FFB347, #FF7A45, #FF4D7B, #E02E8A);
}

.fp-cat-panel .catalog-reset-btn {
    grid-column: 1 / -1;
    text-align: center;
    padding: 11px;
    border-radius: 13px;
    font-size: .84rem;
    font-weight: 700;
    color: rgba(255, 255, 255, .7);
    text-decoration: none;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255, 255, 255, .1);
}

/* Narrow phones: one column inside the panel, and the two pills keep sharing
   the row — they are short enough that stacking them would waste a line. */
/* Only the genuinely small phones drop to one column — at 360–430 px two
   columns still fit comfortably and keep the panel short. */
@media (max-width: 339px) {
    .fp-cat-panel { grid-template-columns: 1fr }
    .fp-cat-pill, .fp-cat-filters > summary { font-size: .8rem; padding: 0 11px; gap: 6px }
}

@media (min-width: 560px) {
    .fp-cat-panel { grid-template-columns: 1fr 1fr 1fr }
    .fp-cat-panel .catalog-filter-btn { grid-column: 1 / 3 }
    .fp-cat-panel .catalog-reset-btn { grid-column: 3 / 4 }
}
