document.addEventListener('DOMContentLoaded', function (){
const toggle=document.querySelector('.ramiro-menu-toggle');
const nav=document.querySelector('.ramiro-header-nav');
if(!toggle||!nav) return;
toggle.addEventListener('click', function (){
const isOpen=nav.classList.toggle('is-open');
toggle.setAttribute('aria-expanded', isOpen ? 'true':'false');
document.body.classList.toggle('ramiro-menu-open', isOpen);
});
const menuItems=document.querySelectorAll('.ramiro-nav .menu-item-has-children > a');
menuItems.forEach(function (link){
link.addEventListener('click', function (e){
if(window.innerWidth > 1024) return;
const parent=link.parentElement;
const alreadyOpen=parent.classList.contains('is-open');
if(!alreadyOpen){
e.preventDefault();
parent.classList.add('is-open');
}});
});
});
(function (){
var CHAR_DELAY=22;   
var PAUSE_NAME=500;
var PAUSE_ROLE=280;
var AUTO_DELAY=2000;
var USER_PAUSE=10000;
function pad(n){ return n < 10 ? '0' + n:'' + n; }
function init(){
var sliders=document.querySelectorAll('[data-ramiro-slider]');
sliders.forEach(function (slider){
var slides=Array.from(slider.querySelectorAll('.ramiro-testimonial-slide'));
var dotsWrap=slider.querySelector('.ramiro-testimonials-slider__dots');
var viewport=slider.querySelector('.ramiro-testimonials-slider__viewport');
var track=slider.querySelector('.ramiro-testimonials-slider__track');
if(!slides.length) return;
var shell=slider.closest('.ramiro-testimonials-home__shell');
var topBox=shell ? shell.querySelector('.ramiro-testimonials-home__top'):null;
var current=0;
var autoTimer=null;
var pauseTimer=null;
var typeTimers=[];
var isTyping=false;
var userPaused=false;
var data=slides.map(function (slide){
var tEl=slide.querySelector('.ramiro-testimonial-slide__text');
var nEl=slide.querySelector('.ramiro-testimonial-slide__name');
var rEl=slide.querySelector('.ramiro-testimonial-slide__role');
return {
text: tEl ? tEl.textContent.trim():'',
name: nEl ? nEl.textContent.trim():'',
role: rEl ? rEl.textContent.trim():''
};});
slides.forEach(function (slide){
var inner=slide.querySelector('.ramiro-testimonial-slide__inner');
if(!inner) return;
inner.innerHTML =
'<div class="ramiro-testimonial-slide__content">' +
'<p class="ramiro-testimonial-slide__text ramiro-tw-text"></p>' +
'</div>' +
'<div class="ramiro-testimonial-slide__footer">' +
'<div class="ramiro-testimonial-slide__author">' +
'<strong class="ramiro-testimonial-slide__name ramiro-tw-name"></strong>' +
'<span class="ramiro-testimonial-slide__separator ramiro-tw-sep" style="display:none;">, </span>' +
'<span class="ramiro-testimonial-slide__role ramiro-tw-role"></span>' +
'</div>' +
'</div>';
});
var navHTML =
'<div class="ramiro-tw-nav">' +
'<div class="ramiro-tw-counter">' +
'<strong class="ramiro-tw-cur">01</strong>' +
'<span class="ramiro-tw-sep2"> / </span>' +
'<span class="ramiro-tw-tot">' + pad(slides.length) + '</span>' +
'</div>' +
'<div class="ramiro-tw-arrows">' +
'<button type="button" class="ramiro-tw-arrow ramiro-tw-prev" aria-label="Prethodno svjedočanstvo">' +
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>' +
'</button>' +
'<button type="button" class="ramiro-tw-arrow ramiro-tw-next" aria-label="Sljedeće svjedočanstvo">' +
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 6 15 12 9 18"/></svg>' +
'</button>' +
'</div>' +
'</div>';
slides.forEach(function (slide){
var inner=slide.querySelector('.ramiro-testimonial-slide__inner');
if(inner) inner.insertAdjacentHTML('beforeend', navHTML);
});
if(dotsWrap) dotsWrap.remove();
var curEl=slider.querySelector('.ramiro-tw-cur');
var prevBtn=slider.querySelector('.ramiro-tw-prev');
var nextBtn=slider.querySelector('.ramiro-tw-next');
function measureAndLock(){
if(!viewport||!track) return;
var maxH=0;
slides.forEach(function (slide, idx){
slide.classList.add('is-measuring');
var inner=slide.querySelector('.ramiro-testimonial-slide__inner');
var d=data[idx];
var tEl=slide.querySelector('.ramiro-tw-text');
var nEl=slide.querySelector('.ramiro-tw-name');
var rEl=slide.querySelector('.ramiro-tw-role');
if(tEl) tEl.textContent=d.text;
if(nEl) nEl.textContent=d.name;
if(rEl) rEl.textContent=d.role;
if(inner) maxH=Math.max(maxH, Math.ceil(inner.offsetHeight));
if(tEl) tEl.textContent='';
if(nEl) nEl.textContent='';
if(rEl) rEl.textContent='';
slide.classList.remove('is-measuring');
});
if(maxH > 0){
viewport.style.height=(maxH + 8) + 'px';
track.style.height=(maxH + 8) + 'px';
}}
var cursor=document.createElement('span');
cursor.className='ramiro-tw-cursor';
function clearTimers(){
typeTimers.forEach(clearTimeout);
typeTimers=[];
if(cursor.parentNode) cursor.parentNode.removeChild(cursor);
}
function typeInto(el, str, charDelay, done){
var i=0;
el.textContent='';
el.appendChild(cursor);
function tick(){
if(i <=str.length){
el.textContent=str.slice(0, i);
el.appendChild(cursor);
i++;
var jitter=charDelay + (Math.random() * charDelay * 0.3) - (charDelay * 0.1);
typeTimers.push(setTimeout(tick, jitter));
}else{
if(cursor.parentNode===el) el.removeChild(cursor);
if(done) done();
}}
tick();
}
function updateCounter(idx){
slider.querySelectorAll('.ramiro-tw-cur').forEach(function (el){
el.style.transition='none';
el.style.transform='translateY(60%)';
el.style.opacity='0';
el.textContent=pad(idx + 1);
el.offsetWidth;
el.style.transition='transform 0.28s cubic-bezier(.4,0,.2,1), opacity 0.28s';
el.style.transform='translateY(0)';
el.style.opacity='1';
});
}
function go(idx, fromUser){
clearTimers();
isTyping=true;
current=idx;
slides.forEach(function (slide, i){
slide.classList.toggle('is-active', i===idx);
});
updateCounter(idx);
var activeSlide=slides[idx];
var tEl=activeSlide.querySelector('.ramiro-tw-text');
var nEl=activeSlide.querySelector('.ramiro-tw-name');
var rEl=activeSlide.querySelector('.ramiro-tw-role');
var sep=activeSlide.querySelector('.ramiro-tw-sep');
if(tEl) tEl.textContent='';
if(nEl) nEl.textContent='';
if(rEl) rEl.textContent='';
if(sep) sep.style.display='none';
var d=data[idx];
typeInto(tEl, d.text, CHAR_DELAY, function (){
typeTimers.push(setTimeout(function (){
typeInto(nEl, d.name, CHAR_DELAY * 0.6, function (){
if(sep) sep.style.display='';
typeTimers.push(setTimeout(function (){
typeInto(rEl, d.role, CHAR_DELAY * 0.5, function (){
isTyping=false;
if(!userPaused) scheduleAuto();
});
}, PAUSE_ROLE));
});
}, PAUSE_NAME));
});
if(fromUser){
userPaused=true;
clearTimeout(pauseTimer);
pauseTimer=setTimeout(function (){
userPaused=false;
if(!isTyping) scheduleAuto();
}, USER_PAUSE);
}}
function scheduleAuto(){
clearTimeout(autoTimer);
autoTimer=setTimeout(function (){
if(!userPaused) go((current + 1) % slides.length, false);
}, AUTO_DELAY);
}
slider.addEventListener('click', function (e){
if(e.target.closest('.ramiro-tw-prev')){
go((current - 1 + slides.length) % slides.length, true);
}else if(e.target.closest('.ramiro-tw-next')){
go((current + 1) % slides.length, true);
}});
var touchX=0;
slider.addEventListener('touchstart', function (e){
touchX=e.changedTouches[0].clientX;
}, { passive: true });
slider.addEventListener('touchend', function (e){
var dx=touchX - e.changedTouches[0].clientX;
if(Math.abs(dx) > 40){
dx > 0
? go((current + 1) % slides.length, true)
: go((current - 1 + slides.length) % slides.length, true);
}}, { passive: true });
window.addEventListener('resize', measureAndLock);
measureAndLock();
go(0, false);
});
}
if(document.readyState==='complete'){
init();
}else{
window.addEventListener('load', init);
}})();
document.addEventListener('DOMContentLoaded', function (){
const faqTriggers=document.querySelectorAll('.ramiro-service-single-faq__trigger');
faqTriggers.forEach(function (trigger){
trigger.addEventListener('click', function (){
const item=trigger.closest('.ramiro-service-single-faq__item');
if(!item) return;
const isOpen=item.classList.contains('is-open');
item.classList.toggle('is-open', !isOpen);
trigger.setAttribute('aria-expanded', String(!isOpen));
});
});
});
document.addEventListener('DOMContentLoaded', function (){
var root=document.querySelector('.ramiro-references');
if(!root){
return;
}
var searchInput=root.querySelector('[data-ramiro-references-search]');
var countEl=root.querySelector('[data-ramiro-references-count]');
var emptyEl=root.querySelector('[data-ramiro-references-empty]');
var filterButtons=root.querySelectorAll('[data-ramiro-reference-filter]');
var groups=root.querySelectorAll('[data-ramiro-reference-group]');
var activeFilter='all';
function normalize(value){
return String(value||'')
.toLowerCase()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.trim();
}
function setActiveButton(filter){
filterButtons.forEach(function (button){
if(button.getAttribute('data-ramiro-reference-filter')===filter){
button.classList.add('is-active');
}else{
button.classList.remove('is-active');
}});
}
function applyFilters(){
var query=normalize(searchInput ? searchInput.value:'');
var visibleCount=0;
groups.forEach(function (group){
var groupKey=group.getAttribute('data-ramiro-reference-group');
var groupMatchesFilter=activeFilter==='all'||activeFilter===groupKey;
var cards=group.querySelectorAll('[data-ramiro-reference-item]');
var visibleInGroup=0;
cards.forEach(function (card){
var name=normalize(card.getAttribute('data-reference-name'));
var matchesSearch=query===''||name.indexOf(query)!==-1;
var shouldShow=groupMatchesFilter&&matchesSearch;
card.classList.toggle('is-hidden', !shouldShow);
if(shouldShow){
visibleInGroup +=1;
visibleCount +=1;
}});
group.classList.toggle('is-hidden', visibleInGroup===0);
});
if(countEl){
var label=visibleCount===1 ? 'klijent':'klijenata';
countEl.textContent='Prikazano ' + visibleCount + ' ' + label;
}
if(emptyEl){
emptyEl.hidden=visibleCount!==0;
}}
filterButtons.forEach(function (button){
button.addEventListener('click', function (){
activeFilter=button.getAttribute('data-ramiro-reference-filter')||'all';
setActiveButton(activeFilter);
applyFilters();
});
});
if(searchInput){
searchInput.addEventListener('input', applyFilters);
}
applyFilters();
});
document.addEventListener("DOMContentLoaded", function (){
function setupBackToTop(rootSelector, visibleClass){
var button=document.querySelector(rootSelector);
if(!button) return;
var threshold=Math.round(window.innerHeight * 0.8);
var isVisible=false;
var ticking=false;
function updateVisibility(){
var shouldShow=window.pageYOffset > threshold;
if(shouldShow!==isVisible){
isVisible=shouldShow;
button.classList.toggle(visibleClass, shouldShow);
}
ticking=false;
}
function onScroll(){
if(!ticking){
window.requestAnimationFrame(updateVisibility);
ticking=true;
}}
function onResize(){
threshold=Math.round(window.innerHeight * 0.8);
updateVisibility();
}
function scrollToTop(){
window.scrollTo({ top: 0, behavior: "smooth" });
}
button.addEventListener("click", scrollToTop);
window.addEventListener("scroll", onScroll, { passive: true });
window.addEventListener("resize", onResize);
updateVisibility();
}
setupBackToTop("[data-ramiro-back-to-top]", "is-visible");
});