/**
 * @file
 * Form
 *
 * Contains styles for forms in main content region.
 */
.main .form {
  margin: 2rem 0;

  .description {
    margin: 0 0 2rem;
  }

  &__item {
    margin-bottom: 2rem;

    &.form--select {
      position: relative;
      display: inline-block;
      min-width: 280px;

      &:before {
        content: "";
        position: absolute;
        width: 9px;
        height: 9px;
        bottom: 18px;
        right: 15px;
        border-right: 3px solid;
        border-bottom: 3px solid;
        transform: rotate(45deg);

        @media (min-width: $break-large) {
          bottom: 20px;
        }
      }
    }

    input,
    textarea {
      &:not(
          [type="submit"],
          [type="checkbox"],
          [type="radio"],
          [type=button],
          [type=reset]
        ) {
        color: $color-black;
        background: transparent;
        -webkit-appearance: none;
        border-radius: .25rem;
        width: 100%;
        padding: .5rem .75rem;
        border: 1px solid $color-blue-dark;
        line-height: 1.52;
      }
    }

    select {
      width: 100%;
      color: black;
      border: 1px solid $color-blue-dark;
      border-radius: .25rem;
      padding: .5rem 2.625rem .5rem .75rem;
      background-color: $color-white;
      line-height: 1.52;
    }

    textarea {
      width: 100%;
      display: block;
      padding: .5rem .75rem;
      min-height: 6.25rem;
      border-radius: .25rem;
      border: 1px solid $color-blue-dark;
      &:focus {
        outline: 2px solid $color-black;
        outline-offset: 2px;
      }
    }

    @media (min-width: $break-medium) {
      input {
        max-width: 17.5rem;
      }

      select {
        max-width: 17.5rem;
      }

      textarea {
        max-width: 31.25rem;
      }
    }

    @media (min-width: $break-large) {
      textarea {
        min-height: 7.5rem;
        width: 100%;
        max-width: 39.688rem;
      }
    }
  }

  &__item:not(.form--fieldset) {
    label {
      display: block;
      font-weight: 700;
      margin-bottom: 0.5rem;
    }
  }

  fieldset {
    border: none;
    padding: 0;
    margin: 0 0 1.625rem;

    legend {
      margin-bottom: .5rem;
      font-weight: 700;
    }
  }

  button,
  input,
  a,
  select,
  textarea  {
    &:focus {
      @include focus-dark();
    }
  }

  input {
    &:focus {
      outline: 2px solid $color-black;
      outline-offset: 2px;
    }
    &.cta--button-submit {
      border: none;
      border-radius: .5rem;
      padding: 0.688rem 0.75rem;

      @media (min-width: $break-medium) {
        padding: 1rem 1.5rem;
      }

      @media (min-width: $break-large) {
        padding: 1rem 2rem;
        @include fontsize(32px);
        line-height: 2rem;
      }
    }
  }

  .form__checkbox,
  .form__radio {

    label {
      position: relative;
      padding-left: 1.5rem;

      &:before,
      &:after {
        content: '';
        position: absolute;
      }

      &:before {
        top: 0.1rem;
        left: -0.4rem;
        width: 1rem;
        height: 1rem;
        border: 2px solid $color-green-dark;
        border-radius: 0.25rem;
        background-color: $color-white;
      }

      &:after {
        top: 0.5rem;
        left: -1px;
        width: 0.5rem;
        height: 0.2rem;
        border-left: 2px solid $color-white;
        border-bottom: 2px solid $color-white;
        transform: rotate(-45deg);
        opacity: 0;
      }

      @media (min-width: $break-large) {
        padding-left: 1.75rem;
        &:before {
          top: 0.1rem;
          left: -0.4rem;
          width: 1.25rem;
          height: 1.25rem;
        }
        &:after {
          top: 0.5rem;
          left: -1px;
          width: 0.7rem;
          height: 0.35rem;
        }
      }

      input[aria-invalid="true"] + label {
        &:before {
          border: 2px solid $color-input-error;
        }
      }
    }

    input[aria-invalid="true"] + label {
      &:before {
        border: 2px solid $color-input-error;
      }
    }

    input:checked + label {
      &:before {
        background: $color-green-dark;
      }

      &:after {
        opacity: 1;
      }
    }

    input:focus {
      outline: 0;
    }

    input:focus + label:before {
      outline: 2px solid;
      outline-offset: 4px;
      transition: none;
      @include focus-dark();
    }

    input {
      opacity: 0;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: 0;
    }
  }

  .form__checkbox {
    margin: .5rem 0 .5rem .1rem;
  }

  .form__radio {
    margin: .5rem 0 .4rem .1rem;
    input {
      opacity: 0;
      width: 1px;
      height: 1px;
      padding: 0;
    }

    label {

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

      &:after {
        color: $color-white;
        top: 9px;
        left: -0.5px;
        width: 8px;
        height: 8px;
        border: none;
        border-radius: 100%;
        opacity: 0;
        background-color: $color-white;
      }

      @media (min-width: $break-large) {
        &:after {
          left: 1.5px;
        }
      }
    }

    input:checked + label {
      &:before {
        width: 0;
        height: 0;
        border: 0.65rem solid $color-green-dark;
        background-color: transparent;

        @media (min-width: $break-large) {
          border: 0.75rem solid $color-green-dark;
        }
      }

      &:after {
        opacity: 1;
      }
    }
  }

  @media (min-width: $break-large) {
    margin: 2.55rem 0;
  }
}