Reptiles were trapped in equatorial rainforests' fragments following global warming 300 million years ago, leading to an explosion in diversity. Steve Mirsky reports