/* Browser shell, toolbar, filter dropdowns. Card styles live in cards.css. */
.blpb-plan-browser {
    color: var(--blpb-text);
    font-size: 16px;
    line-height: 1.45;
}

.blpb-plan-browser *,
.blpb-plan-browser *::before,
.blpb-plan-browser *::after {
    box-sizing: border-box;
}

/* Tripled-up selectors outrank the theme's
   `.entry-content a:not(.wp-block-button__link)` link styling (0,2,1). */
.blpb-plan-browser .blpb-pagination.blpb-pagination a,
.blpb-plan-browser .blpb-filter-form__actions.blpb-filter-form__actions a {
    border-bottom: 0;
    box-shadow: none;
    text-decoration: none;
}

.blpb-plan-browser .blpb-summary__chip.blpb-summary__chip {
    border: 1px solid rgba(179, 37, 51, 0.24);
    box-shadow: inset 0 0 0 1px transparent;
    text-decoration: none;
}

.blpb-plan-browser .blpb-summary__chip.blpb-summary__chip:hover {
    border: 1px solid var(--blpb-accent);
    box-shadow: inset 0 0 0 1px rgba(179, 37, 51, 0.1);
    text-decoration: none;
}

/* `display` on .blpb-badge etc. must not defeat the hidden attribute. */
.blpb-plan-browser [hidden] {
    display: none !important;
}

/* ---------- Toolbar: search + sort ---------- */
.blpb-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 12px;
}

.blpb-search {
    align-items: center;
    background: var(--blpb-surface);
    border: 1px solid var(--blpb-border);
    border-radius: 999px;
    display: flex;
    flex: 1 1 320px;
    gap: 8px;
    min-height: 46px;
    padding: 0 8px 0 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.blpb-search:focus-within,
.blpb-sort:focus-within {
    border-color: var(--blpb-accent);
    box-shadow: 0 0 0 3px rgba(179, 37, 51, 0.15);
}

.blpb-search .blpb-icon {
    color: var(--blpb-muted);
    flex: none;
}

.blpb-search input[type="search"] {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--blpb-text);
    flex: 1;
    font-size: 15px;
    line-height: 1.2;
    /* The theme adds a bottom margin to inputs/selects, which would inflate the
       pill and push the text above its center. */
    margin: 0;
    min-height: 44px;
    min-width: 0;
    outline: none;
    padding: 0;
}

.blpb-search input[type="search"]::placeholder {
    color: var(--blpb-muted);
    opacity: 0.85;
}

.blpb-sort {
    align-items: center;
    background: var(--blpb-surface);
    border: 1px solid var(--blpb-border);
    border-radius: 999px;
    display: inline-flex;
    gap: 6px;
    min-height: 46px;
    padding: 0 14px;
    position: relative;
}

.blpb-sort__label {
    color: var(--blpb-muted);
    flex: none;
    font-size: 13px;
    font-weight: 600;
}

.blpb-sort select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    color: var(--blpb-text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    max-width: 220px;
    min-height: 44px;
    outline: none;
    padding: 0 18px 0 0;
}

.blpb-sort .blpb-icon--chevron {
    color: var(--blpb-muted);
    margin-left: -22px;
    pointer-events: none;
}

/* ---------- Filter bar: dropdown pills ---------- */
.blpb-filterbar {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 6px;
}

.blpb-dd {
    position: relative;
}

.blpb-dd__toggle {
    align-items: center;
    background: var(--blpb-surface);
    border: 1px solid var(--blpb-border);
    border-radius: 999px;
    color: var(--blpb-text);
    cursor: pointer;
    display: inline-flex;
    font-size: 14px;
    font-weight: 600;
    gap: 7px;
    list-style: none;
    min-height: 42px;
    padding: 0 14px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    user-select: none;
}

.blpb-dd__toggle::-webkit-details-marker {
    display: none;
}

.blpb-dd__toggle:hover {
    border-color: #b9c2c9;
}

.blpb-dd[open] > .blpb-dd__toggle {
    border-color: var(--blpb-text);
}

.blpb-dd.is-active > .blpb-dd__toggle {
    background: var(--blpb-accent-soft);
    border-color: var(--blpb-accent);
    color: var(--blpb-accent-deep);
}

.blpb-dd .blpb-icon--chevron {
    color: var(--blpb-muted);
    transition: transform 0.15s ease;
}

.blpb-dd[open] .blpb-icon--chevron {
    transform: rotate(180deg);
}

.blpb-badge {
    align-items: center;
    background: var(--blpb-accent);
    border-radius: 999px;
    color: #ffffff;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    justify-content: center;
    line-height: 1;
    min-width: 20px;
    padding: 4px 6px;
}

.blpb-dd__panel {
    background: var(--blpb-surface);
    border: 1px solid var(--blpb-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(26, 36, 44, 0.16);
    left: 0;
    margin-top: 8px;
    min-width: 230px;
    padding: 14px;
    position: absolute;
    top: 100%;
    z-index: 30;
}

.blpb-dd__panel--sqft {
    min-width: 280px;
}

/* The last dropdowns open near the right edge; keep panels on screen. */
.blpb-dd:nth-last-child(-n+3) .blpb-dd__panel {
    left: auto;
    right: 0;
}

.blpb-filter-group {
    border: 0;
    display: grid;
    gap: 2px;
    margin: 0;
    min-inline-size: 0;
    padding: 0;
}

.blpb-filter-group--columns {
    grid-template-columns: 1fr 1fr;
    max-height: 320px;
    min-width: 360px;
    overflow-y: auto;
}

.blpb-check {
    align-items: center;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    gap: 10px;
    margin: 0;
    padding: 7px 8px;
}

.blpb-check:hover {
    background: var(--blpb-tint);
}

.blpb-check input[type="checkbox"] {
    accent-color: var(--blpb-accent);
    cursor: pointer;
    flex: none;
    height: 17px;
    margin: 0;
    width: 17px;
}

.blpb-check span {
    color: var(--blpb-text);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
}

.blpb-dd__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.blpb-dd__field > span {
    color: var(--blpb-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.blpb-dd__panel select,
.blpb-dd__panel input[type="number"] {
    background: var(--blpb-surface);
    border: 1px solid var(--blpb-border);
    border-radius: 8px;
    color: var(--blpb-text);
    font-size: 14px;
    min-height: 40px;
    padding: 8px 10px;
    width: 100%;
}

.blpb-dd__hint {
    color: var(--blpb-muted);
    font-size: 12px;
    font-weight: 600;
    margin: 12px 0 6px;
}

.blpb-dd__panel select.is-inactive {
    background: var(--blpb-tint);
    color: var(--blpb-muted);
    cursor: not-allowed;
}

.blpb-sqft-bounds {
    align-items: end;
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr auto 1fr;
}

.blpb-sqft-bounds__sep {
    color: var(--blpb-muted);
    padding-bottom: 11px;
}

/* Mobile filters toggle; revealed by JS below the tablet breakpoint. */
.blpb-filters-toggle {
    display: none;
}

/* Explicit states with high specificity outrank theme button styling
   without touching `display`, which the mobile media query owns. */
.blpb-plan-browser .blpb-filters-toggle.blpb-filters-toggle,
.blpb-plan-browser .blpb-filters-toggle.blpb-filters-toggle:hover,
.blpb-plan-browser .blpb-filters-toggle.blpb-filters-toggle:focus,
.blpb-plan-browser .blpb-filters-toggle.blpb-filters-toggle:active {
    align-items: center;
    background: var(--blpb-surface);
    border: 1px solid var(--blpb-border);
    border-radius: 999px;
    color: var(--blpb-text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    gap: 8px;
    margin: 0 0 10px;
    min-height: 42px;
    padding: 0 16px;
}

.blpb-plan-browser .blpb-filters-toggle.blpb-filters-toggle:hover {
    border-color: #b9c2c9;
}

/* No-JS fallback actions; hidden once the enhanced layer takes over. */
.blpb-filter-form__actions {
    align-items: center;
    display: flex;
    gap: 8px;
}

.blpb-filter-form__actions button {
    background: var(--blpb-accent);
    border: 1px solid var(--blpb-accent);
    border-radius: 999px;
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    min-height: 42px;
    padding: 0 18px;
}

.blpb-filter-form__actions a {
    border-radius: 999px;
    color: var(--blpb-muted);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 12px;
    text-decoration: none;
}

.blpb-plan-browser.is-enhanced .blpb-filter-form__actions {
    display: none;
}

/* ---------- Summary: count, chips, reset ---------- */
.blpb-browser__summary {
    margin: 6px 0 16px;
    min-height: 30px;
}

.blpb-summary {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.blpb-summary__count {
    color: var(--blpb-muted);
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.blpb-summary__filters {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.blpb-summary__chip {
    align-items: center;
    background: var(--blpb-accent-soft);
    border: 1px solid rgba(179, 37, 51, 0.24);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px transparent;
    color: var(--blpb-accent-deep);
    display: inline-flex;
    font-size: 13px;
    font-weight: 600;
    gap: 7px;
    line-height: 1.2;
    padding: 6px 11px;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.blpb-summary__chip:hover {
    background: #fff7f8;
    border-color: var(--blpb-accent);
    box-shadow: inset 0 0 0 1px rgba(179, 37, 51, 0.1);
    text-decoration: none;
}

.blpb-summary__chip-x {
    font-size: 15px;
    line-height: 1;
    opacity: 0.7;
}

.blpb-summary__chip:hover .blpb-summary__chip-x {
    opacity: 1;
}

.blpb-summary__reset {
    color: var(--blpb-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.blpb-summary__reset:hover {
    color: var(--blpb-text);
}

/* ---------- Results grid ---------- */
.blpb-browser__results {
    min-height: 240px;
    position: relative;
}

.blpb-browser__results:focus {
    outline: none;
}

.blpb-results-grid {
    display: grid;
    gap: 22px;
    grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
}

/* ---------- Pagination ---------- */
.blpb-browser__pagination {
    min-height: 62px;
}

.blpb-pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 30px;
}

.blpb-pagination a,
.blpb-pagination span.blpb-pagination__page,
.blpb-pagination .blpb-pagination__gap {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 14px;
    font-weight: 600;
    justify-content: center;
    line-height: 1;
    min-height: 40px;
    min-width: 40px;
    padding: 0 12px;
    text-decoration: none;
}

.blpb-pagination a {
    background: var(--blpb-surface);
    border: 1px solid var(--blpb-border);
    color: var(--blpb-text);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.blpb-pagination a:hover {
    border-color: var(--blpb-text);
}

.blpb-pagination span.is-current {
    background: var(--blpb-accent);
    border: 1px solid var(--blpb-accent);
    color: #ffffff;
}

.blpb-pagination__gap {
    color: var(--blpb-muted);
}

.blpb-plan-browser.is-loading .blpb-pagination {
    opacity: 0.65;
    pointer-events: none;
}

/* ---------- Loading overlay ---------- */
.blpb-browser__results[aria-busy="true"] > * {
    opacity: 0.42;
}

.blpb-browser__results[aria-busy="true"]::before,
.blpb-browser__results[aria-busy="true"]::after {
    content: "";
    left: 50%;
    position: absolute;
    top: min(50%, 280px);
    z-index: 2;
}

.blpb-browser__results[aria-busy="true"]::before {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--blpb-border);
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(26, 36, 44, 0.12);
    height: 58px;
    transform: translate(-50%, -50%);
    width: 58px;
}

.blpb-browser__results[aria-busy="true"]::after {
    animation: blpb-spin 0.8s linear infinite;
    border: 3px solid var(--blpb-border);
    border-radius: 50%;
    border-top-color: var(--blpb-accent);
    height: 28px;
    margin: -14px 0 0 -14px;
    width: 28px;
}

@media (prefers-reduced-motion: reduce) {
    .blpb-browser__results[aria-busy="true"]::after {
        animation-duration: 1.6s;
    }
}

/* ---------- States ---------- */
.blpb-state {
    background: var(--blpb-tint);
    border: 1px solid var(--blpb-border);
    border-radius: 12px;
    min-height: 140px;
    padding: 26px;
    text-align: center;
}

.blpb-state p {
    font-weight: 600;
    margin: 0;
}

.blpb-state__hint {
    color: var(--blpb-muted);
    font-weight: 500 !important;
    margin-top: 8px !important;
}

.blpb-state--empty {
    background: #f7fafd;
}

.blpb-state--setup {
    background: #fffaf0;
}

.blpb-state--failure {
    background: #fff6f6;
}

/* ---------- Focus visibility ---------- */
.blpb-dd__panel select:focus-visible,
.blpb-dd__panel input[type="number"]:focus-visible,
.blpb-dd__toggle:focus-visible,
.blpb-filters-toggle:focus-visible,
.blpb-filter-form__actions button:focus-visible,
.blpb-filter-form__actions a:focus-visible,
.blpb-summary__chip:focus-visible,
.blpb-summary__reset:focus-visible,
.blpb-pagination a:focus-visible {
    outline: 3px solid var(--blpb-focus);
    outline-offset: 2px;
}

.blpb-check input[type="checkbox"]:focus-visible + span {
    border-radius: 4px;
    outline: 3px solid var(--blpb-focus);
    outline-offset: 2px;
}

.blpb-sr-only {
    border: 0;
    clip: rect(0, 0, 0, 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

@keyframes blpb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Tablet ---------- */
@media (max-width: 1023px) {
    .blpb-results-grid {
        gap: 16px;
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    }

    .blpb-filter-group--columns {
        min-width: 300px;
    }
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
    .blpb-toolbar {
        gap: 8px;
    }

    .blpb-search {
        flex-basis: 100%;
    }

    .blpb-sort {
        flex: 1;
    }

    .blpb-sort select {
        flex: 1;
        max-width: none;
    }

    /* Enhanced mode collapses the filter bar behind the Filters button. */
    .blpb-plan-browser.is-enhanced .blpb-filters-toggle {
        display: inline-flex;
    }

    .blpb-plan-browser.is-enhanced .blpb-filterbar {
        display: none;
    }

    .blpb-plan-browser.is-enhanced .blpb-filterbar.is-open {
        background: var(--blpb-tint);
        border: 1px solid var(--blpb-border);
        border-radius: 14px;
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-bottom: 14px;
        padding: 10px;
    }

    /* Dropdowns become full-width accordion rows on small screens. */
    .blpb-filterbar .blpb-dd {
        width: 100%;
    }

    .blpb-dd__toggle {
        border-radius: 12px;
        justify-content: space-between;
        min-height: 46px;
        width: 100%;
    }

    .blpb-dd__panel {
        border: 0;
        border-radius: 0 0 12px 12px;
        box-shadow: none;
        margin-top: 0;
        min-width: 0;
        position: static;
        width: 100%;
    }

    .blpb-dd[open] > .blpb-dd__toggle {
        border-radius: 12px 12px 0 0;
    }

    .blpb-filter-group--columns {
        grid-template-columns: 1fr 1fr;
        max-height: 280px;
        min-width: 0;
    }

    .blpb-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
    }

    .blpb-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .blpb-pagination a,
    .blpb-pagination span.blpb-pagination__page {
        min-height: 42px;
        min-width: 42px;
    }
}

@media (max-width: 419px) {
    .blpb-results-grid {
        grid-template-columns: 1fr;
    }
}
