/* ==========================================================================
   Vela — documentation pages: the API docs (body.page-api) and the browser
   manual (body.page-manual). Builds on the docs layout in vela.css.
   ========================================================================== */

/* ---- Shared ---------------------------------------------------------------- */
/* Without scripts the contents menu can still be opened on any screen. */
html:not(.js) .docs-nav summary { display: flex; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: step; }
.steps li {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: baseline;
  padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-size: 15.5px; line-height: 1.5;
}
.steps li::before { counter-increment: step; content: "0" counter(step); font: 600 12px/1.5 var(--font-mono); color: var(--accent); }
.steps a { color: var(--accent); }

.page-api :not(pre) > code,
.page-manual :not(pre) > code {
  font-size: 0.86em; padding: 0.14em 0.42em; border-radius: 6px;
  background: var(--surface-2); color: var(--text); overflow-wrap: anywhere;
}

kbd {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px;
  border-radius: 8px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface-2);
  font: 600 13px/1 var(--font-text); color: var(--text); vertical-align: middle;
}

/* ==========================================================================
   API docs
   ========================================================================== */

/* ---- Hero ------------------------------------------------------------------ */
.api-hero-grid { display: grid; gap: clamp(36px, 6vw, 64px); align-items: center; }
@media (min-width: 1000px) { .api-hero-grid { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); } }
.api-hero h1 { font-size: clamp(42px, 7vw, 80px); }
.api-hero .btn-row { margin-top: 26px; }
@media (max-width: 479px) { .api-hero .btn-row .btn { width: 100%; } }

.api-facts { margin: 22px 0 0; display: grid; gap: 1px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: var(--line); max-width: 36em; }
.api-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 12px 16px; background: var(--bg); }
.api-facts dt { font: 600 10.5px/1.3 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.api-facts dd { margin: 0; font: 500 14px/1.35 var(--font-mono); color: var(--text); text-align: right; overflow-wrap: anywhere; }
@media (min-width: 640px) {
  .api-facts { grid-template-columns: 1.35fr 1fr 1fr; }
  .api-facts > div { display: grid; gap: 7px; align-content: start; }
  .api-facts dd { text-align: left; }
}

.quickstart {
  position: relative; display: grid; gap: 16px; padding: clamp(20px, 3vw, 28px); border-radius: var(--radius);
  border: 1px solid var(--line-2); background: color-mix(in srgb, var(--bg-2) 82%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 40px 100px -50px rgba(0, 0, 0, 0.75);
}
.quickstart h2 { font-size: clamp(26px, 3vw, 32px); letter-spacing: -0.025em; }
.quickstart .eyebrow { margin-bottom: -6px; }
.quickstart .code { margin-top: 4px; }

/* ---- Code windows ------------------------------------------------------------ */
.code-head { min-height: 44px; }
.code-title { min-width: 0; overflow-wrap: anywhere; letter-spacing: 0.02em; }
.code .copy-btn { position: relative; flex: none; }
.code .copy-btn::after { content: ""; position: absolute; inset: -9px -6px; } /* a 44px tap target */
.code pre code { font: inherit; color: inherit; }
.code .json-key { color: #9cd2ff; }
.code .json-str { color: #8ee6b4; }
.code .json-num { color: #ffb86b; }
.code .json-bool { color: #d3a8ff; }
.code .json-comment { color: #7d8fab; }

.docs-main .code { margin-top: 12px; border-radius: 14px; box-shadow: none; }
.docs-main .code-head { padding: 6px 8px 6px 14px; font-size: 12px; }
.docs-main .code pre { padding: 14px 16px; font-size: 13px; line-height: 1.65; }
@media (max-width: 719px) { .docs-main .code pre { font-size: 12.5px; padding: 12px 14px; } }

/* ---- Layout: search + contents -------------------------------------------------- */
.docs-api { padding-top: clamp(8px, 2vw, 24px); }
.api-nav-bar { display: flex; align-items: center; gap: 10px; }

.docs-search { position: relative; flex: 1; min-width: 0; }
.docs-search .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.docs-search input {
  width: 100%; min-height: 46px; padding: 0 40px 0 42px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); font: 16px/1.2 var(--font-text);
  -webkit-appearance: none; appearance: none; transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.docs-search input::placeholder { color: var(--text-3); }
.docs-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.18); background: var(--surface-2); }
.docs-search input::-webkit-search-decoration { -webkit-appearance: none; }
.docs-search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); min-width: 22px; height: 22px; font-size: 12px; color: var(--text-3); pointer-events: none; display: none; }
@media (hover: hover) and (min-width: 1000px) { .docs-search kbd { display: inline-grid; } }
.docs-search input:focus ~ kbd, .docs-search input:not(:placeholder-shown) ~ kbd { display: none; }
html:not(.js) .docs-api .docs-nav { display: none; }
html:not(.js) .docs-api { grid-template-columns: minmax(0, 1fr); }

.api-nav-menu > summary { gap: 8px; }
.api-nav-menu > summary .icon { width: 17px; height: 17px; color: var(--accent); }
.api-nav-count { font: 600 11px/1 var(--font-mono); color: var(--text-3); padding: 4px 7px; border-radius: 99px; background: var(--surface-2); }
.api-nav-count:empty { display: none; }

/* Contents list (built by docs.js) */
.api-nav-group { padding: 4px 10px 10px; font: 600 10.5px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.docs-nav a.api-nav-start {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 6px; padding: 11px 14px;
  border-radius: 14px; border: 1px solid rgba(var(--accent-rgb), 0.3); background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent); font-weight: 600; font-size: 14.5px;
}
.docs-nav a.api-nav-start:hover { background: rgba(var(--accent-rgb), 0.14); color: var(--accent); }
.docs-nav a.api-nav-plain { border-color: var(--line); background: var(--surface); color: var(--text); margin-bottom: 14px; }
.docs-nav a.api-nav-plain:hover { color: var(--text); background: var(--surface-2); }
.sidebar-section[hidden] { display: none; }
.sidebar-heading {
  width: 100%; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: 600 14px/1.3 var(--font-text); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.sidebar-heading:hover { background: var(--surface-2); }
.sidebar-heading.is-current { color: var(--accent); }
.sidebar-name { min-width: 0; }
.section-count { margin-left: auto; flex: none; font: 600 11px/1 var(--font-mono); color: var(--text-3); padding: 4px 7px; border-radius: 99px; background: var(--surface-2); }
.section-count:empty { display: none; }
.sidebar-heading .arrow {
  flex: none; width: 7px; height: 7px; margin: 0 4px 3px 2px; font-size: 0; color: var(--text-3);
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg); transition: transform 0.2s var(--ease);
}
.sidebar-heading.collapsed .arrow { transform: rotate(-45deg); margin-bottom: 0; }
.sidebar-items { display: grid; gap: 1px; margin: 2px 0 8px 14px; padding-left: 8px; border-left: 1px solid var(--line); }
.sidebar-items.hidden { display: none; }
.docs-nav a.sidebar-link {
  display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 6px 8px; border-radius: 8px;
  font: 500 12.5px/1.35 var(--font-mono); color: var(--text-2);
}
.docs-nav a.sidebar-link > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.docs-nav a.sidebar-link:hover, .docs-nav a.sidebar-link.active { color: var(--text); background: var(--surface-2); }
.docs-nav a.sidebar-guide { font-family: var(--font-text); font-size: 14px; }

/* Phones and tablets: search and the contents menu ride along under the navigation. */
@media (max-width: 999px) {
  .docs-api { display: block; }
  .docs-api .docs-nav {
    position: sticky; top: var(--nav-h); z-index: 30; margin: 0 calc(-1 * var(--gutter)) 28px; padding: 10px var(--gutter);
    background: color-mix(in srgb, var(--bg) 90%, transparent); -webkit-backdrop-filter: saturate(160%) blur(20px); backdrop-filter: saturate(160%) blur(20px);
    border-block: 1px solid var(--line);
  }
  .docs-api .docs-nav details.api-nav-menu { flex: none; border: 0; background: none; border-radius: 0; }
  .api-nav-menu > summary {
    min-height: 46px; padding: 0 14px 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface);
    font-size: 15px; -webkit-tap-highlight-color: transparent;
  }
  .api-nav-menu > summary::after { display: none; }
  .api-nav-menu[open] > summary { border-color: rgba(var(--accent-rgb), 0.55); background: var(--surface-2); }
  .api-nav-menu > nav {
    position: absolute; left: var(--gutter); right: var(--gutter); top: calc(100% + 8px);
    max-height: calc(100vh - var(--nav-h) - 100px); max-height: calc(100dvh - var(--nav-h) - 100px);
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 12px 10px;
    border-radius: 20px; border: 1px solid var(--line-2); background: var(--bg-2); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  }
  .docs-search input { padding-right: 14px; }
  .sidebar-heading { min-height: 46px; font-size: 15px; }
  .docs-nav a.sidebar-link { min-height: 44px; font-size: 13.5px; }
  .docs-nav a.api-nav-start { min-height: 46px; }
  .docs-api .docs-main [id] { scroll-margin-top: 76px; }
}
@media (max-width: 419px) { .api-nav-menu > summary { padding: 0 14px; } .api-nav-count { display: none; } }

/* Desktop: a sticky column. */
@media (min-width: 1000px) {
  .docs-api { grid-template-columns: 276px minmax(0, 1fr); gap: 48px; }
  .docs-api .docs-nav > div { display: block; padding-bottom: 24px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
  .docs-search { position: sticky; top: 0; z-index: 2; padding-bottom: 14px; background: var(--bg); }
  .api-nav-menu > nav { padding: 0; }
}

/* ---- Content ------------------------------------------------------------------- */
.guide-grid { gap: 14px; }
@media (min-width: 640px) { .guide-wide { grid-column: 1 / -1; } }
.guide-card { padding: clamp(20px, 2.6vw, 28px); }
.guide-card .card-icon { width: 40px; height: 40px; margin-bottom: 16px; }
.guide-card .card-icon .icon { width: 20px; height: 20px; }
.guide-card p { font-size: 15.5px; line-height: 1.65; }
.guide-card p + p { margin-top: 10px; }
.guide-card strong { color: var(--text); font-weight: 600; }
.guide-card a, .guide-card a strong { color: var(--accent); }

.docs-results {
  display: flex; align-items: center; gap: 14px; margin: clamp(44px, 6vw, 72px) 0 0;
  font: 600 11.5px/1.4 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3);
}
.docs-results::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.api-section { margin-top: clamp(40px, 5vw, 64px); }
.docs-results + .api-section { margin-top: 24px; }
.api-section > h2 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -0.03em; line-height: 1.1; padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.section-intro { margin: 0 0 18px; color: var(--text-2); font-size: 16px; line-height: 1.65; max-width: 46em; }
.section-intro strong { color: var(--text); font-weight: 600; }

.endpoint { margin-bottom: 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); overflow: hidden; transition: border-color 0.2s, background-color 0.2s; }
.endpoint:hover { border-color: var(--line-2); }
.endpoint.open { border-color: rgba(var(--accent-rgb), 0.35); background: var(--surface-2); }
.endpoint-header {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "m p t" "m d t";
  column-gap: 14px; row-gap: 2px; align-items: center; min-height: 60px; padding: 12px 14px 12px 14px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.endpoint-header:focus-visible { outline-offset: -3px; border-radius: 16px; }
.method-badge, .method-sm {
  --m: #8b9bb4;
  color: color-mix(in srgb, var(--m) 62%, var(--text)); background: color-mix(in srgb, var(--m) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--m) 40%, transparent); text-align: center; letter-spacing: 0.04em;
}
.method-badge { grid-area: m; align-self: start; width: 62px; padding: 6px 0; margin-top: 1px; border-radius: 8px; font: 700 11px/1 var(--font-mono); }
.method-sm { flex: none; width: 44px; padding: 4px 0; border-radius: 6px; font: 700 9.5px/1 var(--font-mono); }
.m-get { --m: #34c77b; }
.m-post { --m: #4ea8ff; }
.m-put { --m: #f5a524; }
.m-delete { --m: #ff5f6d; }
.m-ws { --m: #b77dff; }
.endpoint-path { grid-area: p; font: 600 14px/1.45 var(--font-mono); color: var(--text); overflow-wrap: anywhere; }
.path-seg { display: inline-block; }
.endpoint-desc { grid-area: d; font-size: 14.5px; line-height: 1.45; color: var(--text-2); }
.endpoint-toggle {
  grid-area: t; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2);
  font-size: 9px; color: var(--text-2); transition: transform 0.25s var(--ease), background-color 0.2s;
}
.endpoint.open .endpoint-toggle { transform: rotate(90deg); background: rgba(var(--accent-rgb), 0.16); color: var(--accent); }
.js .endpoint-body { display: none; }
.js .endpoint.open .endpoint-body { display: block; }
html:not(.js) .endpoint-toggle { display: none; }
@media (prefers-reduced-motion: no-preference) { .js .endpoint.open .endpoint-body { animation: endpoint-in 0.28s var(--ease); } }
@keyframes endpoint-in { from { opacity: 0; transform: translateY(-4px); } }
.endpoint-body { padding: 2px 16px 18px; border-top: 1px solid var(--line); }
.endpoint-body > p { margin-top: 14px; font-size: 15.5px; line-height: 1.65; color: var(--text-2); }
.endpoint-body strong { color: var(--text); font-weight: 600; }
.endpoint-body a { color: var(--accent); }
.endpoint-body .label { margin: 18px 0 0; font: 600 11px/1.3 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.endpoint-body .label + .table-wrap { margin-top: 8px; }
.note {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface); font-size: 14.5px; line-height: 1.6; color: var(--text-2);
}
.note strong { color: var(--text); }
@media (min-width: 720px) {
  .endpoint-header { padding: 14px 18px; }
  .endpoint-body { padding: 2px 20px 20px; }
}

/* Tables scroll inside their own box */
.table-wrap { margin-top: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 55%, transparent); }
.params-table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
.params-table th { text-align: left; padding: 10px 14px; font: 600 11px/1.3 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; }
.params-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: top; }
.params-table td:last-child { min-width: 13em; }
.params-table tr:last-child td { border-bottom: 0; }
.params-table td:first-child { min-width: 0; font: 500 13px/1.6 var(--font-mono); color: var(--accent); }
@media (max-width: 719px) {
  .params-table th, .params-table td { padding-left: 12px; padding-right: 12px; }
  .params-table td:last-child { min-width: 10.5em; }
}
.params-table .optional { display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 99px; border: 1px solid var(--line-2); font: 500 11px/1.2 var(--font-text); color: var(--text-3); vertical-align: 1px; }

/* Hidden & headless mode cards */
.api-card { margin-top: 14px; padding: clamp(18px, 3vw, 26px); border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.api-card > * + * { margin-top: 12px; }
.api-card h3 { font-size: 19px; letter-spacing: -0.015em; color: var(--accent); }
.api-card p { font-size: 15.5px; line-height: 1.65; color: var(--text-2); }
.api-card strong { color: var(--text); font-weight: 600; }
.api-card.is-good { border-color: rgba(76, 217, 127, 0.35); }
.api-card.is-good h3, .api-card strong.good { color: color-mix(in srgb, var(--good) 66%, var(--text)); }
.api-card.is-note { padding: 16px 18px; }

/* ==========================================================================
   The browser manual
   ========================================================================== */
.docs-manual .docs-main { max-width: 800px; }
.docs-manual .docs-nav a { display: flex; align-items: center; gap: 12px; }
.docs-manual .docs-nav .toc-n { flex: none; font: 600 11px/1 var(--font-mono); color: var(--text-3); letter-spacing: 0.04em; }
.docs-manual .docs-nav a.is-active .toc-n, .docs-manual .docs-nav a:hover .toc-n { color: var(--accent); }
@media (max-width: 999px) {
  .docs-manual .docs-nav .group { display: none; }
  .docs-manual .docs-nav a { min-height: 46px; font-size: 16px; }
  .docs-manual .docs-nav ul { padding: 0 8px 10px; }
}

.chapters { display: grid; gap: 16px; }
.chapter { padding: clamp(22px, 4vw, 40px); }
.chapter-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.chapter .card-icon { margin: 0; flex: none; }
.chapter-number { font: 600 11.5px/1.35 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.chapter h2 { font-size: clamp(27px, 3.6vw, 38px); letter-spacing: -0.03em; line-height: 1.08; margin-bottom: 16px; }
.chapter p { font-size: 17px; line-height: 1.7; color: var(--text-2); }
.chapter > * + * { margin-top: 14px; }
.chapter > .chapter-head + h2 { margin-top: 0; }
.chapter strong { color: var(--text); font-weight: 600; }
.chapter p a, .chapter li a { color: var(--accent); }
.chapter .steps { margin-top: 18px; }
.chapter .steps li { font-size: 16px; }
.manual-tip { margin-top: 20px; padding: 16px 18px; border-radius: 16px; border: 1px solid rgba(var(--accent-rgb), 0.28); background: rgba(var(--accent-rgb), 0.08); color: var(--text-2); font-size: 16px; line-height: 1.7; }
.manual-tip strong { color: var(--text); }
.chapter p.manual-note { margin-top: 18px; padding-left: 14px; border-left: 2px solid var(--line-2); font-size: 14.5px; line-height: 1.6; color: var(--text-3); }
.chapter .text-link { margin-top: 18px; }
.manual-shortcuts { display: grid; gap: 8px; margin-top: 18px; }
.manual-shortcuts > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 10px 12px 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.manual-shortcuts > div > span:first-child { color: var(--text); font-weight: 500; }
.manual-shortcuts > div > span:last-child { display: inline-flex; gap: 5px; flex: none; }
@media (min-width: 640px) { .manual-shortcuts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 479px) { .chapter { padding: 22px 20px; } }
