system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5 Why it's so difficult for countries to build nuclear weapons.

I've learnt about how nuclear weapons work in high school physics. I'm assuming it's a bit more complicated than what I've learnt, but it seems like the science behind nuclear weapons has been public knowledge for a long time.

Are there certain aspects of the science behind them that aren't public knowledge, that a country looking to build nuclear weapons would have to research themselves?

Or is it just the materials/infrastructure needed to build nuclear weapons that makes them so difficult to make?

Edit: thanks for the great answers everyone! Really interesting.
gpt
There are basically 2 kinds of practical nuclear weapons; gun-type and implosion-type.

A gun-type bomb is technically piss easy to build. Take two subcritical masses of high enriched uranium (HEU) and fire them at each other so they become one supercritical mass. The design is so idiot-proof the US didn't even bother to test it before dropping the first one. The problem with the gun-type bomb is getting the HEU. You need a *massive* infrastructure of specialized industry to enrich uranium to the required level, and you need a *shitload* of uranium. Gun-type bombs also don't miniaturize well, so they're no good for long range missiles.

Implosion-type bombs take a hollow sphere of plutonium, and then through a very precisely timed series of explosions implode the sphere into a tiny supercritical mass. Plutonium is comparatively easy to get. You need a nuclear reactor to make the stuff, but compared to enriching uranium the process isn't so difficult. The tricky part of an implosion bomb is the timing. Getting your explosives to detonate in just the right order and with just the right force to implode the plutonium core is very, *very* technically challenging. A few millionths of a second makes the difference between an earth-shattering kaboom and a wimpy little fizzle. Plutonium implosion bombs give you a lot of bang for your buck weight-wise, and can be shrunk to very small sizes. They're the ones you want for an ICBM or SLBM.

Of course, handling any radioactive material is technically challenging. Something as simple as putting it in the wrong shape of container or having people stand near it in just the wrong way can get you a bright flash and a bunch of dead scientists.