However, at one point, it goes:
C#m, A7, A13, D/F#, Ddim.
Can anyone help me understand what is going on here?
The A7 seems to be functioning as a tritone substitute for D#7 which would pull to the G#7 dominant of the C#m key.
Try playing these variations:
C#m A7 G#7 C#m
C#m D#7 G#7 C#m
C#m A#o7 G#7 C#m
A7, D#7 and A#o7 all share the G-C# tritone. Approaching the dominant of a minor key with a diminished harmony (the third example) is common in classical music.
But in this tune, it never completes toward the G#. Instead we are given a signal that it's going in a different direction: the harmony lingers on A, following A7 with A13, perhaps to help shake off our memory of A7's remote connection to C#m, and that dominant becomes a pivot to go to D instead.
It doesn't really matter whether it is a major or minor D at that point; the A13 could go to either.
Why the D works is that it provides a path back to the C#m key again.
What is possibly going on here is that the D functions as a subdominant of
G#m A, whose relative minor key is F#m. This D subdominant of A functions with respect to F#m similarly to how F is related to Am in the key of C.[2014-2-19 edit] The diminished chord then works as a substitute for C#7 or E7, the dominants of F#m and its relative major A, respectively. It shares three notes with both of these.
D Ddim C#m F#m (like F Fdim Em Am in C major! Notes of Fdim are in the Phrygian mode of A harmonic/melodic minor)
D E7 C#m F#m (like F G7 Em Am)
D C#7 C#m F#m (like F E7 Em Am)
But we don't have a F#m. It is C# that is targeted, seemingly as the root of the Phrygian mode of F#m/AMaj. So D is actually IIb: something like the Phrygian II or Neapolitan.
Compare to the very bold Neapolitan cadence (IIb-V-I).
- D G# C#m (The Neapolitan D should typically be in a 6th inversion)
This is like F B Em.
The Ddim choice is interesting. It creates a very soft transition compared to the bolder choices of E7 or C#7 because it stays almost entirely in that Phrygian scale.
So the hypothesis is that the path from the D rooted tonality back to C# via the Ddim is something like the Phrygian-based Neapolitan IIb-V-I device, but with IIb dim substituting for the V.
From the top:
C#m, A7, A13, D/F#, Ddim, C#m
Im (IIb7:G#) (V13:D) (IIb:C#) (IIbdim:C#) Im
From the C#m to the A7 is like the familiar Am to F in C major, but with F altered to a dominant. This A7 behaves as a tritone substitute that wants to pull half a step down to G#, but instead it lingers, and turns into a secondary dominant pulling to the D root, and then we have that aforementioned path back to C#.