const values = [
    "Web developer", 
    "Pc games enjoyer", 
    "Server backend survivor", 
    "python programmer", 
    "Javascript disliker",
    "I use Arch btw",
    "Owo, what's this?",
    "Ultimate procrastinator",
    "Ultrakill gaming",
    "00111010 00110011",
    "fistful of dollar",
    "Thy end is now!!!",
    "Possibly a furry",
    "Prepare thyself!!!",
    "Spegatti code master",
    "Ethernet cable untangler",
    "Caffeine addict",
    "I'm not a robot ☑",
    "Loud Music enjoyer",
    "part time femboy :<",
];
let typing_direction = 1;
let text = "";
let speed = 100; 
let selectedValue = 0;
let currentValueIndex = 0;
let pause = false;

function randomValue() {
    selectedValue = Math.floor(Math.random() * values.length);
    currentValueIndex = 0;
}

function type() {
    if (typing_direction == 1) {
        if (currentValueIndex < values[selectedValue].length) {
            text += values[selectedValue][currentValueIndex];
            currentValueIndex++;
        } else {
            typing_direction = -1;
            pause = true;
        }
    } else {
        if (currentValueIndex > 0) {
            text = text.slice(0, -1);
            currentValueIndex--;
        } else {
            typing_direction = 1;
            randomValue();
        }
    }
}

function typing() {
    type();
    document.getElementById("typing").innerHTML = "$ " + text;
    if (typing_direction == 1) {
        speed = 80 + Math.random() * 100;
    } else {
        speed = 60 + (Math.random() * 100) / 2;
    }
    if (!pause) {
        setTimeout(typing, speed);
    } else {
        setTimeout(typing, 500);
        pause = false;
    }
}

typing();

// HIDDEN STUFF (shh don't tell anyone >:3)

let last15Chars = "";

document.addEventListener('keydown', function(event) {
    last15Chars += event.key;
    if (last15Chars.includes("owo")) {
        console.log("owo, whats this?");
        document.getElementById('furry').style.display = 'block';
        last15Chars = "";
    }
    if (last15Chars.includes("doom")) {
        console.log("Im gonna sing the doom song now");
        document.querySelector(":root").style.setProperty('--font-family', 'Irken');
        document.querySelector(":root").style.setProperty('--ultrafont-font', 'Irken');
        document.querySelector(":root").style.setProperty('--smileos2-font', 'Irken');
        document.querySelector(":root").style.setProperty('--title-font', '1.5em');
        document.querySelector(":root").style.setProperty('--line-height', 'default');
        document.querySelector(":root").style.setProperty('--header-line-height', 'default');
        last15Chars = "";
    }
    if (last15Chars.includes("kfc")) {
        console.log("space chicken");
        document.querySelector(":root").style.setProperty('--font-family', 'Scratch');
        document.querySelector(":root").style.setProperty('--title-font', '1em');
        document.querySelector(":root").style.setProperty('--line-height', '120%');
        document.querySelector(":root").style.setProperty('--header-line-height', '150%');
        document.querySelector(":root").style.setProperty('--ultrafont-font', 'Scratch');
        document.querySelector(":root").style.setProperty('--smileos2-font', 'Scratch');
        last15Chars = "";
    }
    while (last15Chars.length >= 15) {
        last15Chars = last15Chars.slice(1);
    }
});