/*
=====
CORE STYLES
=====
*/

.toggle {
    display: inline-flex;
    position: relative;
}

.toggle__input {
    /*
    The pattern by Sara Soueidan https://www.sarasoueidan.com/blog/inclusively-hiding-and-styling-checkboxes-and-radio-buttons/
    */
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0;

    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
}

/*
1. Calculation of the gap for the custom checkbox
*/

.toggle__label {
    display: inline-flex;
    min-height: 1.25rem;
    padding-left: 1.65rem;
}

.toggle__input:not(:disabled) ~ .toggle__label {
    cursor: pointer;
}

/*
1. Ems helps to calculate size of the checkbox
*/

.toggle__label::after {
    content: "";
    box-sizing: border-box;
    width: 1em;
    height: 1em;
    font-size: 1.25rem; /* 1 */

    background-color: transparent;
    border: 2px solid #2D7ED3;

    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
}

.toggle__input:checked ~ .toggle__label::after {
    background-color: #2D7ED3;
}

.toggle__text {
    margin-top: auto;
    margin-bottom: auto;
}

/*
The arrow size and position depends from sizes of square because I needed an arrow correct positioning from the top left corner of the element toggle

1. Ems helps to calculate size and position of the arrow
*/

.toggle__label::before {
    content: "";
    width: 0;
    height: 0;
    font-size: 1.25rem; /* 1 */

    border-left-width: 0;
    border-bottom-width: 0;
    border-left-style: solid;
    border-bottom-style: solid;
    border-color: #fff;

    position: absolute;
    top: .5428em;
    left: .20em;
    z-index: 3;

    transform-origin: left top;
    transform: rotate(-40deg) skew(10deg);
}

.toggle__input:checked ~ .toggle__label::before {
    width: .4em;
    height: .2em;
    border-left-width: 2px;
    border-bottom-width: 2px;
}

/*
States
*/

/* focus state */

/* disabled state */

.toggle__input:disabled ~ .toggle__label {
    opacity: 0.24;
    cursor: not-allowed;
    user-select: none;
}

/*
=====
PRESENTATION STYLES
=====
*/

/*
The demo skin
*/

.toggle__label::after {
    border-radius: 2px;
}

/*
The animation of switching states
*/

.toggle__input:not(:disabled) ~ .toggle__label::before {
    will-change: width, height;
    opacity: 0;
}

.toggle__input:not(:disabled):checked ~ .toggle__label::before {
    opacity: 1;
    transition: opacity .1s ease-out .25s, width .1s ease-out .5s, height .2s ease-out .3s;
}

.toggle__input:not(:disabled) ~ .toggle__label::after {
    will-change: background-color;
    transition: background-color .2s ease-out;
}
