/* ==========================================================================
   Blog Filter Grid — Front-End Styles
   Responsive from 320px (small mobile) to 3840px (4K)
   All accent colours driven by CSS custom properties set by PHP.
   ========================================================================== */

/* ── CSS Custom Properties (fallback if PHP doesn't inject them) ─────────── */
:root {
    --bfg-accent:      #1472ba;
    --bfg-accent-dark: #1160a0;
    --bfg-accent-rgb:  20, 114, 186;
}

/* ── Main Container ──────────────────────────────────────────────────────── */
.bfg-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    box-sizing: border-box;
}

/* ── Alignment Classes (for shortcode align attribute) ────────────────────── */
.bfg-wrap.alignleft {
    float: left;
    margin-right: 2em;
    margin-left: 0;
    max-width: 50%;
}

.bfg-wrap.alignright {
    float: right;
    margin-left: 2em;
    margin-right: 0;
    max-width: 50%;
}

.bfg-wrap.aligncenter {
    margin-left: auto;
    margin-right: auto;
    display: block;
}

.bfg-wrap.alignwide {
    max-width: 1400px;
}

.bfg-wrap.alignfull {
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
}

/* Clear floats after aligned shortcodes */
.bfg-wrap.alignleft::after,
.bfg-wrap.alignright::after {
    content: '';
    display: table;
    clear: both;
}

.bfg-wrap *,
.bfg-wrap *::before,
.bfg-wrap *::after {
    box-sizing: inherit;
}

/* 4K / ultra-wide — allow wider layout */
@media (min-width: 2400px) {
    .bfg-wrap {
        max-width: 1800px;
        padding: 40px 32px;
    }
}

/* ── Screen-reader only utility ──────────────────────────────────────────── */
.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   TOP FILTER BAR
   Layout: [Sort — LEFT] [Search — CENTER] [Grid/List — RIGHT]
   ========================================================================== */

.bfg-top-filters {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

/* Left zone */
.bfg-filters-left {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

/* Center zone — search always truly centred */
.bfg-filters-center {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Right zone */
.bfg-filters-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* ── Sort Group ──────────────────────────────────────────────────────────── */
.bfg-sort-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bfg-sort-label {
    font-size: 14px;
    font-weight: 600;
    color: #0f2a47;
    white-space: nowrap;
}

.bfg-sort {
    padding: 10px 36px 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background-color: #fff;
    color: #0f2a47;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    min-width: 160px;
    transition: border-color 0.2s ease;
}

.bfg-sort:hover  { border-color: var(--bfg-accent); }
.bfg-sort:focus  {
    outline: none;
    border-color: var(--bfg-accent);
    box-shadow: 0 0 0 3px rgba(var(--bfg-accent-rgb), 0.18);
}

/* ── Search Group ────────────────────────────────────────────────────────── */
.bfg-search-group {
    position: relative;
    width: 100%;
    max-width: 650px;
    min-width: 220px;
}

/* Search icon inside input */
.bfg-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    display: flex;
    align-items: center;
    pointer-events: none;
    z-index: 1;
}

.bfg-search {
    width: 100%;
    padding: 10px 14px 10px 38px; /* left padding for icon */
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: #333;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bfg-search:focus {
    outline: none;
    border-color: var(--bfg-accent);
    box-shadow: 0 0 0 3px rgba(var(--bfg-accent-rgb), 0.18);
}

/* Autocomplete dropdown */
.bfg-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    z-index: 200;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.bfg-search-results div {
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s ease;
}

.bfg-search-results div:last-child { border-bottom: none; }
.bfg-search-results div:hover       { background: #f5f5f5; }

/* ── Grid / List View Toggle ─────────────────────────────────────────────── */
.bfg-view-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 3px;
    border: 1px solid #e0e0e0;
}

.bfg-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
}

.bfg-view-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.bfg-view-btn:hover {
    background: #e5e7eb;
    color: #333;
}

.bfg-view-btn:hover svg {
    transform: scale(1.1);
}

.bfg-view-btn:focus {
    outline: 2px solid var(--bfg-accent);
    outline-offset: 2px;
}

.bfg-view-btn.active {
    background: var(--bfg-accent);
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bfg-view-btn.active:hover {
    background: var(--bfg-accent-dark);
    color: #fff;
}

.bfg-view-btn.active svg {
    transform: scale(1.05);
}

/* ── Responsive: Top Bar ─────────────────────────────────────────────────── */

/* Tablet (≤900px): 2-row layout — row1: sort + toggle / row2: search full width */
@media (max-width: 900px) {
    .bfg-top-filters {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .bfg-filters-left   { grid-column: 1; grid-row: 1; }
    .bfg-filters-right  { grid-column: 2; grid-row: 1; }
    .bfg-filters-center {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: stretch;
    }
    .bfg-search-group {
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }
}

/* Mobile (≤540px): stack all three */
@media (max-width: 540px) {
    .bfg-top-filters {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 12px;
    }
    .bfg-filters-left   { grid-column: 1; grid-row: 1; }
    .bfg-filters-center { grid-column: 1; grid-row: 2; justify-content: stretch; }
    .bfg-filters-right  { grid-column: 1; grid-row: 3; justify-content: flex-start; }
    .bfg-sort           { min-width: 0; width: 100%; }
    .bfg-sort-group     { width: 100%; }
    .bfg-search-group   { max-width: 100%; width: 100%; }
}

/* ==========================================================================
   CATEGORY FILTER ROW
   ========================================================================== */

.bfg-category-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e8e8e8;
}

.bfg-cat-btn {
    padding: 9px 18px;
    border: 1px solid #ddd;
    border-width: 1px;
    background: #fff;
    color: #444;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    line-height: 1.4;
    box-sizing: border-box;
    /* Prevent any movement/transform on hover */
    transform: none;
    will-change: auto;
    /* Ensure consistent dimensions */
    min-width: fit-content;
    display: inline-block;
}

.bfg-cat-btn:hover {
    background: var(--bfg-accent);
    color: #fff;
    border: 1px solid var(--bfg-accent);
    border-width: 1px;
}

.bfg-cat-btn:focus {
    outline: 2px solid var(--bfg-accent);
    outline-offset: 2px;
    border: 1px solid var(--bfg-accent);
    border-width: 1px;
}

.bfg-cat-btn.active {
    background: var(--bfg-accent);
    color: #fff;
    border: 1px solid var(--bfg-accent);
    border-width: 1px;
    font-weight: 600;
}

.bfg-cat-btn.active:hover {
    background: var(--bfg-accent-dark);
    border: 1px solid var(--bfg-accent-dark);
    border-width: 1px;
    color: #fff;
}

/* ==========================================================================
   POST GRID — GRID VIEW (default)
   ========================================================================== */

.bfg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    transition: gap 0.2s ease;
}

/* 4K / large monitors */
@media (min-width: 2400px) {
    .bfg-grid { grid-template-columns: repeat(4, 1fr); gap: 32px; }
}

/* Large tablet */
@media (max-width: 1024px) {
    .bfg-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}

/* Mobile */
@media (max-width: 600px) {
    .bfg-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* ==========================================================================
   POST GRID — LIST VIEW  (toggled by JS adding .bfg-list-view)
   ========================================================================== */

.bfg-grid.bfg-list-view {
    grid-template-columns: 1fr;
    gap: 24px;
}

.bfg-grid.bfg-list-view .bfg-card {
    flex-direction: row;
    height: auto;
    min-height: 240px;
}

.bfg-grid.bfg-list-view .bfg-card-image {
    width: 320px;
    min-width: 320px;
    height: 100%;
    min-height: 240px;
    border-radius: 12px 0 0 12px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bfg-grid.bfg-list-view .bfg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

.bfg-grid.bfg-list-view .bfg-card-content {
    padding: 24px 28px;
    flex: 1;
}

.bfg-grid.bfg-list-view .bfg-card h3 {
    font-size: 22px;
    -webkit-line-clamp: 2;
    max-height: none;
    margin-bottom: 12px;
}

.bfg-grid.bfg-list-view .bfg-excerpt {
    -webkit-line-clamp: 4;
    max-height: none;
    font-size: 15px;
    line-height: 1.7;
}

/* List view on tablet: slightly smaller image */
@media (max-width: 900px) {
    .bfg-grid.bfg-list-view .bfg-card-image {
        width: 280px;
        min-width: 280px;
    }
}

/* List view on mobile: collapse back to card stack */
@media (max-width: 640px) {
    .bfg-grid.bfg-list-view .bfg-card {
        flex-direction: column;
        min-height: auto;
    }
    .bfg-grid.bfg-list-view .bfg-card-image {
        width: 100%;
        min-width: 0;
        height: 220px;
        min-height: 220px;
        border-radius: 12px 12px 0 0;
    }
}

/* ==========================================================================
   POST CARD
   ========================================================================== */

.bfg-card {
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bfg-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
}

/* Card Thumbnail */
.bfg-card-image {
    width: 100%;
    height: 195px;
    overflow: hidden;
    background: #f5f5f5;
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
    margin: 0;
    padding: 0;
    line-height: 0;
}

.bfg-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    margin: 0;
    padding: 0;
    vertical-align: top;
    /* No hover animation - removed per user request */
}

.bfg-card-image a {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    line-height: 0;
}

.bfg-placeholder-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    margin: 0;
    padding: 0;
}

/* Card Body */
.bfg-card-content {
    display: flex;
    flex-direction: column;
    padding: 18px 16px 16px;
    flex: 1;
}

.bfg-card h3 {
    font-size: 18px;
    font-weight: 700;
    color: #0f2a47;
    line-height: 1.35;
    margin: 0 0 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bfg-card h3 a {
    text-decoration: none;
    color: inherit;
    transition: color 0.18s ease;
}

.bfg-card h3 a:hover { color: var(--bfg-accent); }

/* Meta: date / author */
.bfg-meta {
    font-size: 13px;
    color: #888;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.bfg-meta-sep { margin: 0 2px; color: #bbb; }

/* Excerpt */
.bfg-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin: 0 0 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

/* Read Time Badge */
.bfg-read-time {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--bfg-accent);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 12px;
    width: fit-content;
}

/* Read More Link */
.bfg-read-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--bfg-accent);
    text-decoration: none;
    margin-top: auto;
    transition: color 0.18s ease;
}

.bfg-read-more:hover {
    color: var(--bfg-accent-dark);
    text-decoration: underline;
}

/* ==========================================================================
   LOAD MORE BUTTON
   ========================================================================== */

.bfg-load {
    display: block;
    margin: 32px auto 0;
    padding: 13px 36px;
    background: var(--bfg-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.bfg-load:hover:not(:disabled) {
    background: var(--bfg-accent-dark);
    transform: translateY(-1px);
}

.bfg-load:focus {
    outline: 2px solid var(--bfg-accent);
    outline-offset: 3px;
}

.bfg-load:disabled {
    background: #aaa;
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

/* ==========================================================================
   LOADING SPINNER
   ========================================================================== */

.bfg-loading {
    text-align: center;
    padding: 56px 20px;
    font-size: 15px;
    color: var(--bfg-accent);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.bfg-loading::before {
    content: '';
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(var(--bfg-accent-rgb), 0.2);
    border-top-color: var(--bfg-accent);
    border-radius: 50%;
    animation: bfg-spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

/* ==========================================================================
   NO RESULTS MESSAGE
   ========================================================================== */

.bfg-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 56px 24px;
    background: #f9f9fb;
    border: 2px dashed #e0e0e8;
    border-radius: 12px;
    margin: 8px 0 24px;
    animation: bfg-fade-in 0.3s ease;
}

@keyframes bfg-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bfg-no-results-icon {
    font-size: 42px;
    margin-bottom: 16px;
    line-height: 1;
    display: block;
}

.bfg-no-results-headline {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 8px;
    line-height: 1.4;
}

.bfg-no-results-headline strong { color: var(--bfg-accent); }

.bfg-no-results-hint {
    font-size: 14px;
    color: #888;
    margin: 0;
    line-height: 1.6;
}

/* ==========================================================================
   ERROR MESSAGE
   ========================================================================== */

.bfg-error {
    text-align: center;
    padding: 16px 20px;
    color: #c62828;
    background: #fff5f5;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    margin: 20px 0;
    font-size: 14px;
}
