#main-grid > main {
    grid-area: content;
    color: #222;
}

#main-grid > main img {
    max-width: 100%;
}

#main-grid > header {
    grid-area: header;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-bottom: 1em;
    border-bottom: 1px solid #ddd;
    padding: 0.5em 0 1em 0;
    transition: padding 300ms;
    user-select: none;
}

#main-grid > footer {
    grid-area: footer;
    color: #eee;
    font-size: small;
    text-align: right;
}

#logo {
    margin-right: 0.6em;
}

#top-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 1em;
    transition: padding 300ms;
}

#toc {
    grid-area: toc;
    border-bottom: 2px dashed #ccc;
    margin-bottom: 1.5em;
    padding-bottom: 1.8em;
    transition: font-size 100ms ease-out;
}

#toc ul {
    margin: 0 0 0 1.2em;
    padding: 0.1em;
}

#main-grid {
    display: grid;
    grid-row-gap: 10px;
    grid-template-areas:
        "header"
        "toc"
        "content"
        "footer";
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
}

#main-grid > main > h1:first-child {
    margin-top: 0;
}

@media only screen and (min-width: 370px) {
    #main-grid > header {
        flex-direction: row;
    }
    #top-nav {
        padding-top: 0;
    }
}

@media only screen and (min-width: 700px) {
    #top-nav {
        padding-top: 1em;
    }
}

@media only screen and (min-width: 1000px) and (min-device-width: 700px) {
    #main-grid {
        grid-template-areas:
            "header  header"
            "toc     content"
            "footer  footer";
        grid-column-gap: 2.5em;
        grid-row-gap: 20px;
        grid-row-gap: 1em;
        grid-template-columns: 1fr 4fr;
    }

    #main-grid > header {
        padding: 0.5em 1em;
    }

    #toc {
        border-bottom: none;
        font-size: 0.9em;
    }
}

@media only print {
    #main-grid > header, #main-grid > footer, #toc {
        display: none;
    }
}
