With $40,000 to spend, you have lots of excellent options.
The top of the line, current Subaru Forester Limited meets all your requirements quite nicely for about $35K.
Same goes for the 2021 Outback - same drivetrain and many other parts as Forester, but more plush and comfortable. Getting a similarly equipped Outback Limited would cost ~ $2K more than the Forester.
Both Subies are relatively reliable, especially in the 1st 100,000 miles.
Another excellent option that meets your criteria would be the 2021 Hyundai Sante Fe. The Santa Fe is also relatively reliable and its warranty is twice as long as most other cars.
Last but not least, take a look at the 2021 Honda CR-V Hybrid. Still in your price range and reliable and it will use about 20% less gas than the others, even more in city driving! Overall the Honda would be the least expensive to own over 5-10 years.
Happy car shopping and please let us know what you choose.
Disclosure: I have owned one Forester (2004) and two Outbacks - a 2010 and a 2015 which I still have. Very few issues and all were covered by new car warranty.
I too am considering a new car and currently the new Outback, Sante Fe & Honda CR-V are all contenders!