// Text Inputs & Textarea
//
//  - Keep it simple - not all browsers correctly expose multiple labels that are linked to the same form element.
//  - Use labels for every input and make the `for=""` and `id=""` values match. IDs must be unique on each page, only one label can be associated to each unique form element.
//  - Make required fields obvious by using an indicator - border color change, asterisk, description text, etc.
//  - Fields with error validation should have `aria-describedby` to insure that the associated field level error message is read by assistive technology. If the error message has an `id="my-error-message"`, then the input should have `aria-describedby="my-error-message"`.
//
// <section data-action="aria-toggle" class="atblock"><h3 class="atblock__title"><a href="#text_guide">WCAG 2.1 Guidelines</a></h3><div id="text_guide" class="atblock__panel guidelines"><p><a href="https://www.w3.org/WAI/WCAG21/quickref/#text-equiv-all" target="_blank">1.1.1 Non-text Content</a> - All non-text content that is presented to the user has a text alternative that serves the equivalent purpose. (Level A)<br><br><a href="https://www.w3.org/WAI/WCAG21/quickref/#qr-content-structure-separation-programmatic" target="_blank">1.3.1 Info and Relationships</a> - Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. (Level A)<br><br><a href="https://www.w3.org/WAI/WCAG21/quickref/#qr-navigation-mechanisms-descriptive" target="_blank">2.4.6 Headings and Labels</a> - Headings and labels describe topic or purpose. (Level AA)<br><br><a href="https://www.w3.org/WAI/WCAG21/quickref/#qr-minimize-error-cues" target="_blank">3.3.2 Labels or Instructions</a> - Labels or instructions are provided when content requires user input. (Level A)<br><br><a href="https://www.w3.org/WAI/WCAG21/quickref/#qr-ensure-compat-rsv" target="_blank">4.1.2 Name, Role, Value</a> - For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. (Level A)</p></div><div class="markup"></div></section>
//
//
//
// Markup: text-fields.twig
//
// Style guide: Forms.text-fields

// Import site utilities.
@import '../../global/utils/init';

[type='text'],
textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem;
  margin: 8px -2px 20px;
  box-sizing: border-box;
  border-radius: $border-rd-sm;
  border: 2px solid $color-gallery;
  font-size: $padding-sm;
  min-height: 49px;
}

input,
textarea {

  &[aria-invalid] {
    outline-width: 5px;

    & + span {
      display: block;
      font-weight: $font-weight-bold;
      margin: -15px 0 20px;
    }
  }

  &[aria-invalid='true'] {
    border-color: $notification-color-error;

    &:focus {
      outline-color: $notification-color-error;
    }

    & + span {
      color: $color-cherry;
    }
  }

  &[aria-invalid='false'] {
    border-color: $notification-color-success;

    &:focus {
      outline-color: $notification-color-success;
    }

    & + span {
      color: $notification-color-success;
    }
  }
}

textarea {
  min-height: $padding-xxl;
}

fieldset {
  padding: 1.75rem 1.5rem;
  border: 2px solid $color-gallery;
  border-radius: $border-rd-sm;
}

legend {
  font-weight: bold;
}

.required-field {

  &::after {
    content: '*';
    color: $color-cherry;
    display: inline-block;
  }
}
