For what primes $p$ and positive integers $k$ is this algebraic expression divisible by $3$? My initial question is as is in the title:

For what prime $p$ and positive integers $k$ is this algebraic expression divisible by $3$?
$$A(p,k):=\dfrac{p^{2k+2} - 4p^{2k+1} + 6p^{2k} + 2p^{k+1} - 8p^k + 3}{2(p - 1)^2}$$

I would like to qualify that I am specifically interested in those values for $p$ and $k$ satisfying the congruence $p \equiv k \equiv 1 \pmod 4$.
MY ATTEMPT
Here, I will evaluate my expression for
$$p_1 = 5, k_1 = 1,$$
which gives $A(p_1,k_1)=9$ (which is divisible by $3$),
$$p_2 = 13, k_2 = 1,$$
which gives $A(p_2,k_2)=73$ (which is not divisible by $3$), and
$$p_3 = 17, k_3 = 1,$$
which gives $A(p_3,k_3)=129$ (which is divisible by $3$).
Here is my final question:

Will it be possible to consider the cases $p \equiv 1 \pmod 3$ and $p \equiv 2 \pmod 3$ separately, then use the Chinese Remainder Theorem afterwards?  (I know the concept, but I would have forgotten how to do that.)

CONJECTURE: If $p \equiv 2 \pmod 3$, then $3 \mid A(p,k)$.
Alas, this is where I get stuck.

*

*If $p\equiv 2\pmod 3$, then the numerator of $$A(p,k)=\dfrac{p^{2k+2} - 4p^{2k+1} + 6p^{2k} + 2p^{k+1} - 8p^k + 3}{2(p - 1)^2}$$ is divisible by $3$ while the denominator is not divisible by $3$, so $3\mid A(p,k)$.


*If $p\equiv 1\pmod 3$, then since $p$ can be written as $p=12m+1$, we have $$A(p,k)=\dfrac{1+(8 m - 2) (12 m + 1)^k + (48m^2 - 8 m  + 1) (12 m + 1)^{2 k} }{96m^2}$$Now, we have, by the binomial theorem,$$\begin{align}&1+(8 m - 2) (12 m + 1)^k + (48m^2 - 8 m  + 1) (12 m + 1)^{2 k} 
\\\\&=1+(8 m - 2)\sum_{i=0}^{k}\binom{k}{i}(12m)^i + (48m^2 - 8 m  + 1)\sum_{i=0}^{2k}\binom{2k}{i}(12m)^{i}
\\\\&=1+(8 m - 2)\bigg(1+12km+\underbrace{\sum_{i=2}^{k}\binom{k}{i}(12m)^i}_{\text{divisible by $288m^2$}}\bigg) 
\\&\qquad\quad + (48m^2 - 8 m  + 1)\bigg(1+24km+\binom{2k}{2}(12m)^{2}+\underbrace{\sum_{i=3}^{2k}\binom{2k}{i}(12m)^{i}}_{\text{divisible by $288m^2$}}\bigg)
\\\\&\equiv 1+(8 m - 2)(1+12km)
\\&\qquad\quad+ (48m^2 - 8 m  + 1)\bigg(1+24km+\binom{2k}{2}(12m)^{2}\bigg)\pmod{288m^2}
\\\\&\equiv 48(k+1)m^2\pmod{288m^2}
\end{align}$$So, there is an integer $N$ such that $$A(p,k)=\frac{48(k+1)m^2+288m^2N}{96m^2}=3\bigg(\frac{k+1}{6}+N\bigg)$$Since $k+1$ is even, we see that $3\mid A(p,k)$ if and only if $k+1\equiv 0\pmod 3$, i.e. $k\equiv 2\pmod 3$.
In conclusion, considering $p\equiv k\equiv 1\pmod 4$, we can say that

*

*If $p\equiv 5\pmod{12}$, then $3\mid A(p,k)$.


*If $p\equiv 1\pmod{12}$ and $k\equiv 5\pmod{12}$, then $3\mid A(p,k)$.


*If $p\equiv 1\pmod{12}$ and $k\not\equiv 5\pmod{12}$, then $3\not\mid A(p,k)$.
