/* SAN AVELIO - RESPONSIVE TYPOGRAPHY v3 / ZOOM SYNC Compensates the existing RESPONSIVE LAYOUT FINAL v4 zoom. Does not alter layout, background, map geometry, widths or the zoom itself. */ (function(){ 'use strict'; if(window.SA_RESPONSIVE_TYPOGRAPHY_V3)return; window.SA_RESPONSIVE_TYPOGRAPHY_V3=true; /* Remove/disable previous typography patches if still present. */ ['sa-responsive-typography-v1','sa-responsive-typography-v2'].forEach(function(id){ var n=document.getElementById(id); if(n)n.disabled=true; }); var ATTR='data-sa-type-v3-base'; var MARK='data-sa-type-v3'; var lastFactor=0; var timer=0; var selectors=[ /* Standard Rusff */ '.punbb .post-content','.punbb .post-content p','.punbb .post-content li', '.punbb .post-content blockquote','.punbb .post-content td','.punbb .post-content div', '.punbb .post-author','.punbb .post-author li','.punbb .post-author a','.punbb .post-author span', '.punbb .post-links','.punbb .post-links a','.punbb .post h3','.punbb .post h3 a', '.punbb #pun-navlinks a','.punbb #pun-ulinks a','.punbb #pun-status','.punbb #pun-status a', '.punbb .crumbs','.punbb .crumbs a','.punbb .pagelink','.punbb .pagelink a', '.punbb .formal','.punbb .formal label','.punbb .formal input','.punbb .formal textarea', '.punbb .formal select','.punbb .formal button', '.punbb .main .container','.punbb .main .container td','.punbb .main .container li', '.punbb .main .container a','.punbb .main h1','.punbb .main h2','.punbb .main h3', /* SAN AVELIO modules */ '#sa-la-sala h1','#sa-la-sala p','#sa-la-sala small','#sa-la-sala .ls-top','#sa-la-sala .ls-bottom', '#sa-dossier-clean p','#sa-dossier-clean li','#sa-dossier-clean a','#sa-dossier-clean button', '#sa-dossier-clean input','#sa-dossier-clean textarea','#sa-dossier-clean select', '.sa-character-studio p','.sa-character-studio li','.sa-character-studio a', '.sa-character-studio button','.sa-character-studio input','.sa-character-studio textarea', '.sa-character-studio select','#sa-character-studio p','#sa-character-studio li', '#sa-character-studio a','#sa-character-studio button','#sa-character-studio input', '#sa-character-studio textarea','#sa-character-studio select' ].join(','); function forum(){return document.querySelector('.punbb');} function zoomValue(){ var el=forum(); if(!el)return 1; var z=parseFloat(getComputedStyle(el).zoom); if(!isFinite(z)||z<=0)z=1; return z; } /* FINAL v4 shrinks the whole 1280px forum down to as little as .70. Text gets shrunk with it. v3 compensates that shrink so text remains readable. Cap prevents oversized type on very small desktop windows. */ function factor(){ if(window.innerWidth<900)return 1; var z=zoomValue(); var f=1/z; return Math.max(1,Math.min(1.38,f)); } function excluded(el){ if(!el||el.nodeType!==1)return true; if(el.closest('svg,.map-svg,.sa-map-modal,#sa-map-frame,script,style'))return true; return false; } function capture(el){ if(excluded(el)||el.hasAttribute(ATTR))return; var fs=parseFloat(getComputedStyle(el).fontSize); if(!isFinite(fs)||fs<6||fs>72)return; el.setAttribute(ATTR,String(fs)); } function applyOne(el,f){ if(excluded(el))return; capture(el); var base=parseFloat(el.getAttribute(ATTR)); if(!isFinite(base))return; var px=Math.round(base*f*100)/100; el.style.setProperty('font-size',px+'px','important'); el.setAttribute(MARK,'1'); } function apply(root,force){ var f=factor(); if(!force && Math.abs(f-lastFactor)<0.005)return; lastFactor=f; var scope=root&&root.querySelectorAll?root:document; if(root&&root.matches&&root.matches(selectors))applyOne(root,f); scope.querySelectorAll(selectors).forEach(function(el){applyOne(el,f);}); document.documentElement.style.setProperty('--sa-type-zoom-sync',String(f)); } function refresh(force){ clearTimeout(timer); timer=setTimeout(function(){apply(document,!!force);},70); } function start(){ apply(document,true); window.addEventListener('resize',function(){refresh(false);},{passive:true}); window.addEventListener('orientationchange',function(){refresh(true);},{passive:true}); var mo=new MutationObserver(function(ms){ var f=factor(); ms.forEach(function(m){m.addedNodes.forEach(function(n){ if(n.nodeType!==1)return; if(n.matches&&n.matches(selectors))applyOne(n,f); if(n.querySelectorAll)n.querySelectorAll(selectors).forEach(function(el){applyOne(el,f);}); });}); }); mo.observe(document.body,{childList:true,subtree:true}); setTimeout(function(){apply(document,true);},500); setTimeout(function(){apply(document,true);},1600); } if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start); else start(); })();