:root {
    --main-bg-color: black;
    --main-text-color: white;
    --accent-color: violet;
    --code-color: greenyellow;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 55px;

    /* New text size variables */
    --text-size-desktop: 14px;
    --text-size-mobile: 12px;
}

/* General Styles */
html, body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: 'JetBrains Mono', monospace;
    background-color: var(--main-bg-color);
    color: var(--main-text-color);
    font-size: var(--text-size-desktop);
}

body {
    display: flex;
    justify-content: center;
}

/* Typography */
h1 { font-size: 2rem; font-weight: bold; }
h2 { font-size: 1.25rem; font-style: italic; }
h3 { font-size: 1rem; font-weight: bold; }

code { color: var(--code-color); }

/* Links */
a { color: var(--main-text-color); text-decoration: none; }
a:hover { color: var(--accent-color); text-decoration: None; }

p a { color: var(--code-color); }

/* Layout Elements */
.header-line {
    border-top: 3px dashed var(--main-text-color);
    margin: 20px 0;
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

img {
    max-width: 100%;
    height: auto;
    border: 1px solid transparent;
}

img:hover {
    border: 1px solid var(--accent-color);
    cursor: pointer;
}

/* ASCII Art */
.ascii-art {
    white-space: pre;
    font-family: monospace;
    margin: 0 2vw;
}

/* Containers */
.ascii-art-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.image-container {
    width: min(100%, 1000px);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    padding: 10px;
}

.image-grid img {
    width: 100%;
    height: auto;
}

.image-grid b,
.image-grid p {
    font-size: 0.75rem; /* Adjust this value as needed */
}

/* Image Grid Enlargement */
.image-overlay {
    display: none;
    position: fixed; 
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1001;
    justify-content: center;
    align-items: center;
}

.enlarged-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 24px;
    color: var(--main-text-color);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--accent-color);
}

/* Make grid images clickable */
.image-grid img {
    cursor: pointer;
}

/* New media query to remove padding and adjust layout for smaller screens */
@media (max-width: 600px) {
    .img-text-container {
        flex-direction: column;
        align-items: center;
        padding: 0; /* Remove padding */
        margin: 0;
        width: 100%;
    }

    .img-text-container .text {
        margin-left: 0; /* Remove left margin */
        width: 100%; /* Full width */
    }

    .img-text-container .image-container {
        max-width: 100%; /* Full width */
        margin-right: 0; /* Remove right margin */
        margin-bottom: 8px; /* Add some space between image and text */
    }
}

/* Sidebar */
.sidebar {
    height: 100%;
    width: var(--sidebar-width);
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    background-color: var(--main-bg-color);
    overflow-x: hidden;
    transition: 0.5s;
    border-right: 3px dashed var(--main-text-color);
    font-size: inherit; /* This will inherit from the body */
}

.sidebar-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    min-width: var(--sidebar-collapsed-width);
    margin-top: 20px;
}

.toggle-btn {
    padding: 8px;
    cursor: pointer;
    color: var(--main-text-color);
    font-size: 1rem;
    transition: 0.3s;
}

.toggle-btn:hover {
    color: var(--accent-color);
}

.sidebar a {
    padding: 8px;
    font-size: 1rem;
    display: block;
}

#main {
    transition: margin-left .5s;
    width: auto;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
    margin-left: var(--sidebar-width);
    margin-right: auto;
}
#main img {
    max-width: 100%;
    height: auto;
}

.sidebar-collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-content {
    display: none;
}

/* Media Queries */
@media screen and (max-width: 800px) {
    html, body {
        font-size: var(--text-size-mobile);
    }

    .sidebar {
        font-size: inherit;
    }

    .sidebar-content a,
    .sidebar-content li,
    .sidebar-content .project-name {
        font-size: inherit;
        width: 100%;
    }

    .ascii-art-container {
        flex-direction: column;
        justify-content: center;
        margin: 0;
        width: 100%;
    }

    .ascii-art {
        width: 100%;
        margin: 0;
        font-size: 2.72vw;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .img-text-container {
        flex-direction: column;
        align-items: center;
        margin: 0;
        width: 100%;
    }

    .img-text-container .text-container,
    .img-text-container .image-container {
        max-width: 100%;
    }

    .sidebar {
        width: min(30vw, var(--sidebar-collapsed-width));
    }

    .sidebar-content {
        display: none;
    }

    #main {
        margin-left: min(30vw, var(--sidebar-collapsed-width));
    }

    .sidebar-expanded {
        width: min(30vw, var(--sidebar-width));
    }

    .sidebar-expanded .sidebar-content {
        display: block;
    }

    /* Ensure all text elements inherit the new font size */
    #main, #main p, #main li, #main h1, #main h2, #main h3, #main h4, #main h5, #main h6 {
        font-size: inherit;
    }

    /* Adjust heading sizes for mobile */
    #main h1 { font-size: 1.5rem; }
    #main h2 { font-size: 1.3rem; }
    #main h3 { font-size: 1.1rem; }

    .MathJax_Display {
        font-size: 80%; /* Reduce font size on smaller screens */
    }
}

/* Ensure proj3.html specific content inherits font size */
#main .content-wrapper {
    font-size: inherit;
}

@media screen and (min-width: 1500px) {
    #main {
        margin-left: calc(var(--sidebar-width) + (100vw - 1500px) / 2);
    }
}

@media (max-width: 250px) {
    .sidebar-header {
        flex-direction: column;
        align-items: center;
    }
}
.sidebar-content ol {
    list-style-type: none;
    padding-left: 0;
}

.sidebar-content ol ol {
    margin-left: 16px;
}

.sidebar-content li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding-right: 8px;
}

.sidebar-content li > a {
    flex: 1 1 calc(100% - 30px);
    padding: 8px 0 8px 8px;
    font-size: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.caret {
    cursor: pointer;
    user-select: none;
    padding: 8px 4px;
    transition: color 0.3s;
    font-size: 1em;
    line-height: 1;
    flex: 0 0 auto;
    align-self: flex-start;
}

.sidebar-content li.active > ol {
    flex-basis: 100%;
    margin-left: 16px;
}

.sidebar-list {
    list-style-type: decimal;
    padding-left: 16px;
}

.sidebar-list ol {
    list-style-type: lower-alpha;
    padding-left: 16px;
}

.sidebar-list li {
    margin-bottom: 5px;
}

.MathJax_Display {
    overflow-x: auto;
    max-width: 100%;
    font-size: 100%;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0);
    color: white;
    border: none;
    font-size: 2rem;
    padding: 10px;
    cursor: pointer;
}

.nav-btn:hover {
    color: var(--accent-color);
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

/* New side-by-side container */
.image-text-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.image-text-item {
    display: flex;
    flex: 1 1 calc(50% - 10px);
    min-width: 300px;
}

.image-text-item .image-container {
    flex: 0 0 50%;
    max-width: 50%;
    height: auto;
}

.image-text-item .text-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 20px;
}

.image-text-container img{
    cursor: pointer;
}

/* Responsive behavior for mobile devices */
@media screen and (max-width: 768px) {
    .image-text-item {
        flex-direction: column;
    }

    .image-text-item .image-container,
    .image-text-item .text-container {
        flex: 1 1 100%;
        max-width: 100%;
        padding: 0;
    }

    .image-text-item .text-container {
        margin-top: 10px;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    p {
        font-size: var(--text-size-mobile);
    }
}