Gordy details, but the image helps see:
https://photographylife.com/how-phase-detection-autofocus-wo...
On camera sensor focusing was slightly different “contrast detection”. My understanding is modern cameras integrate those phase detection sensors on the image sensor itself. It might effect image quality but nobody notices and focus is fast and reliable. It’s tech that works well so generally nobody cares how it works.
https://www.usa.canon.com/learning/training-articles/trainin...
Recent sensors have AF phase-detect sensors built into the image sensor, by splitting one "pixel" into two sensors (and having lots of them; sometimes in Canon sensors more than half of the pixels have this functionality; on some cameras you can extract the raw image including the different data on those pixels for bigger resolution). The difference between phase detect and contrast being that a phase-detect sensor will give exact values on how to adjust the focus, whilst contrast detection needs focus hunting in small adjustments, so it's slower.