What exactly does it mean that mass is just confined energy? I learned about this a few years ago from a PBS Spacetime video (https://youtu.be/gSKzgpt4HBU, timestamp 1:37), that gave the thought experiment of a massless box of photons gaining mass when accelerated due to the pressure differential created by the photons moving from one side of the box to the other.
That blew my mind initially, but now I'm wondering what it actually MEANS.
In the thought experiment, they seem to be imagining photons as classical particles, but of course they're really more like waves in the EM field and it's unclear to me whether they'd even be affected by pressure.
But, more fundamentally, what does "confinement" even mean in this context?  Obviously there's no such as a massless box, nor are we talk about about physically trapping a particle inside an actual box.  What comes to mind is electrons being "bound" to atoms by the EM force, as well as the protons and neutrons in an atom being held together by the strong force, since the textbook example of mass-energy conversion is nuclear fission.
And then there's the fact that most of the mass of a proton, for example, isn't due to the mass of the quarks making up the photon, but due to the binding energy holding it together, yes?  But what even IS the binding energy exactly?  If we think of particles as little solid spheres then of course it would just be the energy that holds them together.  But that's far too simplistic of a picture to satisfy my curiosity -- particles are more accurately modeled as wave-packets, which, if I understand correctly, are superpositions of infinitely many wavefunctions.  So really, we should be thinking about waves being bound together somehow, and this is where my mental model breaks down -- what does it even mean to "hold waves together" when they aren't even localized in space?  I mean, wavepackets are somewhat localized, but for any particle, there's always a nonzero probability of its position being literally millions of miles away from where we thought it was localized to, as the wavefunction of a particle in a finite well (and, in practice, there's no such thing as an infinite well) encompasses all of space, right?  So what exactly do we mean, in terms of the wavepacket model, when we say a particle's mass is just confined energy?  I'm tempted to say we just mean it's a wavepacket at all, as opposed to a planewave, but that can't be right, because it would mean photons have mass.
Furthermore, even in the context of classical physics, I'm not sure I really understand what "binding energy" actually is.  Normally, if we want to confine something macroscopic to some spacial location, we put physical barriers up to block movement outside that space.  It's not really energy itself keeping the object inside the boundary, but the fact that moving past the boundaries might require more energy then the object has.
And, in the context of chemical bonds, which is where I first remember hearing the term "binding energy", it seems sort of a misleading term, since IIRC, what actually holds a molecule together is the fact that that particle configuration is the lowest energy state available.
 A: There are a lot of questions here.
First, the box thought experiment also works in a relativistic wave picture: in its own frame there exists a standing wave, but due to the relativity of simultaneity together with Doppler shifts, in a frame where the box is moving, the wave has net momentum in the direction of motion: the forward component gets shorter and the backward component gets longer.
Second, since you tagged QFT, I'm going to explain what mass really is in that framework. A central object in QFT is the propagator, which basically answers the question "given that something is here right now, what's the probability it will be over there later?" For spacetime coordinates $y$ (initial) and $x$ (final), it takes the form
$$G(x,y)=\langle\Omega|T\Phi(x)\Phi^\dagger(y)|\Omega\rangle,$$
where $\Omega$ is the vacuum and $\Phi$ is your quantum field.
Now, an important result in QFT is the Källèn-Lehmann spectral theorem, which basically states that you can always write the propagator as
$$G(x,y)=\int_0^\infty d\mu^2\,\rho(\mu^2)\Delta(x,y;\mu^2),$$
with $\Delta$ the free particle propagator at mass $\mu$,
$$\Delta(x,y;\mu^2)=\int\tilde{dk}\,\frac{i}{k^2-\mu^2+i\epsilon}e^{-ik(x-y)}.$$
Now what usually happens is that $\rho$ is very concentrated at some particular points $m_i^2$, and so we can effectively write our propagator taking out the discontinuous and badly behaved bits as
$$G(x,y)=\sum_iZ_i\Delta(x,y;m_i^2)+\text{continuous}.$$
Then these values $m_i$ which correspond to places where our propagator shoots of to infinity are exactly the list of masses of all particles in the theory. What can then happen is we have for example $m_1$ and $m_2$, which could be the masses of two particles with opposite electric charge, and then also $m_3=m_1+m_2-\delta m$, which would then represent a particle made up of the previous two orbiting each other as an "atom". In this context $\delta m$ is our so called "binding energy".
Third, to talk about quarks that make up a proton, I have to talk about renormalization for a second. It turns out that the $m_i$ and $Z_i$ are not exactly fundamental, but depend on the energy scale at which you are analyzing your theory. For Quantum Chromodynamics it just so happens that free quarks with well defined masses can only exist at infinite energy scales (this is called asymptotic freedom).
At finite energies, the masses that appear in your propagator actually correspond to bundles of quarks bound together by gluons, and that by construction has a lot more energy than the free quarks. As such, the proton has a lot more mass than the sum of the constituent quark masses.
Finally, perhaps a more satisfiying part tying back to the beginning. What does mass have to do with energy anyway? Well, special relativity tells us that momentum $\mathbf p$ and energy $E$ are just different components of a same vector $k=(E,\mathbf p)$. Whenever you find a frame where $\mathbf p=\mathbf 0$, you just refer to $E$ by $m$. Why? Because then if you boost by $\mathbf v$, the Lorentz transformation works out to
$$(m,\mathbf 0)\mapsto(\gamma m, \gamma m\mathbf v),$$
or, for small speeds, $\mathbf p=m\mathbf v$.
