There’s a lot of misconceptions about fat loss and muscle gain in the fitness industry. The biggest of which is that, losing fat and building muscle require two polar opposite approaches. This is wrong and in reality, the only major difference between the two is the amount of energy (Calories) you consume
In terms of weight loss, being in a negative energy balance (calorie deficit) is necessary and vice versa for weight gain (Romieu et al., 2017). Whether you're trying to lose or gain weight it's important to track both your kcals and your protein. Research suggests 1.6g/kg of bodyweight (Morton et al., 2017) is ideal, with higher amounts of 2.3-3.1g/kg of Lean Body Mass needed as you get deeper into a weight loss phase (Helms et al., 2012)
As well as this, whether you are trying to lose or gain weight, progressive overload should be the goal. Although hypertrophy is FAR from optimal in a deficit, it can still happen (Garthe et al., 2011) and so training to maintain and build strength and muscle should be a priority no matter your goals.
It’s quite important to note that cardio is NOT needed to lose fat, sure it can help and is a great way of increasing a deficit, but it is in no way necessary. Finally, it should be noted that recovery is vital for optimal hypertrophy; take your rest days and get some adequate sleep