/* Stylesheet of the rendered documentation.
 *
 * The documentation is plain static HTML - no React runtime - but it is the
 * same product, so it uses the application's own design tokens rather than a
 * second visual language: the palettes of src/tokens.css, Inter for the
 * interface, STIX Two Text for reading, Geist Mono for code, and the same
 * `oncall-theme` storage key, so a reader who chose a theme in the
 * application keeps it here. */

:root {
  --sans: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono Variable', 'Geist Mono', ui-monospace, monospace;
  --read: 'STIX Two Text', Georgia, serif;
  --radius: 8px;
  --sidebar-width: 268px;
  --measure: 68ch;
}

/* Dark is the default the pre-paint script stamps on <html>; light is the
   explicit choice, as in the application. */
:root,
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #07152E;
  --paper: #0B1F42;
  --fg: #F4F6FA;
  --heading: #F4F6FA;
  --fg-muted: #A3B5C9;
  --accent: #65B8FF;
  --accent-label: #65B8FF;
  --accent-contrast: #0B1F42;
  --topbar-bg: rgba(11, 31, 66, 0.92);
  --topbar-fg: #F4F6FA;
  --topbar-border: rgba(163, 181, 201, 0.16);
  --nav-active-bg: rgba(101, 184, 255, 0.16);
  --line: rgba(163, 181, 201, 0.16);
  --line-soft: rgba(163, 181, 201, 0.12);
  --code-bg: #122A52;
  --table-header-bg: #122A52;
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #F4F6FA;
  --paper: #FFFFFF;
  --fg: #303030;
  --heading: #0B1F42;
  --fg-muted: #506A97;
  --accent: #064EA1;
  --accent-label: #064EA1;
  --accent-contrast: #FFFFFF;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --topbar-fg: #0B1F42;
  --topbar-border: #E4EAF0;
  --nav-active-bg: rgba(40, 112, 237, 0.1);
  --line: #E4EAF0;
  --line-soft: #E4EAF0;
  --code-bg: #F4F6FA;
  --table-header-bg: #F4F6FA;
}

* { box-sizing: border-box; }

html {
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  /* A #fragment link lands its heading below the sticky top bar, level with
     the top of the sidebar, rather than under the bar. */
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/24px var(--sans);
}

a { color: var(--accent); }
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Top bar: the application's own, at the same height -------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--topbar-border);
  color: var(--topbar-fg);
}

/* The application's own mark and product name. The name is filled in from
   the public configuration when the pages are served next to the API. */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--topbar-fg);
  font: 700 16px/24px var(--sans);
  white-space: nowrap;
  text-decoration: none;
}

.wordmark svg { width: 26px; height: 26px; border-radius: 0; flex: 0 0 auto; }

.topbar-title {
  font: 600 12px/16px var(--sans);
  color: var(--fg-muted);
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-link,
.theme-toggle {
  font: 600 14px/21px var(--sans);
  color: var(--topbar-fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
  text-decoration: none;
}

.topbar-link:hover,
.theme-toggle:hover { background: var(--nav-active-bg); border-color: var(--accent); }

/* --- Shell ----------------------------------------------------------------- */

.shell {
  /* Exactly the sidebar, the gap, one column of prose and the page padding,
     so the pair centres on the page instead of leaving the text stranded
     against a wide empty right-hand margin. */
  --gap: 40px;
  max-width: calc(var(--sidebar-width) + var(--gap) + var(--measure) + 64px + 48px);
  margin-inline: auto;
  padding: 32px 24px 64px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

/* The article and its pager share the second column, so the pager lines up
   under the text rather than under the whole page. */
.column {
  min-width: 0;
  display: grid;
  gap: 20px;
}

.sidebar {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 116px);
  overflow-y: auto;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sidebar-toggle { display: none; }

.sidebar h2 {
  margin: 20px 0 6px;
  font: 600 12px/16px var(--sans);
  color: var(--fg-muted);
}

.sidebar h2:first-child { margin-top: 0; }

.sidebar ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

.sidebar a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  line-height: 21px;
}

.sidebar a:hover { background: var(--nav-active-bg); }

.sidebar a[aria-current='page'] {
  background: var(--nav-active-bg);
  color: var(--accent-label);
  font-weight: 600;
}

/* --- Article --------------------------------------------------------------- */

.content {
  font: 400 18px/26px var(--read);
  min-width: 0;
  padding: 28px 32px 36px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }

.content h1 {
  margin: 0 0 24px;
  font: 700 40px/45px var(--sans);
}

/* Ruled section headings, as in the application. */
.content h2 {
  margin: 48px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font: 700 24px/28px var(--sans);
}

.content h3 {
  margin: 32px 0 8px;
  font: 700 20px/24px var(--sans);
}

.content p,
.content li { overflow-wrap: break-word; }

.content ul,
.content ol { padding-left: 1.4em; }

.content li { margin-block: 4px; }

.content blockquote {
  margin: 20px 0;
  padding: 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--fg-muted);
}

.content strong { font-weight: 700; }
.content :is(h1, h2, h3, h4, h5, h6) { color: var(--heading); }
.content :is(h4, h5, h6) { font: 700 16px/24px var(--sans); }
[data-theme='light'] :is(.content, .sidebar, .pager a) { border-color: transparent; box-shadow: 0 2px 8px rgba(33, 65, 108, 0.08); }

code {
  font-family: var(--mono);
  /* Commands are read to be typed, not interpreted as typographic ligatures. */
  font-variant-ligatures: none;
  font-size: 16px;
  line-height: 24px;
  background: var(--code-bg);
  padding: 0.12em 0.2em;
  border-radius: 4px;
}

pre {
  margin: 20px 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  line-height: 21px;
}

pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  line-height: 21px;
}

.table-scroll {
  margin: 20px 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font: 400 16px/24px var(--sans);
}

th, td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

thead th {
  background: var(--table-header-bg);
  font-weight: 700;
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: 0; }

hr {
  margin: 32px 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
}

/* --- Pager ----------------------------------------------------------------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.pager a {
  font: 600 16px/24px var(--sans);
  flex: 1 1 240px;
  min-width: 0;
  padding: 12px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg);
}

.pager a:hover { border-color: var(--accent); }
.pager .pager-next { text-align: right; }

.pager span {
  display: block;
  font: 600 12px/16px var(--sans);
  color: var(--fg-muted);
}

/* Standalone site only (scripts/build-docs.mjs --site): which release the
   pages describe. The copy inside the image needs no such line; it always
   matches the application it ships with. */
.site-footer {
  margin: 0;
  font: 400 12px/16px var(--mono);
  color: var(--fg-muted);
}

/* --- Narrow screens -------------------------------------------------------- */

@media (max-width: 900px) {
  .topbar { padding-inline: 16px; gap: 10px; }
  .topbar-title { display: none; }

  .shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding: 20px 16px 48px;
  }

  .sidebar {
    position: static;
    max-height: none;
    padding: 0;
    overflow: visible;
  }

  /* The whole navigation collapses behind one disclosure, so a phone opens on
     the page it was sent to rather than on a screenful of links. */
  .sidebar-toggle {
    display: block;
    padding: 14px 16px;
    font: 600 14px/21px var(--sans);
    cursor: pointer;
    list-style: none;
  }

  .sidebar-toggle::-webkit-details-marker { display: none; }
  .sidebar-toggle::after { content: " ▾"; color: var(--fg-muted); }
  .sidebar[open] .sidebar-toggle::after { content: " ▴"; }
  .sidebar-body { padding: 0 16px 16px; }
  .content { padding: 20px 18px 26px; }
  .content h1 { font-size: 32px; line-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media print {
  .topbar, .sidebar, .pager { display: none; }
  .shell { display: block; padding: 0; }
  .content { border: 0; padding: 0; max-width: none; }
}
