/* docs.zerobyte.cloud. Palette from zerobyte.cloud; light or dark follows the system. */

@font-face {
    font-family: "IBM Plex Sans";
    src: url("fonts/ibm-plex-sans-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Sans";
    src: url("fonts/ibm-plex-sans-400-italic.woff2") format("woff2");
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}
@font-face {
    font-family: "IBM Plex Sans";
    src: url("fonts/ibm-plex-sans-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("fonts/jetbrains-mono-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("fonts/jetbrains-mono-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --bg: #000;
    --raised: #0c0c0e;
    --code-bg: #0c0c0e;
    --ink: #e3e3e3;
    --ink-2: #b4b4b8;
    --ink-3: #8a8a90;
    --line: #2a2a2d;
    --orange: #ee7a4a;
    --red: #ff4848;
    --pink: #ff3cc6;
    --violet: #a46cff;
    --link: #f29a74;
    --brand: linear-gradient(90deg, var(--orange), var(--red) 30%, var(--pink) 65%, var(--violet));
    /* Syntax colours. */
    --syn-keyword: #ff7aa8;
    --syn-string: #9fd8a4;
    --syn-number: #f5b97a;
    --syn-title: #b99cff;
    --syn-type: #7fc8f8;
    --syn-comment: #7a7a82;
    --syn-attr: #f29a74;

    --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --top: 60px;
    --foot: 52px;
    --side: 280px;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #fff;
    --raised: #f6f6f7;
    --code-bg: #f6f6f7;
    --ink: #131314;
    --ink-2: #3a3a3f;
    --ink-3: #6e6e73;
    --line: #e1e1e4;
    --orange: #ff5a00;
    --red: #ff1f44;
    --pink: #ff1aa8;
    --violet: #8640ff;
    --link: #c63d00;
    --syn-keyword: #c8007a;
    --syn-string: #1d7a34;
    --syn-number: #a14b00;
    --syn-title: #6a2fd6;
    --syn-type: #005f99;
    --syn-comment: #6e6e73;
    --syn-attr: #b23c00;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-top: calc(var(--top) + 16px);
    scroll-padding-bottom: calc(var(--foot) + 16px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 16px/1.65 var(--sans);
    -webkit-font-smoothing: antialiased;
    /* Room for the fixed footer bar. */
    padding-bottom: var(--foot);
}

a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
a:hover {
    color: var(--ink);
}
:focus-visible {
    outline: 2px solid var(--pink);
    outline-offset: 2px;
    border-radius: 2px;
}

.skip {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 30;
    padding: 8px 14px;
    background: var(--ink);
    color: var(--bg);
    font: 600 14px var(--sans);
    text-decoration: none;
}
.skip:focus {
    top: 12px;
}

.icon {
    flex: none;
    display: block;
}

/* Header ------------------------------------------------------------------ */

.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--top);
    padding: 0 24px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.top::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--brand);
    opacity: 0.55;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
}
.brand__logo {
    display: block;
}
.brand__logo img {
    width: 141px;
    height: 30px;
}

/* Logos follow the theme: the dark-page version unless the light theme is on. */
img.logo--dark {
    display: block;
}
img.logo--light,
:root[data-theme="light"] img.logo--dark {
    display: none;
}
:root[data-theme="light"] img.logo--light {
    display: block;
}
.brand__docs {
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink-2);
    font: 400 12px/1.4 var(--sans);
    letter-spacing: 0.04em;
}

.top__links {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
    font: 400 14px var(--sans);
}
.top__links a {
    color: var(--ink-2);
    text-decoration: none;
}
.top__links a:hover {
    color: var(--ink);
}

.top__menu {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: none;
    color: var(--ink);
    font: 400 13px var(--sans);
    cursor: pointer;
}
.top__menu span,
.top__menu span::before,
.top__menu span::after {
    display: block;
    width: 14px;
    height: 1.5px;
    background: currentColor;
}
.top__menu span {
    position: relative;
}
.top__menu span::before,
.top__menu span::after {
    content: "";
    position: absolute;
    left: 0;
}
.top__menu span::before {
    top: -5px;
}
.top__menu span::after {
    top: 5px;
}
.top__menu[aria-expanded="true"] span {
    background: transparent;
}
.top__menu[aria-expanded="true"] span::before {
    top: 0;
    transform: rotate(45deg);
}
.top__menu[aria-expanded="true"] span::after {
    top: 0;
    transform: rotate(-45deg);
}

/* Shell ------------------------------------------------------------------- */

.shell {
    display: grid;
    grid-template-columns: var(--side) minmax(0, 1fr) 232px;
    align-items: start;
    min-height: calc(100vh - var(--top));
}

.side {
    position: sticky;
    top: var(--top);
    max-height: calc(100vh - var(--top) - var(--foot));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 28px 16px 48px 24px;
    border-right: 1px solid var(--line);
    font: 400 14.5px/1.5 var(--sans);
}
.side ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.side a {
    display: block;
    padding: 5px 10px;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    color: var(--ink-2);
    text-decoration: none;
}
.side a:hover {
    background: var(--raised);
    color: var(--ink);
}
.side a[aria-current="page"] {
    border-left-color: var(--pink);
    background: var(--raised);
    color: var(--ink);
    font-weight: 600;
}
.side__intro {
    margin-bottom: 18px !important;
}
.side__group + .side__group {
    margin-top: 22px;
}
.side__title {
    margin: 0 0 6px;
    padding-left: 12px;
    color: var(--ink-3);
    font: 600 11px/1.4 var(--sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.main {
    min-width: 0;
    padding: 40px 56px 64px;
}

.toc {
    position: sticky;
    top: var(--top);
    max-height: calc(100vh - var(--top) - var(--foot));
    overflow-y: auto;
    padding: 40px 24px 40px 8px;
    font: 400 13px/1.45 var(--sans);
}
.toc__title {
    margin: 0 0 10px;
    color: var(--ink-3);
    font: 600 11px/1.4 var(--sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
    border-left: 1px solid var(--line);
}
.toc a {
    display: block;
    padding: 4px 0 4px 12px;
    color: var(--ink-3);
    text-decoration: none;
}
.toc a:hover {
    color: var(--ink);
}
.toc code {
    font: inherit;
}

/* Article ----------------------------------------------------------------- */

.doc {
    max-width: 880px;
}
.doc > :first-child {
    margin-top: 0;
}

.doc h1,
.doc h2,
.doc h3,
.doc h4 {
    position: relative;
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
}
.doc h1 {
    margin: 0 0 20px;
    font-size: clamp(28px, 3.4vw, 36px);
    letter-spacing: -0.025em;
}
.doc h1::after {
    content: "";
    display: block;
    width: 56px;
    height: 2px;
    margin-top: 16px;
    background: var(--brand);
}
.doc h2 {
    margin: 48px 0 14px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    font-size: 22px;
}
.doc h3 {
    margin: 32px 0 10px;
    font-size: 17px;
}
.doc h4 {
    margin: 24px 0 8px;
    font-size: 15px;
}
.anchor {
    position: absolute;
    left: -1.1em;
    width: 1.1em;
    color: var(--ink-3);
    text-decoration: none;
    opacity: 0;
}
.anchor::before {
    content: "#";
}
.doc h2 .anchor {
    top: 20px;
}
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
.anchor:focus-visible {
    opacity: 1;
}

.doc p,
.doc ul,
.doc ol,
.doc dl,
.doc blockquote,
.doc .table,
.doc figure {
    margin: 0 0 18px;
}
.doc ul,
.doc ol {
    padding-left: 1.4em;
}
.doc li + li {
    margin-top: 4px;
}
.doc li > ul,
.doc li > ol {
    margin: 4px 0 0;
}
.doc li > p {
    margin: 0 0 8px;
}
.doc ul:has(> li > input[type="checkbox"]) {
    padding-left: 0.2em;
    list-style: none;
}
.doc input[type="checkbox"] {
    margin: 0 8px 0 0;
    vertical-align: -1px;
    accent-color: var(--pink);
}
.doc strong {
    font-weight: 600;
}
.doc hr {
    height: 1px;
    margin: 36px 0;
    border: 0;
    background: var(--line);
}
.doc blockquote {
    padding: 12px 18px;
    border-left: 2px solid var(--violet);
    background: var(--raised);
    color: var(--ink-2);
}
.doc blockquote > :last-child {
    margin-bottom: 0;
}
.doc img {
    max-width: 100%;
    height: auto;
}

.doc code {
    padding: 0.12em 0.36em;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--raised);
    font: 400 0.88em/1 var(--mono);
    overflow-wrap: anywhere;
}
.doc h1 code,
.doc h2 code,
.doc h3 code,
.doc h4 code {
    padding: 0 0.2em;
    border: 0;
    background: none;
    font: inherit;
}
.doc a code {
    color: inherit;
}

/* Tables */
.table {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
}
.table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
    line-height: 1.5;
}
.table th,
.table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}
.table th {
    background: var(--raised);
    color: var(--ink);
    font: 600 12.5px/1.4 var(--sans);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.table tr:last-child td {
    border-bottom: 0;
}
.table td code {
    white-space: nowrap;
}

/* Code blocks */
.code {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--code-bg);
}
.code figcaption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    padding: 0 8px 0 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-3);
    font: 400 12px/1 var(--mono);
    letter-spacing: 0.04em;
}
.copy {
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    color: var(--ink-3);
    font: inherit;
    cursor: pointer;
}
.copy:hover {
    border-color: var(--line);
    color: var(--ink);
}
.code pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    font: 400 13.5px/1.6 var(--mono);
    tab-size: 4;
}
.code pre code {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    overflow-wrap: normal;
    white-space: pre;
}

.hljs-keyword,
.hljs-built_in,
.hljs-literal,
.hljs-selector-tag,
.hljs-meta .hljs-keyword {
    color: var(--syn-keyword);
}
.hljs-string,
.hljs-regexp,
.hljs-template-string,
.hljs-addition {
    color: var(--syn-string);
}
.hljs-number,
.hljs-symbol,
.hljs-bullet {
    color: var(--syn-number);
}
.hljs-title,
.hljs-title.function_,
.hljs-section {
    color: var(--syn-title);
}
.hljs-type,
.hljs-title.class_,
.hljs-class .hljs-title {
    color: var(--syn-type);
}
.hljs-comment,
.hljs-quote,
.hljs-meta,
.hljs-deletion {
    color: var(--syn-comment);
}
.hljs-attr,
.hljs-attribute,
.hljs-property,
.hljs-variable,
.hljs-template-variable,
.hljs-params,
.hljs-name,
.hljs-tag {
    color: var(--syn-attr);
}
.hljs-params {
    color: inherit;
}
.hljs-comment {
    font-style: italic;
}

/* Below the article */
.source {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    max-width: 880px;
    margin: 40px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    font: 400 13px var(--sans);
}
.source a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-3);
    text-decoration: none;
}
.source a:hover {
    color: var(--ink);
}
.source .icon {
    width: 16px;
    height: 16px;
}

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 880px;
    margin-top: 24px;
}
.pager a {
    display: block;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: 600 15px/1.4 var(--sans);
    text-decoration: none;
}
.pager a:hover {
    border-color: var(--ink-3);
    background: var(--raised);
}
.pager span {
    display: block;
    margin-bottom: 4px;
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.pager__next {
    grid-column: 2;
    text-align: right;
}

/* Footer: one bar fixed to the bottom of the window, in the colours of the page theme. -- */

.foot {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 28px;
    height: var(--foot);
    padding: 0 24px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink-2);
    font: 400 13px/1.4 var(--sans);
}
.foot a {
    color: var(--ink-2);
    text-decoration: none;
}
.foot a:hover {
    color: var(--ink);
}
.foot__sponsor {
    display: flex;
    flex: none;
    align-items: center;
    gap: 12px;
}
.foot__label {
    color: var(--ink-3);
    font: 600 11px/1 var(--sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.foot__sponsor img {
    width: 125px;
    height: 16px;
}
.foot__legal {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--ink-3);
    font-size: 12.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.foot__legal a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.foot__legal code {
    font: 400 0.95em var(--mono);
}
.foot__github {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.foot__github .icon {
    width: 18px;
    height: 18px;
}

/* Appearance switch. Hidden until theme.js has run, because it does nothing without it. */
.theme-pick {
    display: none;
}
:root[data-theme] .theme-pick {
    display: inline-flex;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.theme-pick button {
    padding: 6px 11px;
    border: 0;
    background: transparent;
    color: var(--ink-3);
    font: 600 11px/1.2 var(--sans);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
}
.theme-pick button + button {
    border-left: 1px solid var(--line);
}
.theme-pick button:hover {
    color: var(--ink);
}
.theme-pick button[aria-pressed="true"] {
    background: var(--ink);
    color: var(--bg);
}

/* Narrower screens -------------------------------------------------------- */

@media (max-width: 1240px) {
    .shell {
        grid-template-columns: var(--side) minmax(0, 1fr);
    }
    .toc {
        display: none;
    }
}

@media (max-width: 900px) {
    :root {
        --top: 56px;
    }
    .top {
        padding: 0 16px;
        gap: 12px;
    }
    .top__menu {
        display: inline-flex;
    }
    .top__menu[hidden] {
        display: none;
    }
    .brand__logo img {
        width: 113px;
        height: 24px;
    }
    .top__links {
        gap: 14px;
        font-size: 13px;
    }
    .shell {
        display: flex;
        flex-direction: column;
    }
    /* Without JavaScript the menu cannot open, so it follows the article instead. */
    .side {
        order: 2;
        position: static;
        max-height: none;
        padding: 24px 20px 40px;
        border-top: 1px solid var(--line);
        border-right: 0;
        font-size: 15px;
    }
    .main {
        order: 1;
    }
    .js .side {
        position: fixed;
        inset: var(--top) 0 var(--foot) 0;
        z-index: 15;
        padding: 20px 20px 48px;
        border-top: 0;
        background: var(--bg);
        visibility: hidden;
        opacity: 0;
        transform: translateY(-8px);
        transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
    }
    .is-menu-open .side {
        visibility: visible;
        opacity: 1;
        transform: none;
        transition: opacity 0.18s ease, transform 0.18s ease;
    }
    .is-menu-open body {
        overflow: hidden;
    }
    .side a {
        padding: 8px 12px;
    }
    .main {
        padding: 28px 20px 48px;
    }
    .anchor {
        display: none;
    }
    .foot {
        gap: 16px;
        padding: 0 16px;
    }
    .foot__legal {
        display: none;
    }
}

@media (max-width: 480px) {
    .top__links a:not(.top__github) {
        display: none;
    }
    .pager {
        grid-template-columns: 1fr;
    }
    .pager__next {
        grid-column: auto;
    }
    .foot__label,
    .foot__github span {
        display: none;
    }
    .theme-pick button {
        padding: 6px 9px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .side {
        transition: none !important;
    }
}

@media print {
    .top,
    .side,
    .toc,
    .pager,
    .source,
    .foot,
    .copy {
        display: none !important;
    }
    .shell {
        display: block;
    }
    .main {
        padding: 0;
    }
    body {
        padding-bottom: 0;
    }
}
