/*
 * Directory styles — scoped to body.cclm-directory.
 *
 * The body class is emitted by the `body_class` filter in functions.php
 * for every page registered in the cclm_filter_page_map filter, so a new
 * host page (e.g. an events directory) inherits the same look without any
 * page-id-N coupling.
 *
 * Search & Filter v3 renders field blocks as empty divs server-side and
 * populates them client-side. The accordion is purely CSS-driven from a
 * .cclm-field-open class set by listings.js — no DOM is moved, so v3 is
 * free to re-render the field's contents without breaking the toggle.
 *
 * AJAX-driven filtering: listings.js intercepts checkbox change events,
 * builds URLs in v3's expected format, and swaps the .search-filter-query
 * contents in place. v3's own Submit and Reset fields are hidden via CSS
 * (wherever they appear in the page layout — top, bottom, or both) and
 * listings.js renders a standalone Reset button at the bottom of the
 * filter column.
 */

/* ---------- Layout ---------- */

body.cclm-directory .wp-block-columns {
    align-items: flex-start;
}

/* ---------- Filter sidebar: accordion triggers ---------- */

body.cclm-directory .search-filter-field--type-choice .cclm-filter-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    color: #333;
    text-align: left;
    cursor: pointer;
    user-select: none;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}

body.cclm-directory .search-filter-field--type-choice {
    margin: 0 0 8px;
}

body.cclm-directory .cclm-filter-heading:hover,
body.cclm-directory .cclm-filter-heading:focus {
    border-color: var(--cclm-purple, #814B99);
    color: var(--cclm-purple, #814B99);
    outline: none;
}

body.cclm-directory .cclm-filter-heading:focus-visible {
    outline: 2px solid var(--cclm-purple, #814B99);
    outline-offset: 2px;
}

body.cclm-directory .search-filter-field--type-choice.cclm-field-open .cclm-filter-heading {
    background: var(--cclm-purple, #814B99);
    border-color: var(--cclm-purple, #814B99);
    color: #fff;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

/* Chevron */
body.cclm-directory .cclm-filter-trigger-icon {
    display: inline-block;
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    margin-left: 12px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .2s ease;
}

body.cclm-directory .search-filter-field--type-choice.cclm-field-open .cclm-filter-trigger-icon {
    transform: rotate(-135deg);
    margin-top: 4px;
}

/* ---------- Filter sidebar: collapse/expand ---------- */

body.cclm-directory .search-filter-field--type-choice > *:not(.cclm-filter-heading) {
    display: none;
}

body.cclm-directory .search-filter-field--type-choice.cclm-field-open > *:not(.cclm-filter-heading) {
    display: block;
}

body.cclm-directory .search-filter-input-group {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

body.cclm-directory .search-filter-field--type-choice.cclm-field-open .search-filter-input-group {
    padding: 12px 16px 16px;
    background: #fff;
    border: 1px solid var(--cclm-purple, #814B99);
    border-top: none;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

body.cclm-directory .search-filter-input-checkbox {
    padding: 3px 0;
}

body.cclm-directory .search-filter-input-checkbox__container {
    color: #495057;
    font-size: 14px;
    line-height: 1.4;
}

/* ---------- v3 Submit + Reset (hidden — replaced by our own AJAX Reset) ----------
   Hides the page-builder-rendered Submit (id=6) and Reset (id=7) wherever they
   appear in the layout. If the user has placed extra Submit/Reset blocks in the
   page builder, they're hidden too. */

body.cclm-directory [data-search-filter-id="6"],
body.cclm-directory [data-search-filter-id="7"] {
    display: none;
}

/* Also hide whole groups whose only content is the Submit/Reset controls,
   so we don't leave a phantom empty bar where v3's control group used to be. */
body.cclm-directory .search-filter-field--type-control {
    display: none;
}

/* ---------- Bottom Reset button (rendered by listings.js) ---------- */

body.cclm-directory .cclm-controls-bottom {
    margin-top: 18px;
}

body.cclm-directory .cclm-reset-btn {
    display: block;
    width: 50%;
    padding: 10px 18px;
    border-radius: 30px;
    border: 1px solid var(--cclm-purple, #814B99);
    background: #fff;
    color: var(--cclm-purple, #814B99);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

body.cclm-directory .cclm-reset-btn:hover,
body.cclm-directory .cclm-reset-btn:focus {
    background: #fdecf2;
    border-color: var(--cclm-blue, #71CCDE);
    color: var(--cclm-purple, #814B99);
    outline: none;
}

body.cclm-directory .cclm-reset-btn:focus-visible {
    outline: 2px solid var(--cclm-pink, #E60F6D);
    outline-offset: 2px;
}

/* ---------- AJAX loading state ----------
   listings.js toggles .is-loading on .search-filter-query while a request is
   in flight. Dim the results slightly so the change is visible. */

body.cclm-directory .search-filter-query.is-loading {
    opacity: 0.55;
    transition: opacity .15s ease;
    pointer-events: none;
}

/* ---------- Results: card grid ---------- */

body.cclm-directory .wp-block-query .wp-block-post-template {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
    padding: 0;
    margin: 0;
    list-style: none;
}

body.cclm-directory .wp-block-query .wp-block-post-template > li {
    margin: 0;
    width: auto;
    padding: 0;
    list-style: none;
    display: flex;
}

body.cclm-directory .wp-block-query li.wp-block-post > .wp-block-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 20px;
    transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}

body.cclm-directory .wp-block-query li.wp-block-post .wp-block-group__inner-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
}

body.cclm-directory .wp-block-query li.wp-block-post > .wp-block-group:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    transform: translateY(-2px);
    border-color: #f0d4df;
}

body.cclm-directory .wp-block-query .wp-block-post-title {
    font-size: 18px;
    line-height: 1.3;
    margin: 0 0 12px;
    font-weight: 500;
}

body.cclm-directory .wp-block-query .wp-block-post-title a {
    color: var(--cclm-purple, #814B99);
    text-decoration: none;
    transition: color .2s ease;
}

body.cclm-directory .wp-block-query .wp-block-post-title a:hover,
body.cclm-directory .wp-block-query .wp-block-post-title a:focus {
    color: var(--cclm-pink, #E60F6D);
    text-decoration: underline;
}

body.cclm-directory .wp-block-query .wp-block-post-excerpt {
    color: #495057;
    font-size: 14.5px;
    line-height: 1.5;
    margin: 0 0 12px;
}

body.cclm-directory .wp-block-query .wp-block-post-excerpt p {
    margin: 0;
}

/* ---------- Learn more button ---------- */

body.cclm-directory .cclm-card-footer {
    margin-top: auto;
    padding-top: 4px;
}

body.cclm-directory .cclm-card-btn {
    display: inline-block;
    padding: 7px 18px;
    background: var(--cclm-purple, #814B99);
    color: #fff;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
}

body.cclm-directory .cclm-card-btn:hover,
body.cclm-directory .cclm-card-btn:focus {
    background: var(--cclm-blue, #71CCDE);
    color: #222;
    text-decoration: none;
}

body.cclm-directory .cclm-card-btn:focus-visible {
    outline: 2px solid var(--cclm-purple, #814B99);
    outline-offset: 2px;
}

/* ---------- Empty results message ---------- */

body.cclm-directory .cclm-no-results {
    padding: 24px;
    background: #fdecf2;
    border: 1px solid #f0d4df;
    border-radius: 6px;
    color: #495057;
    font-size: 15px;
    line-height: 1.5;
    text-align: center;
    margin: 0 0 18px;
}

/* ---------- Pagination ---------- */

body.cclm-directory .wp-block-query-pagination {
    justify-content: center;
    margin-top: 28px;
    gap: 4px;
    flex-wrap: wrap;
}

body.cclm-directory .wp-block-query-pagination .page-numbers,
body.cclm-directory .wp-block-query-pagination-next,
body.cclm-directory .wp-block-query-pagination-previous {
    display: inline-block;
    padding: 6px 12px;
    margin: 0 2px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    text-decoration: none;
    color: #495057;
    font-size: 14px;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

body.cclm-directory .wp-block-query-pagination .page-numbers.current {
    background: var(--cclm-purple, #814B99);
    border-color: var(--cclm-purple, #814B99);
    color: #fff;
}

body.cclm-directory .wp-block-query-pagination a:hover,
body.cclm-directory .wp-block-query-pagination a:focus {
    border-color: var(--cclm-purple, #814B99);
    color: var(--cclm-purple, #814B99);
}

body.cclm-directory .wp-block-query-pagination .page-numbers.dots {
    border-color: transparent;
}

/* ---------- Mobile ---------- */

@media (max-width: 781px) {
    body.cclm-directory .wp-block-columns {
        gap: 0;
    }
    body.cclm-directory .wp-block-column {
        margin-bottom: 24px;
    }
    body.cclm-directory .wp-block-query .wp-block-post-template {
        grid-template-columns: 1fr;
    }
    body.cclm-directory .cclm-reset-btn {
        width: 100%;
    }
}

