@import "morph.css";

html,
body {
    max-width: 800px;
    margin: 2em auto;
    scroll-behavior: smooth;
    font-size: 1.1em;
}

@media print {
    html {
        background-color: white;
    }

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

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

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

p {
    margin: 1em 0;
}

a {
    color: var(--blue);
}

a:visited {
    color: var(--blue);
}

img {
    max-width: 100%;
}

svg {
    height: auto;
    max-width: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 1.4em;
    font-style: italic;
}

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

h6 {
    font-weight: normal;
}

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

li>ol,
li>ul {
    margin-top: 0;
}

blockquote {
    margin: 1em 0 1em 1.7em;
    padding-left: 1em;
    border-left: 2px solid var(--blue);
    color: var(--text-color);
}

code {
    font-family: 'Cascadia Code', Menlo, Monaco, Consolas, monospace;
    font-size: 0.9rem;
    font-variant-ligatures: normal;
    background-color: var(--bg-color);
    margin: 0;
    hyphens: manual;
    padding: 0.2em;
    border-radius: 0.2em;
}

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

pre code {
    padding: 1em;
    overflow: visible;
    overflow-wrap: normal;
}

.sourceCode {
    background-color: var(--bg-color);
    overflow: visible;
}

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

table {
    margin: 1em 0;
    border-collapse: collapse;
    width: 100%;
    overflow-x: auto;
    display: block;
    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 0.25em 0.5em;
}

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

header {
    margin-bottom: 4em;
    text-align: center;
}

#TOC li {
    list-style: none;
    line-height: 1.2em;
    padding-bottom: 0.5em;
}

#TOC ul {
    padding-left: 1.3em;
}

#TOC>ul {
    padding-left: 0;
}

#TOC a:not(:hover) {
    text-decoration: none;
}

code {
    white-space: pre-wrap;
}

span.smallcaps {
    font-variant: small-caps;
}

div.columns {
    display: flex;
    gap: min(4vw, 1.5em);
}

div.column {
    flex: auto;
    overflow-x: auto;
}

div.hanging-indent {
    margin-left: 1.5em;
    text-indent: -1.5em;
}

/* The extra [class] is a hack that increases specificity enough to
       override a similar rule in reveal.js */
ul.task-list[class] {
    list-style: none;
}

ul.task-list li input[type="checkbox"] {
    font-size: inherit;
    width: 0.8em;
    margin: 0 0.8em 0.2em -1.6em;
    vertical-align: middle;
}

/* CSS for syntax highlighting */
pre>code.sourceCode {
    white-space: pre;
    position: relative;
}

pre>code.sourceCode>span {
    line-height: 1.25;
}

pre>code.sourceCode>span:empty {
    height: 1.2em;
}

.sourceCode {
    display: inline-block;
    min-width: 95%;
    overflow: visible;
}

.sourceCode pre {
    width: 100%;
}

div.sourceCode {
    width: 100%;
    border-radius: 0.3em;
    margin: 1em 0;
}

pre.sourceCode {
    margin: 0;
}

@media screen {
    div.sourceCode {
        overflow: auto;
    }
}

@media print {
    pre>code.sourceCode {
        white-space: pre-wrap;
    }

    pre>code.sourceCode>span {
        display: inline-block;
        text-indent: -5em;
        padding-left: 5em;
    }
}

pre.numberSource code {
    counter-reset: source-line 0;
}

pre.numberSource code>span {
    position: relative;
    left: -4em;
    counter-increment: source-line;
}

pre.numberSource code>span>a:first-child::before {
    content: counter(source-line);
    position: relative;
    left: -1em;
    text-align: right;
    vertical-align: baseline;
    border: none;
    display: inline-block;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    padding: 0 4px;
    width: 4em;
    color: #aaaaaa;
}

pre.numberSource {
    margin-left: 3em;
    border-left: 1px solid #aaaaaa;
    padding-left: 4px;
}

@media screen {
    pre>code.sourceCode>span>a:first-child::before {
        text-decoration: underline;
    }
}

p:has(> math) {
    overflow: auto;
    padding-bottom: 1px;
    /* for the bottom scrollbar */
}

.sidenote {
    float: right;
    clear: right;
    width: 300px;
    margin: 0 0 0.5em 0.5em;
    font-size: 0.9rem;
    padding: 0em 1em;
    line-height: 1.4;
    background-color: var(--bg-color-h);
    position: absolute;
    color: var(--text-color);
    transform: translateX(calc(800px + 1em)) translateY(calc(-100% - 0.5em));
    will-change: transform;
}

.sidenote::before {
    content: "";
    position: absolute;
    top: 0.5em;
    bottom: 0.5em;
    left: 0;
    width: 3px;
    background: var(--blue);
    border-radius: 2px;
}

.rainbow {
    /* duplicate the color list twice so it wraps cleanly */
    background: linear-gradient(to right,
            #fb4934, #fe8019, #fb4934, #fe8019, #fabd2f, #fabd2f, #fabd2f, #b8bb26, #b8bb26, #b8bb26,
            #b8bb26, #8ec07c, #8ec07c, #8ec07c, #8ec07c, #8ec07c, #83a598, #83a598, #83a598, #83a598,
            #83a598, #83a598, #d3869b, #d3869b, #d3869b, #d3869b, #d3869b, #d3869b, #fb4934, #fb4934,
            #fb4934, #fe8019, #fb4934, #fe8019, #fabd2f, #fabd2f, #fabd2f, #b8bb26, #b8bb26, #b8bb26,
            #b8bb26, #8ec07c, #8ec07c, #8ec07c, #8ec07c, #8ec07c, #83a598, #83a598, #83a598, #83a598,
            #83a598, #83a598, #d3869b, #d3869b, #d3869b, #d3869b, #d3869b, #d3869b, #fb4934);

    background-size: 400% auto;
    animation: rainbow-slide 15s linear infinite;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@keyframes rainbow-slide {
    from {
        background-position: 0% 0;
    }

    to {
        background-position: -200% 0;
    }
}

@media screen and (max-width: 600px) {
    html {
        font-size: 0.9em;
    }
}

@media screen and (max-width: 1200px) {
    .sidenote {
        transform: none !important;
        float: none;
        clear: both;
        width: calc(100% - 1em);
        position: relative;
        right: 0;
        margin: 0;
        padding: 0.5em;
        border-radius: 0;
        border-top: 1px solid var(--blue);
        border-bottom: 1px solid var(--blue);
    }

    .sidenote::before {
        display: none;
    }

    html {
        width: 100%;
        margin: 0 auto !important;
    }

    html {
        max-width: calc(100% - 32px) !important; /* 32px page padding */
    }

    body {
        max-width: 100% !important;
        width: 100%;
    }

    h1 {
        font-size: 1.5em !important;
    }
}

#TOC {
    position: fixed;
    top: 1em;
    z-index: 999;
    padding: 1em;
    width: 12em;
    transform: translateX(-130%);
    background: none;
}

#TOC::before {
    content: "";
    position: absolute;
    top: 20%;
    bottom: 1em;
    left: 100%;
    width: 3px;
    background: var(--purple);
    border-radius: 3px;
}

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

#TOC a {
    display: block;
    position: relative;
    padding-left: 1em;
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s, font-weight 0.2s;
}

#TOC a:hover {
    color: var(--blue);
}

@media screen and (max-width: 1500px) {
    #TOC {
        display: none;
    }

    html {
        margin: 2em;
    }

    html,
    body {
        max-width: calc(100vw - 300px - 7em);
        /* - sidenote width */
    }

    .sidenote {
        transform: translateX(calc(100vw - 300px - 5em)) translateY(calc(-100% - 0.5em));
    }
}

small {
    font-size: 0.6em;
}
