/* Docs layout and prose. Tokens and shared components (buttons, code, tabs) are in base.css. */

/* ── Top bar ───────────────────────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  border-bottom: 1px solid var(--outline);
  background: var(--bg);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--s-5);
}

.icon-btn {
  display: none;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:focus-visible { border-radius: var(--r-full); }

/* Last in the bar, after the links, and no wider than a short query needs. */
.search {
  position: relative;
  flex: 0 1 220px;
}
.search > .octicon {
  position: absolute;
  top: 10px;
  left: var(--s-3);
  color: var(--text-faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 36px;
  padding: 0 36px;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text);
  font: 400 0.875rem/1 var(--font);
  outline: 0;
  transition: border-color 0.15s, background-color 0.15s;
}
.search input::placeholder { color: var(--text-faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:hover { background: var(--surface-3); }
.search input:focus { border-color: var(--accent); background: var(--surface-1); }
.search kbd { position: absolute; top: 7px; right: var(--s-2); }
.search input:focus ~ kbd { display: none; }

.search-results {
  position: absolute;
  top: calc(100% + var(--s-2));
  right: 0;
  width: min(440px, calc(100vw - 2 * var(--s-3)));
  max-height: min(60vh, 480px);
  padding: var(--s-2);
  overflow-y: auto;
  border: 1px solid var(--outline-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.hit {
  display: block;
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: 0.875rem;
  line-height: 1.5;
}
.hit b { display: block; color: var(--text); font-size: 0.9375rem; font-weight: 500; }
.hit span { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.hit mark { background: none; color: var(--accent); }
.hit:hover, .hit.active { background: var(--surface-4); color: var(--text-dim); }
.search-results .empty { padding: var(--s-3); color: var(--text-faint); font-size: 0.875rem; }

.toplinks {
  display: flex;
  gap: var(--s-1);
  margin-inline: auto;   /* centred between the brand and the search */
}
.toplinks a {
  padding: 6px var(--s-3);
  border-radius: var(--r-full);
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 500;
}
.toplinks a:hover { background: var(--surface-2); color: var(--text); }
/* The waitlist is the one action in the header, so it is drawn as the button. */
.toplinks a[href="/early-access/"] { margin-left: var(--s-2); background: var(--accent); color: var(--on-accent); }
.toplinks a[href="/early-access/"]:hover { background: var(--accent-hover); color: var(--on-accent); }

/* ── Shell ─────────────────────────────────────────────────────────────────────────────────── */

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

.sidenav, .toc {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidenav { padding: var(--s-5) var(--s-3) var(--s-7) var(--s-4); }
.sidenav ul { margin: 0; padding: 0; list-style: none; }
.sidenav li + li, .sidenav details > ul { margin-top: 2px; }
.sidenav ul ul { margin-left: 18px; padding-left: var(--s-2); border-left: 1px solid var(--outline); }
.sidenav a {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 36px;
  padding: 6px var(--s-3);
  border-radius: var(--r-full);
  color: var(--text-dim);
  font-size: 0.9375rem;
  line-height: 1.35;
  transition: background-color 0.15s, color 0.15s;
}
.sidenav a:hover { background: var(--surface-2); color: var(--text); }
.sidenav a[aria-current="page"] {
  background: var(--accent-container);
  color: var(--on-accent-container);
  font-weight: 500;
}
.sidenav a:focus-visible { border-radius: var(--r-full); outline-offset: -2px; }
.sidenav summary { display: flex; align-items: center; gap: 2px; list-style: none; }
.sidenav summary::-webkit-details-marker { display: none; }
.sidenav summary a { flex: 1; min-width: 0; }
.chevron {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  color: var(--text-faint);
  cursor: pointer;
}
.chevron:hover { background: var(--surface-2); color: var(--text); }
.chevron .octicon, .panel > summary .octicon { transition: transform 0.2s; }
details[open] > summary .chevron .octicon, .panel[open] > summary .octicon { transform: rotate(180deg); }
.scrim { display: none; }

#content {
  min-width: 0;
  padding: var(--s-7) var(--s-7) var(--s-8);
}
.prose, .pager, .docs-footer { max-width: 780px; margin-inline: auto; }

.toc { padding: var(--s-7) var(--s-5) var(--s-7) 0; font-size: 0.875rem; }
.toc p { margin-bottom: var(--s-3); color: var(--text); font-weight: 500; }
.toc ul { margin: 0; padding: 0; list-style: none; }
.toc li + li { margin-top: 2px; }
.toc a {
  display: block;
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-faint);
  line-height: 1.4;
  transition: color 0.15s;
}
.toc .sub a { padding-left: var(--s-5); }
.toc a:hover { color: var(--text); }
.toc a[aria-current] { background: var(--surface-2); color: var(--accent); }

/* ── Rhythm ────────────────────────────────────────────────────────────────────────────────────
   One rule sets every gap: siblings in a .flow are separated by margin-top only. Text sits 16px
   apart, block components 24px, and headings open a section with 48 or 32px above. */

.flow > * { margin-block: 0; }
.flow > * + * { margin-top: var(--s-4); }
.flow > * + :is(.code, .tabs, .callout, .table-wrap, .panel, .ref, .card-compact, pre, blockquote, details, video, iframe, hr),
.flow > :is(.code, .tabs, .callout, .table-wrap, .panel, .ref, .card-compact, pre, blockquote, details, video, iframe, hr) + * {
  margin-top: var(--s-5);
}
.flow > :is(.panel, details) + :is(.panel, details),
.flow > .ref + .ref,
.flow > .card-compact + .card-compact { margin-top: var(--s-2); }
.flow > * + h1, .flow > * + h2 { margin-top: var(--s-7); }
.flow > * + h3 { margin-top: var(--s-6); }
.flow > * + :is(h4, h5, h6) { margin-top: var(--s-5); }
.flow > :is(h2, h3, h4, h5, h6) + * { margin-top: var(--s-3); }
.flow > h1 + * { margin-top: var(--s-5); }
.flow > :is(script, style, link) { display: none; }

/* ── Prose ─────────────────────────────────────────────────────────────────────────────────── */

.prose { color: var(--text-dim); overflow-wrap: break-word; }
.prose strong, .prose b { color: var(--text); font-weight: 600; }
.prose h1 { font-size: 2.25rem; line-height: 1.15; letter-spacing: -0.015em; }
.prose h2 { font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.1875rem; line-height: 1.35; }
.prose h4 { font-size: 1rem; line-height: 1.5; }
.prose h5, .prose h6 { color: var(--text-dim); font-size: 0.9375rem; }
.prose [align="center"] { text-align: center; }
.prose img[align="center"] { display: block; margin-inline: auto; }

/* The introduction's opening: both marks over the name, centred. */
.cb-hero { display: flex; flex-direction: column; align-items: center; gap: var(--s-4); }
.cb-hero img { border-radius: 0; }
.cb-hero-title {
  color: var(--text);
  font-size: 2.75rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variation-settings: "ROND" 100;
}

.anchor {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: var(--s-1);
  border-radius: var(--r-full);
  color: var(--text-faint);
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.15s;
}
:is(h2, h3, h4, h5, h6):hover > .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { background: var(--surface-2); color: var(--accent); }

.prose a:not([class]) { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.prose a:not([class]):hover { text-decoration-color: currentColor; }

.prose ul, .prose ol { padding-left: var(--s-5); }
.prose li + li, .prose li > :is(ul, ol) { margin-top: 6px; }
.prose li::marker { color: var(--text-faint); }
.prose li > p + p { margin-top: var(--s-3); }

.prose img, .prose video, .prose iframe { height: auto; border-radius: var(--r-md); }
.prose iframe { max-width: 100%; border: 0; }
.prose a > img { border-radius: var(--r-xs); }

.prose hr {
  height: 2px;
  border: 0;
  border-radius: var(--r-full);
  background: var(--outline);
}
.prose hr[width] { height: 4px; background: var(--outline-strong); }
/* The sponsor block is an outlined card; a rule on top of it is a second border. */
.prose hr:has(+ .sponsor-banner) { display: none; }

.prose blockquote {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

/* ── Tables ────────────────────────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
}
.prose table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.5; }
.prose th, .prose td { padding: 10px var(--s-4); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-1); color: var(--text); font-weight: 500; white-space: nowrap; }
.prose td { border-top: 1px solid var(--outline); }
.prose [align="center"] :is(th, td), .prose :is(th, td)[style*="center"] { text-align: center; }

/* ── Callouts ──────────────────────────────────────────────────────────────────────────────── */

.callout {
  --tone: var(--accent);
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--tone) 9%, var(--bg));
  color: var(--text);
}
.callout > .octicon { margin-top: 5px; color: var(--tone); }
.callout-body { flex: 1; min-width: 0; }
.callout-body > * + * { margin-top: var(--s-2); }
.callout-title { color: var(--tone); font-weight: 600; }
.callout-neutral { --tone: var(--text-dim); }
.callout-info { --tone: var(--info); }
.callout-success { --tone: var(--success); }
.callout-warning { --tone: var(--warning); }
.callout-danger { --tone: var(--danger); }

/* ── Panels, references, cards ─────────────────────────────────────────────────────────────── */

.panel, .prose details:not(.panel) {
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
}
.panel > summary, .prose details:not(.panel) > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 48px;
  padding: 10px var(--s-4);
  border-radius: calc(var(--r-md) - 1px);
  color: var(--text);
  font-weight: 500;
  list-style: none;
  cursor: pointer;
  transition: background-color 0.15s;
}
.panel > summary::-webkit-details-marker, .prose details > summary::-webkit-details-marker { display: none; }
.panel > summary:hover, .prose details:not(.panel) > summary:hover { background: var(--surface-1); }
.panel > summary .octicon { color: var(--text-faint); }
.panel-body { padding: var(--s-1) var(--s-4) var(--s-4); }
.prose details:not(.panel)[open] { padding-bottom: var(--s-4); }
.prose details:not(.panel) > :not(summary) { margin: var(--s-3) var(--s-4) 0; }

.ref, .card-compact {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
  color: var(--text);
  transition: background-color 0.15s, border-color 0.15s;
}
.ref { justify-content: space-between; min-height: 48px; font-weight: 500; }
.ref:hover, .card-compact:hover { border-color: var(--outline-strong); background: var(--surface-1); color: var(--text); }
.ref > .octicon, .card-compact > .octicon { color: var(--text-faint); }
.ref:hover > .octicon, .card-compact:hover > .octicon { color: var(--accent); }
.card-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-dim);
}
.card-text { display: grid; flex: 1; min-width: 0; line-height: 1.45; }
.card-text b { font-weight: 500; }
.card-text span { color: var(--text-faint); font-size: 0.875rem; }

pre.mermaid {
  padding: var(--s-5);
  overflow-x: auto;
  border: 1px solid var(--outline);
  border-radius: var(--r-md);
  font-size: 0.8125rem;
  text-align: center;
}

/* ── Page foot ─────────────────────────────────────────────────────────────────────────────── */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
  margin-top: var(--s-8);
}
.pager a {
  display: grid;
  gap: 2px;
  padding: var(--s-4) 20px;
  border: 1px solid var(--outline);
  border-radius: var(--r-lg);
  transition: background-color 0.15s, border-color 0.15s;
}
.pager a:hover { border-color: var(--outline-strong); background: var(--surface-1); }
.pager span { color: var(--text-faint); font-size: 0.8125rem; }
.pager b { color: var(--text); font-weight: 500; }
.pager-next { text-align: right; }
.docs-footer { margin-top: var(--s-6); color: var(--text-faint); font-size: 0.8125rem; }

/* ── Sponsor blocks (markup and base rules live in _includes/head.html) ────────────────────── */

.sponsor-label { letter-spacing: 0; text-transform: none; }
.sponsor-card, .announcement-primary, .announcement-warning { border-radius: var(--r-md); }

/* ── Small screens ─────────────────────────────────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .shell { grid-template-columns: 272px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 900px) {
  .shell { display: block; }
  .icon-btn { display: grid; }
  .toplinks, .topbar .chip { display: none; }
  /* The Menu button opens the site's links as the same sheet the site header uses. */
  .toplinks.open {
    position: absolute;
    top: calc(var(--header-h) + var(--s-2));
    right: var(--s-4);
    left: var(--s-4);
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: var(--s-3);
    border: 1px solid var(--outline-strong);
    border-radius: var(--r-lg);
    background: var(--surface-2);
  }
  .toplinks.open a { padding: 10px var(--s-3); font-size: 1rem; }
  .toplinks.open a[href="/early-access/"] { margin: var(--s-2) 0 0; font-size: 0.875rem; font-weight: 600; text-align: center; }
  .topbar-inner { gap: var(--s-2); padding: 0 var(--s-3); }
  .search { margin-left: auto; }
  .search kbd { display: none; }
  #content { padding: var(--s-6) var(--s-4) var(--s-7); }
  .prose h1 { font-size: 1.875rem; }

  .sidenav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    width: min(320px, 86vw);
    height: auto;
    padding: var(--s-5) var(--s-3);
    border-radius: 0 var(--r-xl) var(--r-xl) 0;
    background: var(--surface-1);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
  }
  .nav-open .sidenav { transform: none; visibility: visible; }
  .nav-open .scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: rgb(0 0 0 / 0.7);
  }
  .nav-open { overflow: hidden; }
}

@media (max-width: 520px) {
  .brand span { display: none; }
  .brand { flex: none; }
  .pager { grid-template-columns: 1fr; }
}
