/*
 * Guides: a documentation space (templates/docs.mjs, scripts/docs.js). Three columns on wide
 * screens: sidebar, article, "On this page". The article column is sized for reading.
 */

.docs {
  --docs-top: 72px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 232px;
  gap: 0 56px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px;
}

.docs.is-home {
  grid-template-columns: 280px minmax(0, 1fr);
}

/* --- Sidebar ------------------------------------------------------------------------------ */

.docs-side {
  position: sticky;
  top: var(--docs-top);
  align-self: start;
  height: calc(100vh - var(--docs-top));
  margin-left: -32px;
  border-right: 1px solid var(--hairline);
}

.docs-side-inner {
  height: 100%;
  padding: 28px 20px 48px 32px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.docs-space {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.docs-space-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
}

.docs-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-bottom: 22px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
}

.docs-filter:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.docs-filter input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 14px/1 var(--font-text);
  outline: none;
}

.docs-filter input::-webkit-search-cancel-button {
  display: none;
}

.docs-filter kbd,
.guides-search-field kbd {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  font: 500 12px/1 var(--font-text);
}

.docs-filter:focus-within kbd {
  visibility: hidden;
}

.docs-nav-group + .docs-nav-group {
  margin-top: 22px;
}

.docs-nav-title {
  margin: 0 0 6px;
  padding-left: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

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

.docs-nav a {
  display: block;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
}

.docs-nav a:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

:root[data-theme='light'] .docs-nav a:hover {
  background: rgba(11, 21, 37, 0.04);
}

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

.docs-nav-empty {
  padding: 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.docs-nav-empty a {
  color: var(--accent);
}

.docs-mobilebar {
  display: none;
}

/* --- Article --------------------------------------------------------------------------------- */

.docs-main {
  min-width: 0;
  max-width: 760px;
  padding: 40px 0 120px;
}

.docs.is-home .docs-main {
  max-width: 980px;
}

.docs-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
}

.docs-crumbs li + li::before {
  content: '/';
  margin-right: 6px;
  color: var(--hairline-strong);
}

.docs-crumbs a {
  color: var(--muted);
  text-decoration: none;
}

.docs-crumbs a:hover {
  color: var(--ink);
}

.docs-head {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--hairline);
}

.docs-head h1 {
  margin: 0;
  font-size: clamp(34px, 3.4vw, 46px);
  line-height: 1.08;
}

.docs-lede {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.6;
}

.docs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* --- Prose ---------------------------------------------------------------------------------- */

.docs-prose {
  padding-top: 12px;
  color: var(--ink-soft);
  font-size: 16.5px;
  line-height: 1.75;
}

.docs-prose > p,
.docs-prose .block > p {
  margin: 18px 0 0;
}

.docs-prose h2,
.docs-prose .block-title {
  position: relative;
  margin: 52px 0 0;
  color: var(--ink);
  font-size: 27px;
  line-height: 1.25;
  scroll-margin-top: calc(var(--docs-top) + 24px);
}

.docs-prose h3 {
  position: relative;
  margin: 34px 0 0;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.4;
  scroll-margin-top: calc(var(--docs-top) + 24px);
}

.docs-prose .block {
  scroll-margin-top: calc(var(--docs-top) + 24px);
}

.docs-anchor {
  position: absolute;
  top: 50%;
  left: -30px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--muted);
  opacity: 0;
  text-decoration: none;
  transform: translateY(-50%);
  transition: opacity 0.12s;
}

.docs-prose h2:hover .docs-anchor,
.docs-prose h3:hover .docs-anchor,
.docs-anchor:focus-visible {
  opacity: 1;
}

.docs-anchor:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.docs-prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-border);
  text-underline-offset: 3px;
}

.docs-prose a:hover {
  text-decoration-color: currentColor;
}

.docs-prose strong {
  color: var(--ink);
  font-weight: 600;
}

.docs-prose code {
  padding: 2px 6px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: 500 0.88em/1.4 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.docs-prose ul {
  margin: 18px 0 0;
  padding-left: 22px;
}

.docs-prose ul li {
  margin-top: 8px;
  padding-left: 4px;
}

.docs-prose ul li::marker {
  color: var(--accent);
}

/* Ordered lists in guides are steps: numbered discs on a rail. */
.docs-prose > ol {
  list-style: none;
  counter-reset: step;
  margin: 22px 0 0;
  padding: 0;
}

.docs-prose > ol > li {
  position: relative;
  counter-increment: step;
  padding: 0 0 18px 46px;
}

.docs-prose > ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.docs-prose > ol > li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 13.5px;
  top: 34px;
  bottom: 4px;
  width: 1px;
  background: var(--hairline-strong);
}

.docs-prose > ol > li:last-child {
  padding-bottom: 0;
}

.docs-prose blockquote {
  margin: 22px 0 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--hairline-strong);
  color: var(--muted);
}

.doc-callout {
  margin: 26px 0 0;
  padding: 16px 20px 18px 52px;
  border: 1px solid var(--accent-border);
  border-radius: 16px;
  background: var(--accent-soft);
  position: relative;
}

.doc-callout::before {
  content: 'i';
  position: absolute;
  left: 18px;
  top: 18px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--canvas);
  font: 700 12px/1 var(--font-text);
}

.doc-callout.is-tip {
  border-color: rgba(34, 195, 122, 0.35);
  background: rgba(34, 195, 122, 0.08);
}

.doc-callout.is-tip::before {
  content: '✓';
  background: var(--profit);
}

.doc-callout.is-warning {
  border-color: rgba(245, 184, 61, 0.4);
  background: rgba(245, 184, 61, 0.08);
}

.doc-callout.is-warning::before {
  content: '!';
  background: #f5b83d;
  color: #1a1203;
}

:root[data-theme='light'] .doc-callout.is-warning::before {
  background: #9a6700;
  color: #fff;
}

.doc-callout p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.65;
}

.doc-callout-title {
  margin-bottom: 4px !important;
  color: var(--ink);
  font-weight: 700;
}

.docs-prose .table-scroll {
  margin: 24px 0 0;
  overflow-x: auto;
  border: 1px solid var(--hairline);
  border-radius: 16px;
}

.doc-table,
.docs-prose .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  line-height: 1.55;
}

.doc-table th,
.doc-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.doc-table thead th {
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

.doc-table tbody th {
  color: var(--ink);
  font-weight: 600;
}

.doc-table tr:last-child th,
.doc-table tr:last-child td {
  border-bottom: 0;
}

/* Metric pages render content blocks; keep them in the prose rhythm. */
.docs-prose .block {
  margin: 0;
}

.docs-prose .cta-block {
  margin-top: 40px;
}

.docs-prose .faq {
  margin-top: 18px;
}

/* --- Help and pager -------------------------------------------------------------------------- */

.docs-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 64px;
  padding: 24px 26px;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  background: var(--card);
}

.docs-help p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.docs-help .docs-help-title {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.docs-help-actions {
  display: flex;
  flex: none;
  gap: 10px;
}

.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

.docs-pager-link {
  display: grid;
  gap: 4px;
  padding: 18px 22px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  text-decoration: none;
  transition: border-color 0.15s;
}

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

.docs-pager-link span {
  color: var(--muted);
  font-size: 13px;
}

.docs-pager-link strong {
  color: var(--ink);
  font-size: 16px;
}

.docs-pager-link.is-next {
  grid-column: 2;
  text-align: right;
}

.docs-pager-link.is-prev span::before {
  content: '← ';
}

.docs-pager-link.is-next span::after {
  content: ' →';
}

/* --- On this page ------------------------------------------------------------------------- */

.docs-toc {
  position: sticky;
  top: var(--docs-top);
  align-self: start;
  max-height: calc(100vh - var(--docs-top));
  padding: 44px 0 40px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.docs-toc-title {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

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

.docs-toc li a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 14px;
  border-left: 1px solid transparent;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.4;
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s;
}

.docs-toc li.is-l3 a {
  padding-left: 26px;
  font-size: 13px;
}

.docs-toc li a:hover {
  color: var(--ink);
}

.docs-toc li a.is-active {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.docs-top {
  display: inline-block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.docs-top:hover {
  color: var(--ink);
}

/* --- Guides home ---------------------------------------------------------------------------- */

.docs.is-home .docs-head {
  border-bottom: 0;
  padding-bottom: 8px;
}

.docs.is-home .docs-head h1 {
  font-size: clamp(40px, 4.6vw, 64px);
}

.guides-search {
  margin-top: 24px;
}

.guides-search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 22px;
  border: 1px solid var(--hairline-strong);
  border-radius: 100px;
  background: var(--card);
  color: var(--muted);
}

.guides-search-field:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.guides-search-field .icon {
  width: 20px;
  height: 20px;
}

.guides-search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 17px/1 var(--font-text);
  outline: none;
}

.guides-search-empty {
  margin: 14px 0 0 22px;
  color: var(--muted);
}

.guides-search-empty a {
  color: var(--accent);
}

.docs.is-home .docs-prose h2 {
  margin-top: 56px;
  font-size: 24px;
}

.guides-start-list {
  list-style: none;
  counter-reset: start;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0 0;
  padding: 0;
}

.guides-start-list li::before,
.guides-start-list li::after {
  display: none;
}

.docs-prose .guides-start-list > li {
  padding: 0;
}

.guides-start-list a {
  counter-increment: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 22px 22px 20px;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  background: radial-gradient(120% 90% at 0% 0%, rgba(18, 83, 255, 0.16), transparent 60%), var(--card);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.guides-start-list a::before {
  content: counter(start);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.guides-start-list a:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
}

.guides-start-list strong {
  color: var(--ink);
  font-size: 17px;
  line-height: 1.3;
}

.guides-start-list span {
  flex: 1;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.guides-start-list em {
  color: var(--accent);
  font-size: 13px;
  font-style: normal;
  font-weight: 600;
}

.guides-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.guides-card {
  padding: 24px;
  border: 1px solid var(--hairline);
  border-radius: 20px;
}

.guides-card-head {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.guides-card-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.docs-prose .guides-card h3 {
  margin: 0;
  font-size: 18px;
}

.guides-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.docs-prose .guides-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--hairline);
}

.docs-prose .guides-card li {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--hairline);
}

.docs-prose .guides-card li:last-child {
  border-bottom: 0;
}

.docs-prose .guides-card a {
  display: flex;
  justify-content: space-between;
  padding: 11px 2px;
  color: var(--ink-soft);
  font-size: 15px;
  text-decoration: none;
}

.docs-prose .guides-card a::after {
  content: '→';
  color: var(--muted);
  transition: transform 0.15s, color 0.15s;
}

.docs-prose .guides-card a:hover {
  color: var(--ink);
}

.docs-prose .guides-card a:hover::after {
  color: var(--accent);
  transform: translateX(3px);
}

.docs-prose .guides-reading ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 0;
  padding: 0;
}

.docs-prose .guides-reading li {
  margin: 0;
  padding: 0;
}

.docs-prose .guides-reading a {
  display: grid;
  gap: 4px;
  height: 100%;
  padding: 16px 18px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  text-decoration: none;
}

.docs-prose .guides-reading a:hover {
  border-color: var(--hairline-strong);
}

.docs-prose .guides-reading strong {
  font-size: 15px;
}

.docs-prose .guides-reading span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

[data-guides-item][hidden],
[data-guides-card][hidden],
[data-guides-block][hidden] {
  display: none !important;
}

/* --- Responsive ------------------------------------------------------------------------------ */

@media (max-width: 1240px) {
  .docs {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 0 48px;
  }
  .docs-toc {
    display: none;
  }
}

@media (max-width: 920px) {
  .docs,
  .docs.is-home {
    display: block;
    padding: 0 20px;
  }
  .docs-mobilebar {
    position: sticky;
    top: 64px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 -20px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--hairline);
    background: color-mix(in srgb, var(--canvas) 88%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  .docs-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--hairline-strong);
    border-radius: 100px;
    background: var(--card);
    color: var(--ink);
    font: 600 14px/1 var(--font-text);
    cursor: pointer;
  }
  .docs-mobilebar-here {
    overflow: hidden;
    color: var(--muted);
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .docs-side {
    position: fixed;
    z-index: 60;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, 88vw);
    height: auto;
    margin: 0;
    border-right: 1px solid var(--hairline-strong);
    background: var(--canvas);
    box-shadow: 30px 0 60px -20px rgba(0, 0, 0, 0.8);
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s linear 0.22s;
  }
  .docs.is-nav-open .docs-side {
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
  .docs-side-inner {
    padding: 24px 20px 40px;
  }
  .docs-scrim {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.55);
  }
  .docs-main {
    padding-top: 24px;
  }
  .docs-anchor {
    display: none;
  }
  .docs-help {
    flex-direction: column;
    align-items: flex-start;
  }
  .guides-start-list,
  .guides-grid,
  .docs-prose .guides-reading ul {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .docs-mobilebar {
    top: 64px;
  }
  .docs-pager {
    grid-template-columns: 1fr;
  }
  .docs-pager-link.is-next {
    grid-column: auto;
  }
  .docs-prose {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .guides-start-list a {
    transition: none;
  }
  .docs-side {
    transition-duration: 0s;
  }
}

.docs-prose .data-table th,
.docs-prose .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.docs-prose .data-table thead th {
  background: var(--card);
}

.docs-prose .data-table tr:last-child th,
.docs-prose .data-table tr:last-child td {
  border-bottom: 0;
}

/* The last section card spans the row when it would sit alone. */
.guides-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.docs-prose .guides-card:last-child:nth-child(odd) ul {
  columns: 2;
  column-gap: 32px;
}

.docs-prose .guides-card:last-child:nth-child(odd) li {
  break-inside: avoid;
}

@media (max-width: 920px) {
  .docs-prose .guides-card:last-child:nth-child(odd) ul {
    columns: 1;
  }
}
