Let \( S = \{\theta \in [0, 2\pi): \tan(\pi \cos \theta) + \tan(\pi \sin \theta) = 0\} \). Then \( \displaystyle \sum_{\theta \in S} \sin^{2}\!\left(\theta + \frac{\pi}{4}\right) \) is equal to __________.