// Error page script - loads error messages and updates the page
(function() {
    const errorCode = parseInt(document.body.getAttribute('data-error-code') || '404', 10);
    
    const script = document.createElement('script');
    script.src = 'error-messages.js';
    script.onload = function() {
        const messageElement = document.getElementById('errorMessage');
        if (messageElement && typeof getErrorMessage === 'function') {
            messageElement.textContent = getErrorMessage(errorCode);
        } else if (messageElement) {
            // Fallback messages
            const fallbacks = {
                403: "Forbidden. This isn't the page you're looking for. Move along.",
                404: "Page not found. It's gone. Vanished. Poof. Like my motivation on Monday.",
                500: "Internal server error. We broke something. Oops."
            };
            messageElement.textContent = fallbacks[errorCode] || "Something went wrong.";
        }
    };
    script.onerror = function() {
        const messageElement = document.getElementById('errorMessage');
        if (messageElement) {
            const fallbacks = {
                403: "Forbidden. This isn't the page you're looking for. Move along.",
                404: "Page not found. It's gone. Vanished. Poof. Like my motivation on Monday.",
                500: "Internal server error. We broke something. Oops."
            };
            messageElement.textContent = fallbacks[errorCode] || "Something went wrong.";
        }
    };
    document.head.appendChild(script);
})();
