The first animals to copulate were small fish that lived 385 million years ago in what is now Scotland, a study suggests.