Field-line resonances in a time-varying magnetosphere