Writing away the caliph: Political and religious legitimacy in late medieval Islamic political thought