/* Docs and the app's other pages (Help, Support, Release notes, Privacy), set by
   buildscripts/build_website.py in templates/document.html. Loaded after home.css: the text keeps
   the site's column, and on wide screens a long page's sections hang in the margin to its left. */

.doc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(100% - 2 * var(--outer), var(--col)) minmax(0, 1fr);
  column-gap: 0;
  /* The page grows to keep the footer at the window's bottom edge; the rows stay at the top. */
  align-content: start;
  padding: clamp(48px, 9vh, 104px) 0 var(--gap);
}
.doc-head, .doc-body { grid-column: 2; min-width: 0; }

/* The sections: beside the text, held in view while it scrolls, from the header's left edge. */
.doc-contents { grid-column: 1; grid-row: 1 / span 3; margin: 0 40px 0 max(var(--outer), calc(50vw - var(--frame) / 2)); }
.doc-contents-list { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; padding-top: 6px; }
.doc-contents-title { margin-bottom: 8px; color: var(--muted); font-size: var(--step-small); }
.doc-contents a { display: block; padding: 5px 0; color: var(--muted); font-size: var(--step-small); line-height: 1.35; text-decoration: none; transition: color var(--t-hover) ease; }
@media (hover: hover) and (pointer: fine) { .doc-contents a:hover { color: var(--ink); } }

/* The title, with Copy for agents in its corner. */
.doc-head { position: relative; }
.doc-head h1 { font-size: min(3rem, var(--step-display)); }
.doc-head .lead { max-width: 34rem; margin-top: 18px; font-size: var(--step-lead); line-height: 1.45; }
.doc-head:has(.doc-copy:not([hidden])) h1 { padding-right: 56px; }
.doc-copy { position: absolute; top: 4px; right: 0; }
.doc-copy[hidden] { display: none; }
/* A page whose title shows only to screen readers (Help) opens with its first section, Copy for agents
   in that heading's corner. */
.doc-untitled .doc-body { margin-top: 0; }
.doc-untitled:has(.doc-copy:not([hidden])) .doc-body > h2:first-child { padding-right: 56px; }
.doc-copy-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.doc-copy-button:active { transform: scale(0.94); }
.doc-copy-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.doc-copy-done { display: none; }
.doc-copy-button.is-copied { color: var(--accent); }
.doc-copy-button.is-copied .doc-copy-icon { display: none; }
.doc-copy-button.is-copied .doc-copy-done { display: block; }
.doc-copy-status:not(.sr-only) { margin-top: 8px; width: 16rem; color: var(--muted); font-size: var(--step-small); text-align: right; }
@media (hover: hover) and (pointer: fine) { .doc-copy-button:hover { background: var(--surface-strong); } }

/* The text. */
.doc-body { margin-top: clamp(40px, 5vw, 64px); }
.doc-body > :first-child { margin-top: 0; }
.doc-body h2 { margin: clamp(56px, 7vw, 80px) 0 14px; scroll-margin-top: 24px; }
.doc-body h3 { margin: 36px 0 10px; font-size: var(--step-body); font-weight: 600; scroll-margin-top: 24px; }
.doc-body h4 { margin: 26px 0 8px; font-size: var(--step-body); font-weight: 600; }
.doc-body p, .doc-body ul, .doc-body ol, .doc-body table { margin: 0 0 1em; }
.doc-body ul, .doc-body ol { padding-left: 1.3em; }
.doc-body ul { list-style: disc; }
.doc-body li + li { margin-top: 0.45em; }
.doc-body li::marker { color: var(--muted); }
.doc-body a:not(.button) { text-decoration: underline; text-decoration-thickness: 0.07em; text-underline-offset: 0.2em; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
@media (hover: hover) and (pointer: fine) { .doc-body a:not(.button):hover { text-decoration-color: currentColor; } }
.doc-body strong { font-weight: 600; }
.doc-body code { font-family: var(--font-code); font-size: 0.86em; }
.doc-body :not(pre) > code { padding: 0.1em 0.35em; border-radius: 5px; background: var(--surface); overflow-wrap: anywhere; }

/* Code and the agent prompt, each with its own Copy. */
.doc-body pre {
  margin: 0 0 1.25em;
  padding: 22px 24px;
  overflow-x: auto;
  border-radius: var(--radius);
  background: #17181a;
  color: #e9e9ec;
  font-family: var(--font-code);
  font-size: var(--step-small);
  line-height: 1.6;
  tab-size: 2;
}
.doc-body pre:focus-visible { outline-offset: -3px; }
.doc-body pre code { font-size: 1em; }
.doc-body pre.prompt { white-space: pre-wrap; overflow-wrap: anywhere; }
.code-block { position: relative; }
/* Copy sits above the code, so long lines keep the block's whole width. */
.code-block pre { padding-top: 56px; }
/* Where script runs, the room is there from the first frame, so the text below doesn't move (or a
   link to a section further down land elsewhere) when docs.js adds the buttons. */
@media (scripting: enabled) { .doc-body pre { padding-top: 56px; } }
.code-copy {
  position: absolute;
  top: 14px;
  right: 14px;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #2e2f32;
  color: #f2f2f3;
  font-family: var(--font);
  font-size: var(--step-small);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.code-copy:active { transform: scale(0.96); }
.code-copy:focus-visible { outline-color: #fff; outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .code-copy:hover { background: #3d3e42; } }

/* Tables keep their rules: they are real tables. */
.doc-body table { width: 100%; border-collapse: collapse; font-size: var(--step-small); }
.doc-body table code { font-size: 0.94em; }
.doc-body th, .doc-body td { padding: 12px 16px 12px 0; text-align: left; vertical-align: top; border-bottom: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); }
.doc-body thead th { padding-top: 0; color: var(--muted); font-weight: 400; }
.doc-body tbody th { font-weight: 400; white-space: nowrap; }

@media (prefers-color-scheme: dark) {
  .doc-body pre { background: var(--surface-strong); }
  .code-copy { background: #3a3b3f; }
}

/* Below the width that leaves room in the margin, the sections come first, in a tile. */
@media (max-width: 1040px) {
  .doc-contents { grid-column: 2; grid-row: auto; justify-self: stretch; width: auto; margin: 32px 0 0; padding: 20px; border-radius: var(--radius); background: var(--surface); }
  .doc-contents-list { position: static; max-height: none; overflow: visible; padding: 0; }
  .doc-contents ul { columns: 2; column-gap: 20px; }
  .doc-contents li { break-inside: avoid; }
  .doc-contents a { color: var(--ink); }
  /* Without a visible title, Copy for agents keeps its own row above the sections, and the text its gap. */
  .doc-untitled:has(.doc-copy:not([hidden])) .doc-head { height: 44px; }
  .doc-untitled .doc-contents { margin-top: 12px; }
  .doc-untitled .doc-body { margin-top: clamp(40px, 5vw, 64px); }
  .doc-untitled:has(.doc-copy:not([hidden])) .doc-body > h2:first-child { padding-right: 0; }
}
@media (max-width: 1040px) and (scripting: enabled) {
  .doc-untitled:has(.doc-copy) .doc-head { height: 44px; }
}
@media (max-width: 700px) {
  /* Narrower sides only: the top keeps the room for Copy. */
  .doc-body pre { padding-inline: 16px; padding-bottom: 18px; }
  .code-copy { top: 12px; right: 12px; }
  .doc-body tbody th { white-space: normal; }
}
@media (max-width: 440px) {
  .doc-contents ul { columns: 1; }
}
