/* Dark is the default; light applies when the theme script sets data-theme="light". */
:root {
    color-scheme: dark;
    --bg: rgb(12, 12, 12);
    --text: rgb(224, 224, 224);
    --heading: white;
    --link: rgb(221, 221, 221);
    --link-strong: white;
    --accent: rgb(255, 191, 73);
    --muted: #888;
    --code-bg: rgba(65, 65, 65, 0.75);
    --code-border: rgba(0, 0, 0, 0.5);
    --code-text: white;
    --control-bg: rgba(128, 128, 128, 0.15);
    --border: rgba(128, 128, 128, 0.4);
    --active: rgba(128, 128, 128, 0.25);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: rgb(250, 250, 250);
    --text: rgb(48, 48, 48);
    --heading: black;
    --link: rgb(40, 40, 40);
    --link-strong: black;
    --accent: rgb(190, 110, 0);
    --muted: #777;
    --code-bg: rgba(0, 0, 0, 0.06);
    --code-border: rgba(0, 0, 0, 0.12);
    --code-text: rgb(30, 30, 30);
}

body {
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
}

section {
    width: 600px;
}

@media (min-width: 1600px) {
    .wrapper {
        width: 1080px;
    }
    section, .search-row {
        width: 800px;
    }
}

section a {
    text-decoration-line: underline;
    color: var(--link);
}

h1, h2, h3 {
    color: var(--heading);
}

h1 a {
    color: var(--heading);
}

h2 {
    margin-top: 48px;
    margin-bottom: 12px;
}

strong {
    color: var(--heading);
}

p a, li a {
    color: var(--link-strong);
}

a:hover {
    font-weight: unset;
    color: var(--accent);
}

code {
    border: 1px solid var(--code-border);
    background: var(--code-bg);
    color: var(--code-text);
    padding: 4px;
    font-size: 14px;
    border-radius: 4px;
}

img {
    max-width: 100%;
    vertical-align: middle;
    border-radius: 8px;
}

th, td {
    border: 0px;
}
th {
    color: var(--muted);
}

/* undo theme styling on header and footer */
header {
    padding-left: 0px;
    width: 164px;
    position: relative;
}
header .title {
    margin-bottom: 4px;
    font-size: 26px;
    white-space: nowrap;
}
header .tagline {
    font-style: italic;
    margin: 0px 0px 24px;
}
header ul {
    list-style: none;
    position: revert;
    height: auto;
    background: rgba(32, 32, 32, 0);
    border: 0px;
    padding-inline-start: 4px;
}
header li {
    width: auto;
    float: none;
    border: 0px;
    height: auto;
    margin: 3px 0;
}
header ul li a {
    line-height: unset;
    text-align: left;
    height: auto;
    color: var(--link-strong);
    font-size: 16px;
}
header ul li a:hover {
    font-weight: unset;
    color: var(--accent);
}
header ul li a.active {
    color: var(--accent);
}
header ul li a:focus {
    font-weight: unset;
    border: 0px;
}
header ul li a:active {
    background: transparent;
}

/* Keep the side-by-side layout down to 720px; the theme stacks it at 960px. */
@media (min-width: 721px) and (max-width: 960px) {
    div.wrapper {
        width: calc(100% - 40px);
        max-width: 860px;
        margin: 0 auto;
    }
    header {
        float: left;
        position: fixed;
        width: 164px;
        padding: 0;
    }
    section {
        float: right;
        width: calc(100% - 200px);
        max-width: 600px;
        border: 0;
        padding: 0 0 50px;
        margin: 0;
    }
    div.search-row {
        width: calc(100% - 200px);
        max-width: 600px;
    }
}

@media (max-width: 720px) {
    header {
        width: auto;
    }
    div.search-row {
        float: none;
        width: auto;
        margin-top: 20px;
    }
    header .title {
        font-size: 36px;
    }
    section {
        width: auto;
    }
}

/* Search */
.search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    float: right;
    width: 600px;
    margin: 0 0 24px;
}
.search {
    position: relative;
    flex: 1;
    min-width: 0;
}
.search input {
    box-sizing: border-box;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--control-bg);
    color: var(--text);
    font: inherit;
    font-size: 15px;
}
.search input:focus {
    outline: none;
    border-color: var(--accent);
}
.search-results {
    display: none;
    position: absolute;
    z-index: 10;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}
.search-results a {
    display: block;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text);
    font-size: 14px;
}
.search-results a:hover {
    background: var(--active);
}
.search-results a strong {
    display: block;
    color: var(--heading);
}
.search-results a span {
    display: block;
    color: var(--muted);
}
.search-results mark {
    background: none;
    color: var(--accent);
}
.search-results p {
    margin: 0;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 14px;
}

/* Theme switch */
.theme-switch {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    margin-top: 8px;
    border-radius: 8px;
}
.search-row .theme-switch {
    flex: none;
    margin: 0;
}
.theme-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    cursor: pointer;
    opacity: 0.7;
}
.theme-option:hover {
    opacity: 1;
}
.theme-option[aria-pressed="true"] {
    background: var(--active);
    opacity: 1;
}

/* Table of contents on the right, shown when there is room beside the page. */
.toc {
    display: none;
    position: fixed;
    top: 50px;
    left: calc(50% + 366px);
    width: 164px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}
.toc ul {
    position: relative;
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--border);
}
.toc li {
    margin: 0;
}
.toc a {
    display: block;
    padding: 3px 0 3px 12px;
    margin-left: -1px;
    border-left: 1px solid transparent;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.35;
    text-decoration: none;
}
.toc .toc-sub a {
    padding-left: 24px;
}
.toc a:hover {
    color: var(--accent);
}
.toc a.active {
    border-left-color: var(--accent);
    color: var(--heading);
}
@media (min-width: 1320px) {
    .toc {
        display: block;
    }
    /* Three columns: sidebar, content in the exact center, outline. */
    div.wrapper {
        width: 100%;
    }
    header {
        left: calc(50% - 530px);
    }
    section {
        float: none;
        margin: 0 auto;
    }
    .search-row {
        float: none;
        margin: 0 auto 24px;
        width: 600px;
    }
}
@media (min-width: 1600px) {
    .toc {
        left: calc(50% + 466px);
    }
    header {
        left: calc(50% - 630px);
    }
    .search-row {
        width: 800px;
    }
}

/* The sidebar scrolls with the page unless it fits in the window, then it stays put. */
@media (min-width: 721px) {
    header {
        position: absolute;
    }
    header.sticky {
        position: fixed;
    }
}

/* External link icon on hover. */
.outlink:hover::after {
    content: "";
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    margin-left: 8px;
    background: currentColor;
    opacity: 0.4;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E") center / contain no-repeat;
}
