:root {
    --primary-color: #0d0d0d;
    --secondary-color: #1a1a1a;
    --accent-color: #ff1a75;
    --background-color: #0d0d0d;
    --text-color: #f5f5f5;
    --highlight-color: #39ff14;
    --glitch-color1: #ff00ff;
    --glitch-color2: #00ffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Roboto", sans-serif;
    user-select: none;
}

body {
    position: relative;
    min-height: 100vh;
    text-align: center;
    display: flex;
    background-color: var(--background-color);
    justify-content: space-between;
    flex-direction: column;
    align-items: stretch;
    color: var(--text-color);
}

/* Title CSS */
.title {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    text-align: center;
    font-size: 1.5em;
    padding-block: 1em;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.3s ease;
    position: relative;
    z-index: 1;
}

.title:before,
.title:after {
    content: "Sorting Visualizer";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: var(--glitch-color1);
    overflow: hidden;
    clip: rect(0, 900px, 0, 0);
    animation: glitch 2s infinite linear alternate-reverse;
    z-index: -1;
}

.title:after {
    color: var(--glitch-color2);
    animation: glitch 2s infinite linear alternate-reverse 1s;
}

@keyframes glitch {
    0% {
        clip: rect(0, 900px, 0, 0);
    }
    10% {
        clip: rect(20px, 900px, 30px, 0);
    }
    20% {
        clip: rect(10px, 900px, 20px, 0);
    }
    30% {
        clip: rect(30px, 900px, 10px, 0);
    }
    40% {
        clip: rect(20px, 900px, 30px, 0);
    }
    50% {
        clip: rect(10px, 900px, 20px, 0);
    }
    60% {
        clip: rect(30px, 900px, 10px, 0);
    }
    70% {
        clip: rect(20px, 900px, 30px, 0);
    }
    80% {
        clip: rect(10px, 900px, 20px, 0);
    }
    90% {
        clip: rect(30px, 900px, 10px, 0);
    }
    100% {
        clip: rect(20px, 900px, 30px, 0);
    }
}

/* Navbar CSS */
.navbar {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8em;
    font-size: 16px;
    min-height: 70px;
    padding-block: 0.6em;
    background-color: var(--secondary-color);
    transition: all 0.5s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.navbar a {
    all: unset;
    cursor: pointer;
    color: var(--text-color);
    font-weight: bold;
    padding: 10px 15px;
    border-radius: 6px;
    transition: background-color 0.3s, transform 0.3s;
    background-color: var(--primary-color);
}

.navbar a:hover {
    background-color: var(--accent-color);
    transform: translateY(-3px);
}

.navbar #menu {
    width: fit-content;
    outline: none;
    border: none;
    border-radius: 4px;
    padding: 6px 8px;
    background-color: var(--primary-color);
    color: var(--text-color);
    transition: background-color 0.3s, transform 0.3s;
}

.navbar #menu:hover {
    background-color: var(--accent-color);
    transform: translateY(-3px);
}

.navbar > .icon {
    display: none;
}

#menu, #random, #start {
    cursor: pointer;
}

/* Center CSS */
.center {
    margin: 0 auto;
    box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
    height: fit-content;
    width: 90%;
    max-width: 1410px;
    max-height: 731px;
    background-color: #1f1f1f;
    border-radius: 10px;
    padding: 1rem;
    transition: transform 0.3s;
}

.center:hover {
    transform: scale(1.02);
}

.array {
    display: flex;
    align-items: flex-end;
    min-height: 100%;
    height: 100%;
    flex-direction: row;
    gap: 2px;
    padding: 1rem;
}

.cell {
    display: flex;
    align-items: flex-start;
    flex: 0.5;
    width: 0.000001%;
    margin: 1px;
    background-color: #2d2d2d;
    resize: horizontal;
    position: relative;
    initial-value: 57;
    transition: all 0.4s ease-in;
    border-radius: 4px;
}

.cell.done {
    background-color: #39ff14;
    color: white;
    transition: all 0.4s ease-out;
}

.cell.visited {
    background-color: #ff1a75;
    color: white;
    transition: 0.5s;
}

.cell.current {
    background-color: #ff00ff;
    color: white;
    transition: all 0.4s ease-out;
}

.cell.min {
    background-color: #00ffff;
    color: white;
    transition: all 0.4s ease-out;
}

/* Footer CSS */
.fa.fa-heart {
    color: var(--accent-color);
}

footer {
    text-align: center;
    font-size: 18px;
    color: var(--text-color);
    padding: 1.6em;
    background-color: var(--primary-color);
    border-top: 2px solid var(--accent-color);
}

.footer > p:nth-child(1) {
    margin-bottom: 0.6em;
}

.link {
    text-decoration: none;
    font-weight: bold;
    color: var(--highlight-color);
    font-size: 25px;
}

.link:hover {
    color: var(--accent-color);
}

@media screen and (max-width: 600px) {
    .navbar {
        gap: 0.4em;
    }

    .title {
        font-size: 17px;
    }

    .navbar *, .navbar a {
        font-size: 14px;
    }

    .footer {
        font-size: 18px;
    }

    a#random {
        order: 4;
    }

    a.start {
        order: 5;
    }
}

@media screen and (max-width: 550px) {
    .center {
        width: 95%;
    }
}
