/* Docs section — sidebar layout + markdown typography */

/* Never let docs content push the page wider than the viewport */
body {
  overflow-x: clip;
}

.docs-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 52px;
  align-items: start;
  padding: 54px 0 72px;
}

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

.docs-sidebar {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 128px);
  overflow-y: auto;
  padding-right: 22px;
  border-right: 1px solid var(--line);
}

.docs-sidebar-title {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .16em;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 14px;
}

.docs-nav-item {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 6px;
  transition: background-color .14s ease;
}

.docs-nav-item:hover {
  background: var(--paper);
}

.docs-nav-item.active {
  background: var(--accent-soft);
}

.docs-nav-title {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink2);
  letter-spacing: -.01em;
}

.docs-nav-item.active .docs-nav-title {
  color: var(--accent);
}

.docs-nav-blurb {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.docs-subnav {
  position: relative;
  margin: 2px 0 10px 14px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.docs-subnav-pointer {
  position: absolute;
  left: -1px;
  top: 0;
  width: 2px;
  height: 0;
  background: var(--accent);
  border-radius: 1px;
  opacity: 0;
  transition: top .2s ease, height .2s ease, opacity .15s ease;
  pointer-events: none;
}

.docs-subnav a {
  display: block;
  font-size: 13px;
  color: #5a6678;
  padding: 4px 0;
  line-height: 1.35;
  transition: color .14s ease;
}

.docs-subnav a:hover,
.docs-subnav a.active {
  color: var(--accent);
}

.docs-subnav a.active {
  font-weight: 600;
}

/* Rendered markdown */

.md h1 {
  font-size: clamp(30px, 3.4vw, 42px);
  letter-spacing: -.04em;
  line-height: 1.08;
  margin: 0 0 22px;
}

.md h2 {
  font-size: 26px;
  letter-spacing: -.03em;
  line-height: 1.15;
  margin: 42px 0 12px;
  scroll-margin-top: 100px;
}

.md h3 {
  font-size: 20px;
  letter-spacing: -.02em;
  margin: 30px 0 8px;
}

.md h4 {
  font-size: 16.5px;
  margin: 24px 0 6px;
}

.md p {
  margin: 0 0 15px;
  color: #333d4f;
}

.md a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md ul, .md ol {
  margin: 0 0 16px;
  padding-left: 24px;
  color: #333d4f;
}

.md li {
  margin: 5px 0;
}

.md li > ul, .md li > ol {
  margin-bottom: 0;
}

.md blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  margin: 22px 0;
  padding: 12px 20px;
  border-radius: 0 10px 10px 0;
  color: #2b3a4a;
}

.md blockquote p {
  margin: 0;
}

.md blockquote p + p {
  margin-top: 8px;
}

.md code {
  background: #f1f3f6;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: .88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.md pre {
  background: var(--dark);
  color: #e6e9ef;
  padding: 18px 20px;
  border-radius: 12px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 13.5px;
  line-height: 1.55;
}

.md pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.md {
  /* break-word only breaks tokens that can't fit on a line of their own —
     mid-word splits like "Truste-d" happen with 'anywhere', not this */
  overflow-wrap: break-word;
}

.md pre, .md-tablewrap, .md blockquote, .md img {
  max-width: 100%;
}

.md-tablewrap {
  overflow-x: auto;
  margin: 24px 0;
  -webkit-overflow-scrolling: touch;
}

.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 14.5px;
}

.md th, .md td {
  border: 1px solid var(--line);
  padding: 9px 13px;
  text-align: left;
  vertical-align: top;
  /* cells never break inside a word — the tablewrap scrolls instead.
     (Safari treats break-word like anywhere in squeezed table cells,
     which produced the "Truste-d" split on mobile) */
  overflow-wrap: normal;
  word-break: normal;
}

.md th {
  background: var(--paper);
  font-weight: 700;
  white-space: nowrap;
}

/* long code tokens inside cells may still split; ordinary words never do */
.md td code {
  overflow-wrap: break-word;
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 34px 0;
}

.md img {
  max-width: 100%;
}

.docs-loading, .docs-error {
  color: var(--muted);
}

.docs-error {
  color: #a33;
}

@media (max-width: 900px) {
  .docs-layout {
    /* minmax(0,1fr) caps the track at the container width — plain 1fr is
       minmax(auto,1fr) and lets content min-width blow out the page */
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding-top: 36px;
    padding-left: 4px;
    padding-right: 4px;
  }

  .docs-content {
    padding-left: 2px;
    padding-right: 2px;
  }

  .docs-sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 18px;
  }
}
