// Define vars we'll be using
// https://codepen.io/scottloway/pen/zqoLyQ
$brand-success: #5cb85c;
$loader-size: 1.6em;
$check-height: $loader-size/2;
$check-width: $check-height/2;
$check-left: ($loader-size/6 + $loader-size/12);
$check-thickness: 2px;
$check-color: $brand-success;

.circle-loader {
    margin: 0px;
    border: $check-thickness solid rgba(0, 0, 0, 0.2);
    &.circle-loading {
        animation-name: loader-spin;
        animation-duration: 1s;
        animation-iteration-count: infinite;
        animation-timing-function: linear;
        border-left-color: $check-color;
    }
    position: relative;
    display: inline-block;
    vertical-align: top;
}

.circle-loader,
.circle-loader:after {
    border-radius: 50%;
    width: 20px;
    height: 20px;
}

.load-complete {
    -webkit-animation: none;
    animation: none;
    border-color: $check-color;
    transition: border 500ms ease-out;
    .checkmark {
        display: block;
    }
}

.checkmark {
    display: none;

    &.draw:after {
        animation-duration: 800ms;
        animation-timing-function: ease;
        animation-name: checkmark;
        transform: scaleX(-1) rotate(135deg) translate(-58%, -40%);
    }

    &:after {
        opacity: 1;
        height: 50%;
        width: 25%;
        transform-origin: left top;
        border-right: $check-thickness solid $check-color;
        border-top: $check-thickness solid $check-color;
        content: '';
        left: 50%;
        top: 50%;
        position: absolute;
    }
}

@keyframes loader-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes checkmark {
    0% {
        height: 0;
        width: 0;
        opacity: 1;
    }
    20% {
        height: 0;
        width: $check-width;
        opacity: 1;
    }
    40% {
        height: $check-height;
        width: $check-width;
        opacity: 1;
    }
    100% {
        height: $check-height;
        width: $check-width;
        opacity: 1;
    }
}




@-webkit-keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@-webkit-keyframes scale {
    0%,
    100% {
        -webkit-transform: none;
        transform: none;
    }
    50% {
        -webkit-transform: scale3d(1.1, 1.1, 1);
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes scale {
    0%,
    100% {
        -webkit-transform: none;
        transform: none;
    }
    50% {
        -webkit-transform: scale3d(1.1, 1.1, 1);
        transform: scale3d(1.1, 1.1, 1);
    }
}

@-webkit-keyframes fill {
    100% {
        -webkit-box-shadow: inset 0 0 0 100px #46b450;
        box-shadow: inset 0 0 0 100px #46b450;
    }
}

@keyframes fill {
    100% {
        -webkit-box-shadow: inset 0 0 0 100px #46b450;
        box-shadow: inset 0 0 0 100px #46b450;
    }
}


.icon--checkmark {
    -webkit-animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
    animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
    border-radius: 50%;
    -webkit-box-shadow: inset 0 0 0 #46b450;
    box-shadow: inset 0 0 0 #46b450;
    display: block;
    height: 110px;
    left: calc( 50% - 55px);
    position: absolute;
    top: 20px;
    width: 110px;
    stroke: #fff;
    stroke-miterlimit: 10;
    stroke-width: 2;
}
.icon {
    margin-bottom: 2.8em;
    max-width: 100%;
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
}



.icon--checkmark__circle {
    -webkit-animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
    fill: none;
    stroke: #46b450;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-miterlimit: 10;
    stroke-width: 2;
}
.icon--checkmark__check {
    -webkit-animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
    -webkit-transform-origin: 50% 50%;
    -ms-transform-origin: 50% 50%;
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
}


$circle_size: 1.6em;
.cs-btn-circle-btn {
    display: inline-block;
    vertical-align: middle;
    overflow: hidden;
    text-decoration: none;
    position: relative;
    &:hover {
        color: inherit;
    }
    &.circle-loading {
        .cs-btn-circle-text {
            opacity: 0;
        }
    }

    background: #0085ba;
    border-color: #0073aa #006799 #006799;
    box-shadow: 0 1px 0 #006799;
    color: #fff;
    text-decoration: none;
    text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
    &:hover {
        background: #008ec2;
        border-color: #006799;
        color: #fff;
    }

    margin: 0;
    padding: 0 10px 1px;
    cursor: pointer;
    border-width: 1px;
    border-style: solid;
    -webkit-appearance: none;
    border-radius: 3px;
    white-space: nowrap;
    box-sizing: border-box;
}
.cs-btn-circle-text {
    display: inline-block;
    color: #fff;
    padding: 5px 10px;
}
.cs-btn-circle:after {
    border-radius: 50%;
    width: 18px;
    height: 18px;
    content: "";
    display: inline-block;
}
.cs-btn-circle {
    display: block;
    width: 24px;
    height: 24px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: 0px auto;
    opacity: 0;
    -webkit-transform: translate(-50%, -50%) translateZ(0);
    transform: translate(-50%, -50%) translateZ(0);
    &:after {
        border-top: 3px solid rgba(255, 255, 255, 0.2);
        border-right: 3px solid rgba(255, 255, 255, 0.2);
        border-bottom: 3px solid rgba(255, 255, 255, 0.2);
        border-left: 3px solid #ffffff;
    }
}
.circle-loading {
    .cs-btn-circle {
        opacity: 1;
        &:after {
            -webkit-animation: circle_load 1.1s infinite linear;
            animation: circle_load 1.1s infinite linear;
        }
    }
}
@-webkit-keyframes circle_load {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}
@keyframes circle_load {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}



