/*
 * Copyright (c) 2017-2018 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 {
  --dotSize: calc(var(--spacing-3) / 2);
  --dotOffset: calc(var(--dotSize) / 2);
}

.default {
  padding-top: var(--spacing-1);
  padding-bottom: var(--spacing-1);

  width: auto;

  .label::before,
  .label::after {
    border-radius: 50%;
  }

  .input:checked + .label::after {
    display: block;

    top: var(--dotOffset);
    left: var(--dotOffset);

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

    background: var(--PC-BLUE);
  }
  .label /* ‘label’ is the styled checkbox/radio */
 {
    display: flex;
    align-items: center;

    position: relative;

    height: var(--spacing-3);

    cursor: pointer;

    &::before {
      content: "";

      display: block;
      position: relative;

      box-sizing: border-box;
      width: var(--spacing-3);
      height: var(--spacing-3);

      border: 1px solid var(--PC-BLUE--L55);

      background: var(--PC-WHITE);
    }

    &::after {
      content: "";

      display: none;
      position: absolute;

      top: 0;
      left: 0;

      width: var(--spacing-3);
      height: var(--spacing-3);
    }
  }

  .labelContent {
    display: block;
    margin-left: var(--spacing-1);
  }

  .labelText {
    @extend %Nessie-SemiBold;
    color: var(--PC-GREY--D15);
  }

  .input:checked + .label::before,
  .input:focus + .label::before,
  &.fakeHovered .label::before {
    border-color: var(--PC-BLUE);
  }

  .input:focus + .label::before,
  &.fakeHovered .label::before {
    box-shadow: 0 0 0 2px color(var(--PC-BLUE) a(30%));
  }
  .input /* the (hidden) native input */
 {
    position: absolute;
    left: -9999px;
  }
}

.error {
  .input:checked + .label::after {
    background: var(--PC-RED);
  }
  .label::before {
    border: 1px solid var(--PC-RED) !important;
  }

  .input:focus + .label::before,
  &.fakeHovered .label::before {
    box-shadow: 0 0 0 2px color(var(--PC-RED) a(30%));
  }
}

.disabled {
  .labelText {
    color: var(--PC-GREY--L70);
  }

  .input:checked + .label::after {
    background: var(--PC-GREY--L70);
  }

  .label {
    cursor: default;

    &::before {
      border-color: var(--PC-GREY--L70) !important;
    }
  }
}
