Coinbase & Hardware wallet relationship Aside from learning about all of bitcoin just for fun (mathematician with spare time), I currently own some bitcoin IOU's via Robinhood, but I would like to actually own my bitcoin (my keys, my coins! As they say).
I have been investigating Coinbase and hardware wallets like Nano Ledger S.
My understanding is that Coinbase is an exchange or market place where BTC can be bought and sold, but also offers wallet services.
My understanding of a hardware wallet like Nano Ledger S is that it is a very secure hardware device (cold storage, meaning completely offline) that will store the public and private key to my BTC wallet - and the private key to my wallet is synonymous with the bitcoin I hold. It has a 20 word mnemonic so if I hypothetically lost the device, I could buy a new one and access my wallet using the 20 word mnemonic. (I would also like to understand how buying a new Nano Ledger S and entering my mnemonic allows it to essentially restore to my old wallet, it seems like this would require the information to be stored somewhere. But I'll save that for a different question later on)
If my understanding above is correct, I would like to now understand the way transactions take place between the two concepts listed above.

I purchase X BTC on coinbase and it goes to my &quot;hosted wallet&quot; on Coinbase (X used as a variable representing the amount of BTC)
I can send the X BTC I purchased to my hardware wallet by giving the public key to my hardware wallet and specifying perhaps .99X BTC go to that wallet and the remaining .01 BTC is left as the transaction fee.
Coinbase broadcasts the transaction in the P2P network, sent around through full nodes in the network.
When this transaction gets grouped into a block and is mined, my wallet now contains .99X BTC meaning my public key shows up somewhere on the blockchain ledger that I have .99X unspent BTC associated to my public key.

I can repeat this process as many times as I like, continuing to accumulate more BTC in exchange for USD via Coinbase.

Eventually, maybe I want to liquidate some BTC in exchange for USD.
I can do this by using Ledger Live as described on the
ledger website here. Is this still &quot;offline&quot;? even when I &quot;unlock and connect&quot; my ledger device?
I use ledger live to send BTC to my Coinbase &quot;hosted wallet&quot; public key. When the transaction is processed I can sell my BTC on Coinbase market at the market value.

Is my understanding correct? And if so, how is my private key being used when I send BTC using ledger live? I think it is used to &quot;sign&quot; the transaction? So in some way is my private key vulnerable to nano ledger programming or software when sending?
I understand this is very amateur material, I have tried hard to learn on my own without asking here, but the quality of answers on this site, so far, have proven better than anything I have found on my own.
Your understanding is largely correct. I'll nitpick a few points for clarity, but overall I would say you have a decent grasp of whats going on here.

I can send the X BTC I purchased to my hardware wallet by giving the public key to my hardware wallet and specifying perhaps .99X BTC go to that wallet and the remaining .01 BTC is left as the transaction fee.

You will copy your bitcoin address to coinbase, not your public key. (In most cases, they 'pay-to-public-key-hash' (P2PKH) address is, as the name suggests, a hash of the public key). Your wallet will display bitcoin addresses, not public keys, so this is just a matter of terminology.
I am not familiar with Coinbase's interface, but there should be some sort of 'withdraw all' function. You will likely not need to specify a fee (in reality, Coinbase will likely just present you with a fee, which could include both a network transaction fee portion, and a Coinbase service fee portion).

When this transaction gets grouped into a block and is mined, my wallet now contains .99X BTC meaning my public key shows up somewhere on the blockchain ledger that I have .99X unspent BTC associated to my public key.

Wallets do not contain BTC. Wallets contain private keys, which can be used to sign transactions that spend coins which are locked to their associated bitcoin address. Once the transaction confirms, nodes on the network will be aware of an 'unspent transaction output' (UTXO), that is locked to an address that is derived from a private key, which your wallet holds.

I can repeat this process as many times as I like, continuing to accumulate more BTC in exchange for USD via Coinbase.

Yes, though when you eventually want to spend the coins, remember that it is more expensive to create a transaction which includes many small inputs, rather than just one or two larger inputs. See this question for info on fee calculations, and this one for fee info related to segwit transactions.

I can do this by using Ledger Live as described on the ledger website here. Is this still &quot;offline&quot;? even when I &quot;unlock and connect&quot; my ledger device?

The device connects to your computer via USB, and has a very restricted protocol for talking over the USB cable. Your private keys exist on the Ledger, and never leave the Ledger, so this is a more safe way of transacting, then just keeping the private keys on a device which is connected to the internet itself. The transaction can be created using software on your computer, and then that transaction is transmitted to the Ledger, signed, and the signed transaction is then transmitted back to your computer. Some other hardware wallets use different methods of communicating this data back and forth (eg SD card, QR codes, etc), but the general workflow will be the same.

I use ledger live to send BTC to my Coinbase &quot;hosted wallet&quot; public key. When the transaction is processed I can sell my BTC on Coinbase market at the market value.

Again, you'll send to a bitcoin address, but otherwise, this is correct. Note that when sending to coinbase, you will have more control over the transaction fee (and there will be no service fee, like there may be when you withdraw from an exchange).

how is my private key being used when I send BTC using ledger live? I think it is used to &quot;sign&quot; the transaction? So in some way is my private key vulnerable to nano ledger programming or software when sending?

Your private key will remain on the Ledger device, so you need to confirm the transaction looks correct, via the prompts on the device's screen. You should follow the hardware wallet manufacturer's instructions to ensure that you have received an authentic device from a legitimate retailer, and that it is running legitimate and up to date firmware.
Hope that helps!