        (function(){
'use strict';
function smoothScrollTo(el, offset=0){
if(!el) return;
const top=el.getBoundingClientRect().top + window.pageYOffset + offset;
window.scrollTo({top, behavior:'smooth'});
}
function initToggles(){
const showButtons=document.querySelectorAll('.btn-show[aria-controls]');
showButtons.forEach(showBtn=>{
const targetId=showBtn.getAttribute('aria-controls');
if(!targetId) return;
const target=document.getElementById(targetId);
if(!target) return;
const hideBtn=target.querySelector('.btn-hide[aria-controls="'+targetId+'"]');
target.style.overflow='hidden';
if(getComputedStyle(target).display==='none'){
target.style.display='none';
target.classList.remove('is-open');
if(hideBtn) hideBtn.style.display='none';
}else{
target.classList.add('is-open');
target.style.maxHeight=target.scrollHeight+'px';
if(hideBtn) hideBtn.style.display='inline-block';
}
showBtn.addEventListener('click', function(e){
e.preventDefault();
target.style.display='block';
target.style.maxHeight='0px';
requestAnimationFrame(()=>{
target.style.maxHeight=target.scrollHeight+'px';
target.classList.add('is-open');
});
target.setAttribute('aria-hidden','false');
showBtn.setAttribute('aria-expanded','true');
if(hideBtn){
hideBtn.style.display='inline-block';
hideBtn.setAttribute('aria-expanded','true');
}
showBtn.style.display='none';
});
if(hideBtn){
hideBtn.addEventListener('click', function(e){
e.preventDefault();
const offset=window.innerWidth<768?-80:-50;
const height=target.scrollHeight;
target.style.maxHeight=height+'px';
requestAnimationFrame(()=>{
target.style.maxHeight='0px';
target.classList.remove('is-open');
});
target.setAttribute('aria-hidden','true');
hideBtn.setAttribute('aria-expanded','false');
showBtn.style.display='inline-block';
showBtn.setAttribute('aria-expanded','false');
hideBtn.style.display='none';
const ancestor=target.closest('.bloc-beginning');
if(ancestor) setTimeout(()=>smoothScrollTo(ancestor, offset),180);
setTimeout(()=>{target.style.display='none';},350);
});
}});
}
document.addEventListener('DOMContentLoaded', initToggles);
})();