I suggest not over thinking things. There are a few simple truths. To lose fat (weight) we must have a deficit in calories over what our baseline is. To gain weight (muscle) you must have an excess of calories.
They key is to train hard so your body must use the extra calories for repair and growth instead of simply storing the calories in the form of fat. The adjustment you make should be very small. 500 calories a day spaced out over 5 meals in only 100 calories a meal.
Now, I suggest simply using the visual method to determine progress. Add a slight amount of calories to each meal and train with both cardio and strength training. Watch yourself. If you are gaining muscle mass, continue on the approach for as long as you see progress. If you are not gaining muscle, bump it up slightly. If you see too much fat, cut it back slightly or up your training a bit.
Train smart, but keep it simple!