/* ==========================================================================
   MASONRY GRID LAYOUT (Google Photos Style)
   ========================================================================== */

.masonry-grid {
    /* 2 columns on mobile by default */
    column-count: 2;
    column-gap: 12px;
    padding: 10px 15px;
    width: 100%;
}

/* Tablet Layout */
@media (min-width: 768px) {
    .masonry-grid {
        column-count: 3;
        column-gap: 16px;
        padding: 15px 20px;
    }
}

/* Desktop Layout */
@media (min-width: 1024px) {
    .masonry-grid {
        column-count: 4;
        column-gap: 20px;
    }
}

/* ==========================================================================
   MASONRY ITEM (The Image Card)
   ========================================================================== */

.masonry-item {
    /* Crucial: Prevents an item from being split across two columns */
    break-inside: avoid;
    margin-bottom: 12px;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

/* Tap feedback for mobile app feel */
.masonry-item:active {
    transform: scale(0.97);
}

.masonry-item img {
    width: 100%;
    height: auto; /* Allows the image to dictate its own height, creating the scatter effect */
    display: block;
    object-fit: cover;
}

/* ==========================================================================
   ITEM OVERLAY (Name, Price & Button)
   ========================================================================== */

.item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    /* Dark gradient so white text is readable regardless of the image behind it */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
    padding: 30px 12px 12px 12px;
    color: #ffffff;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.item-overlay-text {
    flex: 1;
    padding-right: 10px;
}

/* The dynamically formatted name (e.g., "Aloo Samosa 30") */
.item-overlay h4 {
    margin: 0 0 4px 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    /* Truncate text with ellipsis if it's too long for the column */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* The dynamically calculated price */
.item-overlay p {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffc107; /* High visibility accent color */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   QUICK ADD TO CART BUTTON
   ========================================================================== */

.btn-add-cart-masonry {
    background-color: #d32f2f; /* Primary FrozoFun Theme Color */
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.btn-add-cart-masonry:hover {
    background-color: #b71c1c;
}

.btn-add-cart-masonry:active {
    transform: scale(0.9);
}