/* dev.pairx.org: Pairx's colours (ops/site/build.py), both themes, a docs layout — sidebar, article, contents. */
:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1b1e24; --muted: #6b7280; --line: #e4e7eb; --accent: #226cf0;
  --accent-soft: rgba(34, 108, 240, .09); --code: #f0f2f5; --note: #eef4ff; --note-line: #c9dafc;
  --header: rgba(245, 246, 248, .82); --shadow: 0 8px 30px rgba(15, 23, 42, .12);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --top: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101113; --surface: #17191d; --text: #f3f4f7; --muted: #9aa1ad; --line: #2a2d34; --accent: #81acff;
    --accent-soft: rgba(129, 172, 255, .12); --code: #1d2026; --note: #172033; --note-line: #2b4170;
    --header: rgba(16, 17, 19, .82); --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
.brand img { border-radius: 8px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; padding: 8px 12px; background: var(--surface); border-radius: 8px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--header); border-bottom: 1px solid var(--line); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 19px; letter-spacing: -.3px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .sub { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.menu { display: none; margin-left: -8px; padding: 8px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; }
.links { display: flex; gap: 18px; margin-left: auto; font-size: 15px; white-space: nowrap; }
.links a { color: var(--text); }

/* Search: shown once the script runs */
.search { position: relative; display: none; flex: 0 1 320px; margin-left: auto; }
.js .search { display: block; }
.js .links { margin-left: 0; }
.search input {
  width: 100%; height: 38px; padding: 0 36px 0 14px; border: 1px solid var(--line); border-radius: 12px; outline: none;
  background: var(--surface); color: var(--text); font: 15px var(--sans);
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { position: absolute; right: 10px; top: 9px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font: 12px/18px var(--mono); }
.search input:focus + kbd { display: none; }
.results {
  position: absolute; top: 46px; left: 0; right: 0; min-width: 300px; max-height: 70vh; overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.results a { display: block; padding: 8px 10px; border-radius: 10px; color: var(--text); }
.results a:hover, .results a[aria-selected="true"] { background: var(--accent-soft); text-decoration: none; }
.results b { display: block; font-weight: 600; }
.results small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.results p { margin: 8px 10px; color: var(--muted); font-size: 14px; }

/* Layout */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; max-width: 1360px; margin: 0 auto; }
.side { position: sticky; top: var(--top); align-self: start; height: calc(100vh - var(--top)); overflow-y: auto; padding: 24px 12px 40px 20px; }
.side .group { margin-bottom: 18px; }
.side p { margin: 0 0 4px 10px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: block; padding: 5px 10px; border-radius: 8px; color: var(--text); font-size: 15px; line-height: 1.4; }
.side a:hover { background: var(--accent-soft); text-decoration: none; }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { min-width: 0; padding: 32px 40px 64px; }
article { max-width: 760px; overflow-wrap: break-word; }
.toc { position: sticky; top: var(--top); align-self: start; max-height: calc(100vh - var(--top)); overflow-y: auto; padding: 32px 20px 40px 0; font-size: 14px; }
.toc p { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; margin-left: -1px; padding: 3px 0 3px 12px; border-left: 2px solid transparent; color: var(--muted); line-height: 1.4; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { border-left-color: var(--accent); color: var(--accent); }

/* Article */
h1 { margin: 0 0 16px; font-size: 34px; line-height: 1.2; letter-spacing: -.6px; }
h2 { margin: 44px 0 12px; padding-top: 8px; font-size: 24px; line-height: 1.3; letter-spacing: -.3px; }
h3 { margin: 32px 0 8px; font-size: 19px; line-height: 1.35; }
h4 { margin: 24px 0 8px; font-size: 16px; }
h1 + p { font-size: 18px; color: var(--muted); }
.anchor { margin-left: 8px; color: var(--muted); font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; text-decoration: none; }
p, ul, ol { margin: 0 0 14px; }
ul, ol { padding-left: 24px; }
li { margin-bottom: 6px; }
li::marker { color: var(--muted); }
strong { font-weight: 600; }
code { padding: 1px 5px; border-radius: 6px; background: var(--code); font: 14px/1.5 var(--mono); }
a code { color: inherit; }
.code { position: relative; margin: 0 0 18px; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--code); font: 13.5px/1.6 var(--mono); tab-size: 2; }
.code pre code { padding: 0; background: none; font: inherit; }
.code .copy {
  position: absolute; top: 8px; right: 8px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--muted); font: 13px var(--sans); cursor: pointer; opacity: 0; transition: opacity .15s;
}
.code:hover .copy, .code .copy:focus { opacity: 1; }
@media (hover: none) { .code .copy { opacity: 1; } }
.table { margin: 0 0 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td code { font-size: 13px; }
td:first-child code { white-space: nowrap; }
.note { margin: 0 0 18px; padding: 12px 16px; border: 1px solid var(--note-line); border-radius: 14px; background: var(--note); }
.note p:last-child { margin-bottom: 0; }
.pager { display: flex; gap: 12px; max-width: 760px; margin-top: 48px; }
.pager a { flex: 1; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font-weight: 600; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager span { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.pager .next { text-align: right; margin-left: auto; }
footer { max-width: 1360px; margin: 0 auto; padding: 24px 20px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
footer p { margin: 0 0 4px; }

/* Narrower: no contents column, then the sidebar becomes a drawer */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  :root { --top: 56px; }
  .top { gap: 10px; padding: 0 16px; }
  .menu { display: block; }
  .brand .sub, .links { display: none; }
  .search { flex: 1 1 auto; }
  .search kbd { display: none; }
  .results { position: fixed; top: calc(var(--top) + 6px); left: 12px; right: 12px; min-width: 0; }
  .layout { display: block; }
  .side {
    position: fixed; top: var(--top); left: 0; z-index: 15; width: min(300px, 85vw); height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); padding: 20px 12px 40px 16px;
    background: var(--bg); border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform .2s ease; visibility: hidden;
  }
  .nav-open .side { transform: none; visibility: visible; box-shadow: var(--shadow); }
  main { padding: 24px 16px 48px; }
  h1 { font-size: 28px; }
  h2 { font-size: 21px; margin-top: 36px; }
  .pager { flex-direction: column; }
  .pager .next { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
