/**
 * Field Taxonomy Reference (Entity Reference as tags).
 ============================================================================ */

// Adaptivetheme sets entity reference type classes, e.g. taxonomy-term, node or
// user depending on the reference entity type.
.field-entity-reference-type-taxonomy-term {

  // Items inline.
  @if ($field-taxonomy-items-inline == true) {
    .field__item {
      @include output-rhythm(margin, 0 $xxx-small 0);
      display: inline-block;
    }

    &.field-label-above .field__item:first-child {
      margin-#{$flow-from}: 0;
    }

    // RTL
    [dir="rtl"] & li {
      @include output-rhythm(margin, 0 0 0 $small);
    }
  }

  // Comma separated.
  @if ($field-taxonomy-items-comma-separated == true) {
    .field__item-wrapper {
      &:after {
        content: ",";
        display: inline-block;
      }
    }

    .field__item:last-child {
      .field__item-wrapper:after {
        content: "";
        display: none;
      }
    }
  }

  // Label icon.
  @if $field-taxonomy-label-as-icon == true {
    .field__label {
      &:before {
        font-family: $icon-font;
        content: $field-taxonomy-label-icon;
        @include output-rhythm(margin, 0 $xx-small 0 0);

        // Wait for FontAwesome to load.
        display: none;
        .fa-loaded & {
          display: inline-block;
        }

        // In left-to-right flip the icon.
        [dir="ltr"] & {
          @include fa-icon-flip(-1, 1, 0);
        }
      }
    }
  }

  // As labels.
  @if ($field-taxonomy-item-as-labels == true) {
    .field__item {
      margin: 0;
    }

    .field__item-wrapper {
      display: inline-block;
      margin: 0 $xxxx-small $xxxx-small 0; // LTR
      border: $border-width $border-style;
      border-radius: $border-radius;
      @include output-rhythm(padding, 0 $xx-small);

      &:hover,
      &:focus {}

      a {
        display: inline-block;

        &:hover,
        &:focus {
          text-decoration: none;
        }
      }

      // RTL
      [dir="rtl"] & {
        margin: 0 0 $xxxx-small $xxxx-small;
      }
    }
  }

  // Item icons.
  @if ($field-taxonomy-item-icons == true) {
    .field__item-wrapper {
      display: inline-block;

      &:before {
        font-family: $icon-font;
        content: $field-taxonomy-item-icon;
        @include output-rhythm(font-size, $small);
        @include output-rhythm(margin, 0 $xxx-small 0 0); // LTR
        vertical-align: text-bottom;

        // Wait for FontAwesome to load.
        display: none;
        .fa-loaded & {
          display: inline-block;
        }

        // In left-to-right flip the icon.
        [dir="ltr"] & {
          @include fa-icon-flip(-1, 1, 0);
        }

        // RTL
        [dir="rtl"] & {
          @include output-rhythm(margin, 0 0 0 $xxx-small);
        }
      }
    }
  }

  .field__items {
    padding: 0;
  }

  .field__item {
    padding: 0;
  }

  &.field-label-above {
    .field__label {}
    .field__item {}
  }

  &.field-label-inline {
    .field__label,
    .field__item {}
  }

  &.field-label-hidden,
  &.field-label-visually_hidden {
    .field__label {}
    .field__item {}
  }

  // Adaptivetheme sets entity reference classes for the formatter.
  &.field-formatter-entity-reference-entity-id,
  &.field-formatter-entity-reference-label {

    &.field-label-above {}
    &.field-label-inline {}
    &.field-label-hidden {}
    &.field-label-visually_hidden {}

    .field__label {}
    .field__item {}
  }
}

