@import '@helsenorge/designsystem-react/scss/palette';

$color-primary-1: #a61e7b;

.atom_radio {
  /******** RESET *********/
  input[type='radio'] {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;

    & + label {
      cursor: pointer;
      display: block;
      font-size: 18px;
      font-weight: 400;
      margin: 0;
      word-break: break-word;
      hyphens: auto;
      hyphens: auto;
      hyphens: auto;
    }
  }

  /******** INPUT *********/
  &__input {
    &:hover,
    &:focus {
      & + .atom_radio__label .atom_radio__checkicon:not(.atom_radio__checkicon--disabled) {
        background-color: $neutral400;
        box-shadow: 0 0 0 2px $neutral400;

        &.atom_radio__checkicon--blue:not(.atom_radio__checkicon--disabled) {
          &.atom_checkbox__checkicon--checked {
            border-color: $blueberry700;
          }
        }

        &.atom_radio__checkicon--lilla:not(.atom_radio__checkicon--disabled) {
          &.atom_checkbox__checkicon--checked {
            border-color: $color-primary-1;
          }
        }
      }
    }
  }

  /******** ICON *********/
  &__checkicon {
    display: inline-flex;
    flex-shrink: 0;
    vertical-align: middle;
    border: 2px solid $neutral500;
    margin-right: 0.75rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;

    &:focus {
      outline: none;
    }

    .atom_radio__checkicon_innercicrcle {
      background-color: transparent;
    }
  }

  &__checkicon_innercicrcle {
    display: block;
    width: 50%;
    height: 50%;
    margin: 25%;
    border-radius: 50%;
  }

  &__checkicon--checked:not(.atom_radio__checkicon--disabled) {
    &.atom_radio__checkicon--blue {
      border-color: $blueberry700;

      .atom_radio__checkicon_innercicrcle {
        background-color: $blueberry700;
      }
    }

    &.atom_radio__checkicon--lilla {
      border-color: $color-primary-1;

      .atom_radio__checkicon_innercicrcle {
        background-color: $color-primary-1;
      }
    }
  }

  &__checkicon--disabled {
    background-color: $neutral200;

    &.atom_radio__checkicon--checked {
      .atom_radio__checkicon_innercicrcle {
        background-color: $neutral500;
      }
    }
  }

  /******** TEXT *********/
  &__text {
    display: inline-flex;
  }

  &__text--checked {
    font-weight: 600;
  }

  /******** LABEL *********/
  &__label,
  input[type='radio'] + label.atom_radio__label {
    display: flex;
    align-items: center;
    color: $black;
    line-height: 1.5rem;
    padding: 0.625rem 1rem 0.625rem 0;

    &:hover {
      .atom_radio__checkicon:not(.atom_radio__checkicon--disabled) {
        background-color: $neutral400;
        box-shadow: 0 0 0 2px $neutral400;
      }
    }
  }

  &__label--checked,
  input[type='radio'] + label.atom_radio__label--checked {
    position: relative;
  }

  &__label--boxed,
  input[type='radio'] + label.atom_radio__label--boxed {
    padding: 0.75rem 1rem;
    min-height: 3.125rem;
    background-color: $white;
    box-shadow: 0 0 0 2px $neutral200;

    &.atom_radio__label--checked {
      box-shadow: 0 0 0 2px $blueberry700;
      background-color: $blueberry50;

      &:hover,
      &:focus {
        box-shadow: 0 0 0 4px $blueberry700;
      }
    }
  }
}
