A thermodynamically motivated implicit gradient damage framework and its application to brick masonry cracking