Ignoring Invisibility, Elf/Halfling abilities, Blindsight, Darkvision, being in or out of combat, etc., and assuming making ranged attacks on a foe without an adjacent ally, here is how I understand hiding works:
1. You cannot hide from a creature that can see you (PHB 177).
2. A creature cannot see you if you are in a heavily obscured area (i.e., full concealment), which blocks vision entirely (PHB 184), or if you have total cover, which complete conceals the creature (PHB 196).
3. Therefore, you can hide with a successful stealth roll beating your foe's perception (PHB 177) if you are in a heavily obscured area or have total cover.
I think there is no controversy with #1-3 above, but if so, please let me know what specifically is the issue.
4. You cannot attack a foe from behind total cover, so even though hidden, your cannot sneak attack.
5. If you are in a heavily obscured area and make an attack on a foe you cannot see, your attack roll would be at disadvantage (PHB 194), however when you are in a heavily obscured area then your foe cannot see you and you have advantage on attacks against it (PHB 195), but advantage and disadvantage cancel out each other (PHB 173), so you would not have advantage on your ranged attack and cannot sneak attack.
6. If either total cover or heavy obscurement (concealment) is required to be hidden, given the above, then you basically cannot be hidden and make a ranged sneak attack (setting aside the odd case of being in heavy obscurement attacking blindly at a foe who happens to adjacent to an ally).
7. The rules intend for you to be able to be hidden and make a ranged sneak attack, therefore you must be able to remain hidden under circumstances that are something less than total cover or heavy obscurement.
8. Given #6-7 above, you can become hidden under total cover or heavy obscurement and remain hidden so long as you maintain partial cover or light obscurement from your foe and attack from that position, getting sneak attack.
Please let me know which of the foregoing points you agree or disagree with and why with specificity.