Using IK for walking on stairs

I have animations for walking up and down stairs, but they don’t fit the stairs well.

I want to use IK to adapt the animation, but I don’t know how exactly that works.

I already went through basic tutorials on IK for foot placement, and it works well when the character is just standing on stairs, but not during the animation.

I’m planting the feet on the ground using IK and I move down the whole mesh so the leg on the lower step can always reach the step (and the other leg will bend with IK). but i dont know what sort of formula for lowering the mesh works well. and how you transition for lowering the mesh for one leg to the other while the character is playing the walking animation.

also, when using IK for foot-placement, you have to turn off or lower the alpha value of the IK when the character is taking a step, or it will just slide the feet on the floor the whole time. but how do you do that? i imagine you would add some data to the animation to tell the IK when it should be on. do you use notifications and then interpolate the alpha value to a lower value? all the way to 0 or some other number as the lowest alpha? or do you use a curve added to the animation? (never used that).

it would be ideal to also be able to adapt the length of the steps to the length of the individual steps on the current staircase, but i guess that would be too advanced. but if anyone has any tips or tutorials on that, would love to see that.

edit:

forgot to ask: im currently casting down from the current x/y position of the foot (like in the animation content example 1.8). but i wonder if there’s a way to get the position a bone would have been at if there was no IK applied.