/**
 * TSV Filters Styles
 */

/* Grid Layout (Default) */
.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
    transition: opacity 0.3s ease;
    min-height: 50vh;
    /* Prevent collapse during loading */
}

/* List Layout */
.post-grid.list-view {
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.post-grid.list-view article {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
        "thumb header"
        "thumb content"
        "thumb footer";
    gap: 0 2rem;
    align-items: start;
    background: #fff;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
    /* Separator for list items */
}

/* Fallback for no thumbnail using :has() */
.post-grid.list-view article:not(:has(.post-thumbnail)) {
    grid-template-columns: 1fr;
    grid-template-areas:
        "header"
        "content"
        "footer";
}

/* Assign Grid Areas */
.post-grid.list-view .post-thumbnail {
    grid-area: thumb;
    margin-bottom: 0;
    width: 100%;
    height: 200px;
    /* Fixed height for consistency */
    display: block;
}

.post-grid.list-view .post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.post-grid.list-view .entry-header {
    grid-area: header;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.post-grid.list-view .entry-content {
    grid-area: content;
    margin-bottom: 1rem;
}

.post-grid.list-view .entry-footer {
    grid-area: footer;
    margin-top: auto;
    /* Push to bottom if height allows */
    border-top: none;
    padding-top: 0;
    font-size: 0.85rem;
}

.post-grid.list-view .entry-title {
    font-size: 1.5rem;
    /* Smaller title in list view */
    margin-bottom: 0.5rem;
}

/* Category Hero */
.category-hero {
    text-align: left;
    /* User request: Left align */
    margin-bottom: 1.5rem;
    /* User request: reduce space */
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.category-title {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.category-description {
    max-width: 800px;
    font-size: 1.1rem;
    color: #666;
    margin-left: 0;
    /* Align left */
}

/* Filter Controls */
.category-controls {
    margin-bottom: 2rem;
}

.controls-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.filter-label {
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Date Form - Inline with filter list */
.filter-date-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.filter-item {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.5rem 1.2rem;
    border-radius: 50px;
    /* Pill shape */
    cursor: pointer;
    font-family: var(--body-font);
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-item:hover {
    background: rgba(0, 79, 143, 0.1);
    /* Slight tint of primary */
    transform: translateY(-2px);
}

.filter-item.active {
    background: var(--primary-color);
    color: var(--light-text);
    box-shadow: 0 4px 10px rgba(0, 79, 143, 0.2);
}

/* Date Filters */
.filter-date-group {
    display: flex;
    gap: 0.5rem;
}

.filter-select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    background-color: transparent;
    border-radius: 50px;
    font-family: var(--body-font);
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23004F8F' width='18px' height='18px'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    transition: all 0.3s ease;
    min-width: 130px;
}

.filter-select:hover {
    background-color: rgba(0, 79, 143, 0.1);
}

.filter-select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 79, 143, 0.2);
}

/* Layout Toggle */
.layout-toggle {
    display: flex;
    gap: 0.5rem;
}

.layout-btn {
    background: transparent;
    border: 1px solid #ddd;
    color: #999;
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.layout-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

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


/* Pagination Styling Override */
.tsv-pagination .nav-links {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.tsv-pagination .page-numbers {
    background: #fff;
    border: 1px solid #ddd;
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s;
}

.tsv-pagination .page-numbers.current,
.tsv-pagination .page-numbers:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.tsv-pagination .page-numbers.dots {
    border: none;
    background: transparent;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .post-grid {
        grid-template-columns: 1fr;
        /* Single column on mobile */
    }

    .post-grid.list-view article {
        display: block;
        /* Stack content in mobile list view */
    }

    .post-grid.list-view .post-thumbnail {
        width: 100%;
        margin-bottom: 1rem;
    }

    .category-title {
        font-size: 2rem;
    }

    .controls-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .layout-toggle {
        align-self: flex-end;
        /* Move toggle next to filter if possible, or bottom right */
        /* Or keep it simple */
        width: 100%;
        justify-content: flex-end;
    }

    .filter-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-list {
        width: 100%;
        flex-wrap: wrap;
        /* Wrap topics instead of horizontal scroll */
        gap: 0.5rem;
    }

    .filter-item {
        white-space: nowrap;
        min-height: 44px;
        /* Accessible touch target */
        display: flex;
        align-items: center;
    }

    .filter-date-form {
        width: 100%;
        flex-wrap: wrap;
        margin-top: 0.5rem;
    }

    .filter-select {
        min-width: 120px;
        /* Ensure enough width for text */
    }
}