Mohammad Nabi took three wickets in an over for Afghanistan to spark a Sri Lankan batting collapse in their World Cup clash in Cardiff.