$switch-width: 36px !default;
$switch-height: 24px !default;
$switch-bar-height: 14px !default;
$switch-thumb-size: 20px !default;
@mixin novo-switch-style($thumb, $track) {
    .novo-switch-thumb {
        background-color: $light;
    }
    .novo-switch-bar {
        background-color: lighten($light, 10%);
    } // Can make the checked version style different (same for now)
    &[aria-checked="true"] {
        .novo-switch-thumb {
            background-color: $thumb;
        }
        .novo-switch-bar {
            background-color: $track;
        }
    }
}

novo-switch {
    display: flex;
    align-items: center;
    margin: 15px;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    user-select: none;
    @include ease('all', 'swift-ease-in-out');
    * {
        box-sizing: border-box;
    }
    >div {
        display: flex;
        align-items: center;
    }
    .novo-switch-container {
        cursor: grab;
        width: $switch-width;
        height: $switch-height;
        position: relative;
        user-select: none;
        margin-right: 8px;
    }
    &:not([disabled]) {
        &.novo-switch-dragging .novo-switch-container,
        .novo-switch-dragging {
            cursor: grabbing;
        }
    }
    .novo-switch-label {
        border: 0 transparent;
    }
    .novo-switch-bar {
        left: 1px;
        width: $switch-width - 2px;
        top: $switch-height / 2 - $switch-bar-height / 2;
        height: $switch-bar-height;
        border-radius: 8px;
        position: absolute;
    }
    .novo-switch-thumb-container {
        top: $switch-height / 2 - $switch-thumb-size / 2;
        left: 0;
        width: $switch-width - $switch-thumb-size;
        position: absolute;
        transform: translate3d(0, 0, 0);
        z-index: 1;
    }
    &[aria-checked="true"] .novo-switch-thumb-container {
        transform: translate3d(100%, 0, 0);
    }
    .novo-switch-thumb {
        position: absolute;
        margin: 0;
        left: 0;
        top: 0;
        outline: none;
        height: $switch-thumb-size;
        width: $switch-thumb-size;
        border-radius: 50%;
        box-shadow: $whiteframe-shadow-z1; // todo
        .bh-ripple-container {
            position: absolute;
            display: block;
            width: auto;
            height: auto;
            left: -$switch-thumb-size;
            top: -$switch-thumb-size;
            right: -$switch-thumb-size;
            bottom: -$switch-thumb-size;
        }
    }
    &:not(.novo-switch-dragging) {
        .novo-switch-bar,
        .novo-switch-thumb,
        .novo-switch-thumb-container {
            @include ease('all', 'swift-ease-in-out');
            transition-property: transform, background-color;
        }
        .novo-switch-bar,
        .novo-switch-thumb {
            transition-delay: 0.05s;
        }
    }
    &[disabled] {
        opacity: 0.5;
        cursor: not-allowed;
        .novo-switch-container {
            cursor: not-allowed;
        }
    }
}

novo-switch {
    // Base color: $ocean
    @include novo-switch-style($ocean, lighten($ocean, 18%)); // Loop through analytics colors and make a switch color class for each
    @each $analytic,
    $color in $analytics-colors {
        &.#{$analytic} {
            @include novo-switch-style($color, lighten($color, 18%));
        }
    }
    &.dark {
        @include novo-switch-style($dark, darken($dark, 5%));
    }
    &.light {
        @include novo-switch-style(darken($light, 3%), $light);
    }
    &[disabled] {
        .novo-switch-thumb {
            background-color: darken($light, 20%);
        }
        .novo-switch-bar {
            background-color: $light;
        }
    }
    &:focus {
        .novo-switch-label:not(:empty) {
            border: 1px dotted $light;
        }
    }
}
