/* Only keep the original card and grid styles for fixed-article-card and articles-grid */
.fixed-article-card {
    height: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
}

.card-img-container {
    height: 180px;
    width: 100%;
    background: #f3f3f3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-img-container img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    display: block;
}

.fixed-article-card .card-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 1rem;
    min-height: 0;
}

.fixed-article-card .card-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fixed-article-card .card-text {
    flex: 1 1 auto;
    font-size: 0.95rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.fixed-article-card .btn {
    margin-top: auto;
}

.articles-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.articles-grid > a {
    flex: 0 0 calc(33.333% - 1.34rem);
    max-width: calc(33.333% - 1.34rem);
    box-sizing: border-box;
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

/* Featured Article Styles */
.featured-article .card-img-container {
    height: 100%;
}

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-10px);
    box-shadow: 0 1rem 3rem rgba(0,0,0,.175) !important;
}

/* Utility Classes */
.object-cover {
    object-fit: cover;
    width: 100%;
}

.stretched-link::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    pointer-events: auto;
    content: "";
    background-color: rgba(0,0,0,0);
}

/* Latest Updates Sidebar */
.list-group-item-action:hover {
    background-color: #f8f9fa;
}

/* Responsive Adjustments */
@media (max-width: 991px) {
    .articles-grid > a {
        flex: 0 0 calc(50% - 1rem);
        max-width: calc(50% - 1rem);
    }
}

@media (max-width: 600px) {
    /* Articles grid: one item per row to match category card */
    .articles-grid .col {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    /* Display only first 6 articles in mobile view */
    .articles-grid .col:nth-child(n+7) {
        display: none;
    }


    /* Match article cards to category card dimensions */
    .article-card {
        height: 400px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .article-card .article-img {
        height: 160px;
        width: 100%;
        object-fit: cover;
    }
}

/* Fix equal height for featured section */
.equal-height-row {
    align-items: stretch !important;
}

.featured-content, .card.border-0.shadow-sm.h-100.w-100 {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.below-featured-section .col {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.small-article-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Sidebar: prevent horizontal scroll and truncate text */
.sidebar-fixed-height {
    overflow-x: hidden;
}
.sidebar-fixed-height .fw-bold,
.sidebar-fixed-height .mb-1.fw-bold {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 80%;
}
.sidebar-fixed-height .text-muted {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

@media (min-width: 992px) {
    /* Force 4 cards per row and two rows (8 items) - override Bootstrap */
    .articles-grid.row {
        --bs-gutter-x: 1rem !important;
        --bs-gutter-y: 1rem !important;
        display: flex !important;
        flex-wrap: wrap !important;
        margin: 0 !important;
    }
    .articles-grid.row > .col {
        flex: 0 0 calc(25% - 0.75rem) !important;
        max-width: calc(25% - 0.75rem) !important;
        padding: 0.5rem !important;
        margin-bottom: 1rem !important;
    }
    /* Hide any articles after the 8th to keep exactly 2 rows */
    .articles-grid.row > .col:nth-child(n+9) {
        display: none !important;
    }
}
