/* Operator API documentation: one stylesheet, system fonts, light and dark. */

:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --bg-code: #f3f4f6;
  --bg-head: rgba(255, 255, 255, 0.94);
  --fg: #16191f;
  --fg-soft: #4b5262;
  --fg-faint: #6b7282;
  --line: #e1e4ea;
  --line-strong: #c9ced8;
  --accent: #0a6b66;
  --accent-fg: #ffffff;
  --accent-soft: #e2f1ef;
  --focus: #1d5fd1;
  --note-bg: #eef4fb;
  --note-line: #5b8bd0;
  --warn-bg: #fdf4e3;
  --warn-line: #c98a1c;
  --t-key: #8a2f72;
  --t-str: #1f6a2c;
  --t-num: #8a4b00;
  --t-lit: #1d4fb0;
  --t-com: #6b7282;
  --t-kw: #8a2f72;
  --radius: 8px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1116;
    --bg-soft: #151a21;
    --bg-code: #171c24;
    --bg-head: rgba(14, 17, 22, 0.94);
    --fg: #e5e8ed;
    --fg-soft: #b0b7c3;
    --fg-faint: #8d95a3;
    --line: #262d37;
    --line-strong: #364050;
    --accent: #5fd0c4;
    --accent-fg: #06201e;
    --accent-soft: #10302d;
    --focus: #8ab4ff;
    --note-bg: #13213a;
    --note-line: #5b8bd0;
    --warn-bg: #2c2210;
    --warn-line: #d9a23a;
    --t-key: #e59ad0;
    --t-str: #8fd49b;
    --t-num: #f0b46a;
    --t-lit: #8ab4ff;
    --t-com: #8d95a3;
    --t-kw: #e59ad0;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0e1116;
  --bg-soft: #151a21;
  --bg-code: #171c24;
  --bg-head: rgba(14, 17, 22, 0.94);
  --fg: #e5e8ed;
  --fg-soft: #b0b7c3;
  --fg-faint: #8d95a3;
  --line: #262d37;
  --line-strong: #364050;
  --accent: #5fd0c4;
  --accent-fg: #06201e;
  --accent-soft: #10302d;
  --focus: #8ab4ff;
  --note-bg: #13213a;
  --note-line: #5b8bd0;
  --warn-bg: #2c2210;
  --warn-line: #d9a23a;
  --t-key: #e59ad0;
  --t-str: #8fd49b;
  --t-num: #f0b46a;
  --t-lit: #8ab4ff;
  --t-com: #8d95a3;
  --t-kw: #e59ad0;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--font);
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

code,
pre {
  font-family: var(--mono);
  font-size: 0.88em;
}

:not(pre) > code {
  background: var(--bg-code);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.05em 0.3em;
  overflow-wrap: anywhere;
}

.skip {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 20;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 8px 12px;
  border-radius: var(--radius);
}

.skip:focus {
  top: 8px;
}

/* ---------------------------------------------------------------- header */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--bg-head);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  text-decoration: none;
  min-width: 0;
}

.brand-name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  color: var(--fg-soft);
  font-size: 0.9em;
  white-space: nowrap;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
}

.logo {
  flex-shrink: 0;
}

.logo-bg {
  fill: var(--accent);
}

.logo-ring {
  fill: none;
  stroke: var(--accent-fg);
  stroke-width: 2.5;
}

.logo-cut {
  stroke: var(--accent-fg);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.menu-btn,
.theme-btn,
.copy-btn {
  font: inherit;
  font-size: 0.875rem;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}

.menu-btn:hover,
.theme-btn:hover,
.copy-btn:hover {
  border-color: var(--accent);
}

.theme-btn {
  margin-left: auto;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  max-width: 1440px;
  margin: 0 auto;
}

.side {
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 20px 16px 32px 20px;
  border-right: 1px solid var(--line);
  font-size: 0.92rem;
}

.side-h {
  margin: 18px 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.side-h:first-child {
  margin-top: 0;
}

.side ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.side a {
  display: block;
  padding: 4px 10px;
  margin-left: -10px;
  border-radius: 6px;
  color: var(--fg-soft);
  text-decoration: none;
}

.side a:hover {
  color: var(--fg);
  background: var(--bg-soft);
}

.side a[aria-current='page'] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

main {
  min-width: 0;
  padding: 28px 40px 48px;
}

main:focus {
  outline: none;
}

article {
  max-width: 820px;
}

.toc {
  display: none;
}

@media (min-width: 1280px) {
  .layout {
    grid-template-columns: 272px minmax(0, 1fr) 232px;
  }

  .toc {
    display: block;
    position: sticky;
    top: 56px;
    align-self: start;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    padding: 28px 20px 28px 0;
    font-size: 0.85rem;
  }

  .toc-h {
    margin: 0 0 8px;
    font-weight: 700;
    color: var(--fg-faint);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .toc ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 12px;
    border-left: 1px solid var(--line);
  }

  .toc li {
    margin: 0 0 6px;
  }

  .toc a {
    color: var(--fg-soft);
    text-decoration: none;
  }

  .toc a:hover {
    color: var(--accent);
  }
}

@media (max-width: 959px) {
  .layout {
    display: block;
  }

  .side {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .js .side {
    display: none;
  }

  .js .side.open {
    display: block;
  }

  main {
    padding: 20px 16px 40px;
  }

  .brand-sub {
    display: none;
  }
}

@media (max-width: 480px) {
  .theme-k {
    display: none;
  }
}

@media (min-width: 960px) {
  .menu-btn {
    display: none;
  }
}

/* ---------------------------------------------------------------- article */

.crumb {
  margin: 0 0 4px;
  color: var(--fg-faint);
  font-size: 0.85rem;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h2 {
  margin: 2.2em 0 0.6em;
  padding-top: 0.4em;
  font-size: 1.4rem;
  line-height: 1.3;
  border-top: 1px solid var(--line);
}

h3 {
  margin: 1.8em 0 0.5em;
  font-size: 1.12rem;
  line-height: 1.35;
}

h4 {
  margin: 1.2em 0 0.4em;
  font-size: 1rem;
}

.anchor {
  margin-left: 0.4em;
  color: var(--fg-faint);
  text-decoration: none;
  opacity: 0;
  font-weight: 400;
}

h2:hover .anchor,
h3:hover .anchor,
.anchor:focus {
  opacity: 1;
}

.lead {
  font-size: 1.12rem;
  color: var(--fg-soft);
  margin: 0 0 1.5em;
}

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

li {
  margin: 0.25em 0;
}

dl {
  margin: 0;
}

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

.table-wrap {
  overflow-x: auto;
  margin: 1em 0 1.4em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--fg-soft);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

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

th {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--fg-soft);
  white-space: nowrap;
}

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

table.fields td:first-child,
table.codes td:first-child {
  white-space: nowrap;
}

table.fields td:nth-child(2) {
  min-width: 9em;
}

table.fields td:last-child,
table.codes td:last-child {
  min-width: 16em;
}

.type {
  color: var(--fg-soft);
  font-family: var(--mono);
  font-size: 0.85em;
}

.req {
  font-weight: 600;
}

.opt {
  color: var(--fg-faint);
}

td code.field,
td code.code-num {
  font-weight: 600;
}

/* Events by game: the game columns on a wide screen, the one-line "Sent by" column on a phone. */
table.matrix th:last-child,
table.matrix td:last-child {
  display: none;
}

@media (max-width: 640px) {
  .table-wrap table.matrix td:not(:first-child, :last-child) {
    display: none;
  }

  /* Neither cell shrinks or wraps, so a row stays one line; a games list longer than the line
     overflows to .table-wrap, the focusable, labelled region that scrolls sideways. */
  .table-wrap table.matrix td:first-child {
    flex: none;
  }

  .table-wrap table.matrix td:last-child {
    display: block;
    flex: none;
    white-space: nowrap !important;
    color: var(--fg-soft);
  }

  .table-wrap table.matrix td:last-child::before {
    display: inline;
    margin-right: 0.5em;
  }

  .table-wrap table.matrix tr {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 2px 12px;
    padding: 6px 12px;
  }
}

@media (max-width: 640px) {
  /* Rows become labelled blocks: no column is squeezed below a readable width. */
  .table-wrap table,
  .table-wrap caption,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
  }

  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .table-wrap tr {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }

  .table-wrap tbody tr:last-child {
    border-bottom: 0;
  }

  .table-wrap td {
    padding: 2px 0;
    border: 0;
    min-width: 0 !important;
    white-space: normal !important;
  }

  .table-wrap td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--fg-faint);
  }

  .table-wrap td:first-child::before {
    display: none;
  }

  .table-wrap td:first-child {
    font-weight: 600;
  }

  /* Field tables: type and presence on one line under the name. */
  .table-wrap table.fields td:nth-child(2),
  .table-wrap table.fields td:nth-child(3) {
    display: inline-block;
    margin-right: 12px;
  }

  .table-wrap table.fields td:nth-child(2)::before,
  .table-wrap table.fields td:nth-child(3)::before {
    display: none;
  }
}

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

.code-box {
  position: relative;
  margin: 0.8em 0 1.2em;
}

.code-box.wrap pre.code {
  white-space: pre-wrap;
  word-break: break-all;
}

pre.code {
  margin: 0;
  padding: 14px 64px 14px 16px;
  background: var(--bg-code);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.5;
  tab-size: 2;
}

pre.code code {
  font-size: inherit;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.75rem;
  padding: 2px 8px;
  opacity: 0.85;
}

.code-box:hover .copy-btn,
.copy-btn:focus-visible {
  opacity: 1;
}

.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-com {
  color: var(--t-com);
  font-style: italic;
}

.t-kw {
  color: var(--t-kw);
}

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

.tabs {
  margin: 1em 0 1.6em;
}

.tab-title {
  margin: 1em 0 0.2em;
  font-size: 0.9rem;
  color: var(--fg-soft);
}

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

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.tab-list button {
  font: inherit;
  font-size: 0.875rem;
  background: none;
  color: var(--fg-soft);
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 8px 12px;
  cursor: pointer;
}

.tab-list button[aria-selected='true'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tabs.ready .tab-panel .code-box {
  margin-top: 0;
}

.tabs.ready .tab-panel pre.code {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: 0;
}

/* ---------------------------------------------------------------- blocks */

.endpoint {
  margin: 0 0 1.6em;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.endpoint-line {
  margin: 0 0 10px;
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.endpoint-line code {
  font-size: 0.95em;
  background: none;
  border: 0;
  padding: 0;
}

.verb {
  display: inline-block;
  padding: 1px 8px;
  margin-right: 4px;
  border-radius: 5px;
  background: var(--accent);
  color: var(--accent-fg);
  font: 700 0.78rem/1.6 var(--mono);
  letter-spacing: 0.04em;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 20px;
  font-size: 0.88rem;
}

.facts dt {
  color: var(--fg-faint);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.facts dd {
  margin: 0;
}

.callout {
  margin: 1.2em 0;
  padding: 10px 16px;
  border-left: 4px solid var(--note-line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--note-bg);
}

.callout-warn {
  border-left-color: var(--warn-line);
  background: var(--warn-bg);
}

.callout-title {
  margin: 0.3em 0;
  font-weight: 650;
}

.callout > :last-child {
  margin-bottom: 0.3em;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 1.2em 0;
  padding: 0;
  list-style: none;
}

.cards li {
  margin: 0;
}

.cards a {
  display: block;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
}

.cards a:hover {
  border-color: var(--accent);
}

.cards strong {
  display: block;
  color: var(--accent);
  margin-bottom: 4px;
}

.cards span {
  color: var(--fg-soft);
  font-size: 0.92rem;
}

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
}

.steps > li {
  position: relative;
  padding-left: 2.4em;
  margin: 0 0 0.9em;
}

.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.1em;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85em;
  text-align: center;
  line-height: 1.7em;
}

.checklist {
  list-style: none;
  padding: 0;
}

.checklist li {
  padding-left: 1.8em;
  position: relative;
}

.checklist li::before {
  content: '';
  position: absolute;
  left: 0.2em;
  top: 0.35em;
  width: 0.95em;
  height: 0.95em;
  border: 2px solid var(--line-strong);
  border-radius: 3px;
}

/* ---------------------------------------------------------------- diagrams */

.diagram {
  margin: 1.2em 0 1.6em;
}

.diagram-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 8px;
}

.diagram svg {
  display: block;
  width: 100%;
  min-width: 620px;
  height: auto;
  font-family: var(--font);
}

.diagram figcaption {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--fg-faint);
}

.dg-box {
  fill: var(--bg);
  stroke: var(--line-strong);
}

.dg-actor {
  fill: var(--fg);
  font-size: 13px;
  font-weight: 650;
}

.dg-life {
  stroke: var(--line-strong);
  stroke-dasharray: 4 4;
}

.dg-msg {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.dg-reply {
  stroke: var(--fg-faint);
  stroke-dasharray: 5 3;
}

.dg-head {
  fill: var(--fg-soft);
}

.dg-label {
  fill: var(--fg);
  font-size: 12px;
}

.dg-note {
  fill: var(--accent-soft);
  stroke: var(--line-strong);
}

.dg-note-text {
  fill: var(--fg-soft);
  font-size: 12px;
}

/* ---------------------------------------------------------------- pager, footer */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  max-width: 820px;
  margin-top: 3em;
  padding-top: 1.2em;
  border-top: 1px solid var(--line);
}

.pager a {
  display: block;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  max-width: 48%;
}

.pager a:hover {
  border-color: var(--accent);
}

.pager-next {
  margin-left: auto;
  text-align: right;
}

.pager-k {
  display: block;
  font-size: 0.75rem;
  color: var(--fg-faint);
}

.foot {
  border-top: 1px solid var(--line);
  padding: 20px 16px;
  color: var(--fg-faint);
  font-size: 0.85rem;
  text-align: center;
}

.foot p {
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media print {
  .top,
  .side,
  .toc,
  .pager,
  .copy-btn {
    display: none;
  }

  .layout {
    display: block;
  }
}

[hidden] {
  display: none !important;
}
