.head {
    height: calc(100vh - 100px);
    display: flex;
    flex-direction: row;
    align-items: end;
    box-sizing: border-box;
}

.head h1 {
    margin: 0;
    font-size: 7vw;
    width: 55%;
    box-sizing: border-box;

    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.head .otherWrap {
    text-align: right;
    box-sizing: border-box;
    width: 45%;
}

.head .otherWrap p {
    margin: 50px 0;
}

.copyright {
    margin: 1em 0; padding: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1em;
}

@media(max-width: 500px) {
    .copyright {
        flex-direction: column;
        gap: 0;
        margin-bottom: 5em;

        p {
            margin: 0;
        }
    }
}

.btnWrap {
    display: flex;
    gap: 1em;
    align-items: end;
    flex-direction: row;
    justify-content: end;
}

@media(max-width: 1300px) {
    .btnWrap {
        flex-direction: column;
        justify-content: end;
    }

    .head h1 {
        width: 60%;
    }

    .head .otherWrap {
        width: 40%;
    }

    .head .otherWrap p  {
        margin: 20px 0;
    }

    .head .otherWrap p:last-child {
        margin-bottom: 50px;
    }
}

@media(max-width: 900px) {
    .head {
        flex-direction: column;
        align-items: start;
        height: unset;

        h1 {
            width: 100%;
            font-size: 4em;
            margin-top: 0.5em;
        }

        .otherWrap {
            text-align: left;
            width: 100%;
        }

        .btnWrap {
            /* align-items: start; */
            display: block;

            a {
                display: inline-block;
                margin: 0 5px 10px 0;
            }

        }
    }
}

@media (max-width: 600px) {
    .head h1 {
        font-size: 3em;
        margin-top: 0.75em;
    }
}

.frontMatter {
    display: grid;
    grid-template-columns: 1fr 3fr;
    
    #dedication {
        grid-column: 1 / 3;
        grid-row: 1;

        text-align: center;
        padding: 0 25vw;
        margin-top: 10vh;
    }

    #bioSketch {
        grid-column: 1;
        grid-row: 2;
        padding-right: 2em;

        font-size: 0.7em;
    }

    #ack {
        grid-column: 2;
        grid-row: 2;

        font-size: 0.7em;
    }
}

@media(max-width: 1000px) {
    .frontMatter {
        grid-template-columns: 1fr 2fr;

        #dedication {
            padding: 0 10vw;
        }
    }
}

@media (max-width: 800px) {
    .frontMatter {
        display: block;
    }

    #bioSketch, #ack {
        margin-top: 7em;
    }
}

html:has(:target) {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

section, div, h2, h3, h4, li, figure {
    scroll-margin-top: 120px; 
}

#toc {
    .unnumbered {
        counter-increment: none;
        list-style-type: none;
    }

    ol {
        counter-reset: chapter;
    }

    & > ol {
        column-count: 3;
        column-gap: 1em;
        list-style-position: inside;
        max-width: 1200px;

        & > li:first-child {
            margin-top: 0.8em;
        }
    }

    li {
        counter-increment: chapter;
        break-after: avoid-column;
    }

    li.break {
        break-after: column;
    }

    ol ol li::marker {
        content: counters(chapter, ".") " ";
    }

    .ch > a {
        font-weight: bold;
        margin: 0.5em 0;
        display: inline-block;
        font-size: 1.2em;
    }

    .bumpLeft {
        transform: translateX(-150px);
    }

    button {
        border: none;
        background: none;
        text-decoration: underline;
        color: white;
        font-size: 100%;
        cursor: pointer;
        padding: 0;
        font-family: "Open Sans", sans-serif;
        transition: color 0.2s ease;
    }

    button:hover, button:focus {
        text-decoration: none;
    }

    button:active {
        color: #80D8FF;
    }
}

@media(max-width: 1200px) {
    #toc .bumpLeft {
        transform: translateX(-8vw);
    }
}

@media(max-width: 900px) {
    #toc > ol {
        column-count: unset;
    }
    #toc .bumpLeft {
        transform: none;
    }
}

.chapter h2 {
    font-size: 5vw;
    margin-top: 20vh;

    .chapterNum {
        font-weight: normal;
        display: block;
        font-size: 3vw;
    }
}

@media(max-width: 1000px) {
    .chapter h2 {
        font-size: 4em;
        margin-top: 3em;

        .chapterNum {
            font-size: 0.75em;
        }
    }
}

@media(max-width: 600px) {
    .chapter h2 {
        font-size: 3em;
    }
}

.bib {
    margin-top: 20vh;

    li {
        margin: 0;
    }

    li::marker {
        content: "[" counter(list-item) "] ";
        font-family: "Consolas", monospace;
        font-weight: bold;
        font-size: 1.2em;
    }

    a {
        text-decoration: none;
        background: rgba(0, 0, 0, 0);
        transition: background 0.1s ease-in-out, color 0.1s ease-in-out;
        padding: 0.5em 1em;
        display: block;
        color: white;
    }

    a:hover, a:focus {
        background: rgba(0, 0, 0, 1);
        color: aqua;
    }

    a:active {
        color: black;
        background: white;
    }

    .link {
        text-decoration: underline;
    }
}

.codefig {
    pre {
        padding: 1em;
        margin-top: 0;
        margin-bottom: 0;
    }

    code {
        counter-reset: step;
        counter-increment: step 0;
        font-family: "Consolas", monospace;
    }

    code .line::before {
        content: counter(step);
        counter-increment: step;
        width: 1rem;
        margin-right: 1.5rem;
        display: inline-block;
        text-align: right;
        color: rgba(115,138,148,.4)
    }
}

figcaption {
    text-align: center;
    margin-top: 0.75em;
}

h3 > span,
h4 > span {
    font-weight: normal;
    margin-right: 1em;
}

figure.dual {
    display: grid;
    grid-template-columns: 1fr 1fr;

    .codefig {
        grid-row: 1;
        grid-column: 1;
        margin: 0 0.5em 0 0;
    }

    .codefig[data-rust=true], .figimg {
        grid-column: 2;
        margin: 0 0 0 0.5em;
    }
    
    figcaption {
        grid-row: 2;
        grid-column: 1 / 3;
    }
    
    .narrow {
        display: none;
    }
}

@media(max-width: 1000px) {
    figure.dual {
        grid-template-columns: 1fr;

        .codefig {
            grid-row: 1;
            grid-column: 1;
            margin: 0;
        }

        .codefig[data-rust=true], .figimg {
            grid-column: 1;
            grid-row: 2;
            margin: 1em 0 0 0;
        }

        .figimg {
            margin-top: 1em;
            height: 8em;
        }
        
        figcaption {
            grid-row: 3;
            grid-column: 1;
        }
        
        .narrow {
            display: initial;
        }
        .wide {
            display: none;
        }
    }
}

@media (max-width: 850px) {
    figure {
        margin: 0;
    }
}

code {
    font-family: "Consolas", monospace;
}

.figimg {
    background: #0e1116;
    cursor: grab;
}

.figimg:active {
    cursor: grabbing;
}

#fig3-5-img,
#fig3-6-img {
    height: 20em;
}

th:first-child {
    border-right: 1px white solid;
}

tr:first-child {
    border-bottom: 1px white solid;
}

th, td {
    padding: 0.5em 1em;
}

td {
    text-align: right;
}

th {
    text-align: center;
}

table {
    border-collapse: collapse;
    margin: 0 auto;
    overflow-x: auto;
}

.tableWrap {
    max-width: 100%;
    overflow-x: auto;
}

.bibLink {
    font-family: "Consolas", monospace;
}

dialog {
    --width: 700px;
    padding: 0 3em;

    width: var(--width);
    height: 100vh;
    border: none;
    margin: 0 0 0 auto;
    max-height: 100vh;
    box-sizing: border-box;

    transform: translateX(var(--width));

    &:open {
        transform: translateX(0);
        transition: transform 0.5s cubic-bezier(0.165, 0.840, 0.440, 1.000), overlay 0.5s ease-out allow-discrete, display 0.5s ease-out allow-discrete;

        @starting-style {
            transform: translateX(var(--width));
        }

        &::backdrop {
            opacity: 1;
            transition: opacity 0.5s ease-out;

            @starting-style {
                opacity: 0;
            }
        }
    }

    transition: transform 0.2s ease-in, overlay 0.5s ease-in allow-discrete, display 0.5s ease-in allow-discrete;

    &::backdrop {
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(5px);

        opacity: 0;
        transition: opacity 0.2s ease-in;
    }


    background: #212121;
    color: white;
    box-shadow: 0 0 15px black;

    button {
        padding: 1em 2em;
        border: 1px white solid;
        background: rgba(0, 0, 0, 0);
        color: white;
        cursor: pointer;
        margin-top: 2em;
        
        transition: background 0.2s ease-in-out, border-color 0.1s ease-in-out;;

        &:focus, &:hover {
            background: rgba(0, 0, 0, 1);
        }

        &:active {
            border-color: black;
        }
    }
}

@media(max-width: 600px) {
    dialog {
        --width: 80vw;
    }
}
