One attribute does all the work: aria-expanded. The script flips it, and the CSS reads it to morph the icon: the middle bar fades, and the top and bottom bars move to the center and rotate ±45° into an X. Screen readers hear "Menu, collapsed" or "expanded" from the same attribute, so the visuals and the announcement can never disagree.
The visible text changes from "Menu" to "Close" too, so the button is labelled for sighted keyboard users. Escape closes the menu and puts focus back on the button, and clicking outside closes it.
With reduced motion on, the icon still morphs, just faster, and the menu appears without sliding.