Correct you need energy surplus -calories- (your terms) to build muscle. You cannot build muscle in an energy (caloric) deficit. As has been spewed by these folks previously. Best of luck on your fitness journey 🤙
Discussion
Many here are saying you need to eat a surplus, which isn't true for most people.
Also, I don't think you need to eat enough to gain fat.
Building muscle takes more calories than keeping the same amount which takes more than losing.
If you lift hard, you'll need extra calories to heal that you don't need to stay the same. You can even measure the amount as the after burn effect. You could in theory measure the increased calorie needs after an injury.
If your body is using those calories to improve itself is it really a surplus? If some are turning into fat for sure that is a surplus.
I'm fairly confident that the idea of metabolic rate being fixed is BS. Your body can turn up or turn down the burn. Any 3 or 4 day fast will make you cold because it turned the fire down. If you gained fat you were maxed out and still had too much or the wrong food or some kind of metabolic syndrome.
You have a baseline amount of calories to sustain your current body composition. As you grow larger that baseline amount goes higher. If I was 200lb last year and I'm 210kb this year I have more muscle that require more calories to maintain them.
Again I answered all these things with nostr:npub1ghcetnluhryhynhuyj8s2pazldjm27wl40nu6dfeskvpv09twcnsneygat and nostr:npub1an6xs9jt6apmw45rmvu8pnspewdp6juwcgp76fk72ruky4dmcadqwfze63 questions. You will have to re find them. They had alot of the same misunderstandings as it sounds like you have.
This will probably help you. Very informative. Get your basal and adjust from there.