/*
  The connector documentation, on top of ../landing.css: the same Flight tokens, top bar, buttons, badges, code blocks
  and FAQ rows, plus what a reference page adds: a contents rail, tables, the tool cards and their filters.

  KEEP IN SYNC with app/web/Flight-UI/theme/primitives.ts and semantic.ts: the error tokens below copy Flight's red,
  which the landing page has no use for. Flight rules applied here: sentence case; 8px for rows and controls, 16px for
  cards; the primary muted fill for a selected chip or the current contents link; a background shift, never a border,
  for a hovered table row; red only where a write overwrites what someone made.
*/

:root {
  --error: #b01810;
  --error-rgb: 176 24 16;
  --error-dark: #650f09;
}

:root[data-theme="dark"] {
  --error: #fa8575;
  --error-rgb: 250 133 117;
  --error-dark: #ffe9e5;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --error: #fa8575;
    --error-rgb: 250 133 117;
    --error-dark: #ffe9e5;
  }
}

/* landing.css hides [hidden] with a bare attribute rule, which a class's own display outranks here. */

.badge[hidden] {
  display: none;
}

/* Layout */

.docs {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.toc {
  display: none;
}

.doc {
  min-width: 0;
}

.doc-section {
  padding-block: 40px;
  border-top: 1px solid var(--divider);
  scroll-margin-top: 64px;
}

.doc-section:first-child {
  padding-top: 8px;
  border-top: 0;
}

.doc h1 {
  margin-top: 8px;
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.doc h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.doc h3 {
  margin-top: 28px;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
}

.prose {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 72ch;
  margin-top: 12px;
  color: var(--text-2);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.prose strong,
.prose b {
  color: var(--text);
}

.prose ul,
.prose ol {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 1.25rem;
}

.lede {
  max-width: 64ch;
  margin-top: 16px;
  color: var(--text-2);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

/* Tables: a scroll box of their own, so a wide one never widens the page. */

.table-wrap {
  max-width: 100%;
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--paper);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  line-height: 1.43;
}

.table-wrap th,
.table-wrap td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  text-align: left;
  vertical-align: top;
}

.table-wrap th {
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}

.table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.table-wrap tbody tr:hover {
  background: var(--hover);
}

.table-wrap td:first-child {
  color: var(--text);
  font-weight: 500;
}

/* A parameter or field name is read as one token, so it never breaks mid-word; its column grows instead. */
.tool .table-wrap td:first-child code {
  overflow-wrap: normal;
  white-space: nowrap;
}

.table-wrap code,
.prose code,
.tool code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--hover);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

/* Tool reference */

.tool-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.search {
  display: flex;
  flex: 1 1 260px;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--paper);
  color: var(--text-2);
}

.search:focus-within {
  border-color: var(--primary);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  height: 32px;
  padding: 0 12px;
  border: 1.5px solid var(--divider);
  border-radius: 999px;
  background: var(--paper);
  color: var(--text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.filter:hover {
  background: var(--selected);
}

.filter[aria-pressed="true"] {
  border-color: var(--primary);
  background: rgb(var(--primary-rgb) / 0.08);
  color: var(--primary);
}

.filter[aria-pressed="true"]:hover {
  background: rgb(var(--primary-rgb) / 0.12);
}

.tool-count {
  margin-top: 12px;
}

.tool-group {
  margin-top: 28px;
}

.tool-group > .overline {
  color: var(--text-2);
}

.tool-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.tool {
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--paper);
  scroll-margin-top: 72px;
}

.tool > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 8px;
  list-style: none;
  cursor: pointer;
}

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

.tool > summary:hover {
  background: var(--hover);
}

.tool > summary:focus-visible {
  outline-offset: -2px;
}

.tool__name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tool__title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
}

.tool__id {
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.tool__badges {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: 6px;
}

.tool__chevron {
  grid-row: 1;
  grid-column: 2;
  color: var(--text-2);
  font-size: 12px;
  transition: transform 150ms;
}

.tool[open] .tool__chevron {
  transform: rotate(180deg);
}

.tool__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 16px 18px;
}

.tool__description {
  max-width: 80ch;
  color: var(--text-2);
  font-size: 0.875rem;
  line-height: 1.6;
}

.tool__facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--divider);
  border-radius: 8px;
}

.tool__facts > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  font-size: 0.875rem;
  line-height: 1.43;
}

.tool__facts > div:last-child {
  border-bottom: 0;
}

.tool__facts dt {
  color: var(--text-2);
}

.tool__facts dd {
  margin: 0;
}

.tool__subhead {
  font-size: 0.875rem;
  font-weight: 600;
}

.tool .table-wrap {
  margin-top: 8px;
}

.badge--error {
  background: rgb(var(--error-rgb) / 0.12);
  color: var(--error-dark);
}

.empty {
  margin-top: 20px;
  padding: 24px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.875rem;
}

@media (min-width: 600px) {
  .tool > summary {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .tool__badges {
    grid-column: auto;
    justify-content: flex-end;
  }

  .tool__chevron {
    grid-row: auto;
    grid-column: auto;
  }

  .tool__facts > div {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 16px;
  }
}

@media (min-width: 1024px) {
  .docs {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 48px;
    padding-top: 40px;
  }

  .toc {
    display: block;
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
  }

  .toc .overline {
    padding: 0 12px;
    color: var(--text-2);
  }

  .toc ol {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
  }

  .toc a {
    display: block;
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.43;
  }

  .toc a:hover {
    background: var(--hover);
    color: var(--text);
    text-decoration: none;
  }

  .toc a[aria-current="true"] {
    background: rgb(var(--primary-rgb) / 0.08);
    color: var(--primary);
  }

  .doc h1 {
    font-size: 2.75rem;
  }

  .doc h2 {
    font-size: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tool__chevron {
    transition: none;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
