/*
 * Copyright (c) 2017-2019 dunnhumby Germany GmbH.
 * All rights reserved.
 *
 * This source code is licensed under the MIT license found in the LICENSE file
 * in the root directory of this source tree.
 *
 */

@import "../proto/base.css";

:root {
  --inputHeight: 40px;

  --trackWidth: 40px;
  --trackHeight: 16px;

  --borderWidth: 2px;

  --circleSize: 25px;
  --circleOffset: 4px;

  --backgroundTransition: background-color 0.2s ease-in-out;
  --circleTransition: background-color 0.2s ease-in-out,
    left 0.25s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.default {
  display: flex;
  align-items: center;
  justify-content: center;

  width: calc(var(--trackWidth) + (var(--circleOffset) * 2));
  height: var(--inputHeight);

  .input {
    position: absolute;
    left: -9999px;

    &:focus {
      & + .label {
        outline: none;

        border: 1px solid var(--PC-BLUE);
        box-shadow: 0 0 0 2px color(var(--PC-BLUE) a(30%));

        &::before {
          border-color: var(--PC-BLUE);
          box-shadow: 0 0 0 2px color(var(--PC-BLUE) a(30%));
        }
      }
    }
  }

  .label {
    display: flex;

    width: var(--trackWidth);
    height: var(--trackHeight);

    border-radius: calc(var(--trackHeight) / 2);

    background: var(--PC-GREY--L10);

    cursor: pointer;
    transition: var(--backgroundTransition);

    &::before {
      content: "";

      display: block;
      position: absolute;

      box-sizing: border-box;

      top: 50%;
      left: 0;
      transform: translateY(-50%);

      width: var(--circleSize);
      height: var(--circleSize);

      border-radius: 100%;
      border-style: solid;
      border-width: var(--borderWidth);
      border-color: var(--PC-GREY);

      background: var(--PC-WHITE);

      transition: var(--circleTransition);
    }
  }

  .input:checked + .label {
    background: var(--PC-BLUE--L10);
    transition: var(--backgroundTransition);

    &::before {
      left: calc(100% - var(--circleSize));
      border-color: var(--PC-BLUE);
    }
  }
}

.disabled {
  .label {
    cursor: default;
    background: var(--PC-GREY--L40);

    &::before {
      border-color: var(--PC-GREY--L40);
    }
  }

  .input:checked + .label {
    background: var(--PC-BLUE--L55);

    &::before {
      border-color: var(--PC-BLUE--L55);
    }
  }

  :hover {
    .label {
      background: var(--PC-GREY--L55);

      &::before {
        border-color: var(--PC-GREY--L40);
      }
    }

    input:checked + .label {
      background: var(--PC-BLUE--L55);

      &::before {
        border-color: var(--PC-BLUE--L40);
      }
    }
  }
}
