Now this is where I need help - Warsaw to BA, because I get no discount for a singe ticket, right?
Yes, discount is granted only for return tickets, that is why buying one way might be not the best option.
I saw some special tickets... Spar Day from 29 Euro, Spar Night for 64 Euro for a 2 berth sleeper (perfect for us), but I was wondering if I can buy online, or how far in advance I need to buy themat the station?
Yes, PKP offers discounted tickets for the daytime and overnight trains to Vienna and Budapest (via Bratislava), but unfortunately they don't sell international tickets online, thus it's a bit problematic to catch those sparschiene in case you aren't in Poland.
I'll probably spend 3 nights in Gdansk, and a couple in Warsaw, so maybe 5 days in advance will be enough?
It might be enough during the regular days, but in case of holidays, as you probably understand yourself, nothing can be guaranteed, especially since the number of discounted tickets isn't that big.
But in case you have trouble catching mentioned above tickets, you can always do a small trick, which will save you money comparing to full one way fare - travel on domestic PKP tariff till the border. If your stay in Warsaw won't be that long (<2 days) you can actually buy one through ticket Gdansk-Warsaw-Katowice/Bielsko-Biała (or alternatively Gdansk-Warsaw-Krakow-Zakopane), since tickets from PKP InterCity company (managing TLK, Ex and most international trains) for long-distance are valid for 2 days, thus you can save by buying cheaper one through ticket instead of two separate, then you just make a stopover in Warsaw.
From Katowice/Bielsko-Biała there are two major options: a) go directly by rail to Slovakia via Zwardon-Skalite-Zilina (few trains per day run via that border crossing, international ticket Zwardon-Skalite cost only 2 EUR); b) by bus till polish Cieczyn, then cross by foot to Czech Cesky Tesin and continue by train to Slovakia (either via Cadca or Breclav-Kuty), this option will be a bit more expensive, but transport is much more frequent in this case.
From Zakopane there are few buses to Poprad (at 6am, 9am, 11am and 4pm as of now), the route is quite picturesque, so you won't regret traveling there even considering a bit of time loss. Poprad to Bratislava already an easy task.
p.s. also you might benefit a bit from PKP overnight TLK offer called Tania Kuszetka, basically a discounted tickets for the couchette carriages on major polish domestic routes (can be bought online -
https://bilet.intercity.pl/irez/)