An encounter-based approach for restricted diffusion with a gradient drift