/// Shared declaration for avatar rounding proportions
@mixin round-avatar {
  @include round-image(item-spacing(7));
}

.avatar-container {
  display: flex;
  justify-content: flex-start;
  padding: item-spacing(3 0);

  /// --rtl modifier allows avatars to be animated from right-to-left
  /// avatar-container element should ideally be positioned against the right edge of it's container
  &--rtl {
    justify-content: flex-end;

    &:hover {
      .avatar-item--stacked {
        margin-left: item-spacing(7) / 2;
        transition-duration: 167ms;
        transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
        transition-delay: 0s;
      }
    }
  }

  &:hover {
    .avatar-item--stacked {
      margin-right: item-spacing(7) / 2;
      transition-duration: 167ms;
      transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
      transition-delay: 0s;
    }
  }

  &__list {
    list-style-type: none;
    padding: 0;
    margin: 0;
  }
}

.avatar-item {
  @include round-avatar;
  display: inline-block;
  background-color: get-color(silver3);

  &--stacked {
    transition-duration: 167ms;
    transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
    transition-delay: 0s;
    position: relative;

    &:nth-of-type(1n + 2) {
      margin-left: -(item-spacing(7) / 2);
    }

    &__meta {
      position: absolute;
      right: 0;
      opacity: 0;
      z-index: z(dropdown);
    }

    &:hover {
      .avatar-item--stacked__meta {
        transition-duration: 167ms;
        transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
        transition-delay: 0s;
        opacity: 1;
      }
    }
  }

  &__trigger {
    outline: none;
  }
}

.avatar {
  @include round-avatar;
  box-sizing: border-box;
  background-clip: content-box;
  border: 2px solid transparent;
  background-color: get-color(silver3);

  &--stacked {
    border: 2px solid white;
    transition-duration: 167ms;
    transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
    transition-delay: 0s;

    &:nth-of-type(1n + 2) {
      margin-left: -(item-spacing(7) / 2);
    }
  }

  &--focused {
    border-color: get-color(blue5);
  }
}

.avatar-rollup {
  @include round-avatar;
  box-sizing: border-box;
  background-clip: content-box;
  border: 1px solid get-color(black, 0.5);
  font-weight: 400;
  color: get-color(black, 0.5);
  font-size: 15px;
  display: inline-block;
  background: white;
  text-align: center;
  z-index: 2;
  line-height: item-spacing(7);
  cursor: pointer;
}

.avatar-meta-action {
  background-color: transparent;
  border: 0;
  border-radius: 2px;
  box-sizing: border-box;
  color: get-color(black, 0.7);
  cursor: pointer;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: item-spacing(0 2);
  display: block;
  text-decoration: none;
  vertical-align: middle;

  &:hover {
    background-color: get-color(black, 0.05);
    transition-duration: 167ms;
    transition-property: background-color, box-shadow, color;
    transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

.avatar-metadata {
  max-width: item-spacing(7) * 2;
}
