/*
 * Documentation section.
 *
 * Reads like a reference, not like a wall: a sticky table of contents on the left, a
 * search field that filters whole sections, and compact tables - most answers here are
 * "which of these, and what does it mean", which is a table, not a paragraph.
 */

.docs-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

/* ---------- table of contents ---------------------------------------------------------- */

.docs-toc {
    position: sticky;
    top: 16px;
    padding: 14px;
    border: 1px solid var(--color-border-cool-soft);
    border-radius: 12px;
    background: var(--color-surface);
}

.docs-search {
    position: relative;
    display: block;
    margin-bottom: 12px;
}

.docs-search__icon {
    position: absolute;
    top: 50%;
    left: 10px;
    color: var(--color-slate-400);
    font-size: 15px;
    line-height: 1;
    pointer-events: none;
    transform: translateY(-50%);
}

.docs-search .field-control {
    width: 100%;
    padding: 8px 10px 8px 30px;
    font-size: 13px;
}

.docs-toc__item {
    display: block;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--color-slate-650);
    font-size: 13px;
    line-height: 1.35;
    text-decoration: none;
}

.docs-toc__item:hover {
    background: var(--color-surface-divider);
    color: var(--color-slate-900);
}

/* A section filtered out by the search stays listed but steps back, so the reader keeps
   the shape of the whole document while searching inside it. */
.docs-toc__item.is-dim {
    opacity: 0.35;
}

/* Where the reader is right now, in the same visual language as the main sidebar. */
.docs-toc__item.is-active {
    position: relative;
    background: var(--color-surface-divider);
    color: var(--color-slate-900);
    font-weight: 600;
}

.docs-toc__item.is-active::before {
    position: absolute;
    top: 50%;
    left: 0;
    width: 3px;
    height: 16px;
    border-radius: 0 3px 3px 0;
    background: var(--color-slate-900);
    content: "";
    transform: translateY(-50%);
}

/* ---------- content -------------------------------------------------------------------- */

.docs-body {
    min-width: 0;
}

.docs-result {
    margin: 0 0 12px;
    color: var(--color-slate-450);
    font-size: 13px;
}

.docs-section {
    scroll-margin-top: 16px;
}

.docs-section__title {
    margin: 0 0 12px;
    color: var(--color-slate-900);
    font-size: 19px;
    line-height: 1.25;
}

.docs-p {
    margin: 0 0 10px;
    color: var(--color-slate-700);
    font-size: 14px;
    line-height: 1.65;
}

.docs-list,
.docs-steps {
    margin: 0 0 12px;
    padding-left: 20px;
    color: var(--color-slate-700);
    font-size: 14px;
    line-height: 1.6;
}

.docs-steps li,
.docs-list li {
    margin-bottom: 6px;
}

.docs-steps {
    counter-reset: docs-step;
    list-style: none;
    padding-left: 0;
}

.docs-steps li {
    position: relative;
    padding-left: 32px;
}

.docs-steps li::before {
    position: absolute;
    top: 2px;
    left: 0;
    display: grid;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-slate-900);
    color: var(--color-surface);
    content: counter(docs-step);
    counter-increment: docs-step;
    font-size: 11px;
    font-weight: 700;
    place-items: center;
}

.docs-note {
    display: flex;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--color-warning-fill);
    border-radius: 10px;
    background: var(--color-level-warn-surface);
    color: var(--color-warning-note-ink);
    font-size: 13.5px;
    line-height: 1.55;
}

.docs-note__mark {
    display: grid;
    flex: 0 0 18px;
    height: 18px;
    margin-top: 2px;
    border-radius: 50%;
    background: var(--color-warning);
    color: var(--color-surface);
    font-size: 11px;
    font-weight: 700;
    place-items: center;
}

/* ---------- tables --------------------------------------------------------------------- */

.docs-table-wrap {
    margin: 0 0 14px;
    overflow-x: auto;
    border: 1px solid var(--color-border-cool-soft);
    border-radius: 10px;
}

.docs-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
}

.docs-table th {
    padding: 9px 12px;
    background: var(--color-surface-cool);
    color: var(--color-slate-650);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--color-border-cool-soft);
}

.docs-table td {
    padding: 9px 12px;
    color: var(--color-slate-700);
    line-height: 1.5;
    vertical-align: top;
    border-bottom: 1px solid var(--color-surface-divider);
}

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

.docs-table tbody tr:nth-child(even) td {
    background: var(--color-surface);
}

/* The first column of a reference table is the thing being looked up. */
.docs-table td:first-child {
    color: var(--color-slate-900);
    font-weight: 600;
}

.docs-hit {
    padding: 0 2px;
    border-radius: 3px;
    background: var(--color-highlight-hit);
    color: inherit;
}

/* ---------- narrow screens -------------------------------------------------------------- */

@media (max-width: 1280px) {
    .docs-layout {
        grid-template-columns: 1fr;
    }

    .docs-toc {
        position: static;
    }

    .docs-toc nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .docs-toc__item {
        border: 1px solid var(--color-border-cool-soft);
    }

    /* Reference tables become stacked records, same idea as the admin data table. */
    .docs-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }

    .docs-table,
    .docs-table tbody,
    .docs-table tr,
    .docs-table td {
        display: block;
        width: auto;
    }

    .docs-table tr {
        padding: 4px 0;
        border-bottom: 1px solid var(--color-border-cool-soft);
    }

    .docs-table tbody tr:last-child {
        border-bottom: 0;
    }

    .docs-table td,
    .docs-table tbody tr:nth-child(even) td {
        display: flex;
        gap: 12px;
        justify-content: space-between;
        background: transparent;
        border-bottom: 0;
    }

    .docs-table td::before {
        flex: 0 0 38%;
        color: var(--color-slate-400);
        content: attr(data-label);
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }
}
