first you scan to see if z goes muta (in idra's case he always does anyway)
then build a few at importants places in your base and use marines to defend.
when muta number grows you start making more and more turrets and when you want to push out either leave some marines at home or leave a thor at home.
thankfully mutas are really that good in straight up fights vs marines and thors so when you have your base defended well enough all you need is to force him to engage your main army where you reduce the muta number and then you can focus on doing more drops / tech to counter Z T3 units
ps. of course you can scout if he goes mass muta or not, you have scans and he will keep flying in your base to harass so you'll know if muta number grows. thats why you have marines to defend until you want to push out