/**
 *
 *
 * @param {string} $primary-stylename (v-select-optiongroup) - 
 * @param {bool} $include-additional-styles - 
 *
 * @group optiongroup
 */
@mixin valo-optiongroup ($primary-stylename: v-select-optiongroup, $include-additional-styles: contains($v-included-additional-styles, optiongroup)) {

  .v-radiobutton {
    @include valo-radiobutton-style;
  }

  .#{$primary-stylename} {
    @include valo-optiongroup-style;
  }


  @if $include-additional-styles {
    .#{$primary-stylename}-small {
      @include valo-optiongroup-style($unit-size: $v-unit-size--small);
      font-size: $v-font-size--small;
    }

    .#{$primary-stylename}-large {
      @include valo-optiongroup-style($unit-size: $v-unit-size--large);
      font-size: $v-font-size--large;
    }

    .#{$primary-stylename}-horizontal {
      @include valo-optiongroup-horizontal;
    }
  }

}


/**
 *
 *
 * @param {color} $background-color ($v-background-color) - 
 * @param {size} $unit-size ($v-unit-size) - 
 * @param {color} $selection-color ($v-selection-color) - 
 *
 * @group optiongroup
 */
@mixin valo-radiobutton-style ($background-color: $v-background-color, $unit-size: $v-unit-size, $selection-color: $v-selection-color) {
  @include valo-checkbox-style($background-color: $background-color, $unit-size: $unit-size, $selection-color: $selection-color);

  :root & > input {
    &:checked ~ label:after {
      $size: ceil($unit-size/6);
      $offset: round($unit-size/6);
      width: $size;
      height: $size;
      top: $offset;
      left: $offset;
      background: $selection-color;
    }

    & ~ label:before,
    & ~ label:after {
      border-radius: 50%;
      content: "";
    }
  }
}



/**
 *
 *
 * @param {size} $unit-size ($v-unit-size) - 
 * @param {size} $font-size ($v-font-size) - 
 *
 * @group optiongroup
 */
@mixin valo-optiongroup-style ($unit-size: $v-unit-size, $font-size: $v-font-size) {

  @if $unit-size != $v-unit-size {
    .v-checkbox {
      @include valo-checkbox-style($unit-size: $unit-size);
    }
    .v-radiobutton {
      @include valo-radiobutton-style($unit-size: $unit-size);
    }
  }

  .v-radiobutton,
  .v-checkbox {
    display: block;
    margin: round($unit-size/4) $font-size 0 0;

    &:first-child {
      margin-top: round($unit-size/6);
    }

    &:last-child {
      margin-bottom: round($unit-size/6);
    }
  }

  &.v-has-width label {
    white-space: normal;
  }
}


/**
 *
 *
 *
 * @group optiongroup
 */
@mixin valo-optiongroup-horizontal {
  white-space: nowrap;

  .v-radiobutton,
  .v-checkbox {
    display: inline-block;
  }

  &.v-has-width {
    white-space: normal;

    label {
      white-space: nowrap;
    }
  }
}
