@media print {
    @page {
        size: letter;
        counter-increment: page;
    }
    h1:first-of-type {
        text-align: center !important;
        margin-top: 5em;
        margin-bottom: 2em !important;
    }
    @page :first {
        margin-left: 2.5cm;
        margin-right: 2.5cm;
    }
    @page :left {
        margin-left: 2cm;
        margin-right: 3cm;
        @bottom-left {
            content: counter(page);
        }
        @top-left {
            content: string(doctitle);
        }
    }
    @page :right {
        margin-left: 3cm;
        margin-right: 2cm;
        @bottom-right {
             content: counter(page);
        }
        @top-right {
            content: string(doctitle);
        }
    }
}

body {
    counter-reset: formula;
}

/* Titles */

h1.title span.subtitle {
    font-size: 0.8em;
    color: #888888;
}

/* Navigation */

div#table-of-contents li {
    text-align: left;
}

/* Abstract Block */

div.ABSTRACT {
    margin-left: 2em;
    margin-right: 2em;
    margin-top: 1em;
    margin-left: 3em;
}

div.ABSTRACT > p:first-child::before {
    content: "Abstract.";
    font-weight: bold;
}

/* Main Body Text */

p, li, dd {
    text-align: justify;
    line-height: 1.5em;
}

p {
    margin-bottom: 1.5em;
}

/* Headings */
h2 {
    border-top: 1px solid;
    page-break-before: always;
    string-set: sectitle content();
}

div.content div:nth-of-type(3) h2 {
    page-break-before: avoid;
}

/* Figures/Images */

img {
    max-width: 800px;
    height: auto;
}

div.figure {
    page-break-inside: avoid;
    text-align: center;
}

div.figure p {
    text-align: center;
    margin: 0em;
    padding-top: 0.5em;
    padding-bottom: 0.5em;
}

/* Tables */

table {
    margin-left: auto;
    margin-right: auto;
}

/* Captions */
/* copied from `table caption` and `.figure p` */

div.org-src-container label.org-src-name {
    font: italic 85%/1 arial, sans-serif;
}

/* Admonitions */

div.NOTE {
    margin: 1em;
    padding-left: 1em;
    padding-top: 0.4em;
    padding-bottom: 0.4em;
    border-left: 0.4em solid;
    border-color: darkblue;
}

div.NOTE > p:first-child::before {
    color: darkblue;
    font-weight: bold;
    content: 'ⓘ \00a0';
}

div.NOTE > p:last-child {
    margin-bottom: 0px;
}

div.ADVNOTE {
    margin: 1em;
    padding-left: 1em;
    padding-top: 0.4em;
    padding-bottom: 0.4em;
    border-left: 0.4em solid;
    border-color: darkturquoise;
}

div.ADVNOTE > p:first-child::before {
    color: darkturquoise;
    font-weight: bold;
    content: '🎛 \00a0';
}

div.ADVNOTE > p:last-child {
    margin-bottom: 0px;
}

div.INDENTED {
    margin: 1em !important;
    padding-left: 1em;
    padding-top: 0.4em;
    padding-bottom: 0.4em;
    border-left: 0.4em solid;
    border-color: #edf0f2;
}

div.INDENTED > p:last-child {
    margin-bottom: 0px;
}

blockquote {
    margin: 1em !important;
    padding-left: 1em;
    padding-top: 0.4em;
    padding-bottom: 0.4em;
    border-left: 0.4em solid;
    border-color: darkgray;
}

blockquote > p:first-child::before {
    content: '\201c';
    font-size: 2em;
    color: darkgray;
    vertical-align: text-top;
}

blockquote > p:last-child {
    margin-bottom: 0;
}

/* Hierarchy Lists */

div.HIERARCHY {
    margin-bottom: 1.5em;
}

div.HIERARCHY ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}

div.HIERARCHY ul > li {
    margin-left: 1em;
}

/* TOC */

div#list-of-tables > h2 {
    page-break-before: avoid;
    border-top: 0px;
}

div#list-of-listings > h2 {
    page-break-before: avoid;
    border-top: 0px;
}

/* Footer */

div#footnotes h2.footnotes {
    page-break-before: avoid;
    border-top: 0px;
    display: block;
}

div.footdef sup {
    display: inline-block;
    width: 2em;
}

div.footpara {
    padding: 0px;
    margin-left: 1em;
    display:  inline-block;
}

p.footpara {
    margin-bottom: 0.4em;
    padding-top: 0px;
    padding-left: 0px;
}
