Synology Drive has all the features you want and with desktop (macOS, windows, Ubuntu) and mobile clients (iOS and Android). The potential downside is that you have to buy a Synology NAS to run it. I’ve had one for a number of years and I’m still very happy with it.
I also really like Resilio Sync. The downside there is that while the mobile client supports selective sync (you choose which files and folders to always have on-device) only the paid “pro” version of the desktop client supports it.
For Resilio Sync mobile it is both on-the-fly and a configuration. You can mark individual files and folders as ones that always needs to be synced at all times and available for offline use. For files that are not synced already, simply tapping them will download it. I’m not sure how it behaves on Desktop since I don’t have the Pro version with selective sync.
Synology Drive is pretty much the same as far as being able to mark things for offline use, but the OS integration is nice because all un-synced files and folders still appear in the filesystem, and opening any files will magically sync them if needed.
I would hope Resilio Sync Pro desktop has the same OS-level integration, but I couldn’t say for sure.
Update: For both systems, selecting which content is always synced is a per-device configuration. For example, If you want different files always available on your phone vs your tablet, you just mark those files however you wish using the app on each device.