Catalonia’s separatist parties are in danger of losing their hold on power in the northeastern region after the pro-union Socialist Party scored a historic result in Sunday’s election.