/* ---------------------------------------------------------
 * csf-styles.css
 * Modern, premium UI for Custom Search & Filter
 * --------------------------------------------------------- */

:root {
    --csf-primary: #21a9df;
    /* Brand Blue */
    --csf-primary-hover: #078bc1;
    --csf-bg: #f8f9fa;
    --csf-border: #e2e8f0;
    --csf-text: #334155;
    --csf-text-light: #64748b;
    --csf-radius: 8px;
    --csf-radius-sm: 4px;
    --csf-radius-pill: 9999px;
    --csf-transition: all 0.2s ease;
}

.csf-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--csf-text);
}

/* ───── Filter Form ───── */
.csf-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
    padding: 24px;
    background: var(--csf-bg);
    border: 1px solid var(--csf-border);
    border-radius: var(--csf-radius);
    margin-bottom: 24px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.csf-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
    flex: 1 1 auto;
}

.csf-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--csf-text);
    margin-bottom: 0;
}

/* ───── Inputs & Selects ───── */
.csf-input-wrap {
    position: relative;
}

.csf-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--csf-text-light);
}

.csf-keyword,
.csf-select,
.csf-date-from,
.csf-date-to,
.csf-acf-text,
.csf-range-min,
.csf-range-max {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--csf-border);
    border-radius: var(--csf-radius-sm);
    font-size: 14px;
    color: var(--csf-text);
    background: #fff;
    transition: var(--csf-transition);
    box-sizing: border-box;
}

.csf-input-wrap--search .csf-keyword {
    padding-left: 12px;
    padding-right: 12px;
}

.csf-keyword:focus,
.csf-select:focus,
.csf-date-from:focus,
.csf-date-to:focus,
.csf-acf-text:focus,
.csf-range-min:focus,
.csf-range-max:focus {
    outline: none;
    border-color: var(--csf-primary);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* ───── Date & Range Groups ───── */
.csf-date-group,
.csf-range-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.csf-range-sep {
    color: var(--csf-text-light);
    font-weight: 500;
}

/* ───── Checkbox & Radio Custom ───── */
.csf-checkbox-group,
.csf-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.csf-checkbox-label,
.csf-radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    position: relative;
    user-select: none;
}

.csf-checkbox-label input,
.csf-radio-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.csf-checkbox-custom,
.csf-radio-custom {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
    background-color: #fff;
    border: 1px solid var(--csf-border);
    margin-right: 10px;
    flex-shrink: 0;
    box-sizing: border-box;
    transition: var(--csf-transition);
}

.csf-checkbox-custom {
    border-radius: 4px;
}

.csf-radio-custom {
    border-radius: 50%;
}

.csf-checkbox-label:hover input~.csf-checkbox-custom,
.csf-radio-label:hover input~.csf-radio-custom {
    border-color: var(--csf-primary);
}

.csf-checkbox-label input:checked~.csf-checkbox-custom,
.csf-radio-label input:checked~.csf-radio-custom {
    background-color: var(--csf-primary);
    border-color: var(--csf-primary);
}

.csf-checkbox-custom:after,
.csf-radio-custom:after {
    content: "";
    position: absolute;
    display: none;
}

.csf-checkbox-label input:checked~.csf-checkbox-custom:after,
.csf-radio-label input:checked~.csf-radio-custom:after {
    display: block;
}

.csf-checkbox-label .csf-checkbox-custom:after {
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    box-sizing: content-box;
}

.csf-radio-label .csf-radio-custom:after {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.csf-term-count {
    color: var(--csf-text-light);
    font-size: 12px;
    margin-left: 4px;
}

/* ───── Pill Buttons ───── */
.csf-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.csf-pill {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid var(--csf-border);
    border-radius: var(--csf-radius-pill);
    font-size: 13px;
    font-weight: 500;
    color: var(--csf-text);
    cursor: pointer;
    transition: var(--csf-transition);
}

.csf-pill:hover {
    border-color: var(--csf-primary);
    color: var(--csf-primary);
}

.csf-pill--active {
    background: var(--csf-primary);
    border-color: var(--csf-primary);
    color: #fff;
}

.csf-pill--active:hover {
    background: var(--csf-primary-hover);
    color: #fff;
}

.csf-pill--active .csf-term-count {
    color: rgba(255, 255, 255, 0.8);
}

/* ───── Actions (Submit/Reset) ───── */
.csf-field--actions {
    flex-direction: row;
    align-items: flex-end;
    flex: 0 0 auto;
    height: 100%;
    padding-top: 27px;
    /* Align with inputs */
}

.csf-submit,
.csf-reset {
    padding: 10px 20px;
    border-radius: var(--csf-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--csf-transition);
    border: none;
}

.csf-submit {
    background: var(--csf-primary);
    color: #fff;
}

.csf-submit:hover {
    background: var(--csf-primary-hover);
}

.csf-reset {
    background: transparent;
    color: var(--csf-text-light);
    border: 1px solid var(--csf-border);
}

.csf-reset:hover {
    background: #eee;
    color: var(--csf-text);
}

/* ───── Active Filter Chips (Disabled) ───── */
.csf-active-filters {
    display: none !important;
}

.csf-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: #e2e8f0;
    color: var(--csf-text);
    border-radius: var(--csf-radius-sm);
    font-size: 13px;
    font-weight: 500;
}

.csf-chip-remove {
    margin-left: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
    color: var(--csf-text-light);
}

.csf-chip-remove:hover {
    color: #ef4444;
}

/* ───── Result Count ───── */
.csf-result-count {
    font-size: 14px;
    color: var(--csf-text-light);
    margin-bottom: 16px;
}

/* ───── Results Grid & Loading ───── */
.csf-results {
    position: relative;
    min-height: 200px;
}

.csf-loading {
    opacity: 0.6;
    pointer-events: none;
}

.csf-spinner {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border: 4px solid var(--csf-border);
    border-top: 4px solid var(--csf-primary);
    border-radius: 50%;
    animation: csf-spin 1s linear infinite;
    z-index: 10;
}

@keyframes csf-spin {
    0% {
        transform: translateX(-50%) rotate(0deg);
    }

    100% {
        transform: translateX(-50%) rotate(360deg);
    }
}

.csf-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 28px;
    align-items: stretch;
}

.csf-result-item {
    background: #f8f8f8;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.csf-result-item .csf-thumb {
    display: block;
    background: #e6e9e8;
}

.csf-result-item .csf-thumb img {
    width: 100%;
    height: 242px;
    object-fit: cover;
    display: block;
}

.csf-result-body {
    padding: 24px 20px 52px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.csf-title {
    font-family: "Fjalla One", sans-serif;
    font-size: 24px;
    font-weight: 400;
    font-style: normal;
    margin: 0 0 34px;
    line-height: 35px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.csf-title a {
    color: #000000;
    text-decoration: none;
}

.csf-title a:hover {
    color: #168fc4;
}

.csf-meta {
    font-size: 12px;
    color: var(--csf-text-light);
    margin-bottom: 12px;
    display: flex;
    gap: 10px;
}

.csf-cat {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
}

.csf-excerpt {
    color: rgb(45, 55, 72);
    font-family: "Source Sans 3", sans-serif;
    font-size: 19px;
    font-weight: 300;
    font-style: normal;
    margin: 0 0 22px;
    line-height: 26px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

.csf-read-more {
    display: inline-block;
    margin-top: auto;
    padding: 12px 25px;
    background: #21a9df;
    border-radius: 2px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    text-transform: uppercase;
}

.csf-read-more:hover,
.csf-read-more:focus {
    background: #078bc1;
    color: #fff;
}

/* Card layout: filter sidebar with a three-column result area (30% filters / 70% images, 100% width). */
.csf-wrapper--card {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 40px;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.csf-wrapper--card .csf-filter-sidebar {
    flex: 0 0 calc(30% - 20px);
    width: calc(30% - 20px);
    max-width: calc(30% - 20px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    padding: 0;
    box-sizing: border-box;
}

.csf-wrapper--card .csf-filter-form {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 16px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.csf-wrapper--card .csf-field {
    width: 100%;
    min-width: 0;
}

.csf-wrapper--card .csf-field--keyword>label,
.csf-wrapper--compact .csf-field--keyword>label {
    display: none;
}

.csf-wrapper--card .csf-input-wrap--search .csf-keyword,
.csf-wrapper--card .csf-keyword {
    padding-left: 12px;
    padding-right: 12px;
}

.csf-wrapper--card .csf-field--taxonomy>label {
    display: block;
    margin: 0 0 10px;
    color: rgb(60, 67, 74);
    font-family: "Source Sans 3", sans-serif;
    font-size: 18px;
    font-style: normal;
    font-weight: 700;
    line-height: 18px;
}

.csf-wrapper--compact .csf-field--taxonomy>label {
    display: block;
    margin: 0 0 10px;
    color: rgb(60, 67, 74);
    font-family: "Source Sans 3", sans-serif;
    font-size: 18px;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
}

.csf-wrapper--card .csf-checkbox-group,
.csf-wrapper--compact .csf-checkbox-group {
    gap: 10px;
    max-height: none;
    overflow: visible;
    padding-right: 0;
}

.csf-wrapper--card .csf-checkbox-label,
.csf-wrapper--compact .csf-checkbox-label {
    color: rgb(60, 67, 74);
    font-family: "Source Sans 3", sans-serif;
    font-size: 18px;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
}

.csf-wrapper--card .csf-checkbox-custom,
.csf-wrapper--compact .csf-checkbox-custom {
    width: 16px;
    height: 16px;
    margin-right: 12px;
    border-color: #bfc4c8;
    border-radius: 1px;
}

.csf-wrapper--card .csf-checkbox-label .csf-checkbox-custom:after,
.csf-wrapper--compact .csf-checkbox-label .csf-checkbox-custom:after {
    left: 4px;
    top: 1px;
    width: 4px;
    height: 7px;
    border-width: 0 2px 2px 0;
}

.csf-wrapper--card .csf-field--sort,
.csf-wrapper--compact .csf-field--sort {
    display: none;
}

.csf-wrapper--card .csf-field--actions {
    height: auto;
    padding: 0;
}

.csf-wrapper--card .csf-results-area {
    flex: 0 0 calc(70% - 20px);
    width: calc(70% - 20px);
    max-width: calc(70% - 20px);
    min-width: 0;
    box-sizing: border-box;
}

.csf-wrapper--card .csf-active-filters {
    margin: 2px 0 0;
}

.csf-wrapper--card .csf-result-count,
.csf-wrapper--compact .csf-result-count {
    display: none;
}

.csf-wrapper--card .csf-results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
}

/* Compact layout: a centered search bar above a three-column grid matching card typography. */
.csf-wrapper--compact {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0;
}

.csf-wrapper--compact .csf-filter-form {
    justify-content: center;
    align-items: flex-end;
    gap: 12px;
    padding: 0;
    margin: 0 0 50px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin-left: 100px;
}

.csf-wrapper--compact .csf-field--keyword {
    flex: 0 1 250px;
    min-width: 200px;
    max-width: 335px;
}

.csf-wrapper--compact .csf-field:not(.csf-field--actions):not(.csf-field--keyword) {
    flex: 0 1 180px;
    min-width: 160px;
}

.csf-wrapper--compact .csf-input-wrap--search .csf-keyword,
.csf-wrapper--compact .csf-keyword,
.csf-wrapper--compact .csf-select {
    height: 42px;
    padding: 0 14px;
    font-size: 14px;
    line-height: 40px;
    border: 1px solid var(--csf-border);
    border-radius: 2px;
    box-sizing: border-box;
}

.csf-wrapper--compact .csf-field--actions {
    height: auto;
    padding: 0;
    display: flex;
    align-items: flex-end;
}

.csf-wrapper--compact .csf-reset {
    display: none;
}

.csf-wrapper--compact .csf-submit {
    height: 42px;
    padding: 0 18px;
    border: 1px solid var(--csf-primary);
    border-radius: 2px;
    font-size: 14px;
    font-weight: 600;
    line-height: 40px;
    box-sizing: border-box;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.csf-wrapper--compact .csf-results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
}

.csf-wrapper--compact .csf-result-item .csf-thumb img {
    height: 387px;
}

/* ───── Mobile Filter Toggle (card design) ───── */

/* Toggle button: hidden on desktop — only shown on mobile */
.csf-filter-toggle {
    display: none;
}

/* Filter body: always visible on desktop */
.csf-wrapper--card .csf-filter-body {
    display: block;
}

/* ───── Responsive Media Queries ───── */

/* Tablet (900px and below) */
@media (max-width: 900px) {
    .csf-wrapper--card {
        display: block;
    }

    .csf-wrapper--card .csf-filter-sidebar {
        width: 100%;
        max-width: 100%;
        flex: none;
        margin-bottom: 32px;
    }

    .csf-wrapper--card .csf-results-area {
        width: 100%;
        max-width: 100%;
        flex: none;
    }

    .csf-wrapper--card .csf-results-grid,
    .csf-wrapper--compact .csf-results-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
    }

    .csf-wrapper--compact .csf-filter-form {
        margin-left: 0px;
        margin-bottom: 50px;
    }
}

/* Mobile (600px and below) */
@media (max-width: 600px) {

    .csf-wrapper,
    .csf-wrapper--card,
    .csf-wrapper--compact {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Compact Layout: Fix Search Box & Filter Overflow */
    .csf-wrapper--compact .csf-filter-form {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        max-width: 100%;
        gap: 12px;
        margin-bottom: 24px;
        box-sizing: border-box;
        margin-left: 0px;
        margin-bottom: 50px;
    }

    .csf-wrapper--compact .csf-field,
    .csf-wrapper--compact .csf-field--keyword,
    .csf-wrapper--compact .csf-field:not(.csf-field--actions):not(.csf-field--keyword),
    .csf-wrapper--compact .csf-field--actions {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .csf-wrapper--compact .csf-input-wrap,
    .csf-wrapper--compact .csf-input-wrap--search {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .csf-wrapper--compact .csf-keyword,
    .csf-wrapper--compact .csf-select,
    .csf-wrapper--compact .csf-submit {
        width: 100%;
        max-width: 100%;
        height: 44px;
        line-height: 42px;
        box-sizing: border-box;
    }

    /* Card Layout: Mobile Filter Toggle */
    .csf-filter-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 16px;
        background: var(--csf-bg);
        border: 1px solid var(--csf-border);
        border-radius: var(--csf-radius-sm);
        font-size: 15px;
        font-weight: 600;
        color: var(--csf-text);
        cursor: pointer;
        transition: var(--csf-transition);
        box-sizing: border-box;
        margin-bottom: 0;
    }

    .csf-filter-toggle:hover {
        border-color: var(--csf-primary);
        color: var(--csf-primary);
    }

    .csf-filter-toggle-icon {
        transition: transform 0.25s ease;
        font-size: 12px;
    }

    .csf-filter-toggle[aria-expanded="true"] .csf-filter-toggle-icon {
        transform: rotate(180deg);
    }

    /* Filter body: collapsed by default on mobile */
    .csf-wrapper--card .csf-filter-body {
        display: none;
        padding-top: 16px;
    }

    /* Filter body: visible when open */
    .csf-wrapper--card .csf-filter-body.csf-filter-body--open {
        display: block;
    }

    /* Card Layout: Mobile Friendly Adjustments */
    .csf-wrapper--card .csf-filter-sidebar {
        margin-bottom: 24px;
    }

    .csf-wrapper--card .csf-filter-form {
        gap: 14px;
    }

    .csf-wrapper--card .csf-field {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .csf-wrapper--card .csf-field--taxonomy>label {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .csf-wrapper--card .csf-checkbox-label {
        font-size: 16px;
        padding: 4px 0;
    }

    .csf-wrapper--card .csf-field--actions {
        flex-direction: column;
        gap: 10px;
        width: 100%;
        height: auto;
        box-sizing: border-box;
    }

    .csf-wrapper--card .csf-submit,
    .csf-wrapper--card .csf-reset {
        width: 100%;
        height: 44px;
        box-sizing: border-box;
    }

    .csf-wrapper--card .csf-submit {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
    }

    /* Single Column Grid for Cards on Mobile */
    .csf-results-grid,
    .csf-wrapper--card .csf-results-grid,
    .csf-wrapper--compact .csf-results-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Mobile Image Sizing */
    .csf-result-item .csf-thumb img,
    .csf-wrapper--compact .csf-result-item .csf-thumb img {
        height: 240px;
    }

    /* Mobile Typography & Compact Card Padding */
    .csf-result-body {
        padding: 18px 16px 22px;
    }

    .csf-title {
        font-size: 20px;
        line-height: 28px;
        margin: 0 0 14px;
    }

    .csf-excerpt {
        font-size: 15px;
        line-height: 22px;
        margin: 0 0 16px;
    }

    .csf-read-more {
        padding: 10px 22px;
        font-size: 11px;
    }

    /* Mobile Pagination */
    .csf-pagination {
        gap: 6px;
        margin-top: 28px;
        flex-wrap: wrap;
    }

    .csf-pagination a,
    .csf-pagination span {
        padding: 7px 12px;
        font-size: 13px;
    }
}

.csf-no-results,
.csf-error {
    text-align: center;
    color: var(--csf-text-light);
    padding: 60px 20px;
    background: var(--csf-bg);
    border-radius: var(--csf-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* ───── Pagination ───── */
.csf-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
}

.csf-pagination a,
.csf-pagination span {
    padding: 8px 14px;
    border: 1px solid var(--csf-border);
    border-radius: var(--csf-radius-sm);
    text-decoration: none;
    color: var(--csf-text);
    font-weight: 500;
    transition: var(--csf-transition);
}

.csf-pagination a:hover {
    background: var(--csf-bg);
    border-color: #cbd5e1;
}

.csf-pagination .current {
    background: var(--csf-primary);
    color: #fff;
    border-color: var(--csf-primary);
}