/* CASINO logo spin: fruit-machine symbols (watermelon-heavy) + jackpot every 3rd click of the logo.
Hooked in by the footer slot script via window.CSF (each reel cell) and window.CSJ (end of spin). */
(function () {
var O = 'stroke="#111" stroke-width="1.8" stroke-linejoin="round"', LF = '#5cb84a';
function sh(x, y, r) { r = r || 3; return ''; }
function lf(x, y, a) { return ''; }
function svg(b) { return ''; }
var Y = {
melon: svg('' +
[[16, 22], [21, 19], [26, 16], [19, 25], [25, 22], [29, 19]].map(function (p) { return ''; }).join('')),
apple: svg('' + sh(14, 18) + lf(19, 11, -160) + lf(20, 11, -20)),
heart: svg('' + sh(11, 12)),
cherries: svg('' + lf(20, 10, -150) + lf(20, 10, -30) +
'' + sh(10, 25, 1.8) + sh(25, 23, 1.8) + sh(18, 30, 1.8)),
bar: svg('BAR'),
bell: svg('' + sh(15, 13, 2.4)),
seven: svg(''),
grapes: svg(lf(20, 8, -150) + lf(20, 8, -30) + [[12, 15], [20, 15], [28, 15], [16, 22], [24, 22], [20, 29]].map(function (p) { return '' + sh(p[0] - 1.6, p[1] - 1.6, 1.5); }).join(''))
};
var OTHERS = ['cherries', 'bell', 'seven', 'bar', 'grapes', 'heart', 'apple'];
var SS = {};
try { SS = sessionStorage; } catch (e) {}
// Count clicks on the logo; every 3rd click's spin is a jackpot
document.addEventListener('click', function (ev) {
if (ev.target.closest && ev.target.closest('.brand-img')) {
try { SS.casN = (+SS.casN || 0) + 1; } catch (e) {}
}
}, true);
var n = +SS.casN || 0, J = n > 0 && n % 3 === 0 && SS.casJ != n;
if (J) { try { SS.casJ = n; } catch (e) {} }
// e = reel cell, k = position index, f = symbol size in px, r = row (0 = the landing row)
window.CSF = function (e, k, f, r) {
if (!r) {
if (!J) return; // normal spin lands on the CASINO letters
e.style.background = 'none';
e.style.display = 'flex'; e.style.alignItems = 'center'; e.style.justifyContent = 'center';
e.innerHTML = '
' + Y.melon + '
';
return;
}
var nm = Math.random() < 0.55 ? 'melon' : OTHERS[Math.floor(Math.random() * OTHERS.length)];
var s = Math.round(f * 1.05);
e.innerHTML = '' + Y[nm] + '
';
};
// Called when the spin is set up; returns extra ms to hold before the logo comes back
window.CSJ = function (W, T) {
if (!J) return 0;
// Same-size melons on every reel: reels clip top/bottom only, so the narrow I melon can spill sideways
var z = Math.round(W.offsetHeight * .72);
[].forEach.call(W.children, function (c) { c.style.overflow = 'visible'; c.style.clipPath = 'inset(0 -60px)'; });
// ...and evenly spaced across the logo (the reels themselves are uneven widths)
var ww = W.offsetWidth;
[].forEach.call(W.children, function (c, i) {
var m = c.querySelector('.cs-jm'); if (!m) return;
var dx = Math.round(ww * (i + .5) / 6 - (c.offsetLeft + c.offsetWidth / 2));
m.style.cssText = 'width:' + z + 'px;height:' + z + 'px;flex:none;position:relative;left:' + dx + 'px';
});
setTimeout(function () { jackpot(W); }, T);
return 3200;
};
var COIN = '';
function jackpot(W) {
if (!W.animate) return;
// Reels bounce one after another
[].forEach.call(W.querySelectorAll('.cs-jm'), function (m, i) {
m.animate([{ transform: 'scale(1)' }, { transform: 'scale(1.35) rotate(-8deg)' }, { transform: 'scale(.9) rotate(6deg)' }, { transform: 'scale(1.15)' }, { transform: 'scale(1)' }],
{ duration: 700, delay: i * 90, iterations: 3, easing: 'ease-in-out' });
});
var b = W.getBoundingClientRect(), cx = b.left + b.width / 2, cy = b.top + b.height / 2;
var L = document.createElement('div');
L.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:10000;overflow:hidden';
// JACKPOT banner
var t = document.createElement('div');
t.textContent = 'JACKPOT!';
t.style.cssText = 'position:absolute;left:' + cx + 'px;top:' + (b.bottom + 6) + 'px;transform:translateX(-50%);font:900 ' + Math.max(22, b.height * .55) + 'px/1 Arial Black,Arial,sans-serif;color:#d4111b;letter-spacing:.04em;white-space:nowrap;-webkit-text-stroke:1.5px #111';
L.appendChild(t);
t.animate([{ transform: 'translateX(-50%) scale(0)', opacity: 0 }, { transform: 'translateX(-50%) scale(1.25)', opacity: 1, offset: .15 },
{ transform: 'translateX(-50%) scale(1)', opacity: 1, offset: .25 }, { color: '#f2c230', offset: .4 }, { color: '#d4111b', offset: .55 },
{ color: '#f2c230', offset: .7 }, { transform: 'translateX(-50%) scale(1)', opacity: 1, offset: .88 }, { transform: 'translateX(-50%) scale(.6)', opacity: 0 }],
{ duration: 3100, fill: 'forwards' });
// Shower of coins and watermelons
var count = innerWidth < 700 ? 26 : 44;
for (var i = 0; i < count; i++) {
var p = document.createElement('div'), z = 18 + Math.random() * 22;
p.innerHTML = Math.random() < .6 ? COIN : Y.melon;
p.style.cssText = 'position:absolute;left:' + (cx - z / 2) + 'px;top:' + (cy - z / 2) + 'px;width:' + z + 'px;height:' + z + 'px';
L.appendChild(p);
var dx = (Math.random() - .5) * innerWidth * .9, up = -(80 + Math.random() * 220), down = innerHeight - cy + 60, rot = (Math.random() - .5) * 900;
p.animate([{ transform: 'translate(0,0) rotate(0)', opacity: 1 },
{ transform: 'translate(' + dx * .5 + 'px,' + up + 'px) rotate(' + rot * .4 + 'deg)', opacity: 1, offset: .35, easing: 'ease-in' },
{ transform: 'translate(' + dx + 'px,' + down + 'px) rotate(' + rot + 'deg)', opacity: 1 }],
{ duration: 1800 + Math.random() * 1200, delay: Math.random() * 500, easing: 'cubic-bezier(.2,.7,.4,1)', fill: 'both' });
}
document.body.appendChild(L);
setTimeout(function () { L.remove(); }, 3800);
}
})();
/* Phones/tablets (no hover): show project titles under each tile instead of on hover */
(function () {
var st = document.createElement('style');
st.textContent = '@media (hover: none){.col.item .overlay{position:static!important;opacity:1!important;background:none!important;padding:8px 2px 6px!important;height:auto!important;width:auto!important;display:block!important;transform:none!important}.col.item .overlay *{position:static!important;transform:none!important;text-align:left!important}.col.item .overlay strong{color:#000!important}.col.item .overlay .thumbnail-subtitle,.col.item .overlay .thumbnail-subtitle p{color:#777!important;margin:2px 0 0!important}}';
(document.head || document.documentElement).appendChild(st);
})();