/* W4-D4 (#241) — the docs site's one stylesheet: light and dark from the
   reader's system setting, readable line lengths.
   Design v2 (the Web-Docs board, docs/design/SPEC.md): midnight text,
   tomato-700 links, mist bands and code, the public site's header and
   footer; on dark, night with tomato-400 links and the butter focus ring.
   The system fonts stand in for the board's, so the site loads nothing
   from another host. */

:root {
  --bg: #ffffff;
  --text: #1b1f3b;
  --muted: #5a6080;
  --secondary: #3a3f62;
  --border: #e3e6f0;
  --panel: #f4f5fa;
  --hover: #eef0f6;
  --link: #bf2a0c;
  --mark: #ff5b3a;
  --code: #f4f5fa;
  --focus: #1b1f3b;
  --bubble: #1b1f3b;
  --dot: #ffffff;
  --ok: #23643f;
  --warn: #6f4f07;
  --bad: #8a1846;
  --wide: 76rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11142a;
    --text: #ffffff;
    --muted: #c9cde4;
    --secondary: #c9cde4;
    --border: #2a2f55;
    --panel: #1b1f3b;
    --hover: #2a2f55;
    --link: #ff7a5c;
    --code: #1b1f3b;
    --focus: #ffe08a;
    --bubble: #ffffff;
    --dot: #11142a;
    --ok: #8fd6a8;
    --warn: #ffe08a;
    --bad: #ff9fb8;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: #ffe08a; color: #1b1f3b; }
mark { background: #ffe08a; color: #1b1f3b; padding: 0 0.15em; border-radius: 3px; }

.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 12px; top: 12px; z-index: 10; background: var(--bg); color: var(--text); padding: 8px 12px; border: 1px solid var(--border); }

/* The public site's header: the mark, its pages with Docs current, Status and Log in. */
.site-header { border-bottom: 1px solid var(--border); background: var(--bg); }
.site-bar {
  display: flex; align-items: center; gap: 24px;
  max-width: var(--wide); margin: 0 auto; padding: 12px clamp(16px, 4vw, 48px); min-height: 64px;
}
.wordmark { flex: none; display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.wordmark-name { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.wordmark .docs { color: var(--muted); font-weight: 500; font-size: 1.05rem; }
.logo-bubble { fill: var(--bubble); }
.logo-dot { fill: var(--dot); }
.logo-dot-last { fill: var(--mark); }
.site-nav { display: flex; gap: 4px; flex: 1; }
.site-nav a, .site-menu nav a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 999px;
  color: var(--secondary); text-decoration: none; font-size: 0.88rem; font-weight: 500;
}
.site-nav a:hover, .site-menu nav a:hover { background: var(--hover); color: var(--text); }
.site-nav a[aria-current], .site-menu nav a[aria-current] { color: var(--text); font-weight: 600; background: var(--hover); }
.site-tools { display: flex; align-items: center; gap: 16px; margin-left: auto; font-size: 0.88rem; font-weight: 600; }
.site-tools > a { color: var(--text); text-decoration: none; }
.site-tools > a:hover { text-decoration: underline; }
.site-menu { display: none; position: relative; }
.site-menu summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px;
  border-radius: 999px; background: var(--hover); color: var(--text);
}
.site-menu summary::-webkit-details-marker { display: none; }
.site-menu nav {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 5; min-width: 14rem;
  display: flex; flex-direction: column; padding: 8px; border-radius: 12px; background: var(--bg);
  box-shadow: 0 1px 2px rgb(27 31 59 / 0.06), 0 8px 24px rgb(27 31 59 / 0.1);
}
.site-menu nav a { min-height: 48px; font-size: 1rem; }

.layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); max-width: var(--wide); margin: 0 auto; }
.sidebar { border-right: 1px solid var(--border); padding: 24px 16px; }
.sidebar ul { list-style: none; margin: 0 0 12px; padding: 0; }
.sidebar li a { display: block; padding: 6px 12px; border-radius: 999px; color: var(--secondary); text-decoration: none; font-size: 0.9rem; line-height: 1.4; }
.sidebar li a:hover { background: var(--hover); color: var(--text); }
.sidebar li a[aria-current="page"] { background: var(--border); color: var(--text); font-weight: 600; }
.nav-group { margin: 16px 12px 6px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.nav-wide { position: sticky; top: 16px; }
.contents { display: none; }

main { padding: 32px 48px 64px; min-width: 0; outline: none; }
.doc { max-width: 46rem; }
.doc h1 { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.75rem); line-height: 1.08; letter-spacing: -0.025em; margin: 0 0 12px; text-wrap: balance; }
.doc h2 { font-size: 1.5rem; line-height: 1.25; margin: 2.2em 0 0.5em; letter-spacing: -0.015em; scroll-margin-top: 16px; text-wrap: balance; }
.doc h3 { font-size: 1.15rem; margin: 1.8em 0 0.4em; scroll-margin-top: 16px; }
.doc h4 { font-size: 1rem; margin: 1.4em 0 0.3em; }
.doc p, .doc li, .doc dd { text-wrap: pretty; }
/* A long word (an API field's values, joined by |) wraps rather than widening a phone's page. */
.doc { overflow-wrap: break-word; }
.summary, .lead { color: var(--secondary); font-size: 1.15rem; line-height: 1.6; margin-top: 0; }
.muted { color: var(--muted); font-weight: normal; }
.view-markdown { margin: -0.4em 0 1.6em; font-size: 0.9rem; }
.view-markdown a { display: inline-block; min-height: 24px; line-height: 24px; }
code { font: 0.86em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--code); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--code); padding: 16px 20px; border-radius: 12px; overflow-x: auto; }
pre code { background: none; padding: 0; }
blockquote { margin: 1em 0; padding: 4px 16px; border-left: 3px solid var(--mark); background: var(--panel); border-radius: 0 12px 12px 0; }
.table-wrap { overflow-x: auto; margin: 1em 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.94rem; }
th, td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
th { background: var(--panel); font-weight: 600; }
.align-right { text-align: right; }
.align-center { text-align: center; }
li { margin: 0.25em 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.code-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; margin: 1.2em 0 0.3em; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.code-label + pre { margin-top: 0; }
.copy { min-height: 32px; padding: 0 12px; font-size: 0.8rem; }
/* "Where you work" (assets/tabs.js): the setup sections as tabs, the board's pills. */
.tablist { display: flex; flex-wrap: wrap; gap: 4px; margin: 1.2em 0 0.6em; }
.tab { font: inherit; font-size: 0.9rem; font-weight: 500; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--secondary); cursor: pointer; }
.tab:hover { background: var(--panel); }
.tab[aria-selected="true"] { background: var(--border); color: var(--text); font-weight: 600; }
@media print {
  .tablist { display: none; }
  .has-tabs > section[hidden] { display: block; }
  .has-tabs > section > .vh { position: static; width: auto; height: auto; margin: 1.8em 0 0.4em; overflow: visible; clip: auto; white-space: normal; }
}
.errors { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 8px 16px; }
.errors dt { font-weight: 600; }
.errors dd { margin: 0; }

.help-box, .note { background: var(--panel); border-radius: 12px; padding: 16px 20px; }
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 12px; }
.card { display: block; height: 100%; padding: 16px 20px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); text-decoration: none; }
.card:hover { background: var(--panel); }
.card strong { display: block; color: var(--text); margin-bottom: 4px; text-decoration: underline; text-decoration-color: var(--link); text-underline-offset: 0.18em; }
.card span { color: var(--secondary); font-size: 0.94rem; }

.loop-toc ul, .op-toc ul { columns: 2; padding-left: 1.2em; }
.loop { border-top: 1px solid var(--border); padding-top: 4px; }
.loop-meta { color: var(--muted); font-size: 0.92rem; margin: 0 0 8px; }
.loop dl { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 4px 14px; margin: 0 0 12px; }
.loop dt { font-weight: 600; }
.loop dd { margin: 0; }

.op { border-top: 1px solid var(--border); padding: 4px 0 8px; }
.op h3 { font-size: 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.method { display: inline-block; min-width: 4.2em; text-align: center; font: 700 0.78rem/1.6 ui-monospace, Menlo, monospace; border-radius: 4px; padding: 0 6px; background: var(--code); }
.method-get { color: var(--ok); }
.method-post { color: var(--link); }
.method-put, .method-patch { color: var(--warn); }
.method-delete { color: var(--bad); }
.access { font-size: 0.94rem; color: var(--muted); }
.responses { padding-left: 1.2em; }
.fields { margin: 4px 0 0; padding-left: 1.1em; }
.fields li { margin: 2px 0; }
.filter input { font: inherit; padding: 8px 12px; border: 1px solid #787e9c; border-radius: 12px; background: var(--bg); color: var(--text); min-width: 16rem; }

.entry { border-top: 1px solid var(--border); }
.entry h2 { margin-bottom: 0; }
.entry .date { color: var(--muted); margin-top: 0; }

.status { border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; margin: 1.5em 0; }
.status-title { font-size: 1.35rem; font-weight: 700; margin: 0; }
.status-title::before { content: ""; display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 0.5em; background: var(--muted); vertical-align: 0.05em; }
.status[data-state="ok"] .status-title::before { background: var(--ok); }
.status[data-state="degraded"] .status-title::before { background: var(--warn); }
.status[data-state="unknown"] .status-title::before { background: var(--bad); }
.button { font: inherit; font-size: 0.9rem; font-weight: 600; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--hover); color: var(--text); cursor: pointer; }
.button:hover { background: var(--border); }

/* The public site's footer: the mark, the support line, then its two rows of links. */
.site-footer { border-top: 1px solid var(--border); background: var(--panel); color: var(--secondary); font-size: 0.9rem; }
.footer-inner {
  max-width: var(--wide); margin: 0 auto; padding: 40px clamp(16px, 4vw, 48px) 48px;
  display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: 24px 64px;
}
.footer-brand p { margin: 12px 0 0; }
.site-footer nav ul { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.site-footer nav a { color: var(--text); text-decoration: none; }
.site-footer nav a:hover { text-decoration: underline; }

@media (max-width: 64rem) {
  .site-nav { display: none; }
  .site-menu { display: block; }
}

@media (max-width: 52rem) {
  .layout { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 16px; }
  .nav-wide { display: none; }
  .contents { display: block; }
  .contents summary { cursor: pointer; padding: 8px 0; font-weight: 600; min-height: 40px; }
  main { padding: 24px 16px 48px; }
  .loop dl, .errors { grid-template-columns: 1fr; }
  .loop-toc ul, .op-toc ul { columns: 1; }
  .footer-inner { grid-template-columns: 1fr; }
  /* Tables fit the screen instead of scrolling sideways, where a keyboard could not reach them. */
  th, td { overflow-wrap: anywhere; }
  .site-tools > a:first-child { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  a, .button, .site-menu summary { transition: background-color 180ms cubic-bezier(0.16, 1, 0.3, 1), color 180ms cubic-bezier(0.16, 1, 0.3, 1); }
}
