/*
  The docs page's own look: the top bar, the colours and the type.
  The viewer (scalar.js) reads the --scalar-* variables. The rules under "The viewer's own markup"
  follow its version pinned in apps/api-docs/src/build.ts: look at them again when it changes.
*/

@font-face {
  font-family: 'Inter';
  src: url('inter.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --rd-top: 56px;
  --scalar-custom-header-height: var(--rd-top);
  --scalar-font:
    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --scalar-font-code:
    ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --scalar-radius: 4px;
  --scalar-heading-1: 32px;
  --scalar-heading-2: 25px;
  --scalar-heading-3: 19px;
  --scalar-bold: 700;
  --scalar-semibold: 600;
}

.dark-mode {
  --scalar-background-1: #171b23;
  --scalar-background-2: #1e232d;
  --scalar-background-3: #2a303c;
  --scalar-background-accent: rgba(61, 220, 177, 0.12);
  --scalar-color-1: #f4f6f9;
  --scalar-color-2: #a6afbd;
  --scalar-color-3: #7a8494;
  --scalar-color-accent: #3ddcb1;
  --scalar-border-color: #2b313c;
  --scalar-button-1: #f4f6f9;
  --scalar-button-1-color: #12161d;
  --scalar-button-1-hover: #ffffff;
  --rd-on-accent: #0e1218;
  --rd-note: #e6eafc;
  --rd-note-ink: #161b26;
  --rd-note-edge: #6f84f5;
  color-scheme: dark;
}

.light-mode {
  --scalar-background-1: #ffffff;
  --scalar-background-2: #f5f6f8;
  --scalar-background-3: #eaecf0;
  --scalar-background-accent: rgba(10, 132, 101, 0.1);
  --scalar-color-1: #141821;
  --scalar-color-2: #546071;
  --scalar-color-3: #7b8595;
  --scalar-color-accent: #0a8465;
  --scalar-border-color: #e2e5ea;
  --scalar-button-1: #141821;
  --scalar-button-1-color: #ffffff;
  --scalar-button-1-hover: #2a303c;
  --rd-on-accent: #ffffff;
  --rd-note: #eef1fd;
  --rd-note-ink: #161b26;
  --rd-note-edge: #5b72f0;
  color-scheme: light;
}

html {
  scroll-padding-top: var(--rd-top);
}

body {
  margin: 0;
  background: var(--scalar-background-1);
  color: var(--scalar-color-1);
  font-family: var(--scalar-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.rd-wait {
  margin: 0;
  padding: 96px 24px;
  text-align: center;
  color: var(--scalar-color-2);
}

/* --- the top bar */

.rd-top {
  position: sticky;
  top: 0;
  z-index: 30;
  box-sizing: border-box;
  height: var(--rd-top);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--scalar-background-1);
  border-bottom: 1px solid var(--scalar-border-color);
}

.rd-brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--scalar-color-1);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-decoration: none;
  white-space: nowrap;
}

.rd-brand svg {
  flex: none;
  color: var(--scalar-color-accent);
}

.rd-brand em {
  padding: 3px 8px;
  border: 1px solid var(--scalar-border-color);
  border-radius: 999px;
  color: var(--scalar-color-2);
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0;
}

.rd-nav {
  display: flex;
  gap: 2px;
}

.rd-nav a {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--scalar-color-1);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.rd-nav a:hover {
  background: var(--scalar-background-2);
}

.rd-nav a[aria-current='true'] {
  background: var(--scalar-background-3);
  font-weight: 600;
}

.rd-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rd-search,
.rd-btn,
.rd-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  box-sizing: border-box;
  padding: 0 12px;
  border: 1px solid var(--scalar-border-color);
  border-radius: 8px;
  background: transparent;
  color: var(--scalar-color-1);
  font: 500 14px/1 var(--scalar-font);
  cursor: pointer;
  white-space: nowrap;
}

.rd-search {
  min-width: 190px;
  color: var(--scalar-color-2);
}

.rd-search span {
  flex: 1;
  text-align: left;
}

.rd-search kbd {
  padding: 3px 6px;
  border: 1px solid var(--scalar-border-color);
  border-radius: 5px;
  color: var(--scalar-color-3);
  font: 600 10.5px/1 var(--scalar-font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rd-icon {
  width: 34px;
  justify-content: center;
  padding: 0;
  border-color: transparent;
}

.rd-search:hover,
.rd-btn:hover,
.rd-icon:hover {
  background: var(--scalar-background-2);
  color: var(--scalar-color-1);
}

.rd-search:focus-visible,
.rd-btn:focus-visible,
.rd-icon:focus-visible,
.rd-nav a:focus-visible,
.rd-brand:focus-visible,
.rd-dialog input:focus-visible {
  outline: 2px solid var(--scalar-color-accent);
  outline-offset: 2px;
}

.rd-btn i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--scalar-color-accent);
}

.dark-mode .rd-sun,
.light-mode .rd-moon {
  display: none;
}

/* --- the Environment window */

.rd-dialog {
  width: min(440px, calc(100vw - 32px));
  box-sizing: border-box;
  padding: 0;
  border: 1px solid var(--scalar-border-color);
  border-radius: 14px;
  background: var(--scalar-background-1);
  color: var(--scalar-color-1);
  font-family: var(--scalar-font);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.rd-dialog::backdrop {
  background: rgba(8, 10, 14, 0.6);
}

.rd-dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.rd-dialog h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.rd-dialog p {
  margin: 0;
  color: var(--scalar-color-2);
  font-size: 14px;
  line-height: 1.5;
}

.rd-dialog label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.rd-dialog code {
  margin-left: 4px;
  color: var(--scalar-color-3);
  font: 500 12px var(--scalar-font-code);
}

.rd-dialog input {
  height: 38px;
  box-sizing: border-box;
  padding: 0 10px;
  border: 1px solid var(--scalar-border-color);
  border-radius: 8px;
  background: var(--scalar-background-2);
  color: var(--scalar-color-1);
  font: 13px var(--scalar-font-code);
}

.rd-dialog input::placeholder {
  color: var(--scalar-color-3);
}

.rd-dialog .rd-note {
  font-size: 12.5px;
  color: var(--scalar-color-3);
}

.rd-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.rd-dialog-actions .rd-btn:first-child {
  margin-right: auto;
}

.rd-primary {
  border-color: transparent;
  background: var(--scalar-color-accent);
  color: var(--rd-on-accent);
  font-weight: 600;
}

.rd-primary:hover {
  background: var(--scalar-color-accent);
  color: var(--rd-on-accent);
  filter: brightness(1.08);
}

/* --- The viewer's own markup: the sidebar */

.t-doc__sidebar {
  --scalar-sidebar-padding: 14px;
}

/* the guide pages get a title like the sections below them */
.t-doc__sidebar > ul::before {
  content: 'Guides';
}

.t-doc__sidebar > ul::before {
  display: block;
  padding: 8px;
}

.t-doc__sidebar > ul::before,
.t-doc__sidebar > ul > li > div > a,
.t-doc__sidebar > ul > li > div > a * {
  color: var(--scalar-color-1) !important;
  font-size: 12px;
  font-weight: 700 !important;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* a section is a title, always open: docs.js opens them and this hides the switch */
.t-doc__sidebar > ul > li > div {
  margin-top: 18px;
}

.t-doc__sidebar > ul > li > div > a {
  pointer-events: none;
}

.t-doc__sidebar > ul > li > div > button {
  display: none;
}

/* the pages of a section sit under its title, not one step in */
.t-doc__sidebar > ul > li > ul > li > a > .scalar-sidebar-indent,
.t-doc__sidebar > ul > li > ul > li > div > a > .scalar-sidebar-indent,
.t-doc__sidebar > ul > li > ul > li > ul .scalar-sidebar-indent > :first-child {
  display: none;
}

/* --- The viewer's own markup: the guide pages */

.markdown a {
  color: var(--scalar-color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.markdown blockquote {
  position: relative;
  margin: 22px 0 !important;
  padding: 16px 18px 16px 48px !important;
  border: 0 !important;
  border-left: 4px solid var(--rd-note-edge) !important;
  border-radius: 8px;
  background: var(--rd-note);
  color: var(--rd-note-ink);
  font-weight: 500;
}

.markdown blockquote::before {
  content: '';
  position: absolute;
  top: 19px;
  left: 18px;
  width: 16px;
  height: 18px;
  border-radius: 3px 4px 4px 3px;
  background: var(--rd-note-edge);
  box-shadow: inset 4px 0 0 rgba(255, 255, 255, 0.45);
}

.markdown blockquote p,
.markdown blockquote strong,
.markdown blockquote code {
  color: inherit;
}

.markdown blockquote p:last-child {
  margin-bottom: 0;
}

/* a word of a table is never cut in two: columns take the width their words need */
.markdown table {
  table-layout: auto !important;
}

.markdown th,
.markdown td {
  word-break: normal !important;
  overflow-wrap: break-word !important;
}

/* --- The viewer's own markup: the request window */

/* the OAuth "Metadata URL" row: our API has no such address, and a reader took it for the API's */
tr:has([data-placeholder$='/.well-known/oauth-authorization-server']) {
  display: none !important;
}

/* the hosted page sends no request yet, so it asks for no client ID or secret (the guide says a
   secret never goes in a browser) */
.rd-read-only .scalar-reference-intro-auth {
  display: none !important;
}

/* --- phones and tablets */

@media (max-width: 1180px) {
  .rd-search {
    min-width: 0;
  }

  .rd-search span,
  .rd-search kbd {
    display: none;
  }
}

/* below this width the viewer shows its own bar with the menu: the sections move into it */
@media (max-width: 1023px) {
  .rd-top {
    grid-template-columns: 1fr auto;
    padding: 0 14px;
  }

  .rd-nav {
    display: none;
  }
}

/* a table wider than a phone scrolls sideways inside its own box */
@media (max-width: 640px) {
  .markdown table {
    display: block !important;
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  :root {
    --rd-top: 52px;
    --scalar-heading-1: 27px;
    --scalar-heading-2: 22px;
  }

  .rd-btn span {
    display: none;
  }

  .rd-btn {
    width: 34px;
    justify-content: center;
    padding: 0;
  }

  .rd-btn i {
    position: absolute;
    margin: -16px 0 0 16px;
  }

  .rd-dialog-actions .rd-btn {
    width: auto;
    padding: 0 12px;
  }

  .rd-dialog-actions .rd-btn span {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
