@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,500;1,400;1,500&display=swap');

html {
    line-height: 1.4;
    font-family: 'Spectral', Charter, Georgia, serif;
    font-size: 16px;
    color: #1a1a1a;
    background-color: #fdfdfd;
}

body {
    hyphens: auto;
    text-align: justify;
    word-wrap: break-word;
    text-rendering: optimizeLegibility;
    font-kerning: normal;
    hanging-punctuation: first allow-end last;
    counter-reset: problems-counter;
}

main {
    margin: 0 auto;
    max-width: 40em;
    padding: 50px;
}

/* ============================================================
   TABLE OF CONTENTS
   ============================================================ */

#TOC {
    display: none; /* hidden by default; shown at wide viewports below */
}

@media (min-width: 60em) {
    #TOC {
        display: block;
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        left: min(1em, calc(50% - 22em)); /* hugs left edge, never overlaps text */
        width: 10em;
        font-family: sans-serif;
        font-size: 0.75rem;
        text-align: left;
        line-height: 1.35;
        /* hidden until first heading scrolls past */
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.4s ease;
    }

    #TOC.toc-visible {
        opacity: 1;
        pointer-events: auto;
    }
}

#TOC ul {
    padding-left: 0;
    margin: 0;
    list-style: none;
}

#TOC li {
    margin-top: 0.35em;
    margin-bottom: 0.35em;
    overflow-wrap: break-word;
}

/* nested TOC levels get a small indent */
#TOC ul ul {
    padding-left: 0.75em;
    margin-top: 0.25em;
}

#TOC .toc-title {
    font-weight: bold;
    color: #1a1a1a;
    margin-bottom: 0.5em;
}

/* All TOC links: gray by default, smooth fade */
#TOC a,
#TOC a:visited {
    color: #aaa;
    text-decoration: none;
    transition: color 0.3s ease;
    display: block;
}

#TOC a:hover {
    color: #555;
}

/* Active section link: black */
#TOC a.toc-active {
    color: #1a1a1a;
}

/* ============================================================
   FOOTNOTES
   ============================================================ */

.footnotes {
    margin-top: 10em;
    font-size: 85%;
}

.footnotes li::marker {
    font-weight: bold;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    body {
        font-size: 0.9em;
    }
    main {
        padding: 1em;
    }
}

/* ============================================================
   TYPOGRAPHY & ELEMENTS
   ============================================================ */

p {
    margin: 1em 0;
}

.asterism {
    text-align: center;
    display: block;
}

.asterism:before {
    font-size: 200%;
    font-weight: bold;
    content: '\2042';
}

a:link {
    color: blue;
    background-color: transparent;
}

a:visited {
    color: purple;
    background-color: transparent;
}

a:hover {
    text-decoration: none;
}

a:active {
    color: red;
    text-decoration: none;
}

img {
    margin: 2em auto;
    display: block;
    max-width: 100%;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 2em;
}

h5, h6 {
    font-size: 1em;
    font-style: italic;
}

h6 {
    font-weight: normal;
}

ol, ul {
    padding-left: 1.7em;
    margin-top: 1em;
}

li {
    margin-top: 1em;
    margin-bottom: 1em;
}

li > ol, li > ul {
    padding-right: 2em;
}

.double-column-potentially {
    column-width: 14em;
    column-gap: 2em;
    column-rule: 1px solid #ccc;
}

blockquote {
    background-color: whitesmoke;
    padding: 1em;
    font-size: 80%;
}

blockquote > p:first-child {
    margin-block-start: 0;
}

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

blockquote > p {
    text-indent: 0;
}

.callout-box {
    border: 1px solid black;
    text-align: center;
    width: 75%;
    margin: 2em auto;
    padding: 0.5em;
    font-size: 100%;
}

/* ============================================================
   PROBLEM LISTS
   ============================================================ */

ol.problems ol {
    list-style-type: lower-alpha;
}

ol.problems > li {
    counter-increment: problems-counter;
}

ol.problems > li::marker {
    counter-increment: problems-counter;
    content: counter(problems-counter) ". ";
    font-weight: bold;
}

ol.lettered-list {
    counter-reset: lettered-list-counter;
}

ol.lettered-list li {
    counter-increment: lettered-list-counter;
}

ol.lettered-list li::marker {
    content: counter(lettered-list-counter, lower-alpha) ") ";
}

/* ============================================================
   CODE
   ============================================================ */

code {
    font-family: Menlo, Monaco, 'Lucida Console', Consolas, monospace;
    font-size: 85%;
    margin: 0;
    white-space: pre-wrap;
}

pre {
    margin: 1em 0;
    overflow: auto;
}

pre code {
    padding: 0;
    overflow: visible;
}

.sourceCode {
    background-color: transparent;
    overflow: visible;
}

/* ============================================================
   MISC INLINE
   ============================================================ */

hr {
    background-color: #1a1a1a;
    border: none;
    height: 1px;
    margin: 1em 0;
}

span.smallcaps { font-variant: small-caps; }
span.underline { text-decoration: underline; }
div.column { display: inline-block; vertical-align: top; width: 50%; }
div.hanging-indent { margin-left: 1.5em; text-indent: -1.5em; }
ul.task-list { list-style: none; }

/* ============================================================
   TABLES
   ============================================================ */

table {
    margin: 0 auto;
    border-collapse: collapse;
    overflow-x: auto;
    font-variant-numeric: lining-nums tabular-nums;
}

table caption {
    margin-bottom: 0.75em;
}

tbody {
    margin-top: 0.5em;
    border-top: 1px solid #1a1a1a;
    border-bottom: 1px solid #1a1a1a;
}

th {
    border-top: 1px solid #1a1a1a;
    padding: 0.25em 0.5em;
}

td {
    padding: 0.125em 0.5em 0.25em 0.5em;
}

/* ============================================================
   HEADER / NAV BAR
   ============================================================ */

header {
    background-color: #F0F0F0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em;
    top: 0;
    left: 0;
    position: fixed;
    transition: top 0.25s;
}

#header-logo {
    height: 2em;
    padding: 0.5em;
}

#header-name {
    font-family: Helvetica, sans-serif;
    font-weight: bold;
    font-size: 1.5em;
    text-align: left;
    text-decoration: none;
    padding-left: 1em;
}

#header-name > a {
    text-decoration: none;
    color: rgb(48, 48, 48);
}

#linkback {
    position: fixed;
    right: 20px;
    float: right;
    margin: 2pt;
    padding: 0;
}

#title-block {
    margin-bottom: 4em;
    text-align: center;
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {

    .noprint {
        display: none;
    }

    html {
        font-size: 12pt;
        color: black;
        background-color: transparent;
    }

    header {
        display: none;
    }

    #TOC {
        display: none;
    }

    article {
        font-size: 12pt;
        padding: 0;
    }

    blockquote {
        background-color: transparent;
    }

    .footnote {
        color: black;
        text-decoration: none;
    }

    .footnote-back, .reversefootnote {
        display: none;
    }

    .footnotes {
        margin-top: 10em;
        border-top: 0.25pt solid black;
    }

    p {
        margin: 0;
        text-indent: 2em;
    }

    blockquote p:not(:first-child) {
        margin: 0;
        text-indent: 2em;
    }

    header + p, h1 + p, h2 + p, h3 + p,
    p:has(img) + p, p:has(br) + p,
    li + p, li > p,
    ol + p, ul + p,
    blockquote + p, .callout-box + p {
        text-indent: 0;
    }

    .callout-box {
        padding: 0.5em;
        margin-top: 1em;
        margin-bottom: 1em;
        page-break-inside: avoid;
    }

    h2 {
        margin-bottom: 0.5em;
    }

    p, h2, h3 {
        orphans: 3;
        widows: 3;
    }

    h2, h3, h4 {
        page-break-after: avoid;
    }

    .inline-image {
        max-height: 50vh;
    }
}
