/* Styles for the documentation site. Adapted from the one used by IPS2026-PL103. */

:root {
    --fg: #1f2328;
    --muted: #59636e;
    --bg: #ffffff;
    --accent: #0b5cad;
    --accent-soft: #eaf2fc;
    --border: #d1d9e0;
    --code-bg: #f6f8fa;
    --measure: 80ch;
    --header-height: 3.25rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
}

.wrap {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* --- Header ------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: var(--header-height);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.site-header .wrap {
    max-width: 100rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.5rem;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
}

.brand {
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-left: auto;
}

.site-nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.site-nav a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* --- Content ------------------------------------------------------------ */

main.wrap {
    padding-top: 2rem;
    padding-bottom: 3rem;
}

article.doc h1 {
    font-size: 2rem;
    line-height: 1.25;
    margin-top: 0;
    letter-spacing: -0.02em;
}

article.doc h2 {
    font-size: 1.45rem;
    margin-top: 2.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

article.doc h3 {
    font-size: 1.15rem;
    margin-top: 2rem;
}

article.doc h4 {
    font-size: 1rem;
    margin-top: 1.6rem;
    color: var(--muted);
}

article.doc h1,
article.doc h2,
article.doc h3,
article.doc h4 {
    scroll-margin-top: calc(var(--header-height) + 1rem);
    line-height: 1.3;
}

article.doc a {
    color: var(--accent);
}

article.doc img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5rem auto;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

/* Images that link to the full size file are shown at full size on click */
article.doc a>img {
    cursor: zoom-in;
}

article.doc a:hover>img {
    border-color: var(--accent);
}

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

article.doc blockquote {
    margin: 1.5rem 0;
    padding: 0.25rem 1.25rem;
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 6px 6px 0;
    color: var(--muted);
}

article.doc blockquote p:first-child {
    margin-top: 0.75rem;
}

article.doc blockquote p:last-child {
    margin-bottom: 0.75rem;
}

/* --- Code --------------------------------------------------------------- */

code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.88em;
}

:not(pre)>code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1em 0.35em;
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.9rem 1rem;
    overflow-x: auto;
    line-height: 1.5;
}

/* Pandoc appends its own rules for highlighted code after this sheet, and the one
   it writes for `.sourceCode` says `overflow: visible`. It is a class, so it beats
   the `pre` above and a line longer than the column is painted outside the block
   instead of scrolling inside it. Naming the class here is what keeps the box the
   scroll container, and what keeps the background covering the whole block. */
pre.sourceCode {
    overflow-x: auto;
    /* A bar that appears only while scrolling makes a line cut at the edge look like
       the end of the line. Thin, and in the colour of the borders. */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

pre.sourceCode::-webkit-scrollbar {
    height: 10px;
}

pre.sourceCode::-webkit-scrollbar-track {
    background: transparent;
}

pre.sourceCode::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}

pre code {
    background: none;
    border: 0;
    padding: 0;
}

/* --- Tables ------------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

th,
td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.7rem;
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--code-bg);
}

tbody tr:nth-child(even) {
    background: #fafbfc;
}

/* --- Side index --------------------------------------------------------- */

.toc {
    font-size: 0.92rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 1rem 1rem;
    margin-bottom: 2rem;
    background: var(--bg);
}

.toc h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0.6rem 0 0.5rem;
}

.toc ul {
    list-style: none;
    margin: 0;
    padding-left: 0;
}

.toc li {
    margin: 0.15rem 0;
}

.toc ul ul {
    padding-left: 0.9rem;
}

.toc a {
    color: var(--muted);
    text-decoration: none;
}

.toc a:hover {
    color: var(--accent);
    text-decoration: underline;
}

@media (min-width: 1150px) {
    main.wrap.with-toc {
        max-width: 116ch;
        display: grid;
        grid-template-columns: 20rem minmax(0, 1fr);
        gap: 3rem;
        align-items: start;
    }

    main.wrap>.toc {
        grid-column: 1;
        position: sticky;
        top: calc(var(--header-height) + 2rem);
        max-height: calc(100vh - var(--header-height) - 3rem);
        overflow-y: auto;
        margin-bottom: 0;
    }

    main.wrap.with-toc>article.doc {
        grid-column: 2;
    }
}

/* --- Footer ------------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
}

.site-footer .wrap {
    max-width: 100rem;
    padding-top: 1rem;
    padding-bottom: 1.5rem;
}

/* --- Skip link (accessibility) ------------------------------------------ */

.skip {
    position: absolute;
    left: -9999px;
}

.skip:focus {
    left: 1rem;
    top: 0.5rem;
    z-index: 20;
    background: var(--bg);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
}