/* docs.metricharbor.io.
 *
 * The same design as the public page - its tokens, header, buttons and cards - restated here
 * rather than shared, because the docs live on their own host and a stylesheet loaded across
 * hosts is one more thing that can break the docs when the product changes. The fonts and
 * the mark ARE shared: build.py copies them from web/public at build time.
 *
 * Text is in rem so it follows the reader's own font-size setting. */

:root {
    --bg: #09151e;
    --text: #f3f7f6;
    --mint: #84e8bf;
    --mint-hi: #a3f2d0;

    --font-display: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-code: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    color-scheme: dark;
}

* { box-sizing: border-box; }

/* The header is sticky, so a jump to a heading would otherwise land underneath it. */
html { scroll-behavior: smooth; scroll-padding-top: 92px; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 1rem/1.6 var(--font-body);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
h1, h2, h3, h4, p { margin-top: 0; }

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--mint);
    outline-offset: 3px;
    border-radius: 4px;
}

::selection { background: #7ce4b0; color: #09151e; }

.wrap { width: min(1280px, calc(100% - 48px)); margin-inline: auto; }

.skip {
    position: absolute; left: 16px; top: -60px; z-index: 50;
    padding: 10px 14px; border-radius: 7px;
    background: var(--mint); color: #09251d; font-weight: 700;
}
.skip:focus { top: 12px; }

/* ---------------------------------------------------------------- header */

.top {
    position: sticky; top: 0; z-index: 30;
    height: 72px;
    background: rgba(9, 21, 30, .94);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(130, 179, 185, .12);
}
.top-inner { height: 100%; display: flex; align-items: center; gap: 24px; }

.brand { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-icon { width: 34px; height: 34px; color: var(--mint); flex-shrink: 0; }
.brand-name { font: 700 1.25rem var(--font-display); letter-spacing: -.055em; white-space: nowrap; }
.brand-name span { color: var(--mint); }
.brand-tag {
    margin-left: 2px; padding: 2px 9px;
    border: 1px solid #2e4c57; border-radius: 999px;
    font: 500 .6875rem var(--font-code); letter-spacing: .08em; text-transform: uppercase;
    color: #9eb7bf;
}

.top .search { flex: 1; max-width: 440px; margin-left: 20px; }

.top-links { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.top-links a:not(.btn) { color: #bed0d3; font-size: .9375rem; white-space: nowrap; transition: color .2s; }
.top-links a:not(.btn):hover { color: var(--mint); }
.top-links .sign-in { color: #e6f2f1; font-weight: 700; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    min-height: 42px; padding: 9px 18px;
    border: 1px solid transparent; border-radius: 7px;
    font-size: .9375rem; font-weight: 700; white-space: nowrap;
    transition: background .2s, transform .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--mint); color: #09251d; }
.btn-primary:hover { background: var(--mint-hi); }

/* ---------------------------------------------------------------- search */

.search {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    height: 44px; padding: 0 10px 0 14px;
    background: #0e1f29;
    border: 1px solid #2a4753; border-radius: 9px;
    transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(132, 232, 191, .14); }
.search > svg { width: 18px; height: 18px; color: #7d99a4; flex-shrink: 0; }
.search input {
    flex: 1; min-width: 0; height: 100%;
    background: none; border: 0; outline: 0;
    color: var(--text); font-size: .9375rem;
}
.search input::placeholder { color: #7d99a4; }
.search kbd {
    padding: 1px 7px;
    border: 1px solid #2e4c57; border-radius: 5px;
    font: 500 .75rem var(--font-code); color: #9eb7bf;
}
.search:focus-within kbd { display: none; }

/* Search is the one thing that needs JavaScript; without it the box would accept a query
 * and do nothing, which is worse than not offering it. Every page stays reachable from the
 * front page and the sidebar either way. */
.no-js .search { display: none; }

.search-results {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
    max-height: min(70vh, 540px); overflow: auto;
    padding: 6px;
    background: #10212b;
    border: 1px solid #2a4753; border-radius: 10px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
}
.search-results .result { display: block; padding: 10px 12px; border-radius: 7px; }
.search-results .result:hover,
.search-results .result:focus-visible { background: #16303b; outline: none; }
.result .path { display: block; font: 600 .9375rem/1.35 var(--font-display); color: var(--text); }
.result .path span { color: var(--mint); font-weight: 500; }
.result .snip { display: block; margin-top: 3px; font-size: .8125rem; line-height: 1.5; color: #9eb5bd; }
.result mark { background: rgba(132, 232, 191, .16); color: var(--mint); border-radius: 3px; padding: 0 2px; }
.search-results .note { margin: 0; padding: 10px 12px; font-size: .875rem; color: #9eb5bd; }

/* ------------------------------------------------------------ front page */

.hero {
    padding: 84px 0 68px;
    text-align: center;
    border-bottom: 1px solid rgba(130, 179, 185, .1);
    background: radial-gradient(ellipse 60% 100% at 50% -30%, rgba(132, 232, 191, .1), transparent 70%);
}
.hero .wrap { display: flex; flex-direction: column; align-items: center; }
.eyebrow {
    display: inline-flex; align-items: center; gap: 10px; margin: 0;
    font: 500 .8125rem var(--font-code); letter-spacing: .1em; text-transform: uppercase;
    color: var(--mint);
}
.eyebrow::before { content: ''; width: 18px; height: 1px; background: currentColor; }
.hero h1 {
    max-width: 820px; margin: 16px 0 16px;
    font: 600 clamp(2.25rem, 4.4vw, 3.5rem)/1.08 var(--font-display);
    letter-spacing: -.065em;
}
.lead { max-width: 640px; margin: 0 0 30px; font-size: 1.125rem; line-height: 1.7; color: #a9bec5; }
.hero .search { width: 100%; max-width: 680px; height: 58px; text-align: left; padding: 0 14px 0 18px; border-radius: 11px; }
.hero .search > svg { width: 20px; height: 20px; }
.hero .search input { font-size: 1.0625rem; }
.start { margin: 18px 0 0; font-size: .9375rem; color: #9eb5bd; }
.start a { display: inline-flex; align-items: center; gap: 6px; color: var(--mint); font-weight: 700; }
.start svg { width: 16px; height: 16px; }

/* Columns rather than a grid. Categories hold one page or four, and in rows every card
 * either stretches to the tallest beside it - a large empty box around one link - or leaves
 * a hole under itself. Stacked in columns, each card is as tall as its own list and the next
 * one starts right below it. Reading order runs down each column. */
.cats {
    columns: 3 330px;
    column-gap: 16px;
    padding: 52px 0 72px;
}
.cat {
    break-inside: avoid;
    margin-bottom: 16px;
    display: flex; flex-direction: column;
    padding: 26px 26px 10px;
    background: linear-gradient(160deg, #122730, #0d1e28);
    border: 1px solid #25414b; border-radius: 12px;
}
.cat-icon {
    display: grid; place-items: center;
    width: 50px; height: 50px; margin-bottom: 20px;
    background: #1c403a; color: #9ceccc;
    border: 1px solid #37645b; border-radius: 11px;
}
.cat-icon svg { width: 24px; height: 24px; }
.cat h2 { margin: 0 0 6px; font: 600 1.4375rem var(--font-display); letter-spacing: -.045em; }
.cat > p { margin: 0 0 18px; font-size: .9375rem; line-height: 1.6; color: #9eb5bd; }
.cat ul { margin: 0; padding: 0; list-style: none; border-top: 1px solid #213a45; }
.cat li + li { border-top: 1px solid #213a45; }
.cat li a { display: block; padding: 13px 0 14px; }
.cat .t { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; transition: color .2s; }
.cat .t svg { width: 16px; height: 16px; color: #5f8c87; flex-shrink: 0; transition: transform .2s, color .2s; }
.cat .d { display: block; margin-top: 3px; font-size: .875rem; line-height: 1.55; color: #93abb3; }
.cat li a:hover .t { color: var(--mint); }
.cat li a:hover .t svg { color: var(--mint); transform: translateX(3px); }
.cat code, .gaps code { font: .875em var(--font-code); color: #d6e3e3; }

/* What is not documented yet, as the grid's last tile: dashed, flat and without an icon, so
 * it reads as a list of absences rather than a section to go into. */
.cat.gaps { background: none; border-style: dashed; border-color: #2e4c57; padding-bottom: 22px; }
.gaps h2 { font-size: 1.1875rem; letter-spacing: -.03em; }
.cat.gaps ul { border: 0; padding-left: 1.1em; list-style: disc; color: #a9bec5; font-size: .9375rem; line-height: 1.6; }
.cat.gaps li + li { border: 0; margin-top: 6px; }
.cat.gaps li::marker { color: #4f7480; }

/* --------------------------------------------------------------- articles */

.doc {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 210px;
    gap: 52px;
    align-items: start;
    padding: 40px 0 88px;
}

.sidebar-toggle { display: none; }
.sidebar {
    position: sticky; top: 100px;
    max-height: calc(100vh - 124px); overflow: auto;
    padding: 0 6px 12px 0;
}
.side-cat {
    margin: 26px 0 8px;
    font: 500 .75rem var(--font-code); letter-spacing: .09em; text-transform: uppercase;
    color: #7d99a4;
}
.side-cat:first-child { margin-top: 0; }
.sidebar ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid #213a45; }
.sidebar a {
    display: block; margin-left: -1px; padding: 6px 12px;
    border-left: 2px solid transparent;
    font-size: .9375rem; line-height: 1.4; color: #a9bec5;
    transition: color .15s;
}
.sidebar a:hover { color: var(--text); }
.sidebar a[aria-current="page"] { color: var(--mint); border-left-color: var(--mint); font-weight: 700; }

.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; padding: 0; list-style: none; font-size: .875rem; color: #7d99a4; }
.crumbs li + li::before { content: '/'; margin-right: 6px; color: #3d5c66; }
.crumbs a { color: #9eb5bd; }
.crumbs a:hover { color: var(--mint); }

.toc { position: sticky; top: 100px; font-size: .875rem; }
.toc p { margin: 0 0 10px; font: 500 .75rem var(--font-code); letter-spacing: .09em; text-transform: uppercase; color: #7d99a4; }
.toc ol { margin: 0; padding: 0; list-style: none; border-left: 1px solid #213a45; max-height: calc(100vh - 160px); overflow: auto; }
.toc a {
    display: block; margin-left: -1px; padding: 4px 12px;
    border-left: 2px solid transparent;
    line-height: 1.45; color: #93abb3;
    transition: color .15s;
}
.toc .l3 a { padding-left: 24px; font-size: .8125rem; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--mint); border-left-color: var(--mint); }

/* ------------------------------------------------------------------ prose */

.prose { max-width: 48rem; font-size: 1.0625rem; line-height: 1.75; color: #cbd9dd; }
.prose h1 {
    margin: 0 0 22px;
    font: 600 clamp(2rem, 3.4vw, 2.75rem)/1.12 var(--font-display);
    letter-spacing: -.055em; color: var(--text);
}
.prose h2 {
    margin: 56px 0 14px;
    font: 600 1.6875rem/1.25 var(--font-display);
    letter-spacing: -.04em; color: var(--text);
}
.prose h3 {
    margin: 36px 0 10px;
    font: 600 1.25rem/1.3 var(--font-display);
    letter-spacing: -.03em; color: var(--text);
}
.prose h4 { margin: 28px 0 8px; font-size: 1.0625rem; color: var(--text); }

.prose .anchor { margin-left: 10px; font-weight: 400; color: #4f7480; opacity: 0; transition: opacity .15s; }
.prose h2:hover .anchor,
.prose h3:hover .anchor { opacity: 1; }
.prose .anchor:hover { color: var(--mint); }

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose .table-wrap,
.prose .codeblock { margin: 0 0 20px; }

.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 6px; }
.prose li > p { margin-bottom: 8px; }
.prose li::marker { color: #6f9690; }

.prose a { color: var(--mint); text-decoration: underline; text-decoration-color: rgba(132, 232, 191, .35); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--mint); }
.prose strong { color: var(--text); }

.prose code {
    padding: .08em .38em;
    background: #10212b; border: 1px solid #21404b; border-radius: 5px;
    font: .875em var(--font-code); color: #e6f0ef;
    overflow-wrap: break-word;
}

.prose .codeblock { position: relative; background: #0b1a23; border: 1px solid #21404b; border-radius: 10px; }
.prose .codeblock[data-lang]::before {
    content: attr(data-lang);
    position: absolute; top: 9px; left: 16px;
    font: 500 .6875rem var(--font-code); letter-spacing: .08em; text-transform: uppercase;
    color: #7d99a4;
}
.prose pre {
    margin: 0; padding: 16px 18px; overflow-x: auto;
    font: .875rem/1.65 var(--font-code); color: #dce8e8; tab-size: 4;
}
.prose .codeblock[data-lang] pre,
.js .prose .codeblock pre { padding-top: 36px; }
.prose pre code { padding: 0; background: none; border: 0; font: inherit; color: inherit; overflow-wrap: normal; }

.codeblock .copy {
    position: absolute; top: 7px; right: 8px;
    padding: 3px 10px;
    background: #12262f; border: 1px solid #2a4753; border-radius: 6px;
    font: 500 .75rem var(--font-code); color: #9eb7bf;
    cursor: pointer; transition: color .15s, border-color .15s;
}
.codeblock .copy:hover { color: var(--mint); border-color: #3d6b66; }
.codeblock .copy[data-state="done"] { color: var(--mint); border-color: #3d6b66; }

.prose blockquote {
    margin-left: 0; padding: 14px 18px;
    background: #0e2129;
    border: 1px solid #23443f; border-left: 3px solid var(--mint); border-radius: 8px;
}
.prose blockquote > :last-child { margin-bottom: 0; }

.prose .table-wrap { overflow-x: auto; border: 1px solid #21404b; border-radius: 10px; }
.prose table { width: 100%; border-collapse: collapse; font-size: .9375rem; line-height: 1.55; }
.prose th { padding: 10px 14px; background: #10212b; border-bottom: 1px solid #21404b; text-align: left; color: var(--text); }
.prose td { padding: 10px 14px; border-top: 1px solid #1a333d; vertical-align: top; }
.prose tr:first-child td { border-top: 0; }
/* A table written with an empty header row - a common Markdown idiom for a two-column
 * list - would otherwise render a blank shaded band across its top. */
.prose thead:not(:has(th:not(:empty))) { display: none; }

.prose hr { margin: 40px 0; border: 0; border-top: 1px solid #21404b; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 48rem; margin-top: 60px; }
.pager a {
    display: block; padding: 16px 18px;
    background: #0d1e28; border: 1px solid #25414b; border-radius: 10px;
    transition: border-color .2s;
}
.pager a:hover { border-color: #507c7a; }
.pager .next { grid-column: 2; text-align: right; }
.pager .label { display: block; font: 500 .75rem var(--font-code); letter-spacing: .08em; text-transform: uppercase; color: #7d99a4; }
.pager .title { display: block; margin-top: 2px; font: 600 1.0625rem var(--font-display); color: var(--text); }
.pager a:hover .title { color: var(--mint); }

/* ----------------------------------------------------------------- footer */

footer { border-top: 1px solid #25414b; }
.foot { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 22px 0; }
.foot .brand-icon { width: 28px; height: 28px; }
.foot .brand-name { font-size: 1.0625rem; }
.foot-links { display: flex; flex-wrap: wrap; gap: 22px; font-size: .9375rem; color: #9eb5be; }
.foot-links a:hover { color: var(--mint); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
    .doc { grid-template-columns: 220px minmax(0, 1fr); gap: 44px; }
    .toc { display: none; }
}

@media (max-width: 880px) {
    /* Two rows: brand and sign-in, then search across the full width. Not sticky here,
     * because two rows pinned to a phone screen leave too little for the page itself. */
    .top { position: static; height: auto; }
    .top-inner { flex-wrap: wrap; row-gap: 12px; padding: 14px 0; }
    .top .search { order: 3; flex-basis: 100%; max-width: none; margin: 0; }
    .top-links .product, .top-links .btn { display: none; }
    html { scroll-padding-top: 16px; }

    /* minmax(0, ...) and not 1fr: a bare 1fr column is at least as wide as its widest
     * unbreakable content, so one long command would widen the whole page past the screen. */
    .doc { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 22px; }
    .sidebar-toggle {
        display: inline-flex; align-items: center; gap: 10px; justify-self: start;
        margin-bottom: 16px; padding: 9px 14px;
        background: #0e1f29; border: 1px solid #2a4753; border-radius: 8px;
        color: var(--text); font-weight: 700; cursor: pointer;
    }
    .sidebar-toggle svg { width: 18px; height: 18px; }
    .sidebar {
        position: static; max-height: none; display: none;
        margin-bottom: 22px; padding: 16px;
        background: #0d1e28; border: 1px solid #25414b; border-radius: 10px;
    }
    .sidebar[data-open] { display: block; }
    .no-js .sidebar-toggle { display: none; }
    .no-js .sidebar { display: block; }

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

@media (max-width: 560px) {
    .wrap { width: calc(100% - 32px); }
    .hero { padding: 48px 0 40px; }
    .cats { padding-top: 36px; }
    .cat { padding: 22px 20px 8px; }
    .prose { font-size: 1rem; }
    /* Squeezed to the screen, a three-column table wraps one word per line. Each cell keeps
     * a readable width instead, and the table scrolls sideways inside its own frame. */
    .prose th, .prose td { min-width: 8.5rem; }
    .prose h2 { margin-top: 44px; font-size: 1.5rem; }
    .brand-tag { display: none; }
}

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