/*
 * The API docs (/docs): the site's tokens and type, light and dark, a
 * sidebar per page, a phone layout with the sidebar as a drawer. Plain CSS
 * under the strict CSP; docs.js only toggles classes.
 */

:root {
    color-scheme: light;
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #898781;
    --grid: #e1e0d9;
    --border: rgba(11, 11, 11, 0.10);
    --control-border: #898781;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --focus: #2a78d6;
    --underline: #c3c2b7;
    --backdrop: rgba(11, 11, 11, 0.38);
    --shadow: 0 1px 2px rgba(11, 11, 11, 0.06), 0 12px 32px rgba(11, 11, 11, 0.14);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    --radius: 8px;
    --top: 52px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface: #1a1a19;
        --ink: #ffffff;
        --ink-2: #c3c2b7;
        --muted: #898781;
        --grid: #2c2c2a;
        --border: rgba(255, 255, 255, 0.10);
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --focus: #3987e5;
        --underline: #898781;
        --backdrop: rgba(0, 0, 0, 0.6);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.55);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --focus: #3987e5;
    --underline: #898781;
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 32px rgba(0, 0, 0, 0.55);
}

:root {
    --wash: color-mix(in srgb, var(--series-1) 8%, var(--surface));
    --hover: color-mix(in srgb, var(--ink) 5%, var(--surface));
    --chip: color-mix(in srgb, var(--ink) 6%, var(--surface));
    --sunken: color-mix(in srgb, var(--ink) 3%, var(--page));
    --get: var(--series-3);
    --post: var(--series-1);
}

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

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

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font: 15px/1.6 var(--font);
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration-color: var(--underline);
    text-underline-offset: 2px;
}

a:hover {
    text-decoration-color: currentColor;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 8px;
    top: -48px;
    z-index: 100;
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--control-border);
    border-radius: 6px;
}

.skip-link:focus {
    top: 8px;
}

/* -------------------------------------------------------------- header */

.docs-top {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    height: var(--top);
    padding: 0 16px;
    background: var(--page);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.01em;
    white-space: nowrap;
    text-decoration: none;
}

.brand-mark {
    width: 20px;
    height: 20px;
    flex: none;
}

.brand-mark circle:first-child {
    fill: none;
    stroke: var(--ink);
    stroke-width: 3.5;
}

.brand-mark circle:last-child {
    fill: var(--ink);
}

.docs-home {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--chip);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.top-links {
    display: flex;
    gap: 14px;
    margin-left: auto;
    font-size: 13px;
    color: var(--ink-2);
}

.icon-btn,
.tool-btn,
.tabs button,
.copy-btn {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 13px;
}

.icon-btn:hover {
    background: var(--hover);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.theme-btn svg path {
    fill: currentColor;
    stroke: none;
}

.menu-btn {
    display: none;
    padding: 0 8px;
}

/* -------------------------------------------------------------- layout */

.docs-layout {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr) 220px;
    max-width: 1440px;
    margin: 0 auto;
}

.docs-nav {
    position: sticky;
    top: var(--top);
    align-self: start;
    height: calc(100vh - var(--top));
    overflow-y: auto;
    padding: 20px 12px 40px 16px;
    border-right: 1px solid var(--border);
    font-size: 14px;
}

.nav-section + .nav-section {
    margin-top: 18px;
}

.nav-title {
    margin: 0 0 6px 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.docs-nav ul,
.toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.docs-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    color: var(--ink-2);
    text-decoration: none;
    line-height: 1.3;
}

.docs-nav a:hover {
    background: var(--hover);
    color: var(--ink);
}

.docs-nav a[aria-current="page"] {
    background: var(--wash);
    color: var(--ink);
    font-weight: 600;
}

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

.toc {
    position: sticky;
    top: var(--top);
    align-self: start;
    max-height: calc(100vh - var(--top));
    overflow-y: auto;
    padding: 24px 16px;
    font-size: 13px;
}

.toc a {
    display: block;
    padding: 3px 0;
    color: var(--ink-2);
    text-decoration: none;
}

.toc a:hover {
    color: var(--ink);
}

.toc .toc-3 a {
    padding-left: 12px;
}

/* ------------------------------------------------------------- the page */

.page-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    max-width: 860px;
    margin-bottom: 8px;
}

.crumb {
    color: var(--series-1);
    font-size: 13px;
    font-weight: 600;
}

.page-actions {
    display: flex;
    gap: 8px;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 12.5px;
    text-decoration: none;
    white-space: nowrap;
}

.tool-btn:hover {
    background: var(--hover);
}

.doc {
    max-width: 860px;
}

.doc h1 {
    margin: 0 0 12px;
    font-size: 30px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.doc h2 {
    margin: 40px 0 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 21px;
    line-height: 1.3;
}

.doc h3 {
    margin: 28px 0 8px;
    font-size: 17px;
}

.doc h4 {
    margin: 28px 0 8px;
    font-size: 15px;
}

.doc .anchor {
    margin-left: 4px;
    color: var(--muted);
    text-decoration: none;
    opacity: 0;
}

.doc :is(h2, h3, h4):hover .anchor,
.doc .anchor:focus {
    opacity: 1;
}

.doc p,
.doc ul,
.doc ol {
    margin: 0 0 12px;
}

.doc ul,
.doc ol {
    padding-left: 22px;
}

.doc li + li {
    margin-top: 4px;
}

.doc li > ul,
.doc li > ol {
    margin: 4px 0 0;
}

.doc hr {
    margin: 28px 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.doc code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--chip);
    font: 0.88em/1.4 var(--mono);
    overflow-wrap: anywhere;
}

.doc pre code {
    padding: 0;
    background: none;
    font-size: 13px;
    line-height: 1.55;
    overflow-wrap: normal;
}

.endpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px !important;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.endpoint code {
    padding: 0;
    background: none;
    font-size: 14px;
    font-weight: 600;
}

.method {
    flex: none;
    min-width: 40px;
    padding: 1px 6px;
    border-radius: 4px;
    font: 700 10.5px/1.6 var(--mono);
    letter-spacing: 0.03em;
    text-align: center;
}

.method--get {
    background: color-mix(in srgb, var(--get) 16%, var(--surface));
    color: color-mix(in srgb, var(--get) 75%, var(--ink));
}

.method--post {
    background: color-mix(in srgb, var(--post) 16%, var(--surface));
    color: color-mix(in srgb, var(--post) 75%, var(--ink));
}

.endpoint .method {
    font-size: 12px;
}

.table-wrap {
    max-width: 100%;
    margin: 0 0 16px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.doc table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    line-height: 1.5;
}

.doc th,
.doc td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.doc th {
    background: var(--sunken);
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.doc tbody tr:last-child td {
    border-bottom: 0;
}

.doc td:first-child code {
    white-space: nowrap;
    font-weight: 600;
}

.callout {
    margin: 0 0 16px;
    padding: 10px 14px;
    border-left: 3px solid var(--series-1);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--wash);
}

.callout > :last-child {
    margin-bottom: 0;
}

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

.code {
    position: relative;
    margin: 0 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--sunken);
    overflow: hidden;
}

.code figcaption {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--ink-2);
    font: 600 12px/1.4 var(--mono);
}

.code pre {
    margin: 0;
    padding: 12px 14px;
    max-height: 560px;
    overflow: auto;
}

.copy-btn {
    position: absolute;
    top: 4px;
    right: 6px;
    height: 24px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    font-size: 12px;
    opacity: 0.85;
}

.copy-btn:hover {
    opacity: 1;
    background: var(--hover);
}

.code-group {
    margin: 0 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--sunken);
    overflow: hidden;
}

.code-group .code {
    margin: 0;
    border: 0;
    border-radius: 0;
}

.code-group .code + .code {
    border-top: 1px solid var(--border);
}

.code-group.has-tabs .code + .code {
    border-top: 0;
}

.code-group.has-tabs figcaption {
    display: none;
}

.code-group .code.is-hidden {
    display: none;
}

.tabs {
    display: flex;
    gap: 2px;
    padding: 4px 80px 0 6px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tabs button {
    padding: 6px 10px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.tabs button[aria-selected="true"] {
    border-bottom-color: var(--series-1);
    color: var(--ink);
}

.code-group.has-tabs .copy-btn {
    top: 6px;
}

/* ---------------------------------------------------------------- pager */

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 860px;
    margin-top: 48px;
}

.pager a {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-weight: 600;
    text-decoration: none;
}

.pager a:hover {
    background: var(--hover);
}

.pager small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.pager-next {
    grid-column: 2;
    text-align: right;
}

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

@media (max-width: 1200px) {
    .docs-layout {
        grid-template-columns: 248px minmax(0, 1fr);
    }

    .toc {
        display: none;
    }
}

@media (max-width: 860px) {
    .docs-layout {
        display: block;
    }

    .menu-btn {
        display: inline-flex;
    }

    .top-links {
        display: none;
    }

    .theme-btn {
        margin-left: auto;
    }

    .theme-btn span {
        display: none;
    }

    /* A drawer under the header (which stays on top, menu button included). */
    .docs-nav {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 30;
        width: min(300px, 86vw);
        height: 100vh;
        height: 100dvh;
        padding-top: calc(var(--top) + 16px);
        background: var(--page);
        box-shadow: var(--shadow);
        transform: translateX(-105%);
        transition: transform 0.18s ease;
        visibility: hidden;
    }

    .nav-open .docs-nav {
        transform: none;
        visibility: visible;
    }

    .nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 25;
        background: var(--backdrop);
    }

    .docs-main {
        padding: 16px 16px 48px;
    }

    .doc h1 {
        font-size: 25px;
    }

    .doc h2 {
        font-size: 19px;
    }

    .pager {
        grid-template-columns: 1fr;
    }

    .pager-next {
        grid-column: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .docs-nav {
        transition: none;
    }
}
