High quality factor phase gradient metasurfaces for nonlinear and reconfigurable nanophotonics