A molecular switch modulates assembly and host factor binding of the HIV-1 capsid