:root {
    color-scheme: light dark;
    --color-bg: #171717;
    --color-accent-bg: #2d2d2d; /* Alternate background color */
    --color-text: #eee;
    --color-accent: #ac95f8; /* Alternate color for links and highlights */
    --color-accent-ligher: #ac95f882; /* Lighter shade of accent color */
    --color-table-1: #ac95f83a; /* Table row background color 1 */
    --color-table-2: #ac95f81f; /* Table row background color 2 */
    --font-body: 'Fira Code', monospace; /* Primary font family */
    --font-headers: 'Fira Code', sans-serif; /* Font family for headers */
    font: 1.5em/1.618 var(--font-body);
    background-color: var(--color-bg);
}


body {
    margin: 0;
    padding: 0;
    color: var(--color-text);
    background-color: var(--color-bg);
    align-items: flex-start; 
}

header, nav, footer {
    text-align: center;
    padding: 1em 0;
}

#nav-container {
    width: 95%;
    display: flex;
    justify-content: space-between;
    padding: 0.625rem;
    right: 0;
}

#menu {
    right: 0;
}

nav a {
    color: var(--color-text);
    text-decoration: none;
    padding: 0 1em;
}

nav a:hover, nav a:focus {
    color: var(--color-accent);
    background-color: rgba(0, 0, 0, 0.1); /* Adds a subtle background on hover/focus */
}

h1, h2, h3, h4 {
    font-family: var(--font-headers);
    margin: 0.5em 0;
}

h1 {
    font-size: 2.5em;
}

h2 {
    font-size: 2em;
}

h3 {
    font-size: 1.75em;
}

p {
    margin: 1em 0;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover, a:focus {
    color: var(--color-accent-ligher);
    transition: color 0.1s;
}

/* lists are indented */
ul, ol {
    padding-left: 1.5em;
    padding-top: 0.5em;
}

lu, li {
    margin: 0.5em 0;
    padding-bottom: 0.5em;
}


img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto; /* Center images */
}

#socials {
    display: flex;
    justify-content: center;
    gap: 1em;
}

#socials a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 1.5em;
    margin: 0 0.5em;
}

blockquote {
    font-style: italic;
    margin: 1em 1.25rem;
    padding: 0.5em 1.25rem;
    border-left: 0.1875rem solid var(--color-accent);
}

#post {
    display: flex;
    justify-content: center; /* Center only the article content */
    position: relative; /* Necessary for absolute positioning of TOC */
    margin: 0 auto; /* Ensures the entire post container is centered */
}

#toc {
    position: absolute; /* Changed from sticky to absolute for controlled positioning */
    top: 1.25rem;
    height: fit-content;
    overflow-y: auto; /* Optional, for scrolling if TOC is very long */
    background-color: var(--color-accent-bg);
    border-radius: 0.3125rem;
}

/* TOC styles */
#toc-content {
    overflow: hidden;
    max-height: 0; /* Start collapsed */
    transition: max-height 0.3s; /* Transition for expanding and collapsing */
}

#toc-content.open {
    max-height: 31.25rem; /* Sufficiently high to show all content or adjust as needed */
}

#toc-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.3125rem 0.625rem;
    outline: none;
    display: inline-block;
}

#toc-toggle:before {
    content: '▲'; /* Arrow points down initially */
    display: inline-block;
    transition: transform 0.2s ease-in-out; /* Smooth rotation animation */
}

#toc-toggle.opened:before {
    transform: rotate(-180deg); /* Rotate arrow to point up when TOC is open */
}

#toc-content.open + #toc-toggle:before {
    transform: rotate(-180deg); /* Rotate arrow to point up when TOC is open */
}

#toc-title {
    margin: 0;
    padding: 0.625rem;
    background-color: var(--color-accent-bg);
    color: var(--color-text);
    border-radius: 0.3125rem 0.3125rem 0 0;
    /* bottom border color */
    border-bottom: 1px solid var(--color-accent);
}

footer {
    color: #fff;
    padding: 1em 0;
    font-size: 0.75em;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    bottom: 0;
}

article {
    margin: 0 auto;
    padding: 1em;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid #ddd;
    padding: 0.5em;
    text-align: left;
}

th {
    background-color: var(--color-accent-bg);
}

tr:nth-child(even) {
    background-color: var(--color-table-1);
}

tr:nth-child(odd) {
    background-color: var(--color-table-2);
}

/* media query for smaller screens */
@media (max-width: 75rem) {
    #contents {
        width: 50rem; /* Full width on smaller screens */
        padding: 1rem 1rem; /* Add padding to the content */
    }
    #toc {
        display: none; /* Hide TOC on smaller screens */
    }
}

/* media query for larger screens */
@media (min-width: 75rem) {
    #contents {
        width: 50rem;
    }
    #toc {
        display: block; /* Show TOC on larger screens */
    }
}

/* if we're smaller than 50rem, content should be full width */
@media (max-width: 50rem) {
    #contents {
        width: 100%;
        padding: 0.5rem 0.5rem;
    }
    h1 {
        font-size: 5vw; 
    }

    h2 {
        font-size: 4vw;
    }

    h3 {
        font-size: 3vw;
    }

    a, p {
        font-size: 3vw;
        margin: 1em 0;
    }

    th, td, tr {
        font-size: 3vw;
    }

    ul, ol {
        font-size: 3vw;
    }

    lu, li {
        font-size: 3vw;
    }

    blockquote {
        font-size: 3vw;
    }

    #toc {
        display: none; /* Hide TOC on smaller screens */
    }
}
