{# Discreet cookie consent banner partial #}
<div id="cookie-consent-banner" role="dialog" aria-label="Choix des cookies" aria-live="polite" style="display:none;position:fixed;bottom:1rem;right:1rem;z-index:10000;background:#1e1e1e;color:#fff;padding:.75rem 1rem;border-radius:999px;box-shadow:0 4px 14px rgba(0,0,0,.25);font-size:.75rem;line-height:1.2;font-family:Montserrat, Arial, sans-serif;">
<span style="margin-right:.5rem;">Acceptation des cookies ?</span>
<button id="cookie-accept" type="button" style="background:#0d6efd;border:none;color:#fff;padding:.35rem .7rem;border-radius:999px;font-size:.7rem;cursor:pointer;">OK</button>
<button id="cookie-decline" type="button" style="background:#444;border:none;color:#fff;padding:.35rem .7rem;border-radius:999px;font-size:.7rem;cursor:pointer;margin-left:.3rem;">Non</button>
<button id="cookie-close" type="button" style="background:transparent;border:none;color:#bbb;padding:.35rem .4rem;font-size:.8rem;cursor:pointer;margin-left:.2rem;" aria-label="Fermer">×</button>
<a href="/mentionlegales" style="color:#9ecfff;margin-left:.3rem;text-decoration:none;font-size:.65rem;">Infos</a>
</div>
<script>
(function(){
const banner = document.getElementById('cookie-consent-banner');
function parseConsent(){
const m = document.cookie.match(/(^|;)\s*cookie_consent=([^;]+)/);
if(!m) return null;
try { return JSON.parse(decodeURIComponent(m[2])); } catch(e){ return null; }
}
function setConsent(obj){
const expires = new Date(Date.now()+365*24*3600*1000).toUTCString();
document.cookie = 'cookie_consent='+encodeURIComponent(JSON.stringify(obj))+';expires='+expires+';path=/;SameSite=Lax';
}
function ensureHubspot(){
if(document.getElementById('hs-script-loader')) return;
const s = document.createElement('script');
s.type='text/javascript';
s.id='hs-script-loader';
s.async=true; s.defer=true;
s.src='//js-eu1.hs-scripts.com/147164794.js';
document.head.appendChild(s);
}
function show(){ banner.style.display='flex'; banner.style.alignItems='center'; }
function hide(){ banner.style.display='none'; }
const consent = parseConsent();
if(!consent){ show(); }
else if(consent.analytics === true){ ensureHubspot(); }
document.getElementById('cookie-accept').addEventListener('click', function(){
setConsent({analytics:true});
ensureHubspot();
hide();
});
document.getElementById('cookie-decline').addEventListener('click', function(){
setConsent({analytics:false});
hide();
});
document.getElementById('cookie-close').addEventListener('click', hide);
// Expose reopen for footer link
window.showCookieBanner = function(){ show(); };
})();
</script>