ESP32 how does OTA work exactly?

Hello. I am learning about the OTA and want to know what really happens in the RAM and Flash memory in order to perform a succesfull remote firmware update (OTA).

So I know that the code program is stored in the flash memory and all the program variables and functions stored in the RAM ( that are declared at run-time) unless they are manually places in the flash memory.

When the OTA process starts, what happens first? Is the new binary first written to the RAM and then transferred to the Flash memory rewriting the old program on the flash?

If I remember correctly, the new image gets transferred to a separate flash partition,
that can can be activated as the booting partition after verification.

Does that mean that I must ensure that I have enough space allocated in the seperate flash partition? For example if my .bin file is 1MB, I must ensure that I have an OTA partition > 1MB?

What happens in the meantime with the old program? Does it get deleted and replaced with the new code after OTA?

tons of info here: OTA Updates — ESP8266 Arduino Core 3.0.2-1-g929f0fb6 documentation

Obviously.

Nothing until the new program is correctly stored.