Creating linear color gradient animations for the active window

I have defined a color gradient for the border of both my active and inactive windows and I want an animation over this gradient, but only for the currently active window. I got the animation to play, the problem is, that its playing for all windows (including the inactive ones). Another problem I have is, that for some reason the animation also only works on certain windows. As example the border of my terminal does not get animated, execpt when I switch to the window, then the animation plays once and stops then. Is there any way I can change this? The corresponding code in my config looks like this:

 col = {
            active_border   = { colors = {"#5BCEFA", "#FFFFFF", "#F5A9B8" }, angle = 45},
            inactive_border = { colors = {"#1272ac", "#ecc5e5"}, angle = 45 },
        },
-- Animate the moving color gradient around the current active window
hl.curve("active-window-border", { type = "bezier", points = { {0.2, 0.0}, {0.1, 0.3} } })
hl.animation({ leaf = "borderangle",   enabled = true,  speed = 80,   bezier = "active-window-border", style = "loop" })