Mechanistic investigation of a flame retardant coating made by layer-by-layer assembly