/* BloxMaps docs (docs.bloxmaps.com, /docs): a clean reading layout in the site's colours, light + dark,
   phone first. Tokens match app.css so the docs feel like the site. */

:root {
  --font-display: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif;
  --font-body: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --header-h: 60px;
  --nav-w: 260px;
  --toc-w: 220px;
  --gutter: 16px;

  --bg: #f4f7ff;
  --surface: #ffffff;
  --surface-2: #f3f7ff;
  --surface-3: #e6eefc;
  --ink: #16203b;
  --ink-2: #47526f;
  --ink-3: #6f7a9b;
  --line: #d6e0f3;
  --line-2: #c2cee8;
  --overlay: rgba(14, 20, 44, 0.45);
  --blue: #2f6bff;
  --blue-d: #1a4bd6;
  --blue-soft: #dbe7ff;
  --yellow: #ffc933;
  --yellow-soft: #fff4cf;
  --green: #22c55e;
  --green-d: #15803d;
  --green-soft: #dcf7e6;
  --pink: #ff4f7b;
  --pink-d: #c42651;
  --pink-soft: #ffe3ea;
  --purple: #7c5cff;
  --purple-soft: #ece6ff;
  --focus: #ffb000;

  --code-bg: #f6f8fd;
  --code-ink: #1d2540;
  --code-line: #dde5f5;
  --tk: #7c3aed;
  --ts: #0f7a4a;
  --tc: #7b86a3;
  --tn: #c2410c;
  --tf: #1d4ed8;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c1126;
  --surface: #131a36;
  --surface-2: #19224a;
  --surface-3: #232d5c;
  --ink: #eef2ff;
  --ink-2: #b3bcdf;
  --ink-3: #8a95c0;
  --line: #263163;
  --line-2: #35427d;
  --overlay: rgba(3, 5, 14, 0.66);
  --blue: #6d97ff;
  --blue-d: #9ab6ff;
  --blue-soft: #1f2e66;
  --yellow-soft: #3b3113;
  --green-soft: #133825;
  --green-d: #6ee7a0;
  --pink-soft: #43182a;
  --pink-d: #ff8fab;
  --purple-soft: #2b2360;
  --code-bg: #0e1430;
  --code-ink: #e3e8ff;
  --code-line: #26306a;
  --tk: #c4a5ff;
  --ts: #86e0a8;
  --tc: #7d88b5;
  --tn: #ffb27a;
  --tf: #8fb4ff;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1126;
    --surface: #131a36;
    --surface-2: #19224a;
    --surface-3: #232d5c;
    --ink: #eef2ff;
    --ink-2: #b3bcdf;
    --ink-3: #8a95c0;
    --line: #263163;
    --line-2: #35427d;
    --overlay: rgba(3, 5, 14, 0.66);
    --blue: #6d97ff;
    --blue-d: #9ab6ff;
    --blue-soft: #1f2e66;
    --yellow-soft: #3b3113;
    --green-soft: #133825;
    --green-d: #6ee7a0;
    --pink-soft: #43182a;
    --pink-d: #ff8fab;
    --purple-soft: #2b2360;
    --code-bg: #0e1430;
    --code-ink: #e3e8ff;
    --code-line: #26306a;
    --tk: #c4a5ff;
    --ts: #86e0a8;
    --tc: #7d88b5;
    --tn: #ffb27a;
    --tf: #8fb4ff;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16.5px;
  line-height: 1.65;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--blue-d); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--yellow); color: #1b1300; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.78rem; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: 10px; font-weight: 800; }
.skip-link:focus { top: 8px; }
.i { width: 1.2em; height: 1.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }

/* ---------- header ---------- */
.d-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.d-header-in { height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 var(--gutter); max-width: 1480px; margin: 0 auto; }
.d-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; flex: none; }
.d-logo svg { width: 30px; height: 30px; }
.d-logo-tag { font-size: 0.8rem; font-family: var(--font-body); font-weight: 800; background: var(--blue-soft); color: var(--blue); padding: 2px 8px; border-radius: 999px; }
.d-icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; flex: none; padding: 0; }
.d-icon-btn:hover { background: var(--surface-2); }
#d-theme .i-moon { display: none; }
:root[data-theme="dark"] #d-theme .i-sun { display: none; }
:root[data-theme="dark"] #d-theme .i-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #d-theme .i-sun { display: none; }
  :root:not([data-theme="light"]) #d-theme .i-moon { display: inline; }
}
.d-top-links { display: none; gap: 4px; margin-left: auto; }
.d-top-links a { color: var(--ink-2); text-decoration: none; font-weight: 700; padding: 8px 10px; border-radius: 10px; font-size: 0.95rem; }
.d-top-links a:hover { background: var(--surface-2); color: var(--ink); }

/* search */
.d-search { position: relative; flex: 1 1 auto; min-width: 0; max-width: 460px; margin-left: auto; }
.d-search input {
  width: 100%; height: 40px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--ink); font: inherit; font-size: 0.95rem; padding: 0 36px 0 38px; -webkit-appearance: none; appearance: none;
}
.d-search input::placeholder { color: var(--ink-3); }
.d-search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); background: var(--surface); }
.d-search-i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.d-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: 700 0.75rem var(--font-mono); color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 6px; pointer-events: none; }
.d-search input:focus ~ .d-kbd, .d-search input:not(:placeholder-shown) ~ .d-kbd { display: none; }
.d-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(10, 20, 60, 0.22); max-height: min(70vh, 560px); overflow: auto; padding: 6px;
}
.d-result { display: block; text-decoration: none; color: var(--ink); padding: 10px 12px; border-radius: 10px; }
.d-result:hover, .d-result[aria-selected="true"] { background: var(--blue-soft); }
.d-result b { display: block; font-size: 0.95rem; }
.d-result .d-result-where { display: block; font-size: 0.75rem; color: var(--ink-3); font-weight: 700; }
.d-result .d-result-text { display: block; font-size: 0.84rem; color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.d-result mark { background: var(--yellow-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.d-results-empty { padding: 14px; color: var(--ink-2); font-size: 0.9rem; margin: 0; }

/* ---------- shell ---------- */
.d-shell { display: flex; max-width: 1480px; margin: 0 auto; align-items: flex-start; }
.d-nav {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 50; width: min(86vw, 300px);
  background: var(--surface); border-right: 1px solid var(--line); transform: translateX(-102%);
  transition: transform 0.2s ease; overflow-y: auto; overscroll-behavior: contain;
}
.d-nav.open { transform: none; box-shadow: 18px 0 40px rgba(10, 20, 60, 0.18); }
.d-nav-in { padding: 18px 14px 40px; }
.d-nav-group { margin: 18px 10px 6px; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.d-nav-group:first-child { margin-top: 0; }
.d-nav ul { list-style: none; margin: 0; padding: 0; }
.d-nav li a { display: block; padding: 7px 10px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 700; font-size: 0.95rem; line-height: 1.35; }
.d-nav li a:hover { background: var(--surface-2); color: var(--ink); }
.d-nav li a[aria-current="page"] { background: var(--blue-soft); color: var(--blue); }
.d-nav-site a { font-weight: 600 !important; font-size: 0.88rem !important; }
.d-scrim { position: fixed; inset: var(--header-h) 0 0 0; background: var(--overlay); z-index: 45; }

.d-main { flex: 1 1 auto; min-width: 0; padding: 20px var(--gutter) 40px; }
.d-article { max-width: 780px; margin: 0 auto; }
.d-crumb { margin: 0 0 6px; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--blue); }

/* ---------- typography ---------- */
.d-article h1, .d-article h2, .d-article h3, .d-article h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; position: relative; }
.d-article h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: 0 0 12px; }
.d-article h2 { font-size: clamp(1.4rem, 3.4vw, 1.75rem); margin: 44px 0 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.d-article h3 { font-size: 1.2rem; margin: 30px 0 8px; }
.d-article h4 { font-size: 1.02rem; margin: 22px 0 6px; }
.d-article p, .d-article ul, .d-article ol { margin: 0 0 14px; }
.d-article ul, .d-article ol { padding-left: 1.4em; }
.d-article li { margin: 4px 0; }
.d-article li > ul, .d-article li > ol { margin: 4px 0; }
.d-article .lead { font-size: 1.12rem; color: var(--ink-2); }
.d-article strong { font-weight: 800; }
.d-article hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0; }
.anchor { margin-left: 8px; color: var(--ink-3); text-decoration: none; font-weight: 600; opacity: 0; transition: opacity 0.15s; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
@media (hover: none) { .anchor { display: none; } }

.d-article :not(pre) > code {
  font-family: var(--font-mono); font-size: 0.86em; background: var(--surface-3); color: var(--ink);
  padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere;
}
kbd { font-family: var(--font-mono); font-size: 0.82em; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; background: var(--surface); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.d-article table { border-collapse: collapse; width: 100%; font-size: 0.92rem; line-height: 1.45; }
.d-article th, .d-article td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.d-article th { background: var(--surface-2); font-weight: 800; white-space: nowrap; }
.d-article tr:last-child td { border-bottom: 0; }
.d-article td code { white-space: nowrap; }

/* code blocks */
.code { margin: 0 0 18px; border: 1px solid var(--code-line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--code-line); font-size: 0.78rem; font-weight: 800; color: var(--ink-3); letter-spacing: 0.02em; min-height: 38px; }
.code pre { margin: 0; padding: 14px 16px; overflow: auto; font: 0.84rem/1.6 var(--font-mono); color: var(--code-ink); tab-size: 4; -moz-tab-size: 4; max-height: 640px; }
.code pre:focus-visible { outline-offset: -3px; }
.code[data-lang="prompt"] pre, .code[data-lang="text"] pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--code-line); background: var(--surface);
  color: var(--ink-2); border-radius: 8px; font: 800 0.76rem var(--font-body); padding: 4px 10px; cursor: pointer;
}
.copy-btn:hover { color: var(--ink); border-color: var(--line-2); }
.copy-btn.done { color: var(--green-d); border-color: var(--green); }
.copy-btn .i { width: 1em; height: 1em; }
.tk { color: var(--tk); font-weight: 600; }
.ts { color: var(--ts); }
.tc { color: var(--tc); font-style: italic; }
.tn { color: var(--tn); }
.tf { color: var(--tf); }

/* callouts */
.callout { margin: 0 0 18px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); border-left-width: 5px; background: var(--surface); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 800; margin: 0 0 4px !important; font-size: 0.92rem; }
.callout-note { border-left-color: var(--blue); background: color-mix(in srgb, var(--blue-soft) 45%, var(--surface)); }
.callout-tip { border-left-color: var(--green); background: color-mix(in srgb, var(--green-soft) 50%, var(--surface)); }
.callout-warn { border-left-color: var(--pink); background: color-mix(in srgb, var(--pink-soft) 50%, var(--surface)); }
.callout-rule { border-left-color: var(--yellow); background: color-mix(in srgb, var(--yellow-soft) 60%, var(--surface)); }

/* steps */
.steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.steps > li { position: relative; padding-left: 44px; margin: 0 0 14px; }
.steps > li::before {
  counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 0.9rem;
}

/* cards on the overview */
.d-cards { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0 0 22px; }
.d-card { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; transition: border-color 0.15s, transform 0.15s; }
.d-card:hover { border-color: var(--blue); color: var(--ink); transform: translateY(-1px); }
.d-card b { display: block; font-family: var(--font-display); font-size: 1.08rem; margin-bottom: 2px; }
.d-card span { color: var(--ink-2); font-size: 0.92rem; line-height: 1.45; display: block; }
.d-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--blue); color: #fff; text-decoration: none; font-weight: 800; padding: 10px 16px; border-radius: 12px; }
.d-btn:hover { background: var(--blue-d); color: #fff; }

/* the in-page table of contents */
.d-toc-inline { margin: 4px 0 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.d-toc-inline summary { cursor: pointer; padding: 10px 14px; font-weight: 800; font-size: 0.92rem; }
.d-toc-inline ul { list-style: none; margin: 0; padding: 0 14px 12px; }
.d-toc-inline li a, .d-toc li a { text-decoration: none; color: var(--ink-2); display: block; padding: 3px 0; font-size: 0.9rem; line-height: 1.35; }
.d-toc-inline li.lvl3, .d-toc li.lvl3 { padding-left: 14px; }
.d-toc-inline li a:hover, .d-toc li a:hover { color: var(--blue); }
.d-toc { display: none; }

/* pager, footer */
.d-pager { display: flex; justify-content: space-between; gap: 12px; margin: 44px 0 0; }
.d-pager a { flex: 1 1 0; max-width: 48%; text-decoration: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--surface); color: var(--ink); }
.d-pager a:hover { border-color: var(--blue); }
.d-pager a span { display: block; color: var(--ink-3); font-weight: 700; }
.d-pager .d-next { text-align: right; margin-left: auto; }
.d-footer { max-width: 780px; margin: 40px auto 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 0.85rem; }
.d-footer p { margin: 0 0 6px; }
.d-footer a { color: var(--ink-2); }

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  :root { --gutter: 24px; }
  .d-cards { grid-template-columns: 1fr 1fr; }
  .d-main { padding-top: 28px; }
}
@media (min-width: 1000px) {
  .d-menu-btn { display: none; }
  .d-top-links { display: flex; margin-left: 0; }
  .d-search { margin-left: 24px; }
  .d-nav { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); width: var(--nav-w); transform: none; z-index: 1; box-shadow: none !important; background: transparent; flex: none; }
  .d-scrim { display: none !important; }
  .d-main { padding-left: 40px; padding-right: 40px; }
}
@media (min-width: 1240px) {
  .d-toc { display: block; position: sticky; top: calc(var(--header-h) + 24px); width: var(--toc-w); flex: none; max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto; padding: 4px 16px 24px 0; }
  .d-toc-title { font-size: 0.76rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }
  .d-toc ul { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--line); }
  .d-toc li a.active { color: var(--blue); font-weight: 800; }
  .d-toc-inline { display: none; }
}
@media (max-width: 520px) {
  .d-logo-name { display: none; }
  .d-kbd { display: none; }
  .code pre { font-size: 0.8rem; padding: 12px; }
  .d-pager a { max-width: none; }
  .d-pager { flex-direction: column; }
  .d-pager .d-next { text-align: left; margin-left: 0; }
}
@media print {
  .d-header, .d-nav, .d-toc, .d-toc-inline, .d-pager, .copy-btn { display: none !important; }
  .code pre { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { .d-nav, .d-card, .anchor { transition: none; } }
