/*
 * Predxy documentation (ADR 0129).
 *
 * The site's paper, ink and type rather than a documentation theme's: a partner reading how to
 * call the API is on Predxy, and the page should say so. Sections run down the middle, their
 * examples beside them on a wide screen and below them on a narrow one; the contents stay put
 * down the side. Fonts are self-hosted (fonts.css), as on every other Predxy surface.
 */

:root {
    --paper: #f7f3e9;
    --paper-2: #fffdf7;
    --paper-3: #efe9db;
    --ink: #111111;
    --ink-80: rgba(17, 17, 17, .8);
    --ink-64: rgba(17, 17, 17, .64);
    --ink-48: rgba(17, 17, 17, .48);
    --ink-24: rgba(17, 17, 17, .24);
    --ink-12: rgba(17, 17, 17, .12);
    --ink-06: rgba(17, 17, 17, .06);
    --highlight: #e6f4c7;
    --highlight-ink: #1f3a12;
    --up: #1c6b3f;
    --warn: #8a5a00;

    /* Code is set dark in both themes, as the site's own snippets are. */
    --code: #14140f;
    --code-ink: #f3efe4;
    --code-dim: rgba(243, 239, 228, .5);
    --code-key: #f2c66d;
    --code-string: #b9e59a;
    --code-number: #8fc7ff;
    --code-flag: #f2a37a;

    /* The site's three faces (the app's globals.css): the serif for the guides' headings, the
       sans for words, the mono for code and figures. */
    --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --serif: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --bar: 3.75rem;
    --menu: 2.75rem;
    --side: 17rem;
    --radius: .75rem;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #0f0f0e;
        --paper-2: #171716;
        --paper-3: #1f1f1d;
        --ink: #f3efe4;
        --ink-80: rgba(243, 239, 228, .82);
        --ink-64: rgba(243, 239, 228, .66);
        --ink-48: rgba(243, 239, 228, .5);
        --ink-24: rgba(243, 239, 228, .26);
        --ink-12: rgba(243, 239, 228, .14);
        --ink-06: rgba(243, 239, 228, .07);
        --highlight: #e4ff5a;
        --highlight-ink: #111111;
        --up: #7fe0a3;
        --warn: #f2c66d;
        --code: #1a1a18;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--bar) + 1.5rem); }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--ink-24); text-underline-offset: .2em; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: .25rem; }

.px-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---- the bar, shared with the reference ------------------------------------------------- */

.px-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--bar);
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0 1.5rem;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--ink-12);
}

.px-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    text-decoration: none;
    flex-shrink: 0;
}

.px-mark {
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border: 2.5px solid var(--ink);
    border-radius: .6rem;
    font-family: Quicksand, var(--sans);
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: -.02em;
}

/* The wordmark as the site sets it: Quicksand, which sets only the logo. */
.px-word { font-family: Quicksand, var(--sans); font-size: 1.3rem; font-weight: 600; letter-spacing: -.02em; }

.px-label {
    font-family: var(--mono);
    font-size: .7rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-64);
    padding-left: .6rem;
    border-left: 1px solid var(--ink-24);
}

.px-links { display: flex; gap: .25rem; font-size: .95rem; overflow-x: auto; scrollbar-width: none; }
.px-links::-webkit-scrollbar { display: none; }

.px-links a {
    padding: .35rem .8rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--ink-64);
    white-space: nowrap;
}

.px-links a:hover { color: var(--ink); background: var(--ink-06); }
.px-links a[aria-current="page"] { color: var(--ink); background: var(--paper-3); }

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

.px-layout {
    display: grid;
    grid-template-columns: var(--side) minmax(0, 1fr);
}

.px-sidebar {
    position: sticky;
    top: var(--bar);
    height: calc(100vh - var(--bar));
    overflow-y: auto;
    padding: 1.75rem 1rem 2rem;
    border-right: 1px solid var(--ink-12);
    background: var(--paper);
    font-size: .95rem;
}

.px-sidebar ul { list-style: none; margin: 0 0 1.25rem; padding: 0; }

.px-group {
    margin: 0 0 .4rem;
    padding: 0 .75rem;
    font-family: var(--mono);
    font-size: .7rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-48);
}

.px-sidebar li a {
    display: block;
    padding: .3rem .75rem;
    border-radius: .5rem;
    text-decoration: none;
    color: var(--ink-64);
    line-height: 1.45;
}

.px-sidebar li a:hover { color: var(--ink); background: var(--ink-06); }

.px-sidebar li a[aria-current="true"] {
    color: var(--highlight-ink);
    background: var(--highlight);
    font-weight: 600;
}

.px-admin {
    margin: 1.5rem 0 0;
    padding: 1rem .75rem 0;
    border-top: 1px solid var(--ink-12);
    font-size: .85rem;
    color: var(--ink-64);
}

/* A button takes the page's face; a browser gives it its own. */
button { font: inherit; }

.px-menu { display: none; }

.px-main {
    min-width: 0;
    padding: 0 clamp(1.25rem, 4vw, 3.5rem) 4rem;
    max-width: 82rem;
}

/* ---- a section ---------------------------------------------------------------------------- */

.px-section {
    padding: 3rem 0 2.5rem;
    border-bottom: 1px solid var(--ink-12);
}

.px-section > * { max-width: 46rem; }

.px-section h1,
.px-section h2,
.px-section h3 {
    font-family: var(--serif);
}

.px-section h2 {
    margin: 0 0 1rem;
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.03em;
}

.px-section h3 {
    margin: 2rem 0 .5rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.px-section h4 { margin: 1.5rem 0 .25rem; font-size: 1.05rem; font-weight: 700; }

.px-section p, .px-section ul, .px-section ol { margin: 0 0 1rem; color: var(--ink-80); }
.px-section li { margin: .25rem 0; }
.px-section li::marker { color: var(--ink-48); }
.px-section strong { color: var(--ink); font-weight: 700; }

.px-section code {
    font-family: var(--mono);
    font-size: .88em;
    padding: .1em .4em;
    border-radius: .35rem;
    background: var(--paper-3);
    color: var(--ink);
}

.px-section a code { text-decoration: none; }

.px-section blockquote {
    margin: 0 0 1.25rem;
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    background: var(--highlight);
    color: var(--highlight-ink);
}

.px-section blockquote p { margin: 0; color: inherit; }
.px-section blockquote code { background: rgba(17, 17, 17, .08); color: inherit; }

.px-section table {
    width: 100%;
    margin: 0 0 1.25rem;
    border-collapse: collapse;
    font-size: .95rem;
    display: block;
    overflow-x: auto;
}

.px-section th, .px-section td {
    text-align: left;
    vertical-align: top;
    padding: .55rem .9rem .55rem 0;
    border-bottom: 1px solid var(--ink-12);
}

.px-section th {
    font-family: var(--mono);
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-48);
}

.px-section td:first-child { white-space: nowrap; }

/* A section with examples sets them beside it, kept in view while the section is read. */
@media (min-width: 75rem) {
    .px-section.has-example {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 27rem);
        column-gap: 3rem;
        align-items: start;
    }

    .px-section.has-example > * { grid-column: 1; }

    .px-section.has-example > .example {
        grid-column: 2;
        grid-row: 1 / span 60;
        position: sticky;
        top: calc(var(--bar) + 1.5rem);
        max-width: none;
        margin-top: .4rem;
    }
}

.example { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0 0; }
.example > p { margin: 0; font-size: .9rem; color: var(--ink-64); }

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

.code {
    position: relative;
    margin: 0 0 1.25rem;
    border-radius: var(--radius);
    background: var(--code);
    color: var(--code-ink);
    overflow: hidden;
    border: 1px solid rgba(243, 239, 228, .08);
}

.example .code { margin: 0; }

.code figcaption {
    padding: .55rem 1rem;
    font-family: var(--mono);
    font-size: .7rem;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--code-dim);
    border-bottom: 1px solid rgba(243, 239, 228, .1);
}

.code pre {
    margin: 0;
    padding: 1rem 1.1rem;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: .82rem;
    line-height: 1.65;
    tab-size: 2;
}

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

.t-key { color: var(--code-key); }
.t-string { color: var(--code-string); }
.t-number, .t-literal { color: var(--code-number); }
.t-comment { color: var(--code-dim); font-style: italic; }
.t-flag { color: var(--code-flag); }
.t-command { color: var(--code-key); font-weight: 500; }

.copy {
    position: absolute;
    top: .45rem;
    right: .5rem;
    padding: .2rem .6rem;
    border: 1px solid rgba(243, 239, 228, .18);
    border-radius: 999px;
    background: transparent;
    color: var(--code-dim);
    font: 500 .72rem var(--sans);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}

.code:hover .copy, .copy:focus-visible { opacity: 1; }
.copy:hover { color: var(--code-ink); border-color: rgba(243, 239, 228, .4); }

.px-footer { padding: 2.5rem 0 0; font-size: .9rem; color: var(--ink-48); }

/* ---- narrow screens: the contents behind a button --------------------------------------- */

@media (max-width: 56rem) {
    .px-layout { grid-template-columns: minmax(0, 1fr); }
    .px-bar { gap: 1rem; padding: 0 1rem; }
    .px-label { display: none; }

    .px-menu {
        display: block;
        height: var(--menu);
        position: sticky;
        top: var(--bar);
        z-index: 15;
        width: 100%;
        padding: .7rem 1rem;
        border: 0;
        border-bottom: 1px solid var(--ink-12);
        background: var(--paper-2);
        color: var(--ink);
        font: 600 .95rem var(--sans);
        text-align: left;
        cursor: pointer;
    }

    .px-menu::after { content: "▾"; float: right; color: var(--ink-48); }
    .px-menu[aria-expanded="true"]::after { content: "▴"; }

    .px-sidebar {
        display: none;
        position: fixed;
        inset: calc(var(--bar) + var(--menu)) 0 0;
        height: auto;
        z-index: 14;
        border-right: 0;
    }

    body.contents-open .px-sidebar { display: block; }
    body.contents-open { overflow: hidden; }
    html { scroll-padding-top: calc(var(--bar) + 4rem); }
}
