.gallery_wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    margin-top: -140px;
    width: 100%;
}

.careers_gallery_wrapper {
    margin-top: 0;
    width: unset;
}

.card_stack_wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    width: 100%;
    height: 700px;
    margin-bottom: -200px;
    overflow: hidden;
}

.card-stack {
    position: relative;
    width: 500px;
    height: 500px;
    margin-bottom: -10px;
}

.card {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    border: 2px solid var(--black);
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0px 10px 0px #00000026;
    background-color: var(--white);

    /* Key: Initial values for custom properties */
    --order: 1; 
    --z-index: 4; 
    --direction: 1; /* New: Used by JS to be 1 or -1 for horizontal swing */
  
    transition: 
        transform 0.25s cubic-bezier(0.625, 0.05, 0, 1), 
        z-index 0.001s linear; 
    
    transform: 
        /* Vertical offset (20px per card) */
        translateY(calc(var(--order) * 10px))
        translateX(calc(var(--initial-direction) * var(--order) * 14px)) 
        rotate(calc(var(--initial-direction) * var(--order) * 2deg));
    
    z-index: var(--z-index);
}

.card.is-shuffling {
    transform: 
        translateY(var(--swing-y))
        translateX(calc(var(--direction) * 600px)) 
        rotate(calc(var(--direction) * 15deg));
    z-index: 10;
    transition: 
        transform 0.25s cubic-bezier(0.625, 0.05, 0, 1),
        z-index 0s 0s;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 50%;
    display: block;
}

#shuffleButton {
    z-index: 400;
    background-color: var(--white);
    color: var(--black);
    -webkit-text-stroke: 0px black;
}

.gallery_heading {
    position: absolute;
    right: 8%;
    top: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--melon);
    border: 2px solid var(--black);
    border-radius: 30px;
    height: 46px;
    width: max-content;
    padding: 0 25px;
    font-weight: 600;
    margin-top: 5px;
    margin-bottom: 20px;
    transform: rotate(12deg);
    box-shadow: 0px 5px 0px #00000026;
}

.gallery_wrapper .gallery_arrow_container {
    left: 13%;
    top: 190px;
    bottom: unset;
}

.gallery_wrapper .gallery_arrow_container .arrow_message {
    width: 150px;
    text-align: center;
}

.gallery_wrapper .gallery_arrow_container svg {
    transform: rotate(0deg);
    margin-left: 0px;
    margin-right: -50px;
}

.animations_wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: -110px;
    margin-bottom: -150px;
}

.animations_wrapper #moon_animation {
    margin-left: -110px;
}

.animations_wrapper #rainbow_animation {
    margin-right: -80px;
    margin-top: -40px;
}

@media (max-width: 1500px) {
    .card {
        transform: 
            /* Vertical offset (20px per card) */
            translateY(calc(var(--order) * 10px))
            translateX(calc(var(--initial-direction) * var(--order) * 10px)) 
            rotate(calc(var(--initial-direction) * var(--order) * 2deg));
    }

    .gallery_heading {
        right: 3%;
    }

    .gallery_wrapper .gallery_arrow_container {
        left: 8%;
    }
}

@media (max-width: 1350px) {
    .animations_wrapper {
        margin-top: -100px;
        margin-bottom: -160px;
    }

    .animations_wrapper #rainbow_animation {
        margin-right: -120px;
    }
}

@media (max-width: 1250px) {
    .animations_wrapper #rainbow_animation {
        margin-right: -20px;
    }

    .gallery_wrapper .gallery_arrow_container {
        left: 3%;
    }
}

@media (max-width: 1150px) {
    .animations_wrapper #rainbow_animation {
        margin-top: 40px;
    }
}

@media (max-width: 1100px) {
    .gallery_wrapper {
        margin-top: -220px;
    }

    .careers_gallery_wrapper {
        margin-top: 0;
    }

    .animations_wrapper {
        margin-top: 60px;
        margin-bottom: -170px;
        justify-content: center;
        /* align-items: unset; */
    }

    .animations_wrapper #moon_animation {
        margin-right: 0px;
        margin-top: -80px;
        margin-left: -100px;
    }

    .animations_wrapper #rainbow_animation {
        margin-top: 40px;
    }

    .gallery_wrapper .gallery_arrow_container {
        top: 290px;
    }

    .gallery_heading {
        top: 420px;
    }
}

@media (max-width: 1050px) {
    .gallery_heading,
    .gallery_wrapper .gallery_arrow_container {
        display: none;
    }
}

@media (max-width: 750px) {
    .gallery_wrapper {
        margin-top: -100px;
    }

    .gallery_heading {
        display: flex;
        right: 50%;
        transform: translateX(50%);
        top: -10px;
    }
}

@media (max-width: 700px) {
    .gallery_wrapper {
        padding: 20px 0 0;
        margin-top: -120px;
    }

    .card-stack {
        width: 350px;
        height: 450px;
    }

    .gallery_heading {
        display: flex;
        right: 50%;
        transform: translateX(50%);
        top: 0px;
    }
}

@media (max-width: 650px) {
    .animations_wrapper {
        flex-direction: column;
    }

    .animations_wrapper #moon_animation {
        margin-right: 0px;
        margin-top: -60px;
    }

    .animations_wrapper #rainbow_animation {
        margin-top: -130px;
    }
}

@media (max-width: 600px) {
    .gallery_wrapper button {
        width: max-content;
        margin-top: 20px;
    }

    .card-stack {
        width: 350px;
        height: 500px;
    }
}

@media (max-width: 450px) {
    .card {
        transform: 
            /* Vertical offset (20px per card) */
            translateY(calc(var(--order) * 5px))
            translateX(calc(var(--initial-direction) * var(--order) * 7px)) 
            rotate(calc(var(--initial-direction) * var(--order) * 1deg));
    }

    .gallery_wrapper button {
        margin-top: 0;
    }

    .card-stack {
        width: 320px;
        height: 500px;
    }

    .card_stack_wrapper .upward_small {
        transform: translateY(0%);
    }
}

@media (max-width: 400px) {
    .animations_wrapper #rainbow_animation {
        margin-right: -10px;
        width: 300px;
        height: 300px;
    }
}