Unravelling the demographic dynamics of ethnic residential segregation