Palaeoenvironmental trends in the history of trace fossils