<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Rewrited</title>
    <link rel="icon" href="https://i.ibb.co/179QYyj/circle-logo.png" type="image/png">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            background-color: #000;
            color: #fff;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            padding: 20px;
            overflow: hidden;
        }

        main {
            background-color: #111;
            padding: 30px;
            border-radius: 20px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
            max-width: 600px;
            width: 100%;
            position: relative;
            transition: all 0.5s ease;
        }

        h2 {
            text-align: center;
            margin-bottom: 20px;
            transition: transform 1s ease-out;
            position: relative;
        }

        .dev-mode {
            font-size: 14px;
            color: red;
            text-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
            position: absolute;
            top: 50px;
            left: 50%;
            transform: translateX(-50%);
            display: none;
            opacity: 0;
            animation: fadeIn 1s forwards, pulse 2s infinite alternate;
        }

        @keyframes pulse {
            0% {
                text-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
            }
            50% {
                text-shadow: 0 0 20px rgba(255, 0, 1, 1);
            }
            100% {
                text-shadow: 0 0 10px rgba(255, 0, 0, 0.8);
            }
        }

        @keyframes fadeIn {
            0% {
                opacity: 0;
            }
            100% {
                opacity: 1;
            }
        }

        .credit {
            position: absolute;
            bottom: 10px;
            right: 10px;
            font-size: 12px;
            color: #aaa;
            opacity: 1;
            transition: opacity 1s ease-out;
        }

        textarea {
            width: 100%;
            height: 150px;
            background-color: #222;
            color: #fff;
            border: none;
            border-radius: 20px;
            padding: 15px;
            resize: none;
            transition: box-shadow 0.3s ease;
        }

        textarea:focus {
            outline: none;
            box-shadow: 0 0 15px rgba(87, 202, 58, 0.8); /* Green glow on focus */
        }

        button {
            width: 100%;
            padding: 15px;
            margin-top: 20px;
            background-color: #4CAF50;
            color: #fff;
            border: none;
            border-radius: 30px;
            font-size: 16px;
            cursor: pointer;
            transition: background-color 0.3s ease, opacity 1s ease;
        }

        button:hover {
            background-color: #45a049;
        }

        button.purple {
            background-color: #800080;
            opacity: 0;
            animation: fadeInPurple 1s forwards;
        }

        @keyframes fadeInPurple {
            0% {
                opacity: 0;
            }
            100% {
                opacity: 1;
            }
        }

        #output {
            margin-top: 20px;
            background-color: #222;
            color: #fff;
            padding: 15px;
            border-radius: 20px;
            min-height: 100px;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            white-space: pre-wrap;
        }

        #secretButton {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 15px;
            height: 15px;
            background-color: #333;
            border: 2px solid #444;
            border-radius: 50%;
            cursor: pointer;
            opacity: 0.5;
            transition: opacity 0.3s, box-shadow 0.3s, transform 0.3s;
        }

        #secretButton:hover {
            opacity: 1;
            box-shadow: 0 0 8px rgba(0, 255, 0, 0.8);
            transform: scale(1.2);
        }

        #passwordPrompt {
            display: none;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #222;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
            opacity: 0;
            transition: opacity 0.5s ease, transform 0.5s ease;
        }

        #passwordPrompt.active {
            display: block;
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }

        #passwordPrompt input {
            width: 100%;
            padding: 10px;
            background-color: #111;
            color: #fff;
            border: 1px solid #333;
            border-radius: 5px;
        }

        #blackout {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: #000;
            display: none;
            animation: blackout 1s forwards;
        }

        @keyframes blackout {
            from {
                opacity: 0;
            }
            to {
                opacity: 1;
            }
        }

        #ownerMode {
            display: none;
            color: red;
            text-align: center;
            font-size: 40px;
            text-shadow: 0 0 10px rgba(255, 0, 0, 1);
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            animation: pulse 2s infinite alternate;
        }

        /* New styles for purple glow during blackout */
        .blackout-active:focus {
            box-shadow: 0 0 15px rgba(128, 0, 128, 0.8); /* Purple glow when focused */
        }
    </style>
</head>
<body>
    <main>
        <div id="secretButton"></div>
        <h2 id="title">Rewriter Tool</h2>
        <div class="dev-mode" id="devMode">Dev Mode</div>
        <div id="passwordPrompt">
            <input type="password" id="passwordInput" placeholder="Enter password">
        </div>
        <textarea id="inputText" placeholder="Type your text here..."></textarea>
        <button id="rewriteButton">Rewrite</button>
        <div id="output">Your rewritten text will appear here...</div>
        <div id="blackout"></div>
        <div id="ownerMode">Developer Mode Activated</div>
        <div class="credit" id="credit">by @felony4l</div>
    </main>

    <script>
        const secretButton = document.getElementById('secretButton');
        const passwordPrompt = document.getElementById('passwordPrompt');
        const passwordInput = document.getElementById('passwordInput');
        const blackout = document.getElementById('blackout');
        const ownerMode = document.getElementById('ownerMode');
        const title = document.getElementById('title');
        const devMode = document.getElementById('devMode');
        const rewriteButton = document.getElementById('rewriteButton');
        const output = document.getElementById('output');
        const textarea = document.getElementById('inputText');

        secretButton.addEventListener('click', (event) => {
            event.stopPropagation();
            passwordPrompt.classList.toggle('active');
            passwordPrompt.style.display = passwordPrompt.style.display === 'block' ? 'none' : 'block';
        });

        document.addEventListener('click', (event) => {
            if (
                passwordPrompt.classList.contains('active') &&
                !passwordPrompt.contains(event.target) &&
                event.target !== secretButton
            ) {
                passwordPrompt.style.display = 'none';
                passwordPrompt.classList.remove('active');
            }
        });

        passwordInput.addEventListener('keypress', (event) => {
            if (event.key === 'Enter') {
                const password = passwordInput.value.trim();
                if (password === 'iloveyeat101') {
                    passwordPrompt.style.display = 'none';
                    blackout.style.display = 'block';

                    secretButton.disabled = true;

                    setTimeout(() => {
                        ownerMode.style.display = 'block';
                        ownerMode.style.animation = 'pulse 2s infinite alternate';
                    }, 2000);

                    setTimeout(() => {
                        ownerMode.style.display = 'none';
                        blackout.style.display = 'none';
                        
                        title.style.transform = 'translateY(-20px)';
                        setTimeout(() => {
                            title.innerHTML = 'Zypher Ai (Beta)';
                            rewriteButton.innerHTML = 'Ask';
                            rewriteButton.classList.add('purple');
                            devMode.style.display = 'block';
                            devMode.style.opacity = '1';

                            // Change output text to reflect Zypher mode
                            output.innerHTML = "Your answers will appear here...";
                        }, 500);
                    }, 5000);
                } else {
                    alert('Incorrect password!');
                }
            }
        });

        rewriteButton.addEventListener('click', async () => {
            const inputText = document.getElementById('inputText').value.trim();

            if (!inputText) {
                alert("Please enter text to rewrite!");
                return;
            }

            try {
                const response = await fetch('https://site-production-1c79.up.railway.app/rewrite', {
                    method: 'POST',
                    headers: { 'Content-Type': 'application/json' },
                    body: JSON.stringify({ text: inputText })
                });

                if (!response.ok) {
                    throw new Error('Failed to fetch the response');
                }

                const data = await response.json();
                output.innerHTML = data.rewrittenText || "Error: Unable to process.";
            } catch (error) {
                alert("Error with the API call: " + error.message);
            }
        });

        // Add purple glow to the textarea during blackout when focused
        function toggleBlackout() {
            textarea.classList.toggle('blackout-active', blackout.style.display === 'block');
        }

        blackout.addEventListener('animationend', toggleBlackout);
    </script>
</body>
</html>
