How does ATP synthase produce ATP?

Flexi Says:
The energy held within the proton gradient can be used to synthesize ATP. ATP synthase is a transmembrane enzyme that provides energy for the cell to use by producing ATP. The protein has two distinct regions, F0 and F1. The F0 domain is embedded within the membrane, while the F1 domain is above the membrane, inside the matrix of the mitochondria, or the stroma of the chloroplast. The F0 region is the proton pore, allowing hydrogen ions to diffuse across the membrane. The F1 region of the protein has ATP synthesis activity, catalyzing the formation of ATP from ADP and inorganic phosphate. Hence, ATP synthase is both an ion channel protein and enzyme. The synthesis reaction is driven by the proton flow, which forces the rotation of a part of the enzyme; the ATP synthase is a rotary mechanical motor. Bacteria may also have a version of this enzyme, where it, of course, is embedded in the cell membrane.