<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Custom 3-Item Carousel</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }

        .carousel-container {
            width: 80%;
            margin: 0 auto;
            overflow: hidden;
            position: relative;
        }

        .carousel-track {
            display: flex;
            transition: transform 0.5s ease-in-out;
        }

        .carousel-item {
            flex: 0 0 33.33%;
            text-align: center;
            opacity: 0.6;
            transform: scale(0.95);
            transition: opacity 0.3s ease, transform 0.3s ease;
        }

        .carousel-item.active {
            opacity: 1;
            transform: scale(1.2);
        }

        .carousel-item img {
            width: 100%;
            max-width: 400px;
            /* Increased image size */
            height: auto;
            margin: 0 auto;
        }

        .carousel-controls {
            position: absolute;
            top: 50%;
            width: 100%;
            display: flex;
            justify-content: space-between;
            transform: translateY(-50%);
        }

        .control {
            background-color: rgba(0, 0, 0, 0.5);
            color: #fff;
            border: none;
            font-size: 24px;
            padding: 10px 20px;
            cursor: pointer;
            z-index: 1000;
        }
    </style>
</head>

<body>
    <div class="carousel-container">
        <div class="carousel-track">
            <div class="carousel-item"><img
                    src="https://res.cloudinary.com/dwzmsvp7f/image/upload/f_auto,w_2000/c_crop%2Cg_custom%2Fv1732707000%2Fzkic7axd1d2mi2fgir3a.jpg"
                    alt="Item 1"></div>
            <div class="carousel-item"><img
                    src="https://res.cloudinary.com/dwzmsvp7f/image/upload/f_auto,w_2000/c_crop%2Cg_custom%2Fv1732091541%2Ffiiacxotntwttrz6wo6f.jpg"
                    alt="Item 2"></div>
            <div class="carousel-item active"><img
                    src="https://res.cloudinary.com/dwzmsvp7f/image/upload/f_auto,w_2000/c_crop%2Cg_custom%2Fv1728386533%2Fmgaxevszd5ozfznso2el.jpg"
                    alt="Item 3"></div>
            <div class="carousel-item"><img
                    src="https://res.cloudinary.com/dwzmsvp7f/image/upload/f_auto,w_2000/c_crop%2Cg_custom%2Fv1732527926%2Frpbvprhlgtbh6su0mtf3.jpg"
                    alt="Item 4"></div>
            <div class="carousel-item"><img
                    src="https://res.cloudinary.com/dwzmsvp7f/image/upload/f_auto,w_2000/c_crop%2Cg_custom%2Fv1731074325%2Fbe1iznsdnfznl77wwtlz.jpg"
                    alt="Item 5"></div>
            <div class="carousel-item"><img
                    src="https://res.cloudinary.com/dwzmsvp7f/image/upload/f_auto,w_2000/c_crop%2Cg_custom%2Fv1731572988%2Fm1o1xvzsjxiphbjbemhu.jpg"
                    alt="Item 6"></div>
        </div>
        <div class="carousel-controls">
            <button class="control prev">&lt;</button>
            <button class="control next">&gt;</button>
        </div>
    </div>

    <script>
        const track = document.querySelector('.carousel-track');
        const items = Array.from(track.children);
        const prevButton = document.querySelector('.control.prev');
        const nextButton = document.querySelector('.control.next');

        let currentIndex = 2; // Center item index initially (3rd image)

        // Function to update item classes
        function updateItems() {
            items.forEach((item, index) => {
                item.classList.remove('active');
                if (index === currentIndex) {
                    item.classList.add('active');
                }
            });
        }

        // Function to move the carousel
        function moveCarousel() {
            const offset = -((currentIndex - 1) * (100 / 3)); // Center the active item
            track.style.transform = `translateX(${offset}%)`;
        }

        // Event listeners for buttons
        prevButton.addEventListener('click', () => {
            currentIndex = (currentIndex - 1 + items.length) % items.length; // Loop back to end
            updateItems();
            moveCarousel();
        });

        nextButton.addEventListener('click', () => {
            currentIndex = (currentIndex + 1) % items.length; // Loop back to start
            updateItems();
            moveCarousel();
        });

        // Initialize
        updateItems();
        moveCarousel();
    </script>
</body>

</html>