/* V52-002 (EXP52/v1.0) -- Explore models gallery (/Catalog, /categories/{slug}). SCOPED ONLY: every rule starts with .pb52x
   (Views/Catalog/Index.cshtml); no element / global selector, no change to the shell, header, sidebar or the shared cards.
   Existing PB tokens only (Light / Dark / System through pb-tokens.css); logical properties (RTL / LTR flip once); 48px touch
   targets; no animation. Two compact rows (categories; sort / period / filters) of 48px + one 8px gap = 104px before the grid;
   at 200% text the rows may reflow (no clipping). The category row scrolls inside itself, never the page. */

.pb52x { container-type: inline-size; }

/* ------------------------------------------------------------------ row 1: categories */
.pb52x .pb52x-cats {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    margin: 0;
    padding-block: 0 2px;
    max-inline-size: 100%;
}
.pb52x .pb52x-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-block-size: 48px;
    padding-inline: 16px;
    border: 1px solid var(--pb-divider);
    border-radius: 999px;
    background: var(--pb-surface);
    color: var(--pb-text-primary);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    box-sizing: border-box;
}
.pb52x .pb52x-chip:hover { background: var(--pb-surface-hover, var(--pb-surface)); }
/* selected: not by colour alone -- a 2px selection border + bold weight + aria-current */
.pb52x .pb52x-chip.is-active {
    border: 2px solid var(--pb-selection-border);
    background: var(--pb-surface-selected);
    font-weight: 700;
}
.pb52x .pb52x-chip:focus-visible,
.pb52x .pb52x-select:focus-visible,
.pb52x .pb52x-q:focus-visible,
.pb52x .pb52x-filter__btn:focus-visible {
    outline: 2px solid var(--pb-focus);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ row 2: sort / period / filters */
.pb52x .pb52x-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-block: 8px 16px;
    min-inline-size: 0;
}
.pb52x .pb52x-sort {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    min-inline-size: 0;
    margin: 0;
}
.pb52x .pb52x-period { display: inline-flex; align-items: center; min-inline-size: 0; }
.pb52x .pb52x-period[hidden] { display: none; }
.pb52x .pb52x-select {
    min-block-size: 48px;
    min-inline-size: 0;
    max-inline-size: 11em;
    padding-inline: 12px;
    border: 1px solid var(--pb-control-border);
    border-radius: 10px;
    background: var(--pb-surface);
    color: var(--pb-text-primary);
    font: inherit;
}
.pb52x .pb52x-show { flex: 0 0 auto; }
.pb52x .pb52x-q {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-block-size: 48px;
    max-inline-size: 12em;
    padding-inline: 12px;
    border: 1px solid var(--pb-divider);
    border-radius: 999px;
    color: var(--pb-text-primary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* the filter trigger + panel (native details: closed on entry, works without JS) */
.pb52x .pb52x-filter { position: relative; margin-inline-start: auto; flex: 0 0 auto; }
.pb52x .pb52x-filter > summary { list-style: none; cursor: pointer; }
.pb52x .pb52x-filter > summary::-webkit-details-marker { display: none; }
.pb52x .pb52x-filter__btn { display: inline-flex; align-items: center; gap: 6px; min-block-size: 48px; }
.pb52x .pb52x-ico { flex: 0 0 auto; }
.pb52x .pb52x-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 22px;
    block-size: 22px;
    padding-inline: 6px;
    border-radius: 999px;
    background: var(--pb-action-soft-bg);
    color: var(--pb-action-soft-text, var(--pb-text-primary));
    font-size: 13px;
    font-weight: 700;
    box-sizing: border-box;
}
.pb52x .pb52x-panel {
    position: absolute;
    inset-block-start: calc(100% + 8px);
    inset-inline-end: 0;
    z-index: 40;
    inline-size: 360px;
    max-inline-size: calc(100vw - 32px);
    max-block-size: 70vh;
    overflow: auto;
    padding: 16px;
    border: 1px solid var(--pb-divider);
    border-radius: 12px;
    background: var(--pb-surface);
    color: var(--pb-text-primary);
    box-shadow: var(--pb-shadow-card-theme);
    box-sizing: border-box;
}
.pb52x .pb52x-panel__title { margin: 0 0 12px; font-size: 18px; line-height: 24px; }
.pb52x .pb52x-field { margin: 0 0 12px; padding: 0; border: 0; min-inline-size: 0; }
.pb52x .pb52x-field > legend { margin-block-end: 4px; padding: 0; font-weight: 700; }
.pb52x .pb52x-opt { display: flex; align-items: center; gap: 8px; min-block-size: 48px; cursor: pointer; }
.pb52x .pb52x-opt input { inline-size: 20px; block-size: 20px; margin: 0; flex: 0 0 auto; }
.pb52x .pb52x-hint { margin: 4px 0 0; }
.pb52x .pb52x-tag { margin: 0 0 12px; }
.pb52x .pb52x-panel__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block-end: 16px; }
.pb52x .pb52x-prefs { padding-block-start: 12px; border-block-start: 1px solid var(--pb-divider); }
.pb52x .pb52x-saved { margin: -8px 0 12px; color: var(--pb-success-text, inherit); }
.pb52x .pb52x-catdesc { margin-block: 16px 0; }

/* phone: the panel is a bottom sheet; the selects narrow before anything wraps */
@media (max-width: 599px) {
    .pb52x .pb52x-panel {
        position: fixed;
        inset-inline: 0;
        inset-block: auto 0;
        inline-size: auto;
        max-inline-size: none;
        max-block-size: 80vh;
        border-radius: 16px 16px 0 0;
    }
    .pb52x .pb52x-select { max-inline-size: 8.5em; padding-inline: 8px; }
    .pb52x .pb52x-q { max-inline-size: 7em; }
}
@container (max-width: 359px) {
    .pb52x .pb52x-filter__btn > span:not(.pb52x-count):not(.pb-sr-only) { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
