:root {
    --sans-font: "Open Sans", -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
    --serif-font: palatino, "Palatino Linotype", "Palatino LT STD", "URW Palladio L", "TeX Gyre Pagella", serif;
    --blockquote-indent: 40px;
}
body {
    font-family: var(--serif-font);
    box-sizing: border-box;
    line-height: 1.414;
    margin: 0;
    padding: 0;
}
body > nav {
    display: flex;
    background: #4a8fa3; /* #385c87; */
    color: white;
    flex-flow: row nowrap;
    box-shadow: 0 0 0.2rem #0000001a, 0 0.2rem 0.4rem #00000033;
    padding: 0;
    position: sticky;
    right: 0;
    top: 0;
    z-index: 4;
}
html {
    scroll-padding-top: 5rem;
}
body > nav > div {
    display: flex;
    flex-flow: row nowrap;
    font-size: 1.2rem;
    line-height: 2rem;
    margin: 0;
    padding: 1rem;
}
body > nav > div * {
    margin: 0;
    padding: 0;
}

nav div {
    flex-grow: 1;
}
nav div.middle {
    justify-content: flex-end;
    flex-grow: 0;
    flex-basis: 40em;
}
@media screen and (max-width: 420px) {
    nav div.middle {
        display: none;
    }
}

nav div.right {
    justify-content: flex-end;
}

body > nav > * h1 {
    font-size: 1.4rem;
    font-weight: normal;
    color: white;
}
body > nav > * a {
    color: inherit;
    text-decoration: none;
}
body > nav span.icon > img {
    display: inline-block;
    min-height: 48px;
    max-height: 48px;
    margin: -1.2rem 0;
    line-height: 0;
}
body > nav ul {
    display: flex;
    margin: 0 -0.5rem;
}
body > nav ul > li {
    display: block;
    padding: 0 0.5rem;
}
@media screen and (max-width: 768px) { .md, .lg, .xl { display: none; } }
@media screen and (max-width: 992px) { .lg, .xl { display: none; } }
@media screen and (max-width: 1200px) { .xl { display: none; } }
@media screen {
    main {
        padding-top: 2rem;
        max-width: 40em;
        margin: auto;
        font-size: 120%;
    }
    hr {
        display: none;
    }
}
@media print {
  @page { size: A4; margin: 4rem 0rem 4.333rem 0rem; }
  body > nav { display: none; }
  main { margin-left: 4.5rem; margin-right: 4.5rem; }
  html { font-size: 10.5pt; }
  h1, h2 { page-break-before: always; margin-top: 0; }
  hr+* { page-break-before: always; margin-top: 0; }
  hr { display: none; }
}
h1, h2, h3, h4, h5, h6 { color: #4f81bd; }
h2 { border-bottom: solid #4f81bd 1px; }
h3, h4 { margin: 0; padding: 0; }
pre, code { background-color: #eee; font-family: "DejaVu Sans Mono", monospace; }
code { font-size: 75%; }
pre { padding: 0.33rem; line-height: 1; overflow-x: auto; }

p, ul, table {
    margin: 1em 0;
}

main {
    counter-set: section 0 subsection 0 appendix 0;
}
h2:before, h3:before {
    font-size: 75%;
}
h2:before, h3:before {
    text-align: right;
    display: inline-block;
    position: relative;
    right: 2.33em;
    text-align: right;
    width: 2em;
    margin-right: -2em;
    height: 0;
}

@media screen and (max-width: 53.33em) {
    main {
        margin-left: 2.33em;
        margin-right: 0.5em;
    }
}
h2:before {
    counter-increment: section;
    content: counter(section) ". ";
}
h2 {
    counter-reset: subsection 0;
}
h3:before {
    counter-increment: subsection;
    content: counter(section) "." counter(subsection) ". ";
}

h2[id^="appendix-"]:before {
    counter-increment: appendix;
    content: counter(appendix,upper-latin) ". ";
}
h2[id^="appendix-"] ~ h3:before {
    counter-increment: subsection;
    content: counter(appendix,upper-latin) "." counter(subsection) ". ";
}

body.no-counters {
    h2:before { content: none; }
    h3:before { content: none; }
    h2[id^="appendix-"]:before { content: none; }
    h2[id^="appendix-"] ~ h3:before { content: none; }
}

h2#notes:before {
    display: none;
}

.footnotes > ol { padding: 0; font-size: 90%; }

table {
    border-collapse: collapse;
    width: 100%;
}
thead tr {
    border-bottom: solid black 1px;
}
th {
    font-weight: normal;
    text-align: left;
    padding-right: 0.5rem;
    padding-bottom: 0.3rem;
}
td {
    padding-right: 0.5rem;
}

.postcard-grammar {
    font-family: var(--sans-font);
    font-size: 1rem;
    color: #888;
    line-height: 141.4%;
}
table.postcard-grammar {
    background: #e9f0f9;
}
@media screen and (max-width: 768px) {
    table.postcard-grammar {
        font-size: 0.75rem;
        margin-left: -2rem;
        width: calc(100% + 2rem);
    }
}
.postcard-grammar.binarysyntax { color: black; }

.postcard-grammar tr > *:nth-child(1) { text-align: right; }
.postcard-grammar.textsyntax tr > *:nth-child(1) { width: 7em; }
.postcard-grammar.binarysyntax tr > *:nth-child(1) { width: 13em; }
.postcard-grammar tr > *:nth-child(2) { width: 1em; text-align: center; }
.postcard-grammar.binarysyntax tr > *:nth-child(4) { width: 9.5em; }
@media screen and (max-width: 580px) {
    .postcard-grammar.binarysyntax tr > *:nth-child(1) { width: auto; }
}

.postcard-grammar sup {
    color: #040;
    font-size: 90%;
    &.kleene-star {
        font-size: inherit;
        top: -0.2em;
    }
}
.postcard-grammar em { color: black; }
.postcard-grammar .roman { font-family: var(--serif-font); font-size: 105%; }
.postcard-grammar strong { color: #400; font-weight: normal; }
.postcard-grammar td {
    vertical-align: top;
}
.postcard-grammar pre, .postcard-grammar code {
    color: black;
    display: inline-block;
    font-size: 100%;
    padding: 0 0.33rem;
}
.postcard-grammar .outputish { background: #eee; color: black; }
.postcard-grammar .outputish::before { content: '⌜'; }
.postcard-grammar .outputish::after { content: '⌝'; }

blockquote {
    padding: 0.5rem 1rem;
    border-left: solid #4f81bd 2px;
    margin-left: var(--blockquote-indent);
    margin-right: 0;
}
blockquote :first-child {
    margin-top: 0;
}
blockquote :last-child {
    margin-bottom: 0;
}

.rationale {
    background-color: #e9f0f9;
}

table.equations { width: auto; margin-left: var(--blockquote-indent); }
table.equations tr > *:nth-child(1) { text-align: right; }
table.equations tr > *:nth-child(2) { text-align: center; }

blockquote.pseudocode {
    border-left: none;
    padding: 0;
}
.pseudocode strong, strong.pseudocode {
    font-family: var(--sans-font);
    font-weight: inherit;
    font-size: 90%;
}
.pseudocode pre, .pseudocode code { background-color: inherit; }
.pseudocode p {
    white-space: pre;
}
.pseudocode em > code, .pseudocode strong > code {
    vertical-align: sub;
    font-size: 75%;
    font-family: inherit;
}
.pseudocode code {
    font-size: 80%;
}

/*---------------------------------------------------------------------------*/
/* Rouge syntax classes */

pre.highlight span.dl { color: #888; }
pre.highlight span.k { color: #4f81bd; }
pre.highlight span.kc { color: #4f81bd; }
pre.highlight span.kd { color: #4f81bd; }
pre.highlight span.nb { color: #4f81bd; }
pre.highlight span.nl { color: #4f81bd; }
pre.highlight span.nx { color: #4f81bd; }
pre.highlight span.o { color: #4f81bd; }
pre.highlight span.p { color: #888; }
pre.highlight span.s2 { color: #ff8844; }
