Follow the Path, but is it valid? Follow the Path

I got directions to my friend's house, but it looks like his map might have some mistakes. He's expecting me soon, so I need some short code to figure out if I can get there.

The Challenge

The code should, when given an ASCII representation of a path as input, traverse from the start to the end, and output depending on whether there is a valid path.

Input

Input is an ASCII representation of a map. It will use only the following symbols:

Character = Meaning
(space) = Blocked area
| = Vertical Path
- = Horizontal Path
+ = Intersection
^ or v = Horizontal Bridge
&lt; or &gt; = Vertical Bridge
$ = Start Location
# = End Location


Traversal Rules


Execution always starts on $ and will end when all paths are blocked, an infinite loop, or the pointer hits #. It is guaranteed that input will have exactly 1 of each.
The pointer starts moving to the right and down.
Vertical paths will only connect to vertical paths, vertical bridges, or intersections.
Horizontal paths will only connect to horizontal paths, horizontal bridges, or intersections.
If a vertical and horizontal path meet at a non-bridge, it is considered blocked at that point.
Bridges function according to the following:


 |      |
-^- OR -v- = Horizontal path going over a vertical path
 |      |

 |      |
-&lt;- OR -&gt;- = Vertical path going over a horizontal path
 |      |



When the pointer hits an intersection, movement precedence is in the clockwise direction (up, right, down, left). The pointer will not go back the way it came.
The program must detect/calculate infinite loops and branching paths from +.


Output

The length of the path, or -1, according to the following conditions:


If the program reaches #, output the path length.
If the program detects only blocked paths, return -1.
If the program detects an infinite loop, return -1.


Scoring

This is code-golf, so the shortest code in bytes wins! Standard loopholes are forbidden.

Test Cases

   $
   | 
 +-|
#+-+
= 6 (going north at `#+-` will lead to a blocked path, but going to the west is a valid path)

#-+-+
  | |
$-^-+
  +-+
= -1 (Will infinitely loop)

$#
= 1

#^^^^+
     &gt;
$----^-+
     &gt; +
     +-+
= 20

$------+
|-----+|
 --#--+|
+--+---+
+------+
= 23

$ #
= -1 (Blocked by the space)

$|#
= -1 (Can't go onto a vertical path from the sides)

$
-
#
= -1 (Can't go onto a horizontal path from the top or bottom)

$|#
|--|
++++
= -1 (No valid paths exist)
JavaScript (ES6), 219 bytes
Takes input as a list of lists of characters.
a=&gt;((g=(X,Y,D,n=o=0)=&gt;!(a+0)[n++]|a.some((r,y)=&gt;r.some((c,x)=&gt;D=='975'[i='-| #+$'.indexOf(c),x-X+1]-'450'[y-Y+1]?i-3?i-2?i&gt;3?[3,0,7,4].some(d=&gt;D^d^4&amp;&amp;g(x,y,d,n)):~i&amp;&amp;i^D&amp;1?0:g(x,y,D,n):0:o=-n:X+1|i&lt;5?0:g(x,y,2))))(),~o)

Try it online!
How?
Because they need to be tried in a specific order, the way the directions are handled in this code is a bit unusual.
Given a direction \$D\$ and the source coordinates \$(X,Y)\$, we want to figure out which target coordinates \$(x,y)\$ correspond to a move by one square along \$D\$.
We use the following test for each candidate pair \$(x,y)\$:
D == '975'[x - X + 1] - '450'[y - Y + 1]

This test always fails if \$|x-X|&gt;1\$ or \$|y-Y|&gt;1\$ because we get an undefined value from at least one of the 2 lookup strings.
Otherwise, we have the following table:
$$\begin{array}{r|c|ccc}
&amp;x-X&amp;-1&amp;0&amp;+1\\
\hline
y-Y&amp;&amp;9&amp;7&amp;5\\
\hline
-1&amp;-4&amp;5&amp;3&amp;1\\
0&amp;-5&amp;4&amp;2&amp;0\\
+1&amp;-0&amp;9&amp;7&amp;5
\end{array}$$
Because diagonal moves are not used, our final compass looks as follows:
$$\begin{array}{cccc}
&amp;&amp;3\\
&amp;&amp;↑\\
4&amp;←&amp;2&amp;→&amp;0\\
&amp;&amp;↓\\
&amp;&amp;7
\end{array}$$
The lookup values were chosen in such a way that we end up with some handy properties:

Opposite directions can be detected by testing if \$d\operatorname{xor}d'=4\$. Hence the code to try all directions in clockwise order except the one that would make us going back the way we came:
    [3, 0, 7, 4].some(d =&gt; D ^ d ^ 4 &amp;&amp; g(x, y, d, n))


Vertical moves are connected to odd values.

Horizontal moves are connected to even values (except direction \$2\$, for no move at all, which is only used at the beginning of the process when the starting point has been identified).