Thermodynamics of nonlocal electromagnetism and superconductivity