Real-time gravitational-wave science with neural posterior estimation