Every conditional is two halves: the *if half (the condition) and the result half. What changes between them is how likely you think it is* — the further from reality, the further back the verb goes in time.
That's the trick worth internalising: English signals unreality by moving the tense backwards. A past tense in an if sentence usually isn't about the past at all — it's about distance from the truth.
Comma rule
If the if half comes first, put a comma: If it rains, I'll stay home. If it comes second, don't: I'll stay home if it rains. Same sentence either way.
For the one you'll use most in daily life, see the deep dive on the first conditional.