.masonry-grid {
    column-count: 3; /* Number of columns */
    column-gap: 1.5rem; /* Space between columns */
    padding: 1rem;
    max-width: 100%; /* Use full screen width */
    margin: 0 auto; /* Center the grid */
}

.masonry-item {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 1.5rem; /* Space between items vertically */
    break-inside: avoid; /* Prevent items from being split across columns */
    padding: 1rem;
}

.masonry-item-link {
    display: block; /* Make the entire link behave like a block */
    text-decoration: none; /* Remove underline on the link */
    color: inherit; /* Ensure the text color matches the design */
}

.masonry-item-link:hover .masonry-item {
    border: 5px solid #022f67; /* Add border on hover */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); /* Add shadow on hover */
    text-decoration: none; /* No underline */
    color: inherit; /* No color change */
}

/* Hover effect for the entire masonry item */
.masonry-item-link:hover {
    border: none; /* Ensure border styling applies only to the masonry-item */
    text-decoration: none; /* Prevent underline globally */
    color: inherit; /* Prevent color change */
}

/* Hover-specific rules for text elements */
.masonry-item-link:hover h2,
.masonry-item-link:hover h2 a,
.masonry-item-link:hover p,
.masonry-item-link:hover p a {
    text-decoration: none !important; /* No underline */
    color: inherit !important; /* Prevent text color change */
}

/* Prevent hover effects on links in h2 and p inside masonry-item */
.masonry-item h2 a,
.masonry-item p a {
    color: inherit !important; /* Ensure the color matches the surrounding text */
    text-decoration: none !important; /* Remove underline */
}

.masonry-item h2 a:hover,
.masonry-item p a:hover {
    color: inherit !important; /* Keep the color the same on hover */
    text-decoration: none !important; /* No underline on hover */
}

.masonry-item h2 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.masonry-item p {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.featured-image {
    width: 100%; /* Full width of the grid cell */
    height: auto; /* Maintain image aspect ratio */
    margin-bottom: 0.5rem;
    border-radius: 8px;
    display: block;
}

/* Adjust the minimum column size for wider screens */
@media (min-width: 1600px) {
    .masonry-grid {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); /* Wider columns for large screens */
        gap: 2rem; /* Increase gap for a more spacious layout */
    }
}

/* Responsive Column Adjustments */
@media (max-width: 1200px) {
    .masonry-grid {
        column-count: 2; /* Reduce to 2 columns for medium screens */
    }
}

@media (max-width: 768px) {
    .masonry-grid {
        column-count: 1; /* Single column for small screens */
    }
}
