Change $content_width based on screen size (functions.php)

The nature of $content_width is not to be responsive, there is just nothing you can do to it on wordpress side that will change that. For example it is the width that youtube videos will get when they are embedded and the canculation is done only once and will not be redone again unless you clear the relevant cache.

In general you should avoid any client properties detection on server side (what happens if the window size is changed, something that can happen even on surface and ipad), but if you have a good reason for that, you should filter the content before outputting it to adjust relevant sizes.