/* The API docs sidebar with the marker that slides between endpoints. The sidebar card stands alone on white. In the
   tree, three layers sit under the rows and are moved by the script: the grey ghost under the pointer, the indigo
   pill behind the page you are on and the thin marker on the rail. The groups fold with their wrap's height. All the
   sizes follow --row, which is measured on the height too, so the card fits the phone's preview box. */
:root {
  --page: #ffffff;            /* the page */
  --card: #fcfcfd;            /* the sidebar card */
  --edge: rgba(17, 20, 38, 0.09); /* its one pixel edge */
  --ink: #151722;             /* the words */
  --muted: #6a6f80;           /* the quiet words */
  --faint: #a2a6b3;           /* the counts and the keycap */
  --rule: #e6e7ee;            /* the rail and the rules */
  --ghost: #f1f2f6;           /* the row under the pointer */
  --accent: #4f46e5;          /* the marker and the page you are on */
  --get: #0e8a6c;             /* GET */
  --post: #4f46e5;            /* POST */
  --del: #d23f5c;             /* DEL */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------------------------------------------------------------- the card */
.docs {
  --row: clamp(22px, 6.3vh, 33px);
  position: relative;
  width: min(88vw, 320px);
  padding: calc(var(--row) * 0.34) calc(var(--row) * 0.3) calc(var(--row) * 0.3);
  border-radius: 18px;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--card) 38%, #f9f9fb 100%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 1px rgba(17, 20, 38, 0.04),
    0 6px 14px -6px rgba(17, 20, 38, 0.08),
    0 28px 56px -26px rgba(30, 28, 90, 0.22);
  opacity: 0;
}

.docs__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: calc(var(--row) * 1.25);
  padding: 0 calc(var(--row) * 0.24);
}

.docs__brand {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.docs__mark {
  width: 20px;
  height: 20px;
  flex: none;
}

.docs__mark rect {
  fill: var(--ink);
}

.docs__mark path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.9;
  stroke-linecap: round;
}

.docs__name {
  font-size: 14px;
  font-weight: 620;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.005em;
}

.docs__kind {
  font-size: 12px;
  font-weight: 480;
  color: var(--muted);
}

.docs__ver {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 6px 0 8px;
  border-radius: 7px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--rule), 0 1px 1px rgba(17, 20, 38, 0.04);
}

.docs__ver svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.docs__search {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  height: calc(var(--row) * 1.08);
  margin: calc(var(--row) * 0.16) 0 calc(var(--row) * 0.3);
  padding: 0 7px 0 9px;
  border-radius: 9px;
  background: #ffffff;
  color: var(--faint);
  box-shadow: inset 0 0 0 1px var(--rule), 0 1px 2px rgba(17, 20, 38, 0.04);
  transition: box-shadow 0.2s ease;
}

.docs__search svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.docs__search-words {
  flex: 1;
  text-align: left;
  font-size: 12.5px;
}

.docs__key {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--muted);
  background: linear-gradient(#ffffff, #f4f5f8);
  box-shadow: inset 0 0 0 1px var(--rule), 0 1px 0 var(--rule);
}

/* ---------------------------------------------------------------- the tree */
.tree {
  position: relative;
  /* as tall as the longest group open, so the card never changes size when the groups fold */
  height: calc(var(--row) * 9.15);
}

.tree__ghost,
.tree__pill,
.tree__mark {
  position: absolute;
  top: 0;
  pointer-events: none;
}

.tree__ghost {
  left: 4px;
  right: 4px;
  height: 0;
  border-radius: 8px;
  background: var(--ghost);
  opacity: 0;
}

/* the page you are on: a soft indigo glass with a lit top edge */
.tree__pill {
  left: 24px;
  right: 4px;
  height: 0;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, #ffffff), color-mix(in srgb, var(--accent) 11%, #ffffff));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 2px 6px -3px color-mix(in srgb, var(--accent) 35%, transparent);
}

.tree__sheen {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 60%;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.75) 50%, transparent 80%);
  opacity: 0;
}

/* the marker on the rail */
.tree__mark {
  left: 13px;
  width: 2px;
  height: 0;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px 0 color-mix(in srgb, var(--accent) 45%, transparent);
}

.grp__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: var(--row);
  padding: 0 8px 0 5px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 580;
  font-variation-settings: 'wdth' 100;
  text-align: left;
  z-index: 1;
}

.grp__chev {
  width: 12px;
  height: 12px;
  flex: none;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grp__name {
  flex: 1;
}

.grp__count {
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--faint);
}

.grp__wrap {
  height: 0;
  overflow: hidden;
}

.grp[data-open] .grp__wrap {
  height: auto;
}

/* the rail of a group: one pixel, under the marker */
.grp__list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 calc(var(--row) * 0.12);
}

.grp__list::before {
  content: '';
  position: absolute;
  left: 13.5px;
  top: 2px;
  bottom: calc(var(--row) * 0.12 + 2px);
  width: 1px;
  background: var(--rule);
}

.row {
  display: block;
  height: var(--row);
  padding-left: 24px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.row__face {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 100%;
  padding: 0 8px;
  font-size: 12.8px;
  font-weight: 450;
  transition: color 0.25s ease, font-weight 0.3s ease, transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);
  white-space: nowrap;
}

.row__words {
  overflow: hidden;
  text-overflow: ellipsis;
}

.row.is-current .row__face {
  color: var(--ink);
  font-weight: 590;
  transform: translateX(2px);
}

.row:active .row__face,
.grp__head:active {
  transform: scale(0.985);
}

.row:focus-visible,
.grp__head:focus-visible,
.docs__search:focus-visible,
.docs__ver:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -2px;
}

/* the method of an endpoint, in mono, on a tint of its colour */
.tag {
  --c: var(--get);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 16px;
  border-radius: 5px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 9px;
  font-weight: 640;
  letter-spacing: 0.02em;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 9%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 14%, transparent);
  transition: background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.tag--post {
  --c: var(--post);
}

.tag--del {
  --c: var(--del);
}

.row.is-current .tag {
  color: #ffffff;
  background: var(--c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 3px -1px color-mix(in srgb, var(--c) 70%, transparent);
}

@media (hover: hover) {
  .row:hover .row__face {
    color: var(--ink);
  }

  .docs__search:hover {
    box-shadow: inset 0 0 0 1px #d6d8e2, 0 1px 2px rgba(17, 20, 38, 0.05);
  }
}

/* ---------------------------------------------------------------- the pilot's pointer */
.hand {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgba(17, 20, 38, 0.25));
  z-index: 5;
}

.hand path {
  fill: var(--ink);
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

@media (max-width: 360px) {
  .docs__kind {
    display: none;
  }
}
