Teenage dogs (5 months to 3 years) can be far more interested in the environment than they are in you, even if you have the best food rewards or their favourite toy. This is natural, and it doesn’t mean that your relationship is over, it’s just hormones and the effects of adolescent brain development. Try not to take it personally.

Eventually it will pass.
Unfortunately, those things which they learn and practice during this period might stick.
You might find that your training goes backwards, your puppy who had a perfect recall will suddenly appear to have forgotten what they are called, might seem to be ignoring you on purpose, and to a degree both are true. During this stage the brain is rewiring, your young dog might have forgotten what your recall cue means, or they might be so engaged with the environment that they simply cannot hear you.
Emotional changes during this stage make your teenager more sensitive, you don’t have to be very grumpy with them for them to feel threatened. This is not the time to get angry, you will just make your dog less likely to want to be with you.
So what do you do?
Accept that your dog is not doing any of this to annoy you, I know it’s difficult, all teenagers (including humans) are designed to annoy their parents, this is an adaptive trait for species protection. If the offspring leave and start their own families, there is a reduced risk of mating with your sibling or parent.
Prevent your pup from learning to ignore you. It’s time to go back onto the long line lead.
Never miss a chance to give attention or reward to a dog who is giving attention to you, especially when they are in a distracting environment.
Big up your rewards, make sure you know all your dogs’ favourite things. Now is not the time to be stingy, get the best stuff out when you are out walking, and don’t give them away for easy behaviours at home.
Expect to have to restart training as if your dog has never done it before.