How bootstrap capacitor voltage is added to source voltage?
This is a little bit of a simplification. When the switch is open (ignoring your load resistor) the voltage from drain to source on Q1 is 12V, the voltage at the source is more or less 0. Now say you close that opto coupler. Q1 requires very little current to turn on (only enough to charge gate capacitance) so that cap is going to stay pretty full, AKA it has 12V on it still. When the switch is closed though, that source node is now at 12Vish. Since the cap is still charged, and there is 12V at it's "low" side, the cap is now sitting at 24V wrt ground.