The role of collective action for the emergence and consolidation of democracy