.middlebodycards1 {
    position: relative;
    width: 100%;
}

.middlebodycards2 {
    position: relative;
    top: 3rem;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 260px));
    justify-content: center;
    gap: clamp(16px, 3vw, 32px);
    width: 100%;
    position: relative;
}

.card {
    background-color: rgba(236, 243, 243, 0.411);
    border-radius: 5px;
    overflow: hidden;
    padding: 0;
    margin: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.25s ease-in-out;
    transform: translateZ(0);
    contain: content;
    content-visibility: auto;
    contain-intrinsic-size: 220px 300px;
}

.card:hover {
    transform: translateY(-8px);
}

.card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: cover;
    display: block;
}

.card-content {
    padding: clamp(8px, 1.5vw, 12px);
    text-align: center;
}

.card-content h3 {
    margin-bottom: 8px;
    font-size: clamp(15px, 1vw + 10px, 18px);
}

.card-content p {
    font-size: clamp(12px, 0.5vw + 10px, 14px);
    color: #141414;
    margin-bottom: 10px;
}

.card-content button {
    background-color: #22211f;
    color: white;
    border: none;
    padding: clamp(5px, 1vw, 8px) clamp(7px, 2vw, 12px);
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.25s ease-in-out;
    font-size: clamp(12px, 0.5vw + 10px, 14px);
}

.card-content button:hover {
    background-color: #555;
}

.link {
    font-size: clamp(13px, 0.8vw + 8px, 15px);
}

@media (max-width: 628px) {
    .gallery {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media screen and (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}