You don’t have rights when crossing a border. If you’re not willing to have customs rooting through your data, delete it and restore from backup after you arrive.
The problem is that this also applies within a radius around a “port of entry”. So everybody that lives within about 100 miles of the coast, an airport, or a rail line that crosses a border — which is probably about 80+% of any country.
In the very unlikely instance that happens, fly to the nearest country, make a backup of your phone, factory reset it, then fly back to a different poet of entry
They will detain you. I know the US procedure because i was instructed as i worked there as a representative for an overseas company in Europe.
If you're a national of the US they will detain you and hold you in detention to ask you questions. During this time your phone will either be cloned or confiscated to be decrypted at a later date. You will be released after a few hours. They will likely not bruteforce it, but rather attempt to use security flaws present in your device/firmware. They will do the same to your laptop.
If you're not a national of the US, you will be denied entry and flown back to where you came from. This is common practice in a lot of western countries.
What you should do is not carry sensitive information across borders, by using a cloud service to sync at your destination or use hidden encrypted containers in your device. Unless you're involved in terrorism, white collar crime, CSAM or drugs, they will never have people smart enough to find out hidden containers on you.
Even if my phone is empty, I'm not going to give them a password out of principle. And I'm not saying anything in detention. No questions will be answered.
Again if I really need to get into the country, then I'll try again at a different port of entry. Usually land crossings are easier.