/* ---------- Docs shell (docs.html, docs-setup.html, docs-basic-programing.html, docs-api-*.html) ---------- */
.docs-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  /* Only visible below 861px (single column, sidebar and content stack —
     see below); from 861px up display switches to block and the sidebar
     is positioned fixed, independent of this grid entirely. */
  align-items: start;
  gap: var(--space-4);
  padding-top: var(--space-4);
  padding-bottom: var(--space-5);
  /* Match .header-inner's box model (fixed 32px side padding, 1440px cap)
     instead of .container's growing clamp, so the sidebar's left edge
     lines up with the logo at every viewport width. */
  max-width: 1440px;
  padding-left: 2rem;
  padding-right: 2rem;
}

.docs-sidebar {
  min-width: 0;
}

/* Cap reading width to match the rest of the site's 640px convention
   (article.css prose, code.css blocks, lang-tabs.css cards) instead of
   stretching to fill the grid's remaining space, and center it within
   the content column. This is independent of .docs-sidebar's position,
   which stays pinned to the shell's left edge (aligned with the header
   logo) regardless. */
.docs-content {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  min-width: 0;
}

/* ---------- Docs content typography (self-contained — does not depend on
   article.css, which is tuned for the sidebar-less About/Showcase/Tutorial
   .docs-layout and uses a different, 640px, reading width) ---------- */
.docs-content h1 {
  padding-top: var(--space-2);
  font-size: clamp(1.75rem, 3vw, 1.8rem);
  font-weight: 600;
  scroll-margin-top: calc(76px + var(--space-3));
}

.docs-content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 4rem;
  /* Account for the sticky header (76px) plus the sticky .docs-lang-switch
     (~70px, present on every page that has h2/h3 anchors) so jumping to a
     sidebar sub-link doesn't land the heading underneath either of them. */
  scroll-margin-top: calc(76px + 70px + var(--space-3));
}

.docs-content h2:first-of-type {
  margin-top: 2rem;
}

.docs-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2.5rem;
  scroll-margin-top: calc(76px + 70px + var(--space-3));
}

.docs-content h4 {
  font-size: 1.02rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 2rem;
}

.docs-content h2 + h3 {
  margin-top: 1.5rem;
}

.docs-content p {
  margin-top: var(--space-3);
  font-size: 1.05rem;
  font-weight: 300;
  line-height: 1.8;
  letter-spacing: 0.01em;
  color: var(--color-text);
}

.docs-content h2 + p,
.docs-content h3 + p {
  margin-top: var(--space-2);
}

.docs-content p + p {
  margin-top: var(--space-2);
}

.docs-content ul {
  margin: 1.25rem 0 0;
}

.docs-content li {
  font-size: 1.02rem;
  font-weight: 300;
  line-height: 1.8;
  color: var(--color-text);
}

.docs-content li + li {
  margin-top: 0.4rem;
}

.docs-content li strong,
.docs-content p strong {
  font-weight: 500;
  color: var(--color-text);
}

.docs-content p code,
.docs-content li code,
.docs-content blockquote code {
  background: rgba(0, 0, 0, 0.04);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 400;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.docs-content figure {
  margin: var(--space-2) 0 0;
}

.docs-content figure.example-window {
  margin-left: auto;
  margin-right: auto;
}

.docs-content ul + figure {
  margin-top: 1.25rem;
}

.docs-content blockquote {
  margin: var(--space-3) 0 0;
  padding: 0 0 0 1rem;
  border-left: 4px solid #cdcdcd;
}

.docs-content blockquote p {
  margin-top: 0;
  color: var(--color-text-muted);
}

.docs-content p a,
.docs-content li a,
.docs-content blockquote a {
  color: var(--color-link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s ease;
}

.docs-content p a:hover,
.docs-content li a:hover,
.docs-content blockquote a:hover {
  color: #aaaaaa;
}

.docs-content figure img,
.docs-content figure video {
  width: 100%;
  display: block;
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.docs-content .hero-media {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.docs-content figcaption {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* From 861px up, the sidebar floats free of the shell entirely
   (position: fixed, anchored to the header logo's left edge the same way
   .docs-toc-float already does) so its own height never stretches the
   shell — and therefore never pushes the footer down — on pages whose
   content is shorter than the full sidebar nav (e.g. the short
   Introduction page next to the long Guide sub-link list). */
@media (min-width: 861px) {
  .docs-sidebar {
    position: fixed;
    left: calc(max(0px, (100vw - 1440px) / 2) + 2rem);
    width: 180px;
    top: calc(76px + var(--space-4));
    max-height: calc(100vh - 76px - var(--space-4) - var(--space-4));
    overflow-y: auto;
    padding-bottom: var(--space-4);
  }

  .docs-shell {
    display: block;
  }
}

@media (max-width: 860px) {
  .docs-shell {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Below 1300px .docs-content isn't wide enough to center on the full
   window without overlapping the fixed sidebar, so it's offset from the
   shell's left edge by the sidebar's width + gap instead (matching where
   the old grid column put it), and only centers within what's left. */
@media (min-width: 861px) and (max-width: 1299px) {
  .docs-content {
    margin-left: calc(180px + var(--space-4));
  }
}

.docs-sidebar-group + .docs-sidebar-group {
  margin-top: var(--space-4);
}

.docs-sidebar-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.docs-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.docs-sidebar-link {
  display: block;
  padding: 5px 0;
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--color-text-muted);
  transition: color 0.15s ease;
}

.docs-sidebar-link:hover {
  color: var(--color-text);
}

.docs-sidebar-link.is-active {
  color: var(--color-text);
  font-weight: 500;
}

.docs-sidebar-link.docs-sidebar-sub {
  padding-left: 14px;
  font-size: 0.8rem;
}

.docs-sidebar-item-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.docs-sidebar-item-row .docs-sidebar-link {
  flex: 1;
  min-width: 0;
}

.docs-sidebar-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.15s ease;
}

.docs-sidebar-item-row:hover .docs-sidebar-toggle {
  color: var(--color-text);
}

.docs-sidebar-caret {
  display: block;
  width: 9px;
  height: 6px;
  transition: transform 0.15s ease;
}

.docs-sidebar-item.is-collapsed .docs-sidebar-caret {
  transform: rotate(-90deg);
}

.docs-sidebar-sublist {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.docs-sidebar-item.is-collapsed .docs-sidebar-sublist {
  display: none;
}

/* ---------- Sticky language switch ---------- */
.docs-lang-switch {
  position: sticky;
  top: 76px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-2) 0/*var(--space-2)*/;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.docs-lang-switch .lang-toggle {
  margin-top: 0;
}

.docs-body {
  /*padding-left: var(--space-2);*/
  /*padding-right: var(--space-2);*/
}

/* ---------- Docs landing cards ---------- */
.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.docs-card {
  display: block;
  padding: var(--space-3);
  background: rgba(25, 25, 26, 0.03);
  border-radius: 12px;
  transition: border-color 0.15s ease;
}

.docs-card:hover {
  background: var(--color-bg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

.docs-content .docs-card-title {
  display: flex;
  align-items: center;
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: var(--space-1);
}

.docs-card-title .playground-card-link-icon {
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.35em;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.docs-card:hover .playground-card-link-icon {
  opacity: 1;
  transform: translateX(0);
}

.docs-content .docs-card-desc {
  margin-top: 0.4rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.docs-availability {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: var(--space-2);
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-radius: var(--radius);
}

/* ---------- API reference (docs-api.html) ---------- */
#api-root {
  scroll-margin-top: calc(76px + 70px + var(--space-3));
}

#api-sidebar > .docs-sidebar-list + .docs-sidebar-list {
  margin-top: var(--space-1);
}

.api-meta {
  margin-top: var(--space-1);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.api-meta code,
.api-source code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.api-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-radius: 999px;
  vertical-align: middle;
}

.api-badge.is-experimental {
  color: #8a5a00;
  background: #fff4d6;
}

.api-member {
  margin-top: var(--space-4);
}

.api-member-meta {
  margin-top: var(--space-1);
}

.api-note,
.api-deprecated,
.api-returns,
.api-see,
.api-source {
  margin-top: var(--space-2);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--color-text);
}

.api-deprecated {
  color: #b00020;
}

.api-direction {
  margin-left: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.api-table-wrap {
  margin-top: var(--space-2);
  overflow-x: auto;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.api-table th,
.api-table td {
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
}

.api-table th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.api-table code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.api-loading {
  color: var(--color-text-muted);
}

.docs-content .api-callout {
  display: flex;
  gap: 12px;
  margin-top: var(--space-2);
  padding: 16px 20px;
  overflow: hidden;
  color: #1e40af;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
}

.docs-content .api-callout-icon {
  flex-shrink: 0;
  width: 16px;
  margin-top: 2px;
  line-height: 0;
}

.docs-content .api-callout-icon svg {
  display: block;
  width: 16px;
  height: 16px;
}

.docs-content .api-callout-body {
  min-width: 0;
  flex: 1;
}

.docs-content .api-callout p {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: normal;
  color: #1e40af;
}

.docs-content .api-callout code {
  padding: 2px 8px;
  font-size: 0.875em;
  font-weight: 500;
  color: #1e40af;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: none;
  border-radius: 6px;
}

.docs-content .api-callout.is-warning {
  color: #854d0e;
  background: #fefce8;
  border-color: #fef08a;
}

.docs-content .api-callout.is-warning .api-callout-icon svg {
  width: 20px;
  height: 20px;
}

.docs-content .api-callout.is-warning p {
  color: #854d0e;
}

.docs-content .api-callout.is-warning code {
  color: #854d0e;
}

.docs-content .api-callout.is-warning p strong {
  color: #854d0e;
  font-weight: 600;
}

.api-table td:not(:last-child),
.api-table th:not(:last-child) {
  white-space: nowrap;
}
