gl_FragCoord and glViewport
since that is the case for window-space coordinates in the vertex stage.

There are no &quot;window-space coordinates in the vertex stage&quot;. Or at least, not in the vertex shader.
Window-space is not relative to the viewport; it's relative to the window (or framebuffer, in this case). The viewport transform is used to convert from NDC-coordinates (which are relative to the viewport) to window coordinates (which are not).
If you need your fragment shader to have viewport-relative coordinates, then you need to either compute them in the fragment shader (by providing the viewport as a uniform) or pass NDC coordinates from the vertex shader as an in/out variable pair (just compute gl_Position.xy/gl_Position.w).