Design and characterization of a monolithic CMOS phase-sensitive pixel based on an avalanche photodiode