Brazil court trims Lula sentence, opening door to partial detention