Resize APFS (encrypted) container

Simply resizing Files (disk0s3) and then expanding the container (disk0s2) while "shifting" disk0s3 won't work.

You have to take this path:

  1. Resize disk0s3 with diskutil:

    diskutil resizeVolume disk0s3 40g
    
  2. Create a fourth partition Files2 (HFS+) with Disk Utility at the end of the disk
  3. Copy all files from Files to Files2
  4. Remove disk0s3 (Files) with Disk Utility
  5. Rename Files2 to Files
  6. Expand disk0s2 (if not already done automatically in step 4):

    diskutil ap resizeContainer disk0s2 0