a basic but important grammar question

my question is basically about commas. what i don’t understand is when what’s written after the comma describes the whole idae of the sentence before or just the last word.

i hate to run,making it hard for me to stay in shape

does the “making” describes the “run” or the whole sentence?

i hate to run,which makes it hard for me to stay in shape

here it describes the sentence or the “run”?

thanks in advance for the helpers

the stuff after the comma describes the part before the comma.

e.g. If you get bad grades, then you aren’t performing well in school.

the way to check is if you flip it around and add minor adjustments but the sentence still makes sense (it won’t always be grammatically correct though because of dangling modifiers)

It’s hard for me to stay in shape because I hate to run

I don’t perform well in school so I get bad grades

At least that’s how I learned it.

what i didn’t understand specifically is when is describes the last ward of the sentence and when it describes the whole sentence.

sometimes when i ger a wrong answer it’s because the which doesn’t describe the sentence as whole but only the last word.

thank u for your help