/* The site API reference: page navigation, explanation, and a dark band of code beside it. */
.api-page {
    --api-page: #2d2d2d;
    --api-band: #1f1f1e;
    --api-band-raised: #272725;
    --api-text: #e2e1dc;
    --api-muted: rgba(226, 225, 220, 0.68);
    --api-faint: rgba(226, 225, 220, 0.46);
    --api-line: rgba(226, 225, 220, 0.13);
    --api-accent: #f0d870;
    --api-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
    --api-nav-width: 228px;
    background: var(--api-page);
    color: var(--api-text);
}

.site-shell-page.site-shell-page--immersive.api-page {
    padding-top: 72px;
}

.site-shell-main.api-layout {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: var(--api-nav-width) minmax(0, 1fr);
    align-items: start;
    flex: 1;
}

/* ------------------------------------------------------------ navigation */

.api-nav {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    padding: 34px 18px 34px 28px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 14px;
}

.api-nav__title {
    margin: 0 0 14px;
    font-weight: 600;
    font-size: 15px;
}

.api-nav__group {
    margin: 22px 0 7px;
    color: var(--api-faint);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.api-nav a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 9px;
    margin-left: -9px;
    border-radius: 6px;
    color: var(--api-muted);
    text-decoration: none;
    transition: color 120ms ease, background-color 120ms ease;
}

.api-nav a:hover {
    color: var(--api-text);
}

.api-nav a.is-current {
    color: var(--api-text);
    background: rgba(226, 225, 220, 0.09);
}

.api-nav .verb {
    width: 30px;
    flex: none;
    font-size: 10.5px;
}

.api-nav .api-nav__spec {
    margin-top: 22px;
    font-family: var(--api-mono);
    font-size: 12.5px;
}

.verb {
    font-family: var(--api-mono);
    font-weight: 500;
    color: var(--api-accent);
}

.api-main {
    min-width: 0;
    border-left: 1px solid var(--api-line);
}

.api-row h1 {
    margin: 0 0 12px;
    font-size: 32px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.api-row h1 + p + p + h2 {
    margin-top: 34px;
}

/* ------------------------------------------------------------ rows: text beside code */

.api-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    scroll-margin-top: 72px;
}

.api-row__text {
    min-width: 0;
    padding: 52px 40px 52px 48px;
    border-bottom: 1px solid var(--api-line);
    font-size: 15.5px;
    line-height: 1.62;
}

.api-row__code {
    min-width: 0;
    padding: 52px 28px;
    background: var(--api-band);
    border-bottom: 1px solid rgba(226, 225, 220, 0.07);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.api-row h2 {
    margin: 0 0 14px;
    font-size: 25px;
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: -0.015em;
}

.api-row h3 {
    margin: 30px 0 10px;
    font-size: 15px;
    font-weight: 600;
}

.api-row p {
    margin: 0 0 14px;
    color: var(--api-muted);
}

.api-row a {
    color: var(--api-text);
    text-decoration: underline;
    text-decoration-color: var(--api-faint);
    text-underline-offset: 2px;
}

.api-page code {
    font-family: var(--api-mono);
    font-size: 0.86em;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(226, 225, 220, 0.085);
    color: var(--api-text);
    overflow-wrap: anywhere;
}

.api-route {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 12px !important;
    font-size: 15px;
}

.api-route code {
    background: none;
    padding: 0;
    font-size: 14px;
}

.api-table {
    width: 100%;
    margin: 4px 0 18px;
    border-collapse: collapse;
    font-size: 14.5px;
}

.api-table th,
.api-table td {
    padding: 9px 12px 9px 0;
    border-bottom: 1px solid var(--api-line);
    text-align: left;
    vertical-align: top;
    font-weight: 400;
}

.api-table tbody th,
.api-table thead th {
    color: var(--api-muted);
}

.api-table--codes td {
    color: var(--api-muted);
}

.api-table--fields tbody th {
    width: 1%;
    padding-right: 18px;
    white-space: nowrap;
}

.api-table--fields td {
    color: var(--api-muted);
}

.api-table--codes td:nth-child(2) {
    white-space: nowrap;
}

.api-table--codes td:first-child {
    color: var(--api-text);
    font-family: var(--api-mono);
    font-size: 13px;
}

/* ------------------------------------------------------------ code */

.api-code {
    position: sticky;
    top: 92px;
    border: 1px solid rgba(226, 225, 220, 0.1);
    border-radius: 9px;
    background: var(--api-band-raised);
    overflow: hidden;
    color: #dddcd5;
}

/* A column with two panels scrolls with the page: a held panel would slide over the other. */
.api-code + .api-code,
.api-code:has(+ .api-code) {
    position: static;
}

.api-code__bar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 4px 6px 4px 14px;
    border-bottom: 1px solid rgba(226, 225, 220, 0.09);
}

.api-code__title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: rgba(226, 225, 220, 0.62);
    font-size: 12.5px;
}

.api-code__copy {
    flex: none;
    padding: 4px 9px;
    border: 0;
    border-radius: 5px;
    background: none;
    color: rgba(226, 225, 220, 0.62);
    font: 500 12px var(--site-font-sans);
    cursor: pointer;
}

.api-code__copy:hover,
.api-code__copy:focus-visible {
    color: #fff;
    background: rgba(226, 225, 220, 0.1);
}

.api-code__tabs {
    display: flex;
    gap: 2px;
    padding: 6px 8px 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid rgba(226, 225, 220, 0.09);
}

.api-code__tab {
    flex: none;
    padding: 6px 10px 8px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: rgba(226, 225, 220, 0.62);
    font: 500 12.5px var(--site-font-sans);
    cursor: pointer;
}

.api-code__tab:hover {
    color: #fff;
}

.api-code__tab[aria-selected="true"] {
    color: #fff;
    border-bottom-color: var(--api-accent);
}

.api-code pre {
    margin: 0;
    padding: 15px 16px 17px;
    max-height: calc(100vh - 220px);
    overflow: auto;
    font-family: var(--api-mono);
    font-size: 12.5px;
    line-height: 1.62;
    tab-size: 4;
}

.api-code pre code {
    padding: 0;
    background: none;
    font-size: inherit;
    color: inherit;
    overflow-wrap: normal;
}

.api-code pre[hidden] {
    display: none;
}

.api-page :focus-visible {
    outline: 2px solid var(--api-accent);
    outline-offset: 2px;
}

.tok-comment { color: #8f8e86; }
.tok-string { color: #e9d27a; }
.tok-keyword { color: #a9c7d6; }
.tok-number { color: #d9a98b; }

/* ------------------------------------------------------------ narrower windows */

@media (max-width: 1240px) {
    .api-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .api-row__text {
        padding-bottom: 28px;
        border-bottom: 0;
    }

    .api-row__code {
        padding: 0 40px 44px 48px;
        background: none;
        border-bottom: 1px solid var(--api-line);
    }

    .api-row__code--empty {
        padding-bottom: 0;
    }

    .api-code {
        position: static;
    }

    .api-code pre {
        max-height: none;
    }
}

@media (max-width: 860px) {
    .api-table--fields tbody th,
    .api-table--fields td {
        display: block;
        width: auto;
        padding-right: 0;
        white-space: normal;
    }

    .api-table--fields tbody th {
        padding-bottom: 0;
        border-bottom: 0;
    }

    .site-shell-main.api-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .api-nav {
        position: sticky;
        z-index: 20;
        max-height: none;
        padding: 8px 16px;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
        background: var(--api-page);
        border-bottom: 1px solid var(--api-line);
    }

    .api-nav__title,
    .api-nav__group,
    .api-nav .verb {
        display: none;
    }

    .api-nav a {
        margin: 0;
        flex: none;
    }

    .api-nav .api-nav__spec {
        margin: 0;
    }

    .api-main {
        border-left: 0;
    }

    .api-row {
        scroll-margin-top: 120px;
    }

    .api-row__text {
        padding: 36px 16px 22px;
    }

    .api-row__code {
        padding: 0 16px 32px;
    }

    .api-table--codes thead {
        display: none;
    }

    .api-table--codes tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        column-gap: 10px;
        padding: 11px 0;
        border-bottom: 1px solid var(--api-line);
    }

    .api-table--codes td {
        padding: 0;
        border: 0;
    }

    .api-table--codes td:nth-child(3) {
        grid-column: 1 / -1;
        margin-top: 4px;
    }
}
