MediaWiki:Common.js: Difference between revisions

No edit summary
Tag: Reverted
No edit summary
Tag: Reverted
Line 1,246: Line 1,246:
/* ═══════════════════════════════════════════════════════════════
/* ═══════════════════════════════════════════════════════════════
   Mobile addon — paste at bottom of MediaWiki:Common.js
   Mobile addon — paste at bottom of MediaWiki:Common.js
   Fixes for Minerva skin (mobile):
   Only runs on Minerva (mobile) skin
  1. Hide Minerva page toolbar (Page/Discussion tabs, icons bar)
  2. Hide Minerva header extras (keep only hamburger+logo+search)
  3. ReaderToolbar sticky below header
  4. Hamburger menu with Help/About/Logout
  5. Expand hidden sections
  6. Home page x-scroll fix
   ═══════════════════════════════════════════════════════════════ */
   ═══════════════════════════════════════════════════════════════ */
( function () {
( function () {
   if ( !document.body.classList.contains( 'skin-minerva' ) ) return;
   if ( !document.body.classList.contains( 'skin-minerva' ) ) return;


   /* ── 1. Inject CSS (runs before JS, beats inline styles) ── */
   /* ── 1. CSS injected into <head> — beats all other stylesheets ── */
   function injectMinervaCSS() {
   function injectCSS() {
     if ( document.getElementById( 'gr-minerva-css' ) ) return;
     if ( document.getElementById( 'gr-mob-css' ) ) return;
     var s = document.createElement( 'style' );
     var s = document.createElement( 'style' );
     s.id = 'gr-minerva-css';
     s.id = 'gr-mob-css';
     s.textContent = [
     s.textContent =
       /* Kill body padding — readerToolbar sets it, we override */
       /* Body padding — readerToolbar sets this, we clear it */
       'body,#mw-mf-viewport,#mw-mf-page-center{padding-top:0!important;margin-top:0!important;}',
       'body,#mw-mf-viewport,#mw-mf-page-center{padding-top:0!important;margin-top:0!important;}' +
      'html,body,#mw-mf-viewport,#mw-mf-page-center{overflow-x:hidden!important;max-width:100vw!important;}' +


       /* Header orange + sticky */
       /* Header orange + sticky */
       'header.header-container{background:#b5451b!important;position:sticky!important;top:0!important;z-index:300!important;}',
       'header.header-container{background:#b5451b!important;position:sticky!important;top:0!important;z-index:300!important;}' +
       '.minerva-header{background:#b5451b!important;min-height:56px!important;display:flex!important;align-items:center!important;padding:0 12px!important;}',
       '.minerva-header{background:#b5451b!important;min-height:54px!important;}' +


       /* Hide Minerva header items we don't want */
       /* Header: keep only hamburger + branding, hide search */
      /* Keep: .navigation-drawer (hamburger), .branding-box (logo+name) */
       '.minerva-header .search-toggle,.minerva-header .minerva-user-notifications{display:none!important;}' +
      /* Hide: .search-toggle (search icon in header), language, notifications */
       '.minerva-header .search-toggle{display:none!important;}',
      '.minerva-header .minerva-user-notifications{display:none!important;}',


       /* Site name white */
       /* Logo row: icon + title wrap cleanly */
       '.branding-box a{display:flex!important;align-items:center!important;text-decoration:none!important;flex-wrap:wrap!important;}',
       '.branding-box a{display:flex!important;align-items:center!important;' +
       '.branding-box a span{color:#fff!important;font-size:17px!important;font-weight:700!important;font-family:system-ui,sans-serif!important;line-height:1.2!important;flex-shrink:1!important;}',
        'text-decoration:none!important;flex-wrap:wrap!important;max-width:calc(100vw - 80px)!important;}' +
      '.branding-box a::before{content:"";display:inline-block;width:26px;height:26px;background:url("/favicon.png") center/contain no-repeat;margin-right:8px;flex-shrink:0;}',
      '.branding-box a::before{content:"";display:block;width:30px;height:30px;flex-shrink:0;' +
       '.branding-box a::after{content:"A Digital Archive of Dvaita Vedanta Literature";display:block;flex-basis:100%;font-size:10px;color:rgba(255,255,255,0.82);font-family:sans-serif;width:100%;margin-top:1px;padding-left:34px;}',
        'background:url("/favicon.png") center/contain no-repeat;' +
        'margin-right:8px;}' +
       '.branding-box a span{color:#fff!important;font-size:16px!important;font-weight:700!important;' +
        'font-family:system-ui,sans-serif!important;line-height:1.2!important;' +
        'flex:1 1 auto!important;min-width:0!important;}' +
       '.branding-box a::after{content:"A Digital Archive of Dvaita Vedanta Literature";' +
        'display:block;width:100%;flex-basis:100%;' +
        'padding-left:38px;' +
        'font-size:10px;font-weight:400;color:rgba(255,255,255,0.82);font-family:sans-serif;margin-top:1px;}' +


       /* Hamburger icon white */
       /* Header icons white */
       '.navigation-drawer .toggle-list__toggle,.minerva-header label[for="main-menu-input"]{color:#fff!important;}',
       '.minerva-header svg path,.minerva-header svg rect,.minerva-header svg circle{fill:#fff!important;}' +
       '.minerva-header svg path,.minerva-header svg rect,.minerva-header svg circle{fill:#fff!important;}',
       '.minerva-header label{color:#fff!important;}' +


       /* Hide the page/discussion tabs bar */
       /* Hide Page/Discussion tabs + icon toolbar */
       '.page-actions-menu,.minerva-tabs,.minerva-page-actions,.post-content .page-actions,',
       '.minerva-tabs,.mw-portlet-associated-pages,.page-actions-menu,' +
      '#page-secondary-actions,.last-modified-bar,.minerva-overflow-button,',
        '#page-secondary-actions,.last-modified-bar,.minerva-anon-talk-link{display:none!important;}' +
      '.toolbar,.page-actions,.mw-portlet-views,.minerva-anon-talk-link{display:none!important;}',


       /* Hide the icon bar (translate, watchlist, history, edit, more) */
       /* Drawer: hide default items, show ours */
      '.page-actions-menu{display:none!important;}',
       '#mw-mf-page-left{display:none!important;}' +
      '.minerva-user-links{display:none!important;}',
       '#gr-mob-menu-items{display:block!important;}' +
      /* Hide ALL default drawer content — exact from HTML */
       '#mw-mf-page-left{display:none!important;}',
       '#gr-mob-extra-links{display:block!important;}',
      /* Hide Minerva footer: About/Disclaimers/Privacy */
      '.mw-footer.minerva-footer,#footer-places,.footer-places,.footer-info,.minerva-footer-logo{display:none!important;}',
      '#footer-places-about,#footer-places-disclaimers,#footer-places-privacy{display:none!important;}',


       /* ReaderToolbar sticky below header */
       /* Drawer footer: hide About/Disclaimers */
       '#gr-static-bar{position:sticky!important;top:56px!important;z-index:200!important;order:0!important;}',
       '.mw-footer.minerva-footer,.footer-places,.footer-info,' +
        '.minerva-footer-logo,#footer-places-about,' +
        '#footer-places-disclaimers,#footer-places-privacy{display:none!important;}' +


       /* Expand sections — CSS backup for hidden attribute */
       /* ReaderToolbar below header */
       '[hidden="until-found"],[hidden]{',
       '#gr-static-bar{position:sticky!important;top:54px!important;z-index:200!important;}' +
      '  content-visibility:visible!important;',
      '}',
      '.mf-section-0,.mf-section-1,.mf-section-2,.mf-section-3,.mf-section-4,',
      '.mf-section-5,.mf-section-6,.mf-section-7,.mf-section-8,.mf-section-9,',
      '.mf-section-10,.collapsible-block{display:block!important;visibility:visible!important;}',
      '.section-heading .indicator,.collapsible-heading .indicator{display:none!important;}',
      '.section-heading,.collapsible-heading{pointer-events:none!important;}',


       /* Home page — no x-scroll, single column cards */
       /* Sections expanded */
       '.gr-home,body,#mw-mf-page-center{overflow-x:hidden!important;max-width:100vw!important;}',
       '.mf-section-0,.mf-section-1,.mf-section-2,.mf-section-3,.mf-section-4,' +
      '.gr-home-grid{flex-direction:column!important;flex-wrap:nowrap!important;gap:12px!important;width:100%!important;overflow-x:hidden!important;}',
        '.mf-section-5,.mf-section-6,.mf-section-7,.mf-section-8,.mf-section-9,' +
       '.gr-home-card{width:100%!important;max-width:100%!important;min-width:unset!important;box-sizing:border-box!important;flex:none!important;}',
        '.mf-section-10{display:block!important;visibility:visible!important;}' +
      '.collapsible-block{display:block!important;}' +
       '.section-heading .indicator,.collapsible-heading .indicator{display:none!important;}' +
      '.section-heading,.collapsible-heading{pointer-events:none!important;}' +


       /* Content font */
      /* Home grid single column */
       '.mw-parser-output{font-size:18px!important;line-height:1.8!important;}',
      '.gr-home-grid{flex-direction:column!important;flex-wrap:nowrap!important;' +
       '.mw-parser-output h2,.mw-parser-output .mw-heading2 h2{width:100%!important;}',
        'gap:12px!important;width:100%!important;}' +
       '.mw-parser-output h3,.mw-parser-output .mw-heading3 h3{width:100%!important;}',
      '.gr-home-card{width:100%!important;max-width:100%!important;' +
    ].join('');
        'min-width:unset!important;box-sizing:border-box!important;flex:none!important;}' +
     document.head.appendChild(s);
      '.gr-home-toggle{flex-wrap:wrap!important;}' +
 
       /* Content */
       '.mw-parser-output{font-size:18px!important;line-height:1.8!important;}' +
       '.mw-parser-output h2,.mw-parser-output h3{width:100%!important;}' +
       '.bhashyam-block{margin-left:8px!important;}' +
      '#footer,.mw-footer,.catlinks,#catlinks{display:none!important;}' +
 
      /* TOC overlay */
      '.gr-mob-toc-panel{position:fixed!important;top:0!important;left:0!important;' +
        'bottom:0!important;width:82vw!important;max-width:340px!important;' +
        'background:#fff!important;z-index:10400!important;' +
        'box-shadow:4px 0 28px rgba(0,0,0,0.22)!important;overflow-y:auto!important;' +
        'padding:0 0 40px!important;transform:translateX(-110%)!important;' +
        'transition:transform 0.26s cubic-bezier(0.4,0,0.2,1)!important;display:block!important;}' +
      '.gr-mob-toc-panel.open{transform:translateX(0)!important;}' +
      '.gr-mob-toc-backdrop{display:none!important;position:fixed!important;inset:0!important;' +
        'background:rgba(0,0,0,0.4)!important;z-index:10399!important;}' +
      '.gr-mob-toc-backdrop.open{display:block!important;}' +
      '.gr-mob-toc-header{position:sticky!important;top:0!important;background:#fff!important;' +
        'display:flex!important;align-items:center!important;justify-content:space-between!important;' +
        'padding:16px 16px 12px!important;border-bottom:1px solid #f0ebe6!important;z-index:1!important;}' +
      '.gr-mob-toc-title{font-size:13px!important;font-weight:700!important;text-transform:uppercase!important;' +
        'letter-spacing:0.08em!important;color:#b5451b!important;font-family:system-ui,sans-serif!important;}' +
      '.gr-mob-toc-close{background:none!important;border:none!important;' +
        'font-size:22px!important;color:#999!important;cursor:pointer!important;padding:4px 8px!important;}' +
      '.gr-mob-toc-body{padding:12px 16px!important;}' +
      '.gr-mob-toc-body a{display:block!important;font-size:16px!important;line-height:1.6!important;' +
        'color:#2c1810!important;text-decoration:none!important;padding:8px 0!important;' +
        'border-bottom:1px solid #f5f0ed!important;}';
     document.head.appendChild( s );
   }
   }


   /* ── 2. Remove hidden attribute from sections ── */
   /* ── 2. Expand hidden sections ── */
   function expandSections() {
   function expandSections() {
     document.querySelectorAll(
     document.querySelectorAll( '[class*="mf-section-"], .collapsible-block' )
      '[class*="mf-section-"], .collapsible-block'
      .forEach( function ( el ) {
    ).forEach(function(el) {
        el.removeAttribute( 'hidden' );
      el.removeAttribute('hidden');
        el.style.setProperty( 'display', 'block', 'important' );
      el.style.setProperty('display', 'block', 'important');
        el.style.setProperty( 'visibility', 'visible', 'important' );
      el.style.setProperty('visibility', 'visible', 'important');
        el.removeAttribute( 'aria-hidden' );
      el.removeAttribute('aria-hidden');
      } );
    });
     document.querySelectorAll( '.section-heading, .collapsible-heading' )
     document.querySelectorAll('.section-heading, .collapsible-heading').forEach(function(el) {
      .forEach( function ( el ) {
      el.setAttribute('aria-expanded', 'true');
        el.setAttribute( 'aria-expanded', 'true' );
      el.style.setProperty('pointer-events', 'none', 'important');
        el.style.setProperty( 'pointer-events', 'none', 'important' );
    });
      } );
   }
   }


   /* Persistent observer — MF re-adds hidden after we remove it */
   /* Persistent observer — fight MF re-collapsing */
   function watchAndExpand() {
   function watchSections() {
     var timer = null;
     var t = null;
     var obs = new MutationObserver(function(mutations) {
     var obs = new MutationObserver( function ( ms ) {
       var need = mutations.some(function(m) {
       if ( ms.some( function(m){ return m.attributeName === 'hidden'; } ) ) {
        return m.type === 'attributes' &&
         clearTimeout(t); t = setTimeout( expandSections, 30 );
          (m.attributeName === 'hidden' || m.attributeName === 'aria-hidden');
      });
      if (need) {
         clearTimeout(timer);
        timer = setTimeout(expandSections, 30);
       }
       }
     });
     } );
     var root = document.querySelector('#mw-content-text, #mw-mf-page-center, body');
     var root = document.querySelector( '#mw-content-text' ) || document.body;
     if (root) obs.observe(root, {subtree:true, attributes:true, attributeFilter:['hidden','aria-hidden','style']});
     obs.observe( root, { subtree:true, attributes:true, attributeFilter:['hidden','aria-hidden'] } );
   }
   }


   /* ── 3. Body padding observer ── */
   /* ── 3. Body padding observer ── */
   function watchBodyPadding() {
   function watchBodyPadding() {
     var obs = new MutationObserver(function() {
     new MutationObserver( function () {
       if (document.body.style.paddingTop && document.body.style.paddingTop !== '0px') {
       if ( document.body.style.paddingTop && document.body.style.paddingTop !== '0px' ) {
         document.body.style.paddingTop = '';
         document.body.style.paddingTop = '';
       }
       }
     });
     } ).observe( document.body, { attributes:true, attributeFilter:['style'] } );
    obs.observe(document.body, {attributes:true, attributeFilter:['style']});
   }
   }


   /* ── 4. Hide Minerva page toolbar elements via JS ── */
   /* ── 4. Inject custom links into drawer ── */
   function hideMinervaChrome() {
   function injectMenuLinks() {
     var selectors = [
     /* Already injected */
      /* Page/Discussion tabs */
    if ( document.getElementById( 'gr-mob-menu-items' ) ) return;
      '.minerva-tabs', '.page-actions-menu', '.page-actions',
      '.post-content > .page-actions',
      /* Icon toolbar (translate, watchlist, history, edit, more) */
      '#page-secondary-actions', '.toolbar',
      /* Last modified bar */
      '.last-modified-bar',
      /* Anon talk link */
      '.minerva-anon-talk-link',
      /* User notifications in header */
      '.minerva-user-notifications',
      /* Overflow menu */
      '.minerva-overflow-button',
      /* Page info footer */
      '.post-content .page-actions',
    ];
    selectors.forEach(function(sel) {
      document.querySelectorAll(sel).forEach(function(el) {
        el.style.setProperty('display', 'none', 'important');
      });
    });
  }


  /* ── 5. Hamburger menu: replace default items with custom ones ── */
    /* The drawer container is .navigation-drawer (the <nav> element)
  function setupHamburgerMenu() {
       Our links go AFTER the #mw-mf-page-left div (which we hide via CSS) */
    /* Minerva lazy-renders the drawer on first open.
     var navDrawer = document.querySelector( '.navigation-drawer' );
       We hook the checkbox that opens it. */
     if ( !navDrawer ) return;
     var checkbox = document.getElementById('main-menu-input');
     if (!checkbox) return;


     function patchDrawer() {
     var wrap = document.createElement( 'div' );
      /* Actual drawer list container from HTML: #mw-mf-page-left */
    wrap.id = 'gr-mob-menu-items';
      var pageLeft = document.getElementById('mw-mf-page-left');
    wrap.style.cssText = 'width:100%;background:#fff;margin-top:8px;';
      if ( pageLeft && !pageLeft.querySelector('#gr-mob-extra-links') ) {
        pageLeft.style.setProperty('display', 'none', 'important');
      }


      /* Find the navigation-drawer nav element to append to */
    var itemStyle = 'display:flex;align-items:center;gap:14px;padding:15px 20px;' +
      var drawer = document.querySelector('.navigation-drawer');
       'font-size:16px;color:#2c1810;text-decoration:none;' +
       if (!drawer) return;
       'font-family:system-ui,sans-serif;border-bottom:1px solid #f0ebe6;background:#fff;';
       if (drawer.querySelector('#gr-mob-extra-links')) return;


      /* Hide footer: About/Disclaimers */
    function makeItem( href, emoji, label ) {
       document.querySelectorAll(
       var a = document.createElement( 'a' );
        '.mw-footer.minerva-footer, .footer-places, .footer-info, ' +
      a.href = href;
         '.minerva-footer-logo, #footer-places-about, ' +
      a.style.cssText = itemStyle;
        '#footer-places-disclaimers, #footer-places-privacy'
      a.innerHTML =
      ).forEach(function(el) {
         '<span style="font-size:20px;width:28px;text-align:center;flex-shrink:0">' + emoji + '</span>' +
         el.style.setProperty('display', 'none', 'important');
         '<span>' + label + '</span>';
       });
       return a;
    }


      /* Build clean custom menu */
    wrap.appendChild( makeItem( '/Main_Page', '🏠', 'Home' ) );
      var nav = document.createElement('div');
    wrap.appendChild( makeItem( '/Help:Contents', '', 'Help' ) );
      nav.id = 'gr-mob-extra-links';
    wrap.appendChild( makeItem( '/My_wiki:About', 'ℹ️', 'About' ) );
      nav.style.cssText = 'width:100%;background:#fff;';


      var ls = 'display:flex;align-items:center;gap:14px;padding:15px 20px;' +
    var userName = window.mw ? mw.config.get( 'wgUserName' ) : null;
              'font-size:16px;color:#2c1810;text-decoration:none;' +
    if ( userName ) {
              'font-family:system-ui,sans-serif;border-bottom:1px solid #f0ebe6;';
      var la = document.querySelector( 'a[href*="action=logout"]' );
 
      wrap.appendChild( makeItem(
      function item(href, emoji, label) {
         la ? la.href : '/index.php?title=Special:UserLogout', '', 'Log out'
        var a = document.createElement('a');
      ) );
        a.href = href; a.style.cssText = ls;
    } else {
         a.innerHTML = '<span style="font-size:20px;width:28px;text-align:center;flex-shrink:0">'
      wrap.appendChild( makeItem( '/index.php?title=Special:UserLogin', '→', 'Log in' ) );
          + emoji + '</span><span>' + label + '</span>';
    }
        a.onclick = function() {
          var cb = document.getElementById('main-menu-input');
          if (cb) cb.checked = false;
        };
        return a;
      }


      nav.appendChild( item('/', '🏠', 'Home') );
    /* Insert after the hidden #mw-mf-page-left */
      nav.appendChild( item('/Help:Contents', '❓', 'Help') );
    var pageLeft = document.getElementById( 'mw-mf-page-left' );
      nav.appendChild( item('/My_wiki:About', 'ℹ️', 'About') );
    if ( pageLeft && pageLeft.parentNode === navDrawer ) {
 
      navDrawer.insertBefore( wrap, pageLeft.nextSibling );
      var userName = window.mw ? mw.config.get('wgUserName') : null;
    } else {
      if (userName) {
       /* Fallback: append to drawer toggle container */
        var la = document.querySelector('a[href*="action=logout"]');
       var toggleContainer = navDrawer.querySelector( '.toggle-list' ) || navDrawer;
        nav.appendChild( item(la ? la.href : '/index.php?title=Special:UserLogout', '↩', 'Log out') );
      toggleContainer.appendChild( wrap );
      } else {
        nav.appendChild( item('/index.php?title=Special:UserLogin', '→', 'Log in') );
      }
 
      drawer.appendChild(nav);
      /* Also hide page-left in case it re-appeared */
      var pl = document.getElementById('mw-mf-page-left');
      if (pl) pl.style.setProperty('display','none','important');
 
       /* Hide About/Disclaimers that appear BELOW the drawer nav */
       setTimeout(function() {
        document.querySelectorAll(
          '.navigation-drawer .mw-portlet-footer, ' +
          '.navigation-drawer .footer, ' +
          'nav.navigation-drawer ~ footer, ' +
          '.navigation-drawer p, ' +
          '.navigation-drawer .menu__item--about, ' +
          '.navigation-drawer .menu__item--disclaimers'
        ).forEach(function(el) {
          el.style.setProperty('display', 'none', 'important');
        });
      }, 100);
     }
     }


     /* Patch immediately if drawer already exists */
     /* Hide footer portlets */
     patchDrawer();
     document.querySelectorAll(
 
      '.mw-footer.minerva-footer,.footer-places,.footer-info,' +
    /* Also patch when drawer opens */
      '.minerva-footer-logo,#footer-places-about,' +
     checkbox.addEventListener('change', function() {
      '#footer-places-disclaimers,#footer-places-privacy'
      if (checkbox.checked) setTimeout(patchDrawer, 50);
     ).forEach( function(el) { el.style.setProperty('display','none','important'); } );
    });
   }
   }


   /* ── 6. Mobile TOC overlay (Contents button) ── */
   /* ── 5. Mobile TOC overlay ── */
   var _tocInit = false;
   var _tocDone = false;
   function initMobileToc() {
   function initToc() {
     if (_tocInit) return;
     if ( _tocDone ) return;
     var tocList = document.querySelector('.vector-toc-contents, .vector-toc .vector-toc-list');
     var tocList = document.querySelector( '.vector-toc-contents, .vector-toc .vector-toc-list' );
     if (!tocList) return;
     if ( !tocList ) return;
     _tocInit = true;
     if ( !tocList.querySelector( 'li' ) ) return;
    _tocDone = true;


     var bd = document.createElement('div');
     var bd = document.createElement( 'div' );
     bd.className = 'gr-mob-toc-backdrop';
     bd.className = 'gr-mob-toc-backdrop';
     document.body.appendChild(bd);
     document.body.appendChild( bd );


     var panel = document.createElement('div');
     var panel = document.createElement( 'div' );
     panel.className = 'gr-mob-toc-panel';
     panel.className = 'gr-mob-toc-panel';


     var hdr = document.createElement('div');
     var hdr = document.createElement( 'div' );
     hdr.className = 'gr-mob-toc-header';
     hdr.className = 'gr-mob-toc-header';
     var ttl = document.createElement('div');
     var ttl = document.createElement( 'div' );
     ttl.className = 'gr-mob-toc-title';
     ttl.className = 'gr-mob-toc-title';
     ttl.textContent = 'विषयसूची';
     ttl.textContent = 'विषयसूची';
     var cls = document.createElement('button');
     var cls = document.createElement( 'button' );
     cls.className = 'gr-mob-toc-close';
     cls.className = 'gr-mob-toc-close';
     cls.textContent = '✕';
     cls.textContent = '✕';
     hdr.appendChild(ttl); hdr.appendChild(cls);
     hdr.appendChild( ttl ); hdr.appendChild( cls );
     panel.appendChild(hdr);
     panel.appendChild( hdr );


     var body = document.createElement('div');
     var body = document.createElement( 'div' );
     body.className = 'gr-mob-toc-body';
     body.className = 'gr-mob-toc-body';
     body.appendChild(tocList.cloneNode(true));
     body.appendChild( tocList.cloneNode( true ) );
     panel.appendChild(body);
     panel.appendChild( body );
     document.body.appendChild(panel);
     document.body.appendChild( panel );


    /* TOC button — only on pages with headings */
     var btn = document.createElement( 'button' );
    var hasItems = tocList.querySelector('li,a');
     var btn = document.createElement('button');
    btn.className = 'gr-mob-toc-btn';
     btn.id = 'gr-mob-toc-btn';
     btn.id = 'gr-mob-toc-btn';
     btn.innerHTML = '☰ &nbsp;Contents';
     btn.innerHTML = '☰ &nbsp;Contents';
     if (!hasItems) btn.style.display = 'none';
     btn.style.cssText = 'position:fixed;bottom:148px;left:16px;z-index:9100;' +
     document.body.appendChild(btn);
      'background:#fff;border:1.5px solid #b5451b;border-radius:24px;' +
      'padding:10px 16px;font-size:15px;font-family:system-ui,sans-serif;' +
      'color:#b5451b;font-weight:600;box-shadow:0 3px 14px rgba(0,0,0,0.15);cursor:pointer;';
     document.body.appendChild( btn );


     function open()  { panel.classList.add('open'); bd.classList.add('open'); document.body.style.overflow='hidden'; }
     function open()  { panel.classList.add('open'); bd.classList.add('open'); document.body.style.overflow='hidden'; }
     function close() { panel.classList.remove('open'); bd.classList.remove('open'); document.body.style.overflow=''; }
     function close() { panel.classList.remove('open'); bd.classList.remove('open'); document.body.style.overflow=''; }


     btn.addEventListener('click', open);
     btn.onclick = open; cls.onclick = close; bd.onclick = close;
    cls.addEventListener('click', close);
     body.querySelectorAll('a').forEach(function(a){ a.onclick = close; });
    bd.addEventListener('click', close);
     body.querySelectorAll('a').forEach(function(a){ a.addEventListener('click', close); });
   }
   }


   /* ── Boot ── */
   /* ── Boot ── */
   injectMinervaCSS();
   injectCSS();
   watchBodyPadding();
   watchBodyPadding();


   function onReady() {
   function boot() {
     expandSections();
     expandSections();
     watchAndExpand();
     watchSections();
     hideMinervaChrome();
     injectMenuLinks();
 
     [100, 400, 900, 1800].forEach(function(ms){ setTimeout(expandSections, ms); });
    /* Retry expand multiple times to fight MF */
     setTimeout(initToc, 700);
     [100, 300, 700, 1500].forEach(function(ms) {
      setTimeout(expandSections, ms);
    });
 
    /* Setup hamburger with delay for Minerva drawer to render */
    setTimeout(setupHamburgerMenu, 800);
     setTimeout(initMobileToc, 600);
   }
   }


   if (document.readyState === 'loading') {
   if ( document.readyState === 'loading' ) {
     document.addEventListener('DOMContentLoaded', onReady);
     document.addEventListener( 'DOMContentLoaded', boot );
   } else {
   } else {
     onReady();
     boot();
   }
   }


   if (window.mw) {
   if ( window.mw ) {
     mw.hook('wikipage.content').add(function() {
     mw.hook( 'wikipage.content' ).add(function() {
       setTimeout(function() {
       setTimeout(function(){ expandSections(); injectMenuLinks(); initToc(); }, 300);
        expandSections();
        hideMinervaChrome();
        setupHamburgerMenu();
        initMobileToc();
      }, 200);
     });
     });
   }
   }


}() );
}() );