:root {
    --bg-color: #1C201F;
    --typewriterSpeed: 1.2s;
    --h1typewriterCharacters: 13;
    --grey: grey;
    --white: white;
}

body {
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4 {
    font-family: 'Courier New', Courier, monospace;
    font-weight: normal;
    margin-left: 35px;
    color: var(--grey);
}

h1, h2 {
    position: relative;
    width: max-content;
    text-align: center;
}

h1 {
    font-size: clamp(1.5rem, 8vw, 12rem);
    margin-top: 20px;
    margin-bottom: 0px;
    overflow-wrap: break-word;
    hyphens: auto;
}

h1.active {
    color: #E2E2E2;
}

h1::before,
h1::after,
h2::before,
h2::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

h1::before {
    background: var(--bg-color);
    animation: typewriter var(--typewriterSpeed) steps(var(--h1typewriterCharacters)) 0.1s forwards;
}

h1::after {
    width: 0.125em;
    background: var(--grey);
    animation: 
        typewriter var(--typewriterSpeed) steps(var(--h1typewriterCharacters)) 0.1s forwards, 
        blink 750ms steps(var(--h1typewriterCharacters)) 5,
        fadeOut 1s ease-out 1 2.25s forwards;
}

h2 {
    font-size: clamp(0.5rem, 1.5vw + 0.5rem, 2rem);
    margin-top: 35px;
}

body.about h2::before,
body.about h2::after {
    --h2typewriterCharacters: 21;
}

body.academics h2::before,
body.academics h2::after {
    --h2typewriterCharacters: 25;
}

body.experience h2::before,
body.experience h2::after {
    --h2typewriterCharacters: 26;
}

body.research h2::before,
body.research h2::after {
    --h2typewriterCharacters: 24;
}

body.projects h2::before,
body.projects h2::after {
    --h2typewriterCharacters: 24;
}

body.interests h2::before,
body.interests h2::after {
    --h2typewriterCharacters: 25;
}

body.contact h2::before,
body.contact h2::after {
    --h2typewriterCharacters: 23;
}

body.gallery h2::before,
body.gallery h2::after {
    --h2typewriterCharacters: 23;
}

h2::before {
    background: var(--bg-color);
    animation: typewriter var(--typewriterSpeed) steps(var(--h2typewriterCharacters)) 0.001s forwards;
}

h2::after {
    width: 0.125em;
    background: var(--grey);
    animation: typewriter var(--typewriterSpeed) steps(var(--h2typewriterCharacters)) 0.001s forwards, blink 750ms steps(var(--h2typewriterCharacters)) infinite;
}

h3,
h4 {
    color: rgb(196, 196, 196);
    font-size: clamp(1rem, 1vw + 0.65rem, 1.5rem);
    max-width: 90%;
    margin-bottom: 5px;
    text-align: left;
    opacity: 0;
}

h3 a,
h4 a {
    color: rgb(196, 196, 196);
}

h3 a:hover,
h4 a:hover {
    color: white; /* White color for hyperlinks on hover */
}

h4 a.active {
    color: white;
}

li {
    color: rgb(196, 196, 196);
    font-family: Courier New, monospace;
    font-size: clamp(0.5rem, 1vw + 0.5rem, 2rem);
    opacity: 0;
}

body {
    background-color: var(--bg-color);
    margin-bottom: 50px;
}

body.active h1.stop-blinking::after {
    background: transparent;
}

body:not(.active) h1.stop-blinking::after {
    background: transparent;
}

nav {
    display: none;
    flex-direction: column;
    margin-top: 100px;
    padding: clamp(1rem, 5vw, 6rem);
}

.nav-item span {
    font-family: 'Courier New', Courier, monospace;
    font-size: clamp(2rem, 2vw + 2rem, 5rem);
}

nav > a > img {
    position: absolute;
    opacity: 0;
    transform: translate(-50%, -10%) scale(0.5);
    transition: transform 250ms, opacity 250ms;
    pointer-events: none;
    width: min(50vw, 800px);
}

nav > a > span {
    display: block;
    border: 1px solid transparent;
    position: relative;
    z-index: 2;
}

nav > a:hover > span {
    border-top-color: black;
    border-bottom-color: black;
}

nav > a:hover > img {
    opacity: 0.65;
    transform: translate(-50%, -10%) scale(0.8);
}

#nav a {
    color: grey;
}

#nav > a:hover {
    color: black;
}

#backArrow {
    position: fixed;
    top: 20px;
    right: 20px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

#backArrow svg path {
    stroke: #808080;
}

#backArrow:hover svg path {
    stroke: white;
}

body.active {
    background-color: white;
    transition: background-color 0.5s ease-in-out;
}

body:not(.active) {
    background-color: var(--bg-color);
    transition: background-color 0.3s ease-in-out;
}

.cat {
    margin-bottom: 20px;
    margin-left: 20px; /* Indentation */
    margin-right: 80px;
}

@media (max-width: 768px) {
    nav {
        margin-top: 25px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: clamp(1.5rem, 8vw, 3rem);
    }
}

@keyframes typewriter {
    to { left: 100%; }
}

@keyframes blink {
    0%, 100% { background: var(--grey); }
    50% { background: transparent; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}
