(function() {
// 1. VYTVORENIE HTML KONTAJNERA PRE POP-UP (Ak ešte neexistuje)
if (!document.getElementById('ik-paella-popup')) {
const popup = document.createElement('div');
popup.id = "ik-paella-popup";
popup.setAttribute("data-nosnippet", "");
popup.style.cssText = "display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); z-index:999999; overflow-y:auto; padding:20px; box-sizing:border-box;";
popup.innerHTML = `
✕
Dokonalý prepočet surovín a veľkosti panvice
Paella KALKULAČKA
🛒 Kúpiť výbavu
`;
document.body.appendChild(popup);
}
// 2. FUNKCIE OTVORENIA A ZATVORENIA
window.otvorPaellaKalkulacku = function() {
var p = document.getElementById('ik-paella-popup');
if (p) { p.style.display = 'block'; document.body.style.overflow = 'hidden'; }
};
window.zatvorPaellaKalkulacku = function() {
var p = document.getElementById('ik-paella-popup');
if (p) { p.style.display = 'none'; document.body.style.overflow = 'auto'; }
};
// 3. DATA RECEPTOV
var recipes = {
valenciana: { name: "Tradičná Valenciana", icon: "🥘", items: [{n: "Kuracie mäso", i: "🍗", r: 120}, {n: "Králičie mäso", i: "🐇", r: 100}, {n: "Zelená fazuľa", i: "🫛", r: 60}, {n: "Voda / Vývar", i: "💧", r: 0.35, t: "L"}] },
pollo: { name: "Kuracia Paella", icon: "🍗", items: [{n: "Kuracie stehná", i: "🍗", r: 220}, {n: "Červená paprika", i: "🫑", r: 0.25, t: "ks"}, {n: "Zelený hrášok", i: "🫛", r: 50}, {n: "Kurací vývar", i: "🥣", r: 0.32, t: "L"}] },
marisco: { name: "Morská Paella", icon: "🦐", items: [{n: "Krevety a mušle", i: "🦐", r: 220}, {n: "Sépia / Kalmáre", i: "🦑", r: 120}, {n: "Rybí vývar", i: "🐟", r: 0.35, t: "L"}] },
mixta: { name: "Miešaná Paella", icon: "🍤", items: [{n: "Kuracie mäso", i: "🍗", r: 120}, {n: "Krevety", i: "🦐", r: 80}, {n: "Mušle (Slávky)", i: "🦪", r: 80}, {n: "Vývar (Mix)", i: "🥣", r: 0.35, t: "L"}] },
negro: { name: "Čierna Paella", icon: "🖤", items: [{n: "Sépia", i: "🦑", r: 200}, {n: "Sépiový atrament", i: "🖋️", r: 0.3, t: "ks"}, {n: "Rybí vývar", i: "🐟", r: 0.35, t: "L"}] },
verduras: { name: "Zeleninová Paella", icon: "🥦", items: [{n: "Artičoky / Paprika", i: "🥬", r: 0.6, t: "ks"}, {n: "Mix zeleniny", i: "🥦", r: 220}, {n: "Zeleninový vývar", i: "🥕", r: 0.32, t: "L"}] }
};
var currentK = 'valenciana';
var pans = [{l:2, s:30}, {l:3, s:34}, {l:4, s:38}, {l:6, s:42}, {l:8, s:46}, {l:12, s:50}, {l:16, s:55}, {l:22, s:60}, {l:30, s:70}, {l:50, s:90}];
// 4. LOGIKA VÝPOČTOV
function updatePop() {
var g = parseInt(document.getElementById('pop-range-guests').value);
var p = parseInt(document.getElementById('pop-range-portion').value);
document.getElementById('pop-val-guests').innerText = g;
document.getElementById('pop-val-portion').innerText = p + "g";
var mult = (g * p) / 450;
var rice = Math.round(100 * mult);
var pan = 30;
for (var i = 0; i < pans.length; i++) { if (pans[i].l >= mult) { pan = pans[i].s; break; } }
document.getElementById('pop-res-pan').innerText = pan + " cm";
document.getElementById('pop-res-rice').innerText = (rice >= 1000 ? (rice/1000).toFixed(1) + " kg" : rice + " g");
var html = '📝 NÁKUPNÝ ZOZNAM
';
recipes[currentK].items.forEach(function(item) {
var v = item.r * mult;
var out = item.t === "L" ? v.toFixed(1) + " L" : (item.t === "ks" ? (v < 0.8 ? "1/2 ks" : Math.round(v) + " ks") : (v >= 1000 ? (v/1000).toFixed(1) + " kg" : Math.round(v) + " g"));
html += '' + item.i + ' ' + item.n + '' + out + '
';
});
document.getElementById('pop-ing-list').innerHTML = html + 'Nezabudnite na olivový olej, šafran a soľ.
';
}
function renderGrid() {
var grid = document.getElementById('pop-recipe-grid');
grid.innerHTML = "";
Object.keys(recipes).forEach(function(k) {
var isActive = k === currentK;
var card = document.createElement('div');
card.style.cssText = "border: 2px solid " + (isActive ? "#c5a02e" : "#eee") + "; border-radius: 12px; padding: 15px 10px; text-align: center; cursor: pointer; background: " + (isActive ? "#111" : "#fff");
card.innerHTML = '' + recipes[k].icon + '
' +
'' + recipes[k].name + '
';
card.onclick = function() { currentK = k; renderGrid(); updatePop(); };
grid.appendChild(card);
});
}
// 5. INICIALIZÁCIA PO NAČÍTANÍ
setTimeout(function() {
renderGrid();
updatePop();
// Aktivácia tlačidiel
var btnOpen = document.getElementById('paella-trigger');
if (btnOpen) btnOpen.onclick = function() { window.otvorPaellaKalkulacku(); };
var btnClose = document.getElementById('ik-close-btn');
if (btnClose) btnClose.onclick = function() { window.zatvorPaellaKalkulacku(); };
var gR = document.getElementById('pop-range-guests');
if (gR) gR.oninput = updatePop;
var pR = document.getElementById('pop-range-portion');
if (pR) pR.oninput = updatePop;
// Zatvorenie kliknutím na pozadie
var overlay = document.getElementById('ik-paella-popup');
overlay.onclick = function(e) { if (e.target === overlay) window.zatvorPaellaKalkulacku(); };
}, 500);
})();