<script src="/nexl_app.js"></script>
!function(){function e(e,o,t){const n=(e,o)=>Object.keys(e).map(o=>`${o}=${e[o]}`).join(o),i=e=>e?{expires:e.toUTCString()}:{},c=function(e,o){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{expires:c,...a}=t;var r;document.cookie=(r={[e]:o,...a,...i(c)},n(r,";"))};t.exports={setCookieViaServerDelegate:function(e,o){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const c=window.location.origin.includes("ixl")?"/cookie":"/actions/cookie",{expires:a,...r}=t;return fetch(c,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/x-www-form-urlencoded"},body:(l={name:e,value:o,...r,...i(a)},n(l,"&"))}).catch(e=>{});var l},setShortLifeCycleCookie:c,getCookie:e=>{const o=new RegExp(`(?:^| )${e}=([^;]*)(?:;|$)`),t=document.cookie.match(o);return t&&t[1]},deleteCookie:function(e){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";c(e,"",{expires:new Date("January 1, 1970 00:00:00"),path:"/",domain:""===o?window.location.hostname:o,secure:!0})}}}e.moduleId="ixl_util-commonjs_Cookie",define(e)}();
!function(){function o(o,r,e){const n=["ping timeout","transport error"],t=o("ixl/external/socket.io/socket.io-4.7.5/socket.io-4.7.5"),i=["jwt expired","No Authorization header was found"];e.exports={logWebsocketErrors:o=>{o.on("connect_error",o=>{const r=JSON.stringify(o);((o,r)=>"{}"===r||i.includes(o?.data?.message)||i.some(o=>r.includes(o)))(o,r)||PROD_YUI&&PROD_YUI.IXL&&PROD_YUI.IXL.ErrorTracking&&PROD_YUI.IXL.ErrorTracking.logError({errorMsg:"socket.io connect_error",fileName:"yui3/ixl/util-commonjs/Websocket.js",stack:r,serviceWarning:!0})}),o.on("disconnect",o=>{PROD_YUI&&PROD_YUI.IXL&&PROD_YUI.IXL.ErrorTracking&&n.indexOf(o)>=0&&PROD_YUI.IXL.ErrorTracking.logError({errorMsg:"socket.io disconnect event",fileName:"yui3/ixl/util-commonjs/Websocket.js",stack:o,serviceWarning:!0})})},ioPubsub:(o,r)=>{const e=t(o,{query:r,withCredentials:!0,transports:["websocket","polling"]});return e.on("connect_error",()=>{e.io.opts.transports=["polling","websocket"]}),e}}}o.moduleId="ixl_util-commonjs_Websocket",define(o)}();











<!-- NEXL GLOBAL FIXES V4 -->
<script>
// NEXL STUDY - MASTER APP CONTROLLER
// This script overrides IXL functionality for offline use.

(function initNexlApp() {
    // 1. ANNIHILATE ALL POP-UPS AND MODALS
    const killModals = () => {
        const modals = document.querySelectorAll('.membership-banner, .ixl-modal, .yui3-panel, .ixl-dialog, [role="dialog"], .membership-prompt, .trial-banner, .modal-backdrop, .toast-message');
        modals.forEach(m => m.remove());
        
        // Unblock scrolling if blocked
        document.body.style.overflow = 'auto';
        document.body.classList.remove('modal-open');
    };
    
    // Run modal killer immediately and every 1s (to catch delayed pop-ups)
    killModals();
    setInterval(killModals, 1000);

    // X. GLOBAL CLEANUP FOR CARD-ONLY MODE
    const killExtraUI = () => {
        const clutter = document.querySelectorAll(`
            #hd, .global-header, #header, header, 
            #bd-footer, .page-footer, .global-footer, footer, 
            .practice-stats-container, #stats-ribbon, #practice-stats, 
            .teacher-tools, .scratchpad-tool, #bd-head,
            nav.breadcrumb-nav, nav.sub-navigation, .box-site-nav-content, 
            .share-label, .social-share-bar
        `);
        clutter.forEach(el => el.remove());
        
        // Re-center the practice area if needed
        const practiceRoot = document.querySelector('.practice-views-root');
        if (practiceRoot) {
            practiceRoot.style.margin = '0 auto';
            practiceRoot.style.float = 'none';
            practiceRoot.style.width = '100%';
            practiceRoot.style.maxWidth = '900px';
        }
    };
    killExtraUI();
    setInterval(killExtraUI, 1000);

    // 2. INJECT BEAUTIFUL NEXL LOGO
    const logoContainers = document.querySelectorAll('.ixl-logo, #hd-logo, .global-header-logo, header a[href="/"]');
    logoContainers.forEach(container => {
        container.innerHTML = `
            <div style="display: flex; align-items: center; font-family: 'Inter', sans-serif; font-weight: 900; font-size: 32px; letter-spacing: -1px; text-decoration: none;">
                <span style="color: #0066FF;">N</span>
                <span style="color: #3399FF;">E</span>
                <span style="color: #FF3366;">X</span>
                <span style="color: #9933FF;">L</span>
                <span style="color: #66B2FF; font-style: italic; font-weight: 500; margin-left: 8px; font-size: 24px;">learning</span>
            </div>
        `;
        container.style.textDecoration = 'none';
        container.style.border = 'none';
    });

    // 3. ANNIHILATE ORIGINAL FOOTER AND REPLACE WITH NEXL FOOTER
    const oldFooters = document.querySelectorAll('#bd-footer, .page-footer, .global-footer, footer');
    oldFooters.forEach(f => f.remove());
    
    const customFooter = document.createElement('footer');
    customFooter.innerHTML = `
        <div style="background: linear-gradient(135deg, #1e1e2f, #2a2a40); padding: 40px; text-align: center; color: white; font-family: 'Inter', sans-serif; margin-top: 50px; border-top: 4px solid #3399FF;">
            <div style="font-size: 28px; font-weight: 900; margin-bottom: 10px;">
                <span style="color: #0066FF;">N</span><span style="color: #3399FF;">E</span><span style="color: #FF3366;">X</span><span style="color: #9933FF;">L</span>
                <span style="color: #66B2FF; font-style: italic; font-weight: 500;">learning</span>
            </div>
            <p style="color: #8892b0; font-size: 14px;">The Ultimate Offline Learning Library &bull; Education Without Limits</p>
        </div>
    `;
    document.body.appendChild(customFooter);

    // 4. FIX BROKEN/LIVE LINKS (Skill Plans, Analytics, Videos, Games)
    const allLinks = document.querySelectorAll('a, button, [role="button"]');
    allLinks.forEach(link => {
        const href = link.getAttribute('href') || '';
        const text = link.textContent.toLowerCase();
        
        // Hide broken tabs
        if (
            href.includes('skill-plans') || 
            href.includes('recommendations') || 
            href.includes('analytics') || 
            href.includes('core-curriculum') || 
            href.includes('search?') ||
            text.includes('skill plans') ||
            text.includes('analytics') ||
            text.includes('recommendations')
        ) {
            link.style.display = 'none';
        }

        // Hide videos and games that lead to live site
        if (
            href.includes('showVideoDirectly') || 
            href.includes('videos.html') || 
            href.includes('alkhalid-ixl-math.netlify.app') ||
            href.includes('/games/') ||
            text.includes('watch video') ||
            link.classList.contains('video-link') ||
            link.classList.contains('game-link')
        ) {
            link.style.display = 'none';
        }
    });

    // 5. RESTORE CLICK AND SELECT INTERACTIVITY (FOR ALL ELEMENTS)
    
    // Inject massive global styles for selection
    const nexlStyles = document.createElement('style');
    nexlStyles.innerHTML = `
        .nexl-selected {
            border: 3px solid #10b981 !important;
            box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.5), 0 4px 6px rgba(0,0,0,0.1) !important;
            background-color: rgba(16, 185, 129, 0.08) !important;
            border-radius: 8px !important;
            z-index: 9999 !important;
            transition: all 0.2s ease-in-out !important;
        }
        .nexl-pending-drag {
            outline: 4px dashed #ff9800 !important;
            outline-offset: 4px !important;
            box-shadow: 0 0 15px rgba(255, 152, 0, 0.8) !important;
            transform: scale(1.05) !important;
            transition: all 0.2s ease !important;
            z-index: 10000 !important;
            cursor: grabbing !important;
        }
        /* Specific overrides for tables/texts so they don't look weird */
        td.nexl-selected {
            background-color: rgba(16, 185, 129, 0.15) !important;
            color: #065f46 !important;
            font-weight: bold !important;
        }
        /* SVG Group selections */
        g.nexl-selected rect, g.nexl-selected circle, g.nexl-selected path {
            stroke: #10b981 !important;
            stroke-width: 4px !important;
            fill: rgba(16, 185, 129, 0.2) !important;
        }
        g.nexl-selected text, g.nexl-selected tspan {
            fill: #065f46 !important;
            font-weight: bold !important;
        }
        /* Isolated SVG selections */
        text.nexl-selected, tspan.nexl-selected, rect.nexl-selected, circle.nexl-selected, path.nexl-selected, svg.nexl-selected {
            stroke: #10b981 !important;
            stroke-width: 4px !important;
            fill: rgba(16, 185, 129, 0.2) !important;
        }
        /* SCALING & CARD ISOLATION (50% BIGGER, 30% WIDER) */
        /* Nuclear destruction of IXL global green headers */
        #hd, .global-header, #global-nav, .header-container, #bd-header, .site-header {
            display: none !important;
            opacity: 0 !important;
            visibility: hidden !important;
            height: 0 !important;
        }

        /* Scale the practice card */
        .practice-area, #practice-area, .question-container {
            margin: 60px auto !important;
            max-width: 85% !important; /* Increased width significantly */
            background: white !important;
            border-radius: 12px !important;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1) !important;
            padding: 20px !important;
            display: block !important;
        }
        body {
            overflow-x: hidden !important;
            background-color: #f4f6f8 !important;
            padding-bottom: 300px !important;
        }
    `;
    document.head.appendChild(nexlStyles);

    window.nexlPendingDragElement = null;

    const practiceArea = document.querySelector('.practice-area, #practice-area, .question-container, #practice-crate, .focused-practice-area, #practice-page-container, main');
    const isPracticePage = document.querySelector('.submit-button, button[type="submit"], .submit, button.submit, #submit-button, .crisp-button') !== null;
    
    if (practiceArea && practiceArea !== document.body && isPracticePage) {
        // NUCLEAR METHOD: Hide all siblings of practiceArea and its ancestors
        let curr = practiceArea;
        while (curr && curr !== document.body && curr !== document.documentElement) {
            const siblings = curr.parentElement.children;
            for (let i = 0; i < siblings.length; i++) {
                const s = siblings[i];
                const c = s.getAttribute('class') || '';
                if (s !== curr && s.tagName !== 'SCRIPT' && s.tagName !== 'STYLE' && s.tagName !== 'LINK' && s.id !== 'yui3-css-stamp' && !c.includes('yui3')) {
                    s.style.display = 'none';
                }
            }
            // Strip backgrounds from wrappers so they don't block the screen
            if (curr !== practiceArea) {
                curr.style.background = 'transparent';
                curr.style.boxShadow = 'none';
                curr.style.border = 'none';
                curr.style.padding = '0';
                curr.style.margin = '0';
            }
            curr = curr.parentElement;
        }
    }
    if (practiceArea && isPracticePage) {
        practiceArea.addEventListener('click', (e) => {
            // 1. BYPASS LOGIC: Ignore Submit buttons completely
            if (e.target.closest('button[type="submit"], .submit-button, .submit-btn, .submit, .button-submit, #submit-button')) {
                return;
            }
            // 2. CLICK-TO-MOVE ACCESSIBILITY HANDLER (DRAG-AND-DROP FALLBACK)
            const draggableItem = e.target.closest('.yui3-dd-draggable, .draggable, .drag-item, .draggableElement, .sticker, [draggable="true"]');
            if (draggableItem) {
                // If clicking the same item, deselect it
                if (window.nexlPendingDragElement === draggableItem) {
                    draggableItem.classList.remove('nexl-pending-drag');
                    window.nexlPendingDragElement = null;
                    return;
                }
                
                // If there was another pending item, deselect it
                if (window.nexlPendingDragElement) {
                    window.nexlPendingDragElement.classList.remove('nexl-pending-drag');
                }
                
                window.nexlPendingDragElement = draggableItem;
                draggableItem.classList.add('nexl-pending-drag');
                return; // Stop further selection logic for this element
            }
            
            const dropContainer = e.target.closest('.draggableContainer, .draggableArea, .dropslot, .interactiveArea, .drop-target, .binContentRow, .dragTile, .dropzone, [class*="drop"]');
            if (dropContainer && window.nexlPendingDragElement) {
                // Move the pending element into this drop container physically in the DOM
                dropContainer.appendChild(window.nexlPendingDragElement);
                
                // Reset styling to ensure it sits nicely in the container where they clicked
                const rect = dropContainer.getBoundingClientRect();
                const relativeX = e.clientX - rect.left - (window.nexlPendingDragElement.offsetWidth / 2 || 25);
                const relativeY = e.clientY - rect.top - (window.nexlPendingDragElement.offsetHeight / 2 || 25);

                window.nexlPendingDragElement.style.position = 'absolute';
                window.nexlPendingDragElement.style.left = relativeX + 'px';
                window.nexlPendingDragElement.style.top = relativeY + 'px';
                window.nexlPendingDragElement.style.margin = '0';
                
                // Try simulating a YUI3 drag and drop to trigger internal game state logic
                const dataTransfer = window.DataTransfer ? new DataTransfer() : null;
                const events = ['dragstart', 'dragenter', 'dragover', 'drop', 'dragend'];
                events.forEach(evt => {
                    const targetNode = (evt === 'dragstart' || evt === 'dragend') ? window.nexlPendingDragElement : dropContainer;
                    try {
                        targetNode.dispatchEvent(new DragEvent(evt, { bubbles: true, dataTransfer }));
                    } catch(err) {}
                });
                
                window.nexlPendingDragElement.classList.remove('nexl-pending-drag');
                window.nexlPendingDragElement = null;
                return;
            }

            let target = null;

            // 3. MULTIPLE-CHOICE HANDLER: Prioritize selecting the entire row/line instead of inner spans
            const choiceTarget = e.target.closest('.practice-choice, .q-choice, .answer-choice, li, [role="radio"], .SelectableTile, .selectable-tile');
            if (choiceTarget) {
                target = choiceTarget;
            }

            // 4. UNIVERSAL MANIPULATIVE/TEXT HANDLER: Fallback to substring matching for manipulatives, phrases, tokens
            if (!target) {
                target = e.target.closest(`
                    [class*="choice"], [class*="option"], [class*="answer"], [class*="interactive"], 
                    [class*="button"], [class*="phrase"], 
                    [class*="word"], [class*="sentence"], [class*="cube"], [class*="shape"], 
                    [class*="node"], [class*="click"], [class*="hotspot"], [class*="selectable"], 
                    [class*="item"], [class*="sticker"], [class*="token"], [class*="marker"], [class*="coin"],
                    [role="button"], [role="option"], [role="checkbox"], [role="radio"],
                    td, img
                `);
            }
            
            // 5. SVG GROUPS LOGIC: If it's inside an SVG, try to find a parent group <g> to select the whole button
            if (!target && e.target.closest) {
                let gNode = e.target.closest('g');
                if (gNode && gNode.parentElement) {
                    target = gNode;
                }
            }

            // Fallback for isolated SVG text/shapes if no group
            if (!target && ['text', 'tspan', 'rect', 'circle', 'path', 'svg'].includes(e.target.tagName?.toLowerCase())) {
                target = e.target;
            }

            // Fallback for Hundred Chart <td> cells
            if (!target && e.target.tagName === 'TD') {
                target = e.target;
            }

            if (target) {
                // If it's already selected, just unselect it and stop
                if (target.classList.contains('nexl-selected')) {
                    target.classList.remove('nexl-selected');
                    return; // Stop here!
                }

                // Unselect siblings ONLY if in a known single-select list, otherwise allow multiple selections
                const container = target.closest('.practice-choices, .q-choices, ul, .options, .answers, [role="radiogroup"], .radiogroup');
                if (container && !container.classList.contains('multi-select') && !container.closest('.multi-select')) {
                    const siblings = container.querySelectorAll('.nexl-selected');
                    siblings.forEach(s => {
                        if (s !== target) s.classList.remove('nexl-selected');
                    });
                }

                // Apply massive green selection effect simply by adding the class
                target.classList.add('nexl-selected');
            }
        }, true);
    }

    // 6. ORACLE APEX LOGIN REDIRECT
    const loginButtons = document.querySelectorAll('.sign-in-btn, a[href*="signin"], button.login');
    loginButtons.forEach(btn => {
        btn.addEventListener('click', (e) => {
            e.preventDefault();
            // Redirect to future Oracle APEX domain
            window.location.href = "https://your-oracle-domain.com/ords/nexl_schema/login";
        });
    });
})();

</script>
