.custom-news-grid-container {
    display: grid;
    gap: 15px;
    width: 100%;
    /* Use aspect-ratio to maintain proportions instead of fixed height/width */
    aspect-ratio: 1232 / 540;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(4, 1fr);
    grid-template-areas:
      "item-1 item-1 item-1 item-1 item-2 item-2 item-3 item-3"
      "item-1 item-1 item-1 item-1 item-2 item-2 item-3 item-3"
      "item-1 item-1 item-1 item-1 item-4 item-4 item-5 item-5"
      "item-1 item-1 item-1 item-1 item-4 item-4 item-5 item-5";
}

.news-item-1 { grid-area: item-1; }
.news-item-2 { grid-area: item-2; }
.news-item-3 { grid-area: item-3; }
.news-item-4 { grid-area: item-4; }
.news-item-5 { grid-area: item-5; }

.news-item,
.news-item:visited,
.news-item:hover,
.news-item:active {
    color: #fff !important;
    text-decoration: none;
}

.news-item {
    position: relative;
    display: flex;
    align-items: flex-end; /* Aligns content to the bottom */
    justify-content: flex-start;
    padding: 1.2rem;
    border-radius: 8px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: transform 0.3s ease;
    box-sizing: border-box;
}

.news-item:hover {
    transform: scale(1.03);
}

/* Dark overlay for text readability */
.news-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 60%);
    z-index: 1;
}

.news-item-content {
    position: relative;
    z-index: 2;
}

.news-item-title {
    color: #fff !important;
    margin: 0;
    /* Make font size responsive and smaller overall */
    font-size: clamp(1rem, 1.5vw + 0.5rem, 1.5rem);
    line-height: 1.2;
    font-weight: bold;
}

/* Adjust font size for smaller items */
.news-item-2 .news-item-title,
.news-item-3 .news-item-title,
.news-item-4 .news-item-title,
.news-item-5 .news-item-title {
    font-size: clamp(0.9rem, 1.2vw + 0.2rem, 1.1rem);
}


/* --- Responsive Design --- */

/* Tablet and Mobile view: All items stack equally */
@media (max-width: 1024px) {
    .custom-news-grid-container {
        display: flex;
        flex-direction: column;
        gap: 15px;
        aspect-ratio: unset; /* Let height be determined by content */
    }

    .news-item {
        height: 220px; /* Force a consistent height for all items on smaller screens */
        width: 100%; /* Ensure all items take full width */
    }
}
