Nit: time difference, phase difference, amplitude difference, and head related transfer function (HRTF) all are involved. Different methods for different frequency localisation.
There's this excellent (German?) for website that lets you play around and understand these via demos. I’ll see if I can find it.
Edit: found it, it’s https://www.audiocheck.net/audiotests_stereophonicsound.php