/**
 * Browse Articles Filter — front-end styles.
 *
 * Colours are exposed as custom properties on .browse-articles-scope-free
 * selectors so a child theme can restyle without touching this file.
 */

:root {
    --baf-accent: #ff7a00;
    --baf-accent-contrast: #ffffff;
    --baf-border: #e6e6e6;
    --baf-text: #444444;
    --baf-muted: #888888;
    --baf-surface: #ffffff;
    --baf-radius: 10px;
}

/* ---------------------------------------------------------------
 * Filter bar
 * --------------------------------------------------------------- */
.baf-filters {
    margin: 24px 0 0;
    padding: 20px;
    background: var(--baf-surface);
    border: 1px solid var(--baf-border);
    border-radius: var(--baf-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.baf-filters-heading {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 600;
    color: var(--baf-text);
}

/* Auto-fit means the number of columns follows the available width rather than
   a fixed breakpoint, so the bar reflows the same way whether it is in a full
   width Divi section or a narrow sidebar column. Below ~350px of usable space
   it collapses to a single column on its own. */
.baf-filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    align-items: end;
}

.baf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* Search gets its own full-width row above the dropdowns. */
.baf-field-search {
    grid-column: 1 / -1;
}

/* The button is a normal grid cell, so it fills the gap left by the last row
   of dropdowns instead of stranding a row of its own. */
.baf-field-actions {
    justify-content: flex-end;
}

.baf-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--baf-muted);
}

.baf-select,
.baf-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--baf-text);
    background: var(--baf-surface);
    border: 1px solid var(--baf-border);
    border-radius: 6px;
    line-height: 1.3;
    box-sizing: border-box;
}

.baf-select:focus,
.baf-input:focus {
    outline: 2px solid var(--baf-accent);
    outline-offset: 1px;
    border-color: var(--baf-accent);
}

.baf-submit {
    width: 100%;
    /* Matches the rendered height of .baf-select so the button lines up with
       the dropdown sitting beside it in the grid row. */
    padding: 11px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--baf-accent-contrast);
    background: var(--baf-accent);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.3;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.baf-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* The button stays visible even though the script auto-submits on change:
   it is the only way to submit a typed search term by pointer, and hiding it
   would drop it out of the tab order for keyboard users. */

/* ---------------------------------------------------------------
 * Active filter chips
 * --------------------------------------------------------------- */
.baf-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.baf-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 13px;
    text-decoration: none;
    color: var(--baf-text);
    background: #f5f5f5;
    border: 1px solid var(--baf-border);
    border-radius: 30px;
    transition: background 0.2s ease, color 0.2s ease;
}

.baf-chip:hover {
    background: var(--baf-accent);
    color: var(--baf-accent-contrast);
    border-color: transparent;
}

.baf-chip-x {
    font-size: 15px;
    line-height: 1;
}

.baf-chip-clear {
    font-weight: 600;
}

/* ---------------------------------------------------------------
 * Article grid
 * --------------------------------------------------------------- */
.browse-articles-count {
    margin: 24px 0 0;
    font-size: 14px;
    color: var(--baf-muted);
}

.browse-articles-grid {
    display: grid;
    grid-template-columns: repeat(var(--baf-columns, 3), minmax(0, 1fr));
    gap: 30px;
    margin-top: 20px;
}

@media (max-width: 980px) {
    .browse-articles-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px;
    }
}

@media (max-width: 600px) {
    .browse-articles-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .baf-filters {
        padding: 16px;
    }

    .baf-filters-row {
        /* One column outright below 600px. Two 160px dropdowns can technically
           fit a 360px phone, but the labels above them start truncating. */
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* iOS Safari zooms the viewport when a focused form control is under 16px,
       and never zooms back out. */
    .baf-input,
    .baf-select {
        font-size: 16px;
    }
}

.browse-article-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: var(--baf-radius);
    overflow: hidden;
    background: var(--baf-surface);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.browse-article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.browse-article-thumb {
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #f0f0f0;
}

.browse-article-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.browse-article-title {
    margin: 0;
    padding: 18px 20px 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.4;
    color: #222;
}

.browse-article-meta {
    margin: 0;
    padding: 10px 20px 20px;
    font-size: 13px;
    color: var(--baf-muted);
}

.browse-article-sep {
    margin: 0 6px;
}

.browse-articles-empty {
    text-align: center;
    padding: 60px 0;
    color: var(--baf-muted);
    font-size: 16px;
}

.browse-articles-empty p {
    margin: 0 0 16px;
}

/* ---------------------------------------------------------------
 * Pagination
 * --------------------------------------------------------------- */
.browse-articles-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 36px;
}

.browse-articles-pagination a,
.browse-articles-pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--baf-border);
    text-decoration: none;
    color: var(--baf-text);
    font-size: 14px;
}

.browse-articles-pagination .current {
    background: var(--baf-accent);
    color: var(--baf-accent-contrast);
    border-color: transparent;
}
