/* The documentation: the list of pages at one side, the page, and its outline at the other. */

.docs {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) 190px;
    align-items: start;
    gap: 56px;
}

.docs-main {
    min-width: 0;
    max-width: 740px;
    padding-block: 44px 80px;
}

/* MARK: List of pages */

.docs-nav,
.docs-outline {
    position: sticky;
    top: var(--header-height);
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.docs-nav {
    margin-left: -10px;
    padding-block: 36px 48px;
}

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

.docs-nav h2,
.docs-outline h2 {
    margin: 0 0 6px;
    padding-inline: 10px;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
}

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

.docs-nav a {
    display: block;
    padding: 5px 10px;
    border-radius: 7px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.35;
}

.docs-nav a:hover {
    background: var(--fill);
    color: var(--text);
    text-decoration: none;
}

.docs-nav a[aria-current] {
    background: var(--fill-strong);
    color: var(--text);
    font-weight: 500;
}

.docs-menu {
    display: none;
    height: 30px;
    margin-right: 6px;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--fill);
    font-size: 13px;
    font-weight: 500;
}

/* MARK: Outline */

.docs-outline {
    padding-block: 48px;
}

.docs-outline h2 {
    padding-inline: 0;
}

.docs-outline a {
    display: block;
    padding: 3px 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.docs-outline .level-3 a {
    padding-left: 12px;
}

.docs-outline a:hover,
.docs-outline a.is-current {
    color: var(--text);
    text-decoration: none;
}

.docs-outline a.is-current {
    font-weight: 500;
}

/* MARK: Page */

.prose {
    overflow-wrap: break-word;
}

.prose h1 {
    margin: 0 0 18px;
    font-size: clamp(30px, 4vw, 38px);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.022em;
}

.prose h2 {
    margin: 48px 0 12px;
    font-size: 24px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -0.016em;
}

.prose h3 {
    margin: 32px 0 8px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.prose h4 {
    margin: 24px 0 6px;
    font-size: 16px;
    font-weight: 600;
}

.prose p,
.prose ul,
.prose ol {
    margin: 0 0 16px;
}

.prose ul,
.prose ol {
    padding-left: 1.35em;
}

.prose li {
    margin: 6px 0;
}

.prose li > ul,
.prose li > ol {
    margin: 6px 0 0;
}

.prose li::marker {
    color: var(--text-tertiary);
}

.prose strong {
    font-weight: 600;
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.prose hr {
    height: 1px;
    margin: 40px 0;
    border: 0;
    background: var(--separator);
}

.prose .anchor {
    margin-left: 0.35em;
    color: var(--text-tertiary);
    font-weight: 400;
    opacity: 0;
    transition: opacity 0.15s;
}

.prose :is(h2, h3, h4):hover .anchor,
.prose .anchor:focus-visible {
    opacity: 1;
    text-decoration: none;
}

.prose code {
    padding: 0.12em 0.38em;
    border-radius: 5px;
    background: var(--fill);
    font-size: 0.875em;
}

.prose :is(h1, h2, h3) code {
    font-size: 0.9em;
}

.code {
    position: relative;
    margin: 0 0 20px;
    border-radius: 12px;
    background: var(--background-tinted);
}

.code pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 13.5px;
    line-height: 1.6;
}

.code code {
    padding: 0;
    background: none;
    font-size: inherit;
}

.code .comment {
    color: var(--text-secondary);
}

.code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    height: 28px;
    padding: 0 10px;
    border-radius: 7px;
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--separator);
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.15s;
}

.code:hover .code-copy,
.code-copy:focus-visible,
.code-copy.is-copied {
    opacity: 1;
}

.code-copy.is-copied {
    color: var(--accent);
}

/* A table like a grouped list in System Settings: in a rounded box, its rows parted by hairlines. */
.table {
    margin: 0 0 20px;
    overflow-x: auto;
    border: 1px solid var(--separator);
    border-radius: 12px;
}

.table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    line-height: 1.45;
}

.table th,
.table td {
    padding: 10px 16px;
    text-align: left;
    vertical-align: top;
}

.table th {
    background: var(--background-tinted);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.table td {
    border-top: 1px solid var(--separator);
}

.table .is-headless thead {
    display: none;
}

.table .is-headless tr:first-child td {
    border-top: 0;
}

.table .is-headless td:first-child {
    color: var(--text-secondary);
    white-space: nowrap;
}

.table td:first-child code {
    white-space: nowrap;
}

/* A diagram is drawn by a script. Until then, and without one, it is its own source. */
.mermaid {
    margin: 4px 0 24px;
    padding: 14px 16px;
    overflow-x: auto;
    border-radius: 12px;
    background: var(--background-tinted);
    font-size: 13px;
    line-height: 1.6;
}

.js .mermaid:not([data-processed], .has-failed) {
    min-height: 140px;
    color: transparent;
}

.mermaid[data-processed] {
    padding: 20px 8px;
    background: none;
    text-align: center;
}

.mermaid svg {
    display: inline-block;
    max-width: 100%;
    height: auto;
}

.docs-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 56px;
}

.docs-pager a {
    padding: 14px 18px;
    border: 1px solid var(--separator);
    border-radius: 14px;
    color: var(--text);
    font-weight: 500;
    line-height: 1.35;
    transition: background-color 0.15s;
}

.docs-pager a:hover {
    background: var(--fill);
    text-decoration: none;
}

.docs-pager span {
    display: block;
    margin-bottom: 2px;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 500;
}

.docs-pager-next {
    text-align: right;
}

.docs-edit {
    margin: 24px 0 0;
    font-size: 13px;
}

.docs-edit a {
    color: var(--text-secondary);
}

/* MARK: First page */

.docs-group {
    margin-top: 36px;
}

.docs-group h2 {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -0.012em;
}

.docs-group ul {
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--separator);
    border-radius: 14px;
    list-style: none;
}

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

.docs-group a {
    position: relative;
    display: block;
    padding: 12px 40px 12px 16px;
    color: var(--text);
    transition: background-color 0.15s;
}

.docs-group a:hover {
    background: var(--fill);
    text-decoration: none;
}

.docs-group a::after {
    content: "›";
    position: absolute;
    top: 50%;
    right: 16px;
    color: var(--text-tertiary);
    font-size: 20px;
    line-height: 1;
    transform: translateY(-58%);
}

.docs-group strong {
    display: block;
    font-size: 15.5px;
    font-weight: 600;
}

.docs-group span {
    display: block;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* MARK: Sizes */

@media (max-width: 1099px) {
    .docs {
        grid-template-columns: 220px minmax(0, 1fr);
        gap: 44px;
    }

    .docs-outline {
        display: none;
    }
}

/* Too narrow for the list next to the page. With the script, a button in the header opens it over the
   page; without, it follows the page. */
@media (max-width: 799px) {
    .docs {
        display: flex;
        flex-direction: column;
    }

    .docs-main {
        max-width: none;
        padding-block: 32px 56px;
    }

    .docs-nav {
        position: static;
        order: 1;
        max-height: none;
        margin-left: -10px;
        padding-block: 24px 40px;
        border-top: 1px solid var(--separator);
    }

    .site-nav {
        display: none;
    }

    .site-brand {
        margin-right: auto;
    }

    .js .docs-menu {
        display: block;
    }

    .js .docs-nav {
        position: fixed;
        inset: var(--header-height) 0 0;
        z-index: 15;
        display: none;
        margin: 0;
        padding: 20px calc(var(--gutter) - 10px) 48px;
        border: 0;
        background: var(--background);
    }

    .js.is-showing-contents .docs-nav {
        display: block;
    }

    .js.is-showing-contents body {
        overflow: hidden;
    }
}
