/* Row Grid Layout (Variable Widths, Same Height) */
.masonry-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.masonry-item {
    /* Fixed height controls the row height */
    height: 250px;

    /* Flex-grow fills the row, Flex-basis auto respects image aspect ratio */
    flex: 1 0 auto;
    margin: 0;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background-color: #f8f9fa;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .masonry-item {
        height: 260px;
    }
}

@media (max-width: 768px) {
    .masonry-item {
        height: 220px;
    }
}

@media (max-width: 576px) {
    .masonry-item {
        height: 200px;
    }
}

/* Last row spacing fix: Prevents items from stretching too wide on the last row */
.masonry-grid::after {
    content: '';
    flex-grow: 99999;
    min-width: 200px;
}

/* Link Wrapper */
.masonry-item a {
    display: block;
    width: 100%;
    height: 100%;
}

/* Image Styling */
.masonry-item img {
    height: 100%;
    width: auto;

    /* Intrinsic aspect ratio defines the flex-basis */
    min-width: 100%;

    /* Ensures the image covers the gap when the item grows */
    object-fit: cover;
    display: block;
    transition: transform 0.7s cubic-bezier(0.2, 1, 0.3, 1);
}

/* Hover Interaction */
.masonry-item:hover img {
    transform: scale(1.05);
}

/* Overlay Styling */
.masonry-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 50%);
    opacity: 0;
    transition: opacity 0.35s ease;
    display: flex;
    align-items: flex-end;
    padding: 1.5rem;
}

.masonry-item:hover .masonry-overlay {
    opacity: 1;
}

/* Typography */
.artwork-info {
    color: #fff;
    transform: translateY(12px);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    width: 100%;
}

.masonry-item:hover .artwork-info {
    transform: translateY(0);
}

.artwork-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    letter-spacing: -0.01em;
}

.artwork-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.9;
    letter-spacing: 0.08em;
    font-weight: 500;
}