* {
    margin: 0;
    padding: 0;
}

:root {
    --num: 9;
    /* num of divs/images */
    --wd: 130;
    /* width of card div */
    --gap: 20px;
}



.carousel {
    display: flex;
    align-items: flex-start;
    height: 100vh;
    overflow: hidden;
    mask-image: linear-gradient(to right, transparent, #000 5% 95%, transparent);
}

.carousel .gallery {
    list-style-type: none;
    display: flex;
    align-items: center;
    width: 100%;
    height: 450px;
    position: relative;
    perspective: 40em;
}

.carousel .gallery .card img {
    width: 100%;
    border-radius: 5px;
    box-shadow: 0px 0px 16px #cecece;
    -webkit-box-reflect: below 0px linear-gradient(to bottom, rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.4));
}

.carousel .gallery .card {
    width: calc(var(--wd) / 1.2 * 1px);
    height: auto;
    position: absolute;
    transform-style: preserve-3d;
    left: 100%;
    animation: slide 9s linear infinite,
        scaleEffect 9s ease-in-out infinite;
    animation-delay: calc(9s * ((var(--timer) - 1) / var(--num) - 1));
    transition: transform 0.25s ease-in-out;

}

@keyframes slide {
    from {
        left: 100%;
    }

    to {
        left: calc(-1 * var(--wd)* 1px);
    }
}

@keyframes scaleEffect {

    0%,
    40%,
    60%,
    100% {
        transform: scale(1);
        z-index: 0;
        filter: grayscale(1);
    }

    50% {
        transform: scale(2);
        z-index: 10;
        filter: grayscale(0);
    }
}

/* responsive */
@media only screen and (max-width: 1300px) {
    .carousel .gallery .card {
        width: calc(var(--wd) / 2 * 1px);
    }
}

@media only screen and (max-width: 600px) {
    .carousel .gallery .card {
        width: calc(var(--wd) / 1.5 * 1px);
        /* Slightly larger than desktop ratio relative to screen but smaller absolute size */
        /* Actually, let's make it smaller for mobile fitting */
        width: 80px;
    }

    .carousel .gallery {
        height: 300px;
        /* Reduce height on mobile */
    }
}