$mainColor: #fff;
$strokeColor: #000;

@keyframes clockwise {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes anticlockwise {
    0% {
        transform: rotate(360deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

@keyframes clockwiseError {
    0% {
        transform: rotate(0deg);
    }
    20% {
        transform: rotate(30deg);
    }
    40% {
        transform: rotate(25deg);
    }
    60% {
        transform: rotate(30deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

@keyframes anticlockwiseErrorStop {
    0% {
        transform: rotate(0deg);
    }
    20% {
        transform: rotate(-30deg);
    }
    60% {
        transform: rotate(-30deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

@keyframes anticlockwiseError {
    0% {
        transform: rotate(0deg);
    }
    20% {
        transform: rotate(-30deg);
    }
    40% {
        transform: rotate(-25deg);
    }
    60% {
        transform: rotate(-30deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

.h1,
.h2 {
    transition: opacity 0.5s linear, margin-top 0.5s linear;
}

.h1 {
    margin: 100px auto 0 auto;
    color: $strokeColor;
    font-size: 3rem;
    line-height: 1.2;
    text-align: center;
}

.h2 {
    margin: 20px auto 50px auto;
    font-size: 1.5rem;
    color: #7f8084;
    line-height: 1.429;
    text-align: center;
}

.gear {
    position: relative;
    z-index: 0;
    width: 120px;
    height: 120px;
    margin: 0 auto;
    border-radius: 50%;
    background: $strokeColor;

    &:before {
        position: absolute;
        left: 5px;
        top: 5px;
        right: 5px;
        bottom: 5px;
        z-index: 2;
        content: '';
        border-radius: 50%;
        background: $mainColor;
    }

    &:after {
        position: absolute;
        left: 25px;
        top: 25px;
        z-index: 3;
        content: '';
        width: 70px;
        height: 70px;
        border-radius: 50%;
        border: 5px solid $strokeColor;
        box-sizing: border-box;
        background: $mainColor;
    }

    &.one {
        left: -130px;
        animation: anticlockwiseErrorStop 2s linear infinite;
    }

    &.two {
        top: -75px;
        animation: anticlockwiseError 2s linear infinite;
    }

    &.three {
        top: -235px;
        left: 130px;
        animation: clockwiseError 2s linear infinite;
    }

    .bar {
        position: absolute;
        left: -15px;
        top: 50%;
        z-index: 0;
        width: 150px;
        height: 30px;
        margin-top: -15px;
        border-radius: 5px;
        background: $strokeColor;

        &:before {
            position: absolute;
            left: 5px;
            top: 5px;
            right: 5px;
            bottom: 5px;
            z-index: 1;
            content: '';
            border-radius: 2px;
            background: $mainColor;
        }

        &:nth-child(2) {
            transform: rotate(60deg);
            transform: rotate(60deg);
        }
        &:nth-child(3) {
            transform: rotate(120deg);
        }
    }
}

.loading {
    .h1,
    .h2 {
        margin-top: 0px;
        opacity: 0;
    }

    .gear {
        &.one,
        &.three {
            animation: clockwise 3s linear infinite;
        }
        &.two {
            animation: anticlockwise 3s linear infinite;
        }
    }
}
