// Radio buttons & checkboxes

// By default, multiple choice inputs stack vertically
.multiple-choice {

  $is-ie: false;

  display: block;
  float: none;
  clear: left;
  position: relative;

  padding: (8px 8px 9px 50px);
  margin-bottom: 8px;

  cursor: pointer; // Encourage clicking on the label

   // remove 300ms pause on mobile
  -ms-touch-action: manipulation;
  touch-action: manipulation;

  @include grid-media($sbc-grid-medium) {
    float: left;
    padding-top: 7px;
    padding-bottom: 7px;
    // width: 25%; - Test : check that text within labels will wrap
  }

  // Absolutely position inputs within label, to allow text to wrap
  input {
    position: absolute;
    cursor: pointer;
    left: 0;
    top: 0;
    width: 38px;
    height: 38px;
    z-index: 1;

    // IE8 doesn’t support pseudoelements, so we don’t want to hide native elements there.
    @if ($is-ie == false) or ($ie-version == 9) {
      margin: 0;
      opacity: 0;
    }
  }

  label {
    cursor: pointer;
  }

  [type=radio] + label::before {
    content: "";
    border: 2px solid;
    background: transparent;
    width: 34px;
    height: 34px;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 100px;
  }

  [type=radio] + label::after {
    content: "";
    border: 10px solid;
    width: 0;
    height: 0;
    position: absolute;
    top: 9px;
    left: 9px;
    border-radius: 100px;
    opacity: 0;
  }

  [type=checkbox] + label::before {
    content: "";
    border: 2px solid;
    background: transparent;
    width: 34px;
    height: 34px;
    position: absolute;
    top: 0;
    left: 0;
  }

  [type=checkbox] + label::after {
    content: "";
    border: solid;
    border-width: 0 0 5px 5px;
    background: transparent;
    width: 17px;
    height: 7px;
    position: absolute;
    top: 10px;
    left: 8px;
    -moz-transform: rotate(-45deg); // Firefox 15 compatibility
    -o-transform: rotate(-45deg); // Opera 12.0 compatibility
    -webkit-transform: rotate(-45deg); // Safari 8 compatibility
    -ms-transform: rotate(-45deg); // IE9 compatibility
    transform: rotate(-45deg);
    opacity: 0;
  }

  // Focused state
  [type=radio]:focus + label::before {
    box-shadow: 0 0 0 4px $focus-colour;
  }

  [type=checkbox]:focus + label::before {
    box-shadow: 0 0 0 3px $focus-colour;
  }

  // Selected state
  input:checked + label::after {
    opacity: 1;
  }

  // Disabled state
  input:disabled + label {
    opacity: 0.5;
  }

  &:last-child,
  &:last-of-type {
    margin-bottom: 0;
  }
}

// To sit multiple choice inputs next to each other, use .inline on parent
.inline .multiple-choice {
  clear: none;

  @include grid-media($sbc-grid-medium) {
    margin-bottom: 0;
    margin-right: $gutter;
  }
}
