/*
 * docs.plota.live
 *
 * The colour tokens are the landing page's (`src/dashboard.css`) so the three
 * hostnames read as one product, and both schemes are defined because the
 * editor respects the system theme and a docs site that ignores it is jarring
 * at night.
 */

:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: rgb(20 39 67 / 13%);
  --line-soft: rgb(20 39 67 / 7%);
  --muted: #637188;
  --text: #17243a;
  --blue: #4054d8;
  --cyan: #087f91;
  --amber: #a66208;
  --code-bg: #eef2f8;
  --mark: #fff3c4;
  --shadow: 0 1px 2px rgb(20 39 67 / 6%), 0 8px 24px rgb(20 39 67 / 6%);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --side-w: 16.5rem;
  --toc-w: 15rem;
  --top-h: 3.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090d15;
    --panel: #101722;
    --line: rgb(255 255 255 / 10%);
    --line-soft: rgb(255 255 255 / 6%);
    --muted: #8995a8;
    --text: #edf3fb;
    --blue: #7886ff;
    --cyan: #48d5e7;
    --amber: #f5b94d;
    --code-bg: #17202e;
    --mark: #3a3410;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top-h) + 1rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--panel); color: var(--text); padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

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

/* ── top bar ─────────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 96rem; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--text); text-decoration: none; font-weight: 600; letter-spacing: -.01em;
  white-space: nowrap;
}
.brand svg { fill: none; stroke: var(--blue); stroke-width: 1.7; stroke-linecap: round; }
.brand b { color: var(--muted); font-weight: 500; }

.top-links { margin-left: auto; display: flex; align-items: center; gap: 1.1rem; font-size: .9rem; }
.top-links a { color: var(--muted); text-decoration: none; }
.top-links a:hover { color: var(--text); }
.top-links .cta {
  background: var(--blue); color: #fff; padding: .42rem .85rem; border-radius: 7px; font-weight: 500;
}
.top-links .cta:hover { color: #fff; filter: brightness(1.08); }

.menu {
  display: none; margin-left: auto; background: none; border: 1px solid var(--line);
  color: var(--text); border-radius: 7px; width: 2.1rem; height: 2.1rem; font-size: 1rem; cursor: pointer;
}

/* ── search ──────────────────────────────────────────────── */
.search { position: relative; flex: 1 1 22rem; max-width: 26rem; }
.search input {
  width: 100%; height: 2.2rem; padding: 0 .75rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: .9rem;
}
.search input::placeholder { color: var(--muted); }
.results {
  position: absolute; top: calc(100% + .4rem); left: 0; right: 0; z-index: 40;
  max-height: min(70vh, 28rem); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: .3rem;
}
.results a {
  display: block; padding: .5rem .6rem; border-radius: 7px; text-decoration: none; color: var(--text);
}
.results a:hover, .results a.sel { background: var(--code-bg); }
.results .r-p { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.results .r-h { display: block; font-weight: 600; font-size: .92rem; }
.results .r-x { display: block; font-size: .84rem; color: var(--muted); }
.results .none { padding: .8rem .6rem; color: var(--muted); font-size: .9rem; }
.results mark { background: var(--mark); color: inherit; border-radius: 2px; }

/* ── layout ──────────────────────────────────────────────── */
.page {
  max-width: 96rem; margin: 0 auto; padding: 0 1.25rem;
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w); gap: 2.5rem;
  align-items: start;
}
body.wide .page { grid-template-columns: var(--side-w) minmax(0, 1fr); }

/* ── sidebar ─────────────────────────────────────────────── */
.side {
  position: sticky; top: var(--top-h);
  max-height: calc(100vh - var(--top-h)); overflow-y: auto;
  padding: 1.75rem 0 3rem;
}
.nav-group + .nav-group { margin-top: 1.5rem; }
.nav-h {
  margin: 0 0 .5rem; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: flex; gap: .6rem; align-items: baseline;
  padding: .36rem .6rem; margin-left: -.6rem;
  border-radius: 7px; color: var(--muted); text-decoration: none; font-size: .92rem;
}
.side li a:hover { color: var(--text); background: var(--line-soft); }
.side li a.here { color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, transparent); font-weight: 600; }
.side .n { font-variant-numeric: tabular-nums; font-size: .78rem; color: var(--muted); min-width: 1ch; }
.side li a.here .n { color: var(--blue); }

/* ── content ─────────────────────────────────────────────── */
main { min-width: 0; padding: 2rem 0 4rem; }

.doc h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 1.25rem; }
.doc h2 {
  font-size: 1.4rem; letter-spacing: -.01em; margin: 2.75rem 0 .9rem;
  padding-top: .5rem; border-top: 1px solid var(--line-soft);
}
.doc h3 { font-size: 1.1rem; margin: 2rem 0 .6rem; }
.doc h4 { font-size: .98rem; margin: 1.5rem 0 .5rem; color: var(--muted); }
.doc p { margin: 0 0 1rem; }
.doc ul, .doc ol { margin: 0 0 1rem; padding-left: 1.35rem; }
.doc li { margin: .3rem 0; }
.doc li > ul, .doc li > ol { margin: .3rem 0; }
.doc strong { font-weight: 650; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

.anchor {
  margin-left: .45rem; color: var(--line); text-decoration: none; font-weight: 400;
  opacity: 0; transition: opacity .12s;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; color: var(--muted); }

.doc code {
  font: 500 .875em/1.4 var(--mono);
  background: var(--code-bg); padding: .12em .38em; border-radius: 5px;
  overflow-wrap: break-word;
}
.doc pre {
  background: var(--code-bg); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: .9rem 1rem; overflow-x: auto; margin: 0 0 1.25rem;
}
.doc pre code { background: none; padding: 0; font-size: .85rem; line-height: 1.55; }

.doc blockquote {
  margin: 0 0 1.25rem; padding: .1rem 0 .1rem 1rem;
  border-left: 3px solid var(--amber); color: var(--muted);
}

.doc figure { margin: 1.5rem 0; }
.doc img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; display: block; }
.doc figcaption { margin-top: .5rem; font-size: .85rem; color: var(--muted); }

.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; border: 1px solid var(--line); border-radius: 10px; }
.doc table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.doc th, .doc td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.doc th { background: var(--code-bg); font-weight: 600; white-space: nowrap; }
.doc tbody tr:last-child td { border-bottom: 0; }
.doc td code { white-space: nowrap; }

/* ── on this page ────────────────────────────────────────── */
.toc {
  position: sticky; top: var(--top-h);
  max-height: calc(100vh - var(--top-h)); overflow-y: auto;
  padding: 2.4rem 0 3rem; font-size: .86rem;
}
.toc-h {
  margin: 0 0 .5rem; font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a {
  display: block; padding: .26rem 0 .26rem .85rem; margin-left: -1px;
  border-left: 2px solid transparent; color: var(--muted); text-decoration: none;
}
.toc li.d3 a { padding-left: 1.7rem; font-size: .83rem; }
.toc li a:hover { color: var(--text); }
.toc li a.here { color: var(--blue); border-left-color: var(--blue); }

/* ── pager + footer ──────────────────────────────────────── */
.pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3.5rem 0 0; }
.pg {
  flex: 0 1 18rem; display: flex; flex-direction: column; gap: .15rem;
  padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; background: var(--panel);
}
.pg:hover { border-color: var(--blue); }
.pg.next { text-align: right; margin-left: auto; }
.pg-l { font-size: .78rem; color: var(--muted); }
.pg-t { font-weight: 600; color: var(--text); }

.foot {
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .87rem;
}
.foot p { margin: .3rem 0; }

/* ── overview page ───────────────────────────────────────── */
.hero { padding: 1.5rem 0 .5rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 2.9rem); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 .75rem; }
.lede { font-size: 1.12rem; color: var(--muted); max-width: 46rem; margin: 0 0 1.5rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .7rem; }
.btn {
  display: inline-block; padding: .6rem 1.1rem; border-radius: 9px;
  background: var(--blue); color: #fff; text-decoration: none; font-weight: 550;
}
.btn:hover { filter: brightness(1.08); color: #fff; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); filter: none; }

.quick, .chapters, .note { margin-top: 3rem; }
.quick h2, .chapters h2, .note h2 {
  font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 1rem;
}
.chapters h2:not(:first-child) { margin-top: 2.5rem; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem; }
.qk {
  display: flex; flex-direction: column; gap: .2rem;
  padding: .9rem 1rem; border: 1px solid var(--line); border-left: 3px solid var(--cyan);
  border-radius: 9px; background: var(--panel); text-decoration: none; color: var(--text);
}
.qk:hover { border-left-color: var(--blue); box-shadow: var(--shadow); }
.qk span { color: var(--muted); font-size: .88rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .75rem; }
.card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: .1rem .75rem;
  padding: 1rem; border: 1px solid var(--line); border-radius: 11px;
  background: var(--panel); text-decoration: none; color: var(--text);
}
.card:hover { border-color: var(--blue); box-shadow: var(--shadow); }
.card-n {
  grid-row: 1 / 3; font-variant-numeric: tabular-nums; font-size: .82rem;
  color: var(--blue); font-weight: 650; padding-top: .18rem;
}
.card.wt { grid-template-columns: 1fr; }
.card-t { font-weight: 600; }
.card-b { color: var(--muted); font-size: .88rem; }

.note p { color: var(--muted); max-width: 52rem; }
.note code { font: 500 .875em var(--mono); background: var(--code-bg); padding: .12em .38em; border-radius: 5px; }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 68rem) {
  .page { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 52rem) {
  .page { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .menu { display: block; }
  .top-links { display: none; }
  .search { flex: 1 1 auto; max-width: none; }
  .side {
    position: static; max-height: none; padding: 1rem 0;
    display: none; border-bottom: 1px solid var(--line);
  }
  .side.open { display: block; }
  main { padding-top: 1.5rem; }
  .doc h1 { font-size: 1.7rem; }
  .pager { flex-direction: column; }
  .pg, .pg.next { flex: 1 1 auto; text-align: left; margin-left: 0; }
}

@media (max-width: 30rem) {
  .brand span { display: none; }
}

@media print {
  .top, .side, .toc, .pager, .skip { display: none; }
  .page { display: block; max-width: none; }
  body { background: #fff; color: #000; }
}
