A situation in the past which already happened, and we imagine that it happened in a different way.
The if clause is the cause usually of the consequence.
It rained yesterday and I got wet.
If it hadn’t rained, I wouldn’t have got wet.
If + past perfect +
would / wouldn’t + have + past participle
(instead would we can use other modals)
I lost my key. I couldn’t get in.
If I hadn’t lost my key, I could have got in.
I didn’t eat breakfast. I was hungry.
If I had eaten breakfast, I wouldn’t have been hungry.