/* Quitting subtitle-preview tester (behind ?sub=jonjon) */
(function(){
var K='qg_sub',q=location.search,d=document,c=d.documentElement.classList;
try{if(q.indexOf('sub=jonjon')>-1)localStorage.setItem(K,1);else if(q.indexOf('sub=off')>-1)localStorage.removeItem(K)}catch(e){}
try{if(localStorage.getItem(K)!='1')return}catch(e){return}
var MAP={
"tool-3-drink-calculator":"Translates what you drink into standard drinks, calories, and cost.",
"comebacks":"Bracket of one-liners for when people ask why you're not drinking.",
"map-card":"The whole road from first dry day to long-haul, in one diagram.",
"halt-card":"Tiered menu of things to do right now when a craving hits hard.",
"letter-card":"Write today. Get it back in your inbox months from now.",
"wheel-of-quit-card":"Spin for a quick sober challenge from Sobera the lemon.",
"the-quiz":"Five questions that hand you back your own reasons.",
"smarterer-soberer":"Trivia about alcohol, the brain, and what booze actually does.",
"looking-glass-card":"Seven soothing scenes for when you just need somewhere to put your eyes."
};
var STYLE='html.qgsub .qgs{display:block!important;margin:0.15rem 0 0;font:italic 500 clamp(0.92rem,1.6vw,1.1rem) \'Cormorant Garamond\',Georgia,serif;color:#8C7256;letter-spacing:0.01em;line-height:1.32}html:not(.qgsub) .qgs{display:none}#qgsubb{position:fixed;bottom:14px;left:14px;z-index:99998;display:flex;flex-direction:column;gap:6px;font:italic .85rem \'Cormorant Garamond\',serif}#qgsubb b{background:#FBF7EE;border:1px solid #2B1E14;border-radius:3px;padding:6px 10px;color:#2B1E14;cursor:pointer;display:block}html.qgsub #qgsubb b.t{background:#7A5236;color:#FBF7EE}';
function inject(){
if(!d.body.classList.contains('home-template'))return;
c.add('qgsub');
var s=d.createElement('style');s.id='qgs-style';s.textContent=STYLE;d.head.appendChild(s);
d.querySelectorAll('.fg-card.post').forEach(function(card){
var link=card.querySelector('.fg-card-title a');
if(!link)return;
var href=link.getAttribute('href')||'';
var m=href.match(/\/([^/]+)\/?$/);
var slug=m&&m[1];
if(!slug||!MAP[slug])return;
if(card.querySelector('.qgs'))return;
var p=d.createElement('p');p.className='qgs';p.textContent=MAP[slug];
var sub=card.querySelector('.fg-card-subtitle');
var title=card.querySelector('.fg-card-title');
if(sub&&sub.parentNode){sub.parentNode.insertBefore(p,sub.nextSibling);sub.style.display='none'}
else if(title&&title.parentNode){title.parentNode.insertBefore(p,title.nextSibling)}
});
var b=d.createElement('div');b.id='qgsubb';
b.innerHTML='Subtitle preview: ONExit preview';
b.children[0].onclick=function(){c.toggle('qgsub');this.textContent='Subtitle preview: '+(c.contains('qgsub')?'ON':'OFF')};
b.children[1].onclick=function(){
c.remove('qgsub');try{localStorage.removeItem(K)}catch(e){}b.remove();
d.querySelectorAll('.qgs').forEach(function(x){x.remove()});
d.querySelectorAll('.fg-card-subtitle').forEach(function(x){x.style.display=''});
};
d.body.appendChild(b);
}
if(d.body)inject();else d.addEventListener('DOMContentLoaded',inject);
})();