/* ==========================================================================
   Mertrack API documentation — stylesheet
   Palette is taken from the Mergroup identity: aubergine + orange.
   ========================================================================== */

:root {
  --brand:        #301743;
  --brand-soft:   #4a2a63;
  --accent:       #ef7c1a;
  --accent-soft:  #fac16b;

  --bg:           #ffffff;
  --bg-alt:       #faf9fb;
  --bg-sunken:    #f4f2f7;
  --bg-code:      #f7f5fa;
  --bg-hover:     #f1edf6;

  --text:         #1d1526;
  --text-dim:     #605870;
  --text-faint:   #8b8399;
  --border:       #e6e1ee;
  --border-strong:#d3cbdf;

  --link:         #b8560d;
  --link-hover:   #8c4109;

  --ok:           #17734a;
  --warn:         #a4620a;
  --danger:       #b3261e;
  --info:         #2a5fa8;

  --radius:  10px;
  --radius-s: 6px;
  --sidebar: 292px;
  --toc:     232px;
  --topbar:  56px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;

  --shadow: 0 1px 2px rgba(30, 16, 45, .05), 0 8px 24px rgba(30, 16, 45, .07);

  --t-key:     #7b2d8f;
  --t-str:     #17734a;
  --t-num:     #b8560d;
  --t-lit:     #2a5fa8;
  --t-kw:      #a2185f;
  --t-punct:   #77708a;
  --t-comment: #8b8399;
  --t-url:     #2a5fa8;
  --t-flag:    #7b2d8f;
  --t-var:     #b8560d;
  --t-tag:     #a2185f;
}

[data-theme="dark"] {
  --brand:        #efe8f6;
  --brand-soft:   #cfc2de;
  --accent:       #f7961e;
  --accent-soft:  #b8770f;

  --bg:           #15101c;
  --bg-alt:       #1a1424;
  --bg-sunken:    #211a2d;
  --bg-code:      #1e1729;
  --bg-hover:     #271f35;

  --text:         #ece8f2;
  --text-dim:     #a79fb6;
  --text-faint:   #7d7590;
  --border:       #2d2540;
  --border-strong:#3d3454;

  --link:         #f0a24f;
  --link-hover:   #f7bd83;

  --ok:           #4ec98d;
  --warn:         #e3ab4a;
  --danger:       #f0837b;
  --info:         #74aaf0;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .45);

  --t-key:     #d9a2e8;
  --t-str:     #7fd6a6;
  --t-num:     #f0a24f;
  --t-lit:     #74aaf0;
  --t-kw:      #f28cb8;
  --t-punct:   #8b839f;
  --t-comment: #6f6785;
  --t-url:     #74aaf0;
  --t-flag:    #d9a2e8;
  --t-var:     #f0a24f;
  --t-tag:     #f28cb8;
}

/* Light is the default. Dark is opt-in through the theme toggle only, so the
   documentation always opens on a white page. */

/* --- base ---------------------------------------------------------------- */

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar) + 16px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--bg); color: var(--text); padding: 10px 16px; border: 1px solid var(--border);
}
.skip:focus { left: 8px; top: 8px; }

/* --- top bar ------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar); padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand img { display: block; width: 26px; height: 26px; object-fit: contain; }
.brand-name { font-weight: 680; letter-spacing: -.015em; font-size: 16px; }
.brand-sub {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); padding-left: 9px; margin-left: 2px; border-left: 1px solid var(--border-strong);
}

.menu-btn {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 34px; height: 34px; padding: 0 7px; background: none;
  border: 1px solid var(--border); border-radius: var(--radius-s); cursor: pointer;
}
.menu-btn span { display: block; height: 1.5px; background: var(--text); border-radius: 2px; }

.search { position: relative; flex: 1; max-width: 460px; margin-left: auto; }
.search input {
  width: 100%; height: 34px; padding: 0 34px 0 12px;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg-sunken); border: 1px solid transparent; border-radius: var(--radius-s);
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { background: var(--bg); border-color: var(--border-strong); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search kbd {
  position: absolute; right: 8px; top: 7px; pointer-events: none;
  font: 600 11px/18px var(--sans); color: var(--text-faint);
  min-width: 18px; height: 20px; text-align: center;
  border: 1px solid var(--border-strong); border-radius: 4px; background: var(--bg);
}
.search input:focus + kbd { display: none; }

.results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; max-height: 68vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; z-index: 70;
}
.results[hidden] { display: none; }
.results .hit { display: block; padding: 8px 10px; border-radius: var(--radius-s); color: var(--text); }
.results .hit:hover, .results .hit.sel { background: var(--bg-hover); text-decoration: none; }
.results .hit b { display: block; font-size: 14px; font-weight: 620; }
.results .hit small { display: block; color: var(--text-faint); font-size: 12.5px; }
.results .hit code { font-size: 12.5px; color: var(--link); background: none; padding: 0; border: 0; }
.results .empty { padding: 14px 10px; color: var(--text-faint); font-size: 14px; }
.results .group-label {
  padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint);
}

.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.theme-btn {
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-s);
  color: var(--text-dim); font-size: 15px; line-height: 1;
}
.theme-btn:hover { color: var(--text); background: var(--bg-hover); }
.theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: block; }

/* --- shell --------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
  align-items: start;
}

.sidebar {
  position: sticky; top: var(--topbar);
  height: calc(100vh - var(--topbar));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 60px 20px;
  border-right: 1px solid var(--border);
  background: var(--bg-alt);
  scrollbar-width: thin;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar .nav-root > li { margin-bottom: 2px; }
.sidebar li ul { margin-left: 9px; padding-left: 9px; border-left: 1px solid var(--border); }

.sidebar a {
  display: block; padding: 4px 8px; border-radius: var(--radius-s);
  color: var(--text-dim); font-size: 13.9px; line-height: 1.45;
}
.sidebar a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sidebar a.current {
  color: var(--text); font-weight: 620;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar .nav-root > li > details > summary > a,
.sidebar .nav-root > li > a { font-weight: 640; color: var(--text); font-size: 14.3px; }

.sidebar summary {
  display: flex; align-items: center; gap: 2px; list-style: none; cursor: pointer;
}
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary > a { flex: 1; min-width: 0; }
.sidebar .caret {
  flex: none; width: 20px; height: 20px; border-radius: 4px; position: relative; opacity: .55;
}
.sidebar .caret::before {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 5px; height: 5px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: translateY(-1px) rotate(-45deg); transition: transform .15s ease;
}
.sidebar details[open] > summary .caret::before { transform: translateY(-2px) rotate(45deg); }
.sidebar summary:hover .caret { opacity: 1; background: var(--bg-hover); }

/* --- main ---------------------------------------------------------------- */

main { min-width: 0; }
.content { padding: 30px 46px 20px; max-width: 946px; margin-inline: auto; }

.crumbs { font-size: 12.5px; color: var(--text-faint); margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs a { color: var(--text-faint); }
.crumbs a:hover { color: var(--text-dim); }
.crumbs .sep { opacity: .5; }
.crumbs [aria-current] { color: var(--text-dim); }

.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
  position: relative; line-height: 1.25; letter-spacing: -.018em; scroll-margin-top: calc(var(--topbar) + 14px);
}
.content h1 { font-size: 2.05rem; font-weight: 700; margin: 0 0 .5em; }
.content h2 {
  font-size: 1.42rem; font-weight: 660; margin: 2.4em 0 .7em;
  padding-bottom: .32em; border-bottom: 1px solid var(--border);
}
.content h3 { font-size: 1.16rem; font-weight: 650; margin: 2em 0 .6em; }
.content h4 { font-size: 1rem; font-weight: 650; margin: 1.7em 0 .5em; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; font-size: .82rem; }
.content h5, .content h6 { font-size: .95rem; font-weight: 650; margin: 1.5em 0 .5em; }

.alias { display: block; height: 0; scroll-margin-top: calc(var(--topbar) + 14px); }

.anchor {
  position: absolute; left: -.75em; top: 0; width: .75em;
  color: var(--text-faint); opacity: 0; text-decoration: none; font-weight: 400;
}
h1:hover > .anchor, h2:hover > .anchor, h3:hover > .anchor, h4:hover > .anchor { opacity: .6; }
.anchor:hover { opacity: 1 !important; text-decoration: none; }

.content p { margin: 0 0 1.05em; }
.content ul, .content ol { margin: 0 0 1.05em; padding-left: 1.45em; }
.content li { margin: .3em 0; }
.content li > ul, .content li > ol { margin: .35em 0; }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 2.4em 0; }
.content blockquote {
  margin: 0 0 1.05em; padding: .1em 0 .1em 1.1em;
  border-left: 3px solid var(--border-strong); color: var(--text-dim);
}
.content blockquote p:last-child { margin-bottom: 0; }
.content strong { font-weight: 650; }
.content img { max-width: 100%; height: auto; }

.content :not(pre) > code {
  font-family: var(--mono); font-size: .855em;
  padding: .13em .38em; border-radius: 5px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  word-break: break-word;
}

/* --- tables -------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto; margin: 0 0 1.4em;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg);
}
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table-wrap th, .table-wrap td {
  padding: 9px 14px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.table-wrap thead th {
  background: var(--bg-alt); font-weight: 640; font-size: 12px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim);
  white-space: nowrap; position: sticky; top: 0;
}
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover { background: var(--bg-alt); }
.table-wrap td:first-child { white-space: nowrap; font-family: var(--mono); font-size: 13px; }
.table-wrap td:first-child code { white-space: nowrap; }
.table-wrap p { margin: 0; }

/* --- code ---------------------------------------------------------------- */

figure.code {
  position: relative; margin: 0 0 1.4em;
  background: var(--bg-code); border: 1px solid var(--border); border-radius: var(--radius);
}
figure.code::before {
  content: attr(data-lang);
  position: absolute; top: 8px; right: 62px;
  font: 600 10.5px/1 var(--sans); letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint); pointer-events: none;
}
figure.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
figure.code code {
  font-family: var(--mono); font-size: 13px; line-height: 1.62;
  background: none; border: 0; padding: 0; white-space: pre;
}
figure.code .copy {
  position: absolute; top: 6px; right: 7px; z-index: 2;
  font: 600 11px/1 var(--sans); color: var(--text-dim);
  padding: 5px 8px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
  opacity: 0; transition: opacity .12s ease;
}
figure.code:hover .copy, figure.code .copy:focus-visible { opacity: 1; }
figure.code .copy:hover { color: var(--text); border-color: var(--border-strong); }
figure.code .copy.done { color: var(--ok); border-color: var(--ok); }
html.no-js figure.code .copy { display: none; }

.codeblock[data-title]::before {
  content: attr(data-title);
  display: block; font: 600 11.5px/1 var(--sans); letter-spacing: .04em;
  color: var(--text-faint); margin-bottom: 6px;
}

.t-key { color: var(--t-key); }
.t-str { color: var(--t-str); }
.t-num { color: var(--t-num); }
.t-lit { color: var(--t-lit); }
.t-kw { color: var(--t-kw); font-weight: 600; }
.t-punct { color: var(--t-punct); }
.t-comment { color: var(--t-comment); font-style: italic; }
.t-url { color: var(--t-url); }
.t-flag { color: var(--t-flag); }
.t-var { color: var(--t-var); }
.t-tag { color: var(--t-tag); }

/* --- tabs ---------------------------------------------------------------- */

.tabs { margin: 0 0 1.4em; }
.tab-bar {
  display: flex; gap: 2px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}
.tab-bar button {
  font: 600 13px/1 var(--sans); color: var(--text-dim);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 12px; margin-bottom: -1px; cursor: pointer; border-radius: 6px 6px 0 0;
}
.tab-bar button:hover { color: var(--text); background: var(--bg-alt); }
.tab-bar button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs .tab > *:last-child { margin-bottom: 0; }
html.js .tabs .tab[hidden] { display: none; }
html.no-js .tab::before {
  content: attr(data-title);
  display: block; font: 600 11.5px/1 var(--sans); letter-spacing: .04em;
  color: var(--text-faint); margin: 0 0 6px;
}

/* --- hints --------------------------------------------------------------- */

.hint {
  margin: 0 0 1.4em; padding: 13px 16px;
  border: 1px solid var(--border); border-left: 3px solid var(--info);
  border-radius: var(--radius-s); background: var(--bg-alt); font-size: 14.5px;
}
.hint > *:last-child { margin-bottom: 0; }
.hint::before {
  content: "Note"; display: block;
  font: 700 10.5px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--info); margin-bottom: 6px;
}
.hint-warning { border-left-color: var(--warn); }
.hint-warning::before { content: "Important"; color: var(--warn); }
.hint-danger { border-left-color: var(--danger); }
.hint-danger::before { content: "Warning"; color: var(--danger); }
.hint-success { border-left-color: var(--ok); }
.hint-success::before { content: "Tip"; color: var(--ok); }

/* --- stepper ------------------------------------------------------------- */

.stepper { counter-reset: step; margin: 0 0 1.4em; }
.step {
  counter-increment: step; position: relative;
  padding: 0 0 1.6em 44px; border-left: 1px solid var(--border); margin-left: 13px;
}
.step:last-child { border-left-color: transparent; padding-bottom: 0; }
.step::before {
  content: counter(step);
  position: absolute; left: -13px; top: 1px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font: 700 12.5px/1 var(--sans); color: #fff; background: var(--brand);
}
[data-theme="dark"] .step::before { color: #1b1226; }
.step > h3:first-child, .step > h4:first-child { margin-top: 0; }
.step > *:last-child { margin-bottom: 0; }

/* --- cards --------------------------------------------------------------- */

.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 12px; margin: 0 0 1.8em;
}
.card {
  display: block; padding: 15px 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .13s ease, transform .13s ease, box-shadow .13s ease;
}
.card:hover {
  text-decoration: none; border-color: var(--accent); transform: translateY(-1px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--brand) 9%, transparent);
}
.card b { display: block; font-size: 15px; font-weight: 640; margin-bottom: 3px; }
.card span { display: block; font-size: 13.5px; color: var(--text-dim); line-height: 1.5; }

/* --- home ---------------------------------------------------------------- */

body.home .content h1 { font-size: 2.5rem; letter-spacing: -.03em; }
body.home .content h1 + p { font-size: 1.08rem; color: var(--text-dim); max-width: 62ch; }

/* --- endpoint index ------------------------------------------------------ */

.ep-filter { margin: 0 0 14px; }
.ep-filter input {
  width: 100%; height: 38px; padding: 0 13px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: var(--radius-s);
}
.ep-filter input:focus { background: var(--bg); border-color: var(--border-strong); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.ep-table td:first-child { font-family: var(--mono); }
.ep-table td:nth-child(2) { color: var(--text-dim); font-size: 13px; }

.badge {
  display: inline-block; vertical-align: middle;
  font: 600 10.5px/1 var(--sans); letter-spacing: .04em; text-transform: uppercase;
  padding: 4px 7px; border-radius: 999px; white-space: nowrap;
}
.badge-off { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.badge-on  { color: var(--ok); background: color-mix(in srgb, var(--ok) 11%, transparent); }
h1 .badge, h2 .badge, h3 .badge, h4 .badge { text-transform: none; }

/* --- pager & footer ------------------------------------------------------ */

.pager { display: flex; gap: 12px; margin: 3em 0 0; padding-top: 1.6em; border-top: 1px solid var(--border); }
.pager a {
  flex: 1; min-width: 0; padding: 11px 14px; color: var(--text); font-weight: 600; font-size: 14.5px;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager a span { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 2px; }
.pager .next { text-align: right; }

.foot {
  padding: 26px 46px 44px; border-top: 1px solid var(--border); margin-top: 30px;
  color: var(--text-faint); font-size: 13px;
  max-width: 946px; margin-inline: auto;
}
.foot p { margin: 0; }
.foot a { color: var(--text-dim); }

/* --- on this page -------------------------------------------------------- */

.toc {
  position: sticky; top: var(--topbar);
  max-height: calc(100vh - var(--topbar)); overflow-y: auto;
  padding: 30px 20px 40px 4px; font-size: 13px;
}
.toc-title {
  margin: 0 0 8px; font: 700 10.5px/1 var(--sans); letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block; padding: 3px 10px; color: var(--text-dim);
  border-left: 2px solid var(--border); line-height: 1.45;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--link); border-left-color: var(--accent); font-weight: 600; }
.toc .toc-d3 a { padding-left: 22px; font-size: 12.5px; }
.toc .toc-d4 a { padding-left: 34px; font-size: 12.5px; color: var(--text-faint); }

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

@media (max-width: 1220px) {
  .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding-left: 34px; padding-right: 34px; }
  .foot { padding-left: 34px; padding-right: 34px; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: flex; }
  .brand-sub { display: none; }
  .sidebar {
    position: fixed; inset: var(--topbar) auto 0 0; width: min(86vw, 320px); z-index: 55;
    transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  body.nav-open { overflow: hidden; }
  .content { padding: 22px 20px 10px; }
  .foot { padding: 22px 20px 36px; }
  .content h1 { font-size: 1.72rem; }
  body.home .content h1 { font-size: 2rem; }
  .pager { flex-direction: column; }
}

@media print {
  .topbar, .sidebar, .toc, .pager, .copy { display: none !important; }
  .shell { display: block; }
  .content { max-width: none; padding: 0; }
  figure.code, .table-wrap { break-inside: avoid; }
}
