@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    height: 100vh;
    display: flex;
    overflow: hidden;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    background-color: #bbb;
    font-family: 'Poppins', sans-serif;
}

.toggle-container {
    width: 200px;
    display: flex;
    margin: 10px 0;
    align-items: center;
}

.toggle {
    visibility: hidden;
}

.label {
    width: 80px;
    height: 40px;
    cursor: pointer;
    margin: 0 15px 0;
    position: relative;
    border-radius: 50px;
    display: inline-block;
    background-color: slategray;
}

.toggle:checked + .label {
    background-color: tomato;
}

.ball {
    top: 3px;
    left: 3px;
    width: 34px;
    height: 34px;
    position: absolute;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    animation: slideOff 0.3s linear forwards;
    background-color: white;
}

.toggle:checked + .label .ball {
    animation: slideOn 0.3s linear forwards;
}

@keyframes slideOn {
    0% {
        transform: translateX(0) scale(1);
    }

    50% {
        transform: translateX(20px) scale(1.2);
    }

    100% {
        transform: translateX(40px) scale(1);
    }
}

@keyframes slideOff {
    0% {
        transform: translateX(40px) scale(1);
    }
    
    50% {
        transform: translateX(20px) scale(1.2);
    }
    
    100% {
        transform: translateX(0) scale(1);
    }
}