/* Shelf's documentation, in Shelf's own look: warm paper, library green, Lora for reading, Inter for the rest.
   The tokens follow src/Shelf.Api/wwwroot/app.css and docs/design-system.md. */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-display: swap;
    font-weight: 100 900;
    src: url("fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

@font-face {
    font-family: "Lora";
    font-style: normal;
    font-display: swap;
    font-weight: 400 700;
    src: url("fonts/lora-latin-wght-normal.woff2") format("woff2-variations");
}

@font-face {
    font-family: "Lora";
    font-style: italic;
    font-display: swap;
    font-weight: 400 700;
    src: url("fonts/lora-latin-wght-italic.woff2") format("woff2-variations");
}

:root {
    color-scheme: light;
    --color-brand: #263e38;
    --color-on-brand: #f5f1e8;
    --color-canvas: #f5f1e8;
    --color-surface: #fffdf9;
    --color-sunken: #ece6d9;
    --color-accent: #d5a46a;
    --color-ink: #252a28;
    --color-muted: #66716b;
    --color-rule: #ddd5c6;
    --color-control: #79837d;
    --color-danger: #8a1f11;
    --color-code: #efe9dd;
    --color-tip: #2f5d4a;
    --shadow: 0 1px 2px rgb(37 42 40 / 0.06), 0 6px 18px rgb(37 42 40 / 0.07);
    --font-serif: "Lora", "Iowan Old Style", Georgia, serif;
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
    --radius-card: 12px;
    --radius-control: 8px;
    --top: 3.75rem;
    --sidebar: 16rem;
    --toc: 14rem;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --color-brand: #86a995;
        --color-on-brand: #202824;
        --color-canvas: #202824;
        --color-surface: #2b342f;
        --color-sunken: #1a211e;
        --color-ink: #f1ede4;
        --color-muted: #c0c9c1;
        --color-rule: #3c4842;
        --color-control: #6f7b73;
        --color-danger: #f0b4a8;
        --color-code: #1a211e;
        --color-tip: #9cc7b1;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.25);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --color-brand: #86a995;
    --color-on-brand: #202824;
    --color-canvas: #202824;
    --color-surface: #2b342f;
    --color-sunken: #1a211e;
    --color-ink: #f1ede4;
    --color-muted: #c0c9c1;
    --color-rule: #3c4842;
    --color-control: #6f7b73;
    --color-danger: #f0b4a8;
    --color-code: #1a211e;
    --color-tip: #9cc7b1;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 6px 18px rgb(0 0 0 / 0.25);
}

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

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

body {
    margin: 0;
    background: var(--color-canvas);
    color: var(--color-ink);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
}

a {
    color: var(--color-brand);
    text-underline-offset: 0.18em;
}

a:hover {
    text-decoration-thickness: 2px;
}

:focus-visible {
    outline: 3px solid var(--color-brand);
    outline-offset: 2px;
    border-radius: 4px;
}

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

.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 30;
    padding: 0.5rem 1rem;
    background: var(--color-brand);
    color: var(--color-on-brand);
    border-radius: var(--radius-control);
}

.skip:focus {
    top: 0.75rem;
}

/* The bar along the top. */
.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: var(--top);
    padding: 0 1.25rem;
    background: color-mix(in srgb, var(--color-canvas) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-rule);
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--color-brand);
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
    letter-spacing: -0.01em;
    flex: none;
}

.wordmark svg {
    width: 1.45rem;
    height: 1.45rem;
}

.wordmark span {
    color: var(--color-muted);
    font-weight: 500;
}

.menu,
.theme {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-ink);
    cursor: pointer;
}

.menu {
    display: none;
}

.menu svg,
.theme svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.theme .moon {
    display: none;
}

:root[data-theme="dark"] .theme .sun {
    display: none;
}

:root[data-theme="dark"] .theme .moon {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme .sun {
        display: none;
    }

    :root:not([data-theme="light"]) .theme .moon {
        display: block;
    }
}

.search {
    position: relative;
    flex: 1;
    max-width: 30rem;
    margin-left: auto;
}

.search input {
    width: 100%;
    height: 2.5rem;
    padding: 0 2.5rem 0 0.9rem;
    border: 1px solid var(--color-control);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-ink);
    font: inherit;
    font-size: 0.95rem;
}

.search kbd {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 0.4rem;
    border: 1px solid var(--color-rule);
    border-radius: 4px;
    color: var(--color-muted);
    font: 0.75rem var(--font-sans);
}

.results {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    max-height: min(70vh, 30rem);
    overflow-y: auto;
    padding: 0.35rem;
    background: var(--color-surface);
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
}

.results a {
    display: block;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-control);
    color: var(--color-ink);
    text-decoration: none;
}

.results a[aria-selected="true"],
.results a:hover {
    background: var(--color-sunken);
}

.results .where {
    display: block;
    color: var(--color-muted);
    font-size: 0.78rem;
}

.results .what {
    display: block;
    font-weight: 600;
}

.results .words {
    display: block;
    color: var(--color-muted);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.results mark {
    background: color-mix(in srgb, var(--color-accent) 40%, transparent);
    color: inherit;
    border-radius: 2px;
}

.results .none {
    padding: 0.7rem;
    color: var(--color-muted);
}

.tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: none;
}

.github {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    height: 2.5rem;
    padding: 0 0.8rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-control);
    background: var(--color-surface);
    color: var(--color-ink);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
}

.github svg {
    width: 1.1rem;
    height: 1.1rem;
}

/* Sidebar, content, and the list of sections. */
.frame {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
    max-width: 84rem;
    margin: 0 auto;
}

.sidebar {
    position: sticky;
    top: var(--top);
    align-self: start;
    height: calc(100vh - var(--top));
    overflow-y: auto;
    padding: 1.75rem 1.25rem 2rem;
    border-right: 1px solid var(--color-rule);
}

.nav-group + .nav-group {
    margin-top: 1.5rem;
}

.nav-title {
    margin: 0 0 0.4rem;
    color: var(--color-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

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

.sidebar a {
    display: block;
    padding: 0.32rem 0.7rem;
    margin: 0 -0.7rem;
    border-radius: var(--radius-control);
    color: var(--color-ink);
    text-decoration: none;
    font-size: 0.95rem;
}

.sidebar a:hover {
    background: var(--color-sunken);
}

.sidebar a[aria-current="page"] {
    background: var(--color-brand);
    color: var(--color-on-brand);
    font-weight: 600;
}

main {
    min-width: 0;
    padding: 2.5rem 3rem 3rem;
}

main:focus {
    outline: none;
}

.toc {
    position: sticky;
    top: var(--top);
    align-self: start;
    max-height: calc(100vh - var(--top));
    overflow-y: auto;
    padding: 2.5rem 1.25rem 2rem 0;
    font-size: 0.85rem;
}

.toc a {
    display: block;
    padding: 0.2rem 0 0.2rem 0.75rem;
    border-left: 2px solid var(--color-rule);
    color: var(--color-muted);
    text-decoration: none;
}

.toc .depth-3 a {
    padding-left: 1.5rem;
}

.toc a:hover,
.toc a.here {
    color: var(--color-brand);
    border-left-color: var(--color-brand);
}

/* Reading. */
.prose {
    max-width: 46rem;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--color-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.prose h1,
.prose h2,
.prose h3 {
    position: relative;
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.prose h1 {
    margin: 0 0 1rem;
    font-size: clamp(1.9rem, 4vw, 2.5rem);
}

.prose h2 {
    margin: 2.75rem 0 0.9rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--color-rule);
    font-size: 1.6rem;
}

.prose h3 {
    margin: 2rem 0 0.6rem;
    font-size: 1.22rem;
}

.prose h4 {
    margin: 1.5rem 0 0.4rem;
    font-size: 1rem;
}

.anchor {
    position: absolute;
    left: -1.1em;
    color: var(--color-control);
    text-decoration: none;
    opacity: 0;
    font-family: var(--font-sans);
}

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

.prose p,
.prose li {
    max-width: 42rem;
}

.prose > p:first-of-type:not(.eyebrow),
.lead {
    font-size: 1.12rem;
    color: var(--color-ink);
}

.prose ul,
.prose ol {
    padding-left: 1.4rem;
}

.prose li + li {
    margin-top: 0.3rem;
}

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

.prose img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
}

.prose blockquote {
    margin: 1.25rem 0;
    padding: 0.2rem 0 0.2rem 1.1rem;
    border-left: 3px solid var(--color-accent);
    color: var(--color-muted);
    font-family: var(--font-serif);
    font-style: italic;
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--color-rule);
    margin: 2.5rem 0;
}

.prose code {
    padding: 0.12em 0.36em;
    border-radius: 5px;
    background: var(--color-code);
    font-family: var(--font-mono);
    font-size: 0.88em;
    overflow-wrap: anywhere;
}

.prose pre {
    position: relative;
    margin: 1.25rem 0;
    padding: 1rem 1.15rem;
    overflow-x: auto;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-card);
    background: var(--color-code);
    line-height: 1.55;
}

.prose pre code {
    padding: 0;
    background: none;
    font-size: 0.86rem;
    overflow-wrap: normal;
}

.copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--color-rule);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-muted);
    font: 500 0.75rem var(--font-sans);
    cursor: pointer;
    opacity: 0;
}

.prose pre:hover .copy,
.copy:focus-visible,
.copy.done {
    opacity: 1;
}

.table-wrap {
    margin: 1.25rem 0;
    overflow-x: auto;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-card);
    background: var(--color-surface);
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.prose th,
.prose td {
    padding: 0.6rem 0.85rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--color-rule);
}

.prose th {
    background: var(--color-sunken);
    font-weight: 600;
    white-space: nowrap;
}

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

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

.callout {
    margin: 1.5rem 0;
    padding: 0.85rem 1.1rem;
    border: 1px solid var(--color-rule);
    border-left: 4px solid var(--color-brand);
    border-radius: var(--radius-control);
    background: var(--color-surface);
}

.callout p {
    margin: 0.3rem 0 0;
}

.callout .callout-title {
    margin: 0;
    color: var(--color-brand);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.callout.tip {
    border-left-color: var(--color-tip);
}

.callout.tip .callout-title {
    color: var(--color-tip);
}

.callout.warning {
    border-left-color: var(--color-danger);
}

.callout.warning .callout-title {
    color: var(--color-danger);
}

/* Cards of links, on the home page and at the end of sections. */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 0;
    list-style: none;
}

.cards li {
    margin: 0;
    max-width: none;
}

.cards a {
    display: block;
    height: 100%;
    padding: 1.1rem 1.15rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    color: var(--color-ink);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.15s;
}

.cards a:hover {
    border-color: var(--color-brand);
    transform: translateY(-1px);
}

.cards strong {
    display: block;
    margin-bottom: 0.25rem;
    font-family: var(--font-serif);
    font-size: 1.08rem;
    color: var(--color-brand);
}

.cards span {
    color: var(--color-muted);
    font-size: 0.92rem;
}

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    max-width: 46rem;
    margin-top: 3.5rem;
}

.pager a {
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    text-decoration: none;
    font-weight: 600;
}

.pager a:hover {
    border-color: var(--color-brand);
}

.pager span {
    display: block;
    color: var(--color-muted);
    font-size: 0.78rem;
    font-weight: 500;
}

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

.foot {
    max-width: 46rem;
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-rule);
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* The home page: wider, with a hero and screenshots. */
.layout-home .frame {
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.layout-home .prose {
    max-width: 62rem;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem 0 0.5rem;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2.2rem, 5vw, 3.3rem);
    line-height: 1.1;
}

.hero .lead {
    max-width: 40rem;
    margin: 0.5rem 0 0;
    font-size: 1.2rem;
    color: var(--color-muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.25rem 0 0.5rem;
}

.button {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 1.2rem;
    border: 1px solid var(--color-brand);
    border-radius: var(--radius-control);
    color: var(--color-brand);
    font-weight: 600;
    text-decoration: none;
}

.button.primary {
    background: var(--color-brand);
    color: var(--color-on-brand);
}

.shot {
    margin: 2rem 0 1rem;
}

.shot img {
    margin: 0;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.gallery figure {
    margin: 0;
}

.gallery img {
    margin: 0 0 0.6rem;
}

.gallery figcaption {
    color: var(--color-muted);
    font-size: 0.92rem;
}

.gallery figcaption strong {
    color: var(--color-ink);
}

/* Features: each part's pictures side by side, one wide, or a row of phones. */
.feature-shots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1.25rem;
    margin: 1.25rem 0 0.75rem;
}

.feature-shots.single {
    grid-template-columns: minmax(0, 1fr);
}

.feature-shots.phones {
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    align-items: start;
}

.feature-shots figure {
    margin: 0;
}

.feature-shots img {
    margin: 0 0 0.5rem;
}

.feature-shots figcaption {
    color: var(--color-muted);
    font-size: 0.92rem;
}

.feature-shots figcaption strong {
    color: var(--color-ink);
}

.more {
    margin: 0 0 2.5rem;
    font-weight: 500;
}

.more a::after {
    content: " →";
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1.25rem 2rem;
    margin: 1.5rem 0;
    padding: 0;
    list-style: none;
}

.features li {
    margin: 0;
    padding-left: 1rem;
    border-left: 3px solid var(--color-accent);
}

.features strong {
    display: block;
    font-family: var(--font-serif);
    font-size: 1.05rem;
}

.features span {
    color: var(--color-muted);
    font-size: 0.93rem;
}

/* Narrower screens: the list of sections goes, then the sidebar becomes a drawer. */
@media (max-width: 75rem) {
    .frame {
        grid-template-columns: var(--sidebar) minmax(0, 1fr);
    }

    .toc {
        display: none;
    }
}

@media (max-width: 52rem) {
    .menu {
        display: inline-grid;
    }

    .frame,
    .layout-home .frame {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: var(--top) auto 0 0;
        z-index: 15;
        width: min(20rem, 85vw);
        height: auto;
        background: var(--color-canvas);
        box-shadow: var(--shadow);
        transform: translateX(-105%);
        transition: transform 0.2s;
    }

    body.nav-open .sidebar {
        transform: none;
    }

    /* The page behind the open menu dims, and a tap there closes it. */
    body.nav-open::after {
        content: "";
        position: fixed;
        inset: var(--top) 0 0 0;
        z-index: 14;
        background: rgb(20 24 22 / 0.35);
    }

    main {
        padding: 1.75rem 1rem 2.5rem;
    }

    .top {
        gap: 0.6rem;
        padding: 0 1rem;
    }

    .search kbd,
    .github span,
    .wordmark span {
        display: none;
    }

    .anchor {
        display: none;
    }

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

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

@media (max-width: 30rem) {
    .wordmark {
        font-size: 1.05rem;
    }

    .github {
        padding: 0 0.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
