Mechanism of action of phosphorus-based flame retardants in nylon 6. I. Ammonium polyphosphate