/* Developer docs (/docs/*): the docs menu beside the page, the API reference and the shared table
   style. App-owned; semantic tokens only. Mirrors the vendored .profile-sidebar look but keeps its
   links reachable on a phone, where the vendored rule collapses that menu to a back link.

   The content column takes the whole container beside the menu: text, cards, tables and code all
   reach the header's right edge. */

.docs-main .connect {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.docs-main [id] {
  scroll-margin-top: var(--spacing-xl);
}

/* The "#" permalink beside a heading with a stable anchor. */
.docs-anchor {
  margin-left: var(--spacing-sm);
  color: var(--color-text-muted);
  font-weight: var(--font-weight-ui-regular);
  text-decoration: none;
}

.docs-anchor:hover,
.docs-anchor:focus-visible {
  color: var(--color-accent-primary);
  text-decoration: none;
}

/* Collapsed menu and contents: shown only where the page is narrow. */
.docs-collapse {
  display: none;
}

.docs-collapse > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  min-height: var(--button-min-height);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-ui-medium);
  cursor: pointer;
  list-style: none;
}

.docs-collapse > summary::-webkit-details-marker {
  display: none;
}

.docs-collapse > summary::after {
  content: "\25BE";
  color: var(--color-text-muted);
  transition: transform var(--motion-duration-fast) var(--motion-easing-standard);
}

.docs-collapse[open] > summary::after {
  transform: rotate(180deg);
}

.docs-collapse > :not(summary) {
  margin-top: var(--spacing-sm);
}

.docs-sidebar {
  width: 14rem;
  flex-shrink: 0;
  position: sticky;
  top: var(--spacing-xl);
}

.docs-sidebar__nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.docs-sidebar__nav a {
  display: flex;
  align-items: center;
  min-height: var(--button-min-height);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-ui-medium);
  text-decoration: none;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.docs-sidebar__nav a:hover {
  background: var(--color-surface-sunk);
  color: var(--nav-link-hover);
  text-decoration: none;
}

.docs-sidebar__nav a.active {
  background: var(--color-accent-primary);
  color: var(--color-text-on-accent);
}

@media (max-width: 768px) {
  .docs-sidebar {
    position: static;
    width: 100%;
  }

  .docs-sidebar__nav--wide,
  .connect-toc--wide {
    display: none;
  }

  .docs-collapse {
    display: block;
  }

  .docs-collapse--toc {
    margin-bottom: var(--spacing-xl);
  }

  .docs-collapse .connect-toc {
    margin-bottom: 0;
  }

  .docs-sidebar .docs-sidebar__nav a {
    border: 1px solid var(--color-border-default);
  }
}

/* Tables: scroll inside their own wrapper, never the page; on a phone each row stacks, its cells
   labelled by the data-label of the column. */
.docs-table-wrap {
  overflow-x: auto;
  margin-bottom: var(--spacing-lg);
  -webkit-overflow-scrolling: touch;
}

.docs-table-wrap table {
  width: 100%;
  min-width: 28rem;
}

.docs-table-wrap td,
.docs-table-wrap th {
  text-align: left;
  vertical-align: top;
  padding: var(--spacing-xs) var(--spacing-sm);
}

.docs-table-wrap td code,
.docs-table-wrap th code,
.docs-code {
  font-family: var(--font-mono);
  font-size: var(--font-size-small);
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .docs-table-wrap {
    overflow-x: visible;
  }

  .docs-table-wrap table,
  .docs-table-wrap tbody,
  .docs-table-wrap tr,
  .docs-table-wrap td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .docs-table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .docs-table-wrap tr {
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border-default);
  }

  .docs-table-wrap td {
    padding: var(--spacing-xs) 0;
  }

  .docs-table-wrap td:empty {
    display: none;
  }

  .docs-table-wrap td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--font-size-micro);
    font-weight: var(--font-weight-ui-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
  }
}

.docs-cards {
  display: grid;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
}

@media (min-width: 640px) {
  .docs-cards { grid-template-columns: 1fr 1fr; }
}

.docs-cards .card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--spacing-sm);
}

.docs-cards .card p {
  flex: 1;
}

/* API reference */
.docs-operation {
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-lg);
  border: 1px solid var(--color-border-default);
  border-radius: var(--card-radius);
  background: var(--color-surface-raised);
  scroll-margin-top: var(--spacing-xl);
}

.docs-operation__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.docs-operation__path {
  font-family: var(--font-mono);
  font-size: var(--font-size-small);
  overflow-wrap: anywhere;
}

.docs-method {
  background: var(--color-surface-sunk);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-default);
  font-family: var(--font-mono);
}

.docs-method--post {
  background: var(--color-accent-primary);
  color: var(--color-text-on-accent);
  border-color: var(--color-accent-primary);
}

.docs-operation h4 {
  margin: var(--spacing-lg) 0 var(--spacing-xs);
  font-family: var(--font-ui);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-ui-semibold);
}

.docs-operation p {
  line-height: var(--line-height-editorial);
}

.docs-model {
  scroll-margin-top: var(--spacing-xl);
}

.docs-op-index {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  margin: 0 0 var(--spacing-xl);
  padding: 0;
  list-style: none;
}

.docs-op-index__method {
  font-family: var(--font-mono);
  font-weight: var(--font-weight-ui-semibold);
}

.docs-layout {
  margin-top: var(--spacing-lg);
}
