Elucidating the evolutionary origins of collective animal behavior