/**
 * Home page: searchable sub-category dropdown beside each main category.
 * Colours, borders and type follow the category list and the header
 * "Select Category" dropdown so it reads as part of the existing theme.
 */

/* Row: make room for the chevron on the right. */
.bl-subcat-ready .bl-has-subcats {
    position: relative;
}
.bl-subcat-ready .bl-has-subcats .directorypress-parent-category {
    position: relative;
}
.bl-subcat-ready .bl-has-subcats .directorypress-parent-category > a {
    padding-right: 40px;
    box-sizing: border-box;
}
.bl-subcat-ready .bl-subcat-open .directorypress-parent-category > a,
.bl-subcat-ready .bl-subcat-open .directorypress-parent-category > a .categories-name {
    color: #2874f0;
}

/* Chevron toggle */
.bl-subcat-ready .bl-subcat-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    color: #888;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bl-subcat-ready .bl-subcat-toggle:focus {
    outline: none;
}
.bl-subcat-ready .bl-subcat-toggle:focus-visible {
    outline: 2px solid #2874f0;
    outline-offset: -4px;
}
.bl-subcat-ready .bl-has-subcats:hover .bl-subcat-toggle,
.bl-subcat-ready .bl-subcat-open .bl-subcat-toggle {
    color: #2874f0;
}
.bl-subcat-chevron {
    display: block;
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform .15s ease;
}
/* On touch / narrow screens the panel opens downwards, so the chevron does too. */
@media (hover: none), (pointer: coarse), (max-width: 767px) {
    .bl-subcat-chevron {
        transform: rotate(45deg);
        margin-top: -4px;
    }
    .bl-subcat-open .bl-subcat-chevron {
        transform: rotate(-135deg);
        margin-top: 4px;
    }
}

/* Panel */
.bl-subcat-panel {
    box-sizing: border-box;
    background: #fff;
    font-family: inherit;
    text-align: left;
}
.bl-subcat-panel[hidden] {
    display: none !important;
}
.bl-subcat-panel *,
.bl-subcat-panel *::before,
.bl-subcat-panel *::after {
    box-sizing: border-box;
}
.bl-subcat-panel--flyout {
    position: absolute;
    top: 0;
    left: 100%;
    z-index: 60;
    width: 280px;
    border: 1px solid #d3d3d3;
    border-top: 2px solid #2874f0;
    box-shadow: 0 8px 24px rgba(17, 24, 39, .10);
}
.bl-subcat-panel--inline {
    position: static;
    width: auto;
    border: 1px solid #d3d3d3;
    border-top: 2px solid #2874f0;
    border-bottom: 0;
    background: #fafbfc;
}
.directorypress-category-item:last-child .bl-subcat-panel--inline {
    border-bottom: 1px solid #d3d3d3;
}

/* Search */
.bl-subcat-search {
    position: relative;
    padding: 10px;
    border-bottom: 1px solid #eee;
}
.bl-subcat-search::before {
    content: "";
    position: absolute;
    left: 22px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M20 20l-4.6-4.6'/%3E%3C/svg%3E") no-repeat center / contain;
    pointer-events: none;
}
.bl-subcat-panel .bl-subcat-input,
.bl-subcat-panel .bl-subcat-input[type="search"] {
    display: block;
    box-sizing: border-box;
    width: 100%;
    height: 38px;
    margin: 0;
    padding: 0 12px 0 34px;
    border: 1px solid #dde3ea;
    border-radius: 5px;
    background: #fff;
    box-shadow: none;
    color: #333;
    font-family: inherit;
    font-size: 13px;
    line-height: 36px;
    -webkit-appearance: none;
    appearance: none;
}
.bl-subcat-panel .bl-subcat-input::placeholder {
    color: #999;
    opacity: 1;
}
.bl-subcat-panel .bl-subcat-input:focus {
    border-color: #2874f0;
    outline: none;
}
.bl-subcat-panel .bl-subcat-input::-webkit-search-cancel-button {
    cursor: pointer;
}

/* List */
.bl-subcat-panel .bl-subcat-list {
    max-height: 308px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.bl-subcat-panel--inline .bl-subcat-list {
    max-height: 290px;
}
.bl-subcat-panel .bl-subcat-list li {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #eee;
    list-style: none;
}
.bl-subcat-panel .bl-subcat-list li[hidden] {
    display: none;
}
.bl-subcat-panel .bl-subcat-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 40px;
    padding: 8px 14px;
    color: #444;
    font-size: 13px;
    font-weight: 400;
    line-height: 20px;
    text-decoration: none;
    text-transform: none;
}
.bl-subcat-panel .bl-subcat-link:hover,
.bl-subcat-panel .bl-subcat-link:focus {
    background: #f5f8ff;
    color: #2874f0;
    outline: none;
}
.bl-subcat-panel .bl-subcat-name mark {
    padding: 0;
    background: transparent;
    color: inherit;
    font-weight: 600;
}
.bl-subcat-panel .bl-subcat-count {
    flex: none;
    min-width: 28px;
    padding: 0 8px;
    border-radius: 3px;
    background: #ecf1f5;
    color: #777;
    font-size: 10px;
    line-height: 20px;
    text-align: center;
}

.bl-subcat-panel .bl-subcat-empty {
    margin: 0;
    padding: 14px;
    border-bottom: 1px solid #eee;
    color: #888;
    font-size: 13px;
}

/* "View all …" footer */
.bl-subcat-panel .bl-subcat-all {
    display: block;
    padding: 11px 14px;
    background: #fafbfc;
    color: #1d1c72;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    text-decoration: none;
}
.bl-subcat-panel--inline .bl-subcat-all {
    background: #fff;
}
.bl-subcat-panel .bl-subcat-all::after {
    content: " \2192";
}
.bl-subcat-panel .bl-subcat-all:hover,
.bl-subcat-panel .bl-subcat-all:focus {
    color: #2874f0;
}
.bl-subcat-panel .bl-subcat-all[hidden] {
    display: none;
}

/* ---------------------------------------------------------------------------
 * Phones with the mobile navigation on (see inc/mobile-nav.php): the list
 * shows in two columns, the whole row opens the sub-category sheet, and only
 * the busiest categories show until "All categories" is tapped.
 * ------------------------------------------------------------------------- */
.bl-cats-more {
    display: none;
}
@media (max-width: 767px) {
    /* One card. The 1px gaps between the white cells draw the dividers, so they
       always line up; when an odd number of categories shows, a white ::after
       cell fills the gap beside the last one (the script adds .bl-grid-odd). */
    .bl-subcat-sheetmode > .directorypress-categories-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1px;
        margin: 0;
        padding: 0;
        border: 1px solid #e3e6ea;
        border-radius: 10px 10px 0 0;
        background: #e3e6ea;
        overflow: hidden;
    }
    .bl-subcat-sheetmode > .directorypress-categories-wrapper:last-child {
        border-radius: 10px;
    }
    .bl-subcat-sheetmode > .directorypress-categories-wrapper::before,
    .bl-subcat-sheetmode > .directorypress-categories-wrapper::after {
        display: none;
        content: none;
    }
    .bl-subcat-sheetmode > .directorypress-categories-wrapper.bl-grid-odd::after {
        display: block;
        content: "";
        background: #fff;
    }
    .bl-subcat-sheetmode.bl-cats-collapsed .bl-cat-extra {
        display: none !important;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper .directorypress-category-item {
        width: auto !important;
        min-width: 0;
        max-width: none;
        float: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper .directorypress-category-item .directorypress-category-holder {
        height: 100%;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: #fff;
        box-shadow: none;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper .directorypress-category-item .directorypress-category-holder .directorypress-parent-category {
        display: flex;
        height: 100%;
        min-height: 56px;
        border: 0 !important;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper .directorypress-category-holder .directorypress-parent-category > a,
    .bl-subcat-ready.bl-subcat-sheetmode .bl-has-subcats .directorypress-parent-category > a {
        display: flex !important;
        flex: 1 1 auto;
        align-items: center;
        gap: 10px;
        min-width: 0;
        height: auto;
        padding: 8px 10px 8px 12px !important;
        -webkit-tap-highlight-color: transparent;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper .directorypress-category-holder .directorypress-parent-category > a:active {
        background: #f5f8ff;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper .directorypress-category-holder .directorypress-parent-category a .cat-icon {
        display: flex;
        flex: none;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        padding: 0;
        border: 0 !important;
        line-height: normal;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper .directorypress-category-holder .directorypress-parent-category a .cat-icon .directorypress-field-icon {
        width: 28px !important;
        height: 28px;
        margin: 0;
        object-fit: contain;
    }
    .bl-subcat-sheetmode .directorypress-categories-wrapper:not(.slick-carousel) .directorypress-category-holder .directorypress-parent-category a .categories-name {
        display: -webkit-box;
        min-width: 0;
        padding: 0;
        overflow: hidden;
        color: #333;
        font-size: 14px;
        font-weight: 500;
        line-height: 18px;
        white-space: normal;
        overflow-wrap: break-word;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }
    .bl-subcat-ready.bl-subcat-sheetmode .bl-subcat-open .directorypress-parent-category > a .categories-name {
        color: #2874f0;
    }
    .bl-subcat-sheetmode .bl-subcat-toggle {
        display: none;
    }

    /* "All categories (17)" / "Show fewer": the card's footer. */
    .bl-subcat-sheetmode .bl-cats-more {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
        height: 48px;
        margin: 0;
        padding: 0 16px;
        border: 1px solid #e3e6ea;
        border-top: 0;
        border-radius: 0 0 10px 10px;
        background: #f7f9fc;
        box-shadow: none;
        color: #1d1c72;
        font-family: inherit;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bl-subcat-sheetmode .bl-cats-more:active {
        background: #eef2fa;
    }
    .bl-subcat-sheetmode .bl-cats-more::after {
        content: "";
        width: 8px;
        height: 8px;
        margin-top: -4px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
    }
    .bl-subcat-sheetmode .bl-cats-more[aria-expanded="true"]::after {
        margin-top: 4px;
        transform: rotate(-135deg);
    }
    /* Sheet: search, then "All <category>", then the list. */
    .bl-subcat-panel--sheet {
        display: flex;
        flex-direction: column;
        border: 0;
    }
    .bl-subcat-panel--sheet[hidden] {
        display: none !important;
    }
    .bl-subcat-panel--sheet .bl-subcat-search {
        position: sticky;
        top: 56px;
        z-index: 1;
        order: 1;
        padding: 12px 16px;
        background: #fff;
    }
    .bl-subcat-panel--sheet .bl-subcat-search::before {
        left: 28px;
    }
    .bl-subcat-panel--sheet .bl-subcat-all {
        order: 2;
        min-height: 48px;
        padding: 14px 18px;
        border-bottom: 1px solid #eee;
        background: #f5f8ff;
        color: #1d1c72;
        font-size: 15px;
    }
    .bl-subcat-panel--sheet .bl-subcat-list {
        order: 3;
        max-height: none;
        overflow: visible;
    }
    .bl-subcat-panel--sheet .bl-subcat-empty {
        order: 4;
    }
    .bl-subcat-panel--sheet .bl-subcat-link {
        min-height: 48px;
        padding: 12px 18px;
        font-size: 15px;
    }
    .bl-subcat-panel--sheet .bl-subcat-count {
        font-size: 12px;
    }
}
/* 16px stops iOS zooming into the search box when it's tapped. */
@media (pointer: coarse), (max-width: 767px) {
    .bl-subcat-panel .bl-subcat-input,
    .bl-subcat-panel .bl-subcat-input[type="search"] {
        font-size: 16px;
    }
}
