//
//  Animations styles
//  ____________________________________________

//
//  Variables
//  --------------------------------------------

@animating-element-size: 20px;

//
//  Keyframes
//  --------------------------------------------

@keyframes am-criss-cross-left {
    0% {
        left: -@animating-element-size;
    }
    50% {
        left: 50%;
        width: @animating-element-size;
        height: @animating-element-size;
    }
    100% {
        left: 50%;
    }
}

@keyframes am-criss-cross-right {
    0% {
        right: -@animating-element-size;
    }
    50% {
        right: 50%;
        width: @animating-element-size;
        height: @animating-element-size;
    }
    100% {
        right: 50%;
    }
}

//
//  Common
//  --------------------------------------------

& when (@media-common = true) {
    .amcustombutton-animation-element {
        position: absolute;
        z-index: 1;
    }

    .amcustombutton-button-element.-animation-circle {
        & {
            transition: color .3s .1s ease-out;
        }

        .amcustombutton-animation-element {
            top: 0;
            right: 0;
            bottom: 0;
            display: block;
            margin: auto;
            border-radius: 50%;
            content: '';
            transition: box-shadow .5s ease-out;
        }
    }

    .amcustombutton-button-element.-animation-position-aware {
        & {
            transition: color .3s .1s ease-out;
        }

        .amcustombutton-animation-element {
            display: block;
            width: 0;
            height: 0;
            border-radius: 50%;
            transition: width .4s ease-in-out, height .4s ease-in-out;
            transform: translate(-50%, -50%);
        }
    }

    .amcustombutton-button-element.-animation-collision {
        .amcustombutton-animation-element {
            top: 50%;
            width: @animating-element-size;
            height: @animating-element-size;
            border-radius: 50%;
            content: '';
        }

        .amcustombutton-animation-element:first-of-type {
            left: -@animating-element-size;
            transform: translate(-50%, -50%);
        }

        .amcustombutton-animation-element:last-of-type {
            right: -@animating-element-size;
            transform: translate(50%, -50%);
        }

        &:hover {
            .amcustombutton-animation-element:first-of-type {
                animation: am-criss-cross-left .8s both;
                animation-direction: alternate;
            }

            .amcustombutton-animation-element:last-of-type {
                animation: am-criss-cross-right .8s both;
                animation-direction: alternate;
            }
        }
    }

    .amcustombutton-button-element.-animation-border-race {
        & {
            transition: all .2s linear;
        }

        .amcustombutton-animation-element {
            & {
                position: absolute;
                transition: inherit;
                transition-duration: .4s;
            }

            &:nth-of-type(1),
            &:nth-of-type(3) {
                width: 0;
                height: 2px;
            }

            &:nth-of-type(2),
            &:nth-of-type(4) {
                width: 2px;
                height: 0;
            }

            &:nth-of-type(1),
            &:nth-of-type(4) {
                top: 0;
                left: 0;
            }

            &:nth-of-type(2),
            &:nth-of-type(3) {
                right: 0;
                bottom: 0;
            }
        }

        &:hover .amcustombutton-animation-element {
            &:nth-of-type(1),
            &:nth-of-type(3) {
                width: 100%;
            }

            &:nth-of-type(2),
            &:nth-of-type(4) {
                height: 100%;
            }
        }
    }
}
