Psychology of animal groups: when and how collective intelligence emerges from individual cognition"