/*------------------------------------*\
  $FORMS
\*------------------------------------*/

$input-padding: 10px;
$input-border-color: #ddd;
$input-text-color: $mid-grey;
$input-text-size: 14;

.mce-tinymce {
  max-width: 800px !important;
}

form {
  position: relative;
}

.page-url {
  @include mq(mq1200) {
    position: absolute;
    top: 10px;
    right: 0;
  }
}

fieldset {
  border: 0;

  .no-js & {
    border: {
      bottom: 2px solid #E6E6E6;
    }
  }

  &[data-state="hidden"] {
    display: none;
  }

  &[data-state="visible"] {
    display: block;
  }
}

legend {
  margin-bottom: 20px;
  color: $dark-grey;
  font: {
    size: font-size(18);
    weight: bold;
  }
}

label {
  display: block;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: font-size(16);
  max-width: 600px;
}

label + p {
  margin: {
    top: 10px;
  }
}

input {
  display: block;
}

/**
 * 1. Remove the default browser styling from elements
 */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="url"],
input[type="password"],
input[type="file"],
input[type="datetime-local"],
select,
textarea {
  padding: $input-padding;
  width: 100%;
  font: {
    family: $body-font;
    size: font-size($input-text-size);
  }
  color: $input-text-color;
  background-color: #fff;
  border: 1px solid $input-border-color;
  border-radius: 6px;
  -webkit-appearance: none; /* 1 */
  -moz-appearance: none; /* 1 */
  font-size: font-size(16);
  max-width: 600px;

  &::-ms-expand {
    display: none;
  }

  &.error {
    border-color: mix(#d9534f, $white, 35%);
  }
}

meter,
progress,
input[type="range"] {
  width: 100%;
}

input[type="number"] {
  width: 25%;

  @include mq(mq600) {
    width: 12.5%;
  }
}

select {
  @include mq(mq600) {
    width: 50%;

    @include mq(mq600) {
      width: 25%;
    }
  }
}

/**
 * It should be clear that the textarea allows
 * for longer prose, the default is a little too small
 */
textarea {
  height: 150px;
}

/**
 * Add an arrow to the select menu since we removed
 * the default one with `appearance: none;`
 */
select {
  @include svg-background('select-arrow-down');
  background-repeat: no-repeat;
  background-position: right $input-padding center;

  padding: {
    right: 35px;
  }
}

/**
 * Give checkboxes and radio buttons
 * some breathing space next to labels
 */
input[type="radio"],
input[type="checkbox"] {
  margin-right: 5px;
  display: inline-block;
}

/**
 * 1. Remove the default browser styling from elements
 * 2. Fixed an issue where [type="submit"] gets an
 *    additional 2px padding in Firefox.
 */
input[type="submit"],
button {
  -webkit-appearance: none; /* 1 */
  -moz-appearance: none; /* 1 */

  &::-moz-focus-inner,
  &::-moz-focus-inner {
    border: 0; /* 2 */
    padding: 0; /* 2 */
  }
}


/**
 * `.field` should wrap a label and input
 */
.field {
  margin-bottom: $base-spacing-unit;

  p { margin-bottom: 0; }
}


/**
 * `.field--choice` contains either
 * radio buttons or checkboxes
 */
.field--choice {
  label:last-child {
    margin-bottom: 0;
  }
}


/**
 * `.field--error` modifies the defaults
 * only when the input errors
 */
.field--error {
  input,
  textarea {
    color: mix($error-color, black, 40%);
    background-color: $error-color;
    border: 1px solid darken($error-color, 50%);
  }
}



.notice {
  display: block;
  padding: 20px;
  margin: {
    bottom: 20px;
  }
  border-radius: 6px;
  color: $white;

  @include mq(mq600) {
    padding: 25px;
    margin: {
      bottom: 25px;
    }
  }

  @include mq(mq960) {
    padding: 30px;
    margin: {
      bottom: 30px;
    }
  }

  &.success {
    background: #5cb85c;;
  }

  &.alert {
    background: #d9534f;
  }

  p {
    font-weight: bold;
    margin: 0;
  }
}

#error_explanation,
.message-box--error {
  background: mix(#d9534f, $white, 10%);
  color: #d9534f;
  padding: 20px 20px 0;
  margin: {
    bottom: 20px;
  }
  overflow: hidden;
  border-radius: 6px;

  @include mq(mq600) {
    padding: 25px 25px 5px;
    margin: {
      bottom: 25px;
    }
  }

  @include mq(mq960) {
    padding: 30px 30px 10px;
    margin: {
      bottom: 30px;
    }
  }

  p {
    font-weight: bold;
  }

  ul {
    margin: {
      bottom: 20px;
    }
  }
}

.message-text {
  font-weight: bold;
  margin: {
    top: 10px;
  }

  &--error {
    color: #d9534f;
  }
}
