/*
 * The API reference page. Tokens, fonts and the header come from styles.css;
 * this file only lays out a long document: a sticky index and the operations.
 * Method badges use the site's colour rule — mint for a verified read, brass
 * for a write, rust only for destructive calls — never decoration.
 */

.docs .top {
  background: rgba(7, 17, 14, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}

.docs-main {
  padding: 44px 0 100px;
}

.docs-wrap {
  width: min(1280px, 100% - 64px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

/* --- index ----------------------------------------------------------------- */

.docs-nav {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow-y: auto;
  padding: 0 14px 0 0;
  border-right: 1px solid var(--line);
  font-size: 12.5px;
}

.docs-nav-head {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
}

.docs-nav a {
  display: block;
  padding: 3px 0;
  color: var(--muted);
  transition: color 160ms ease;
}

.docs-nav a:hover { color: var(--text); }

.docs-nav .nav-tag {
  color: var(--text);
  font-weight: 600;
  margin-top: 6px;
}

.docs-nav .nav-op {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding-left: 2px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  overflow-wrap: anywhere;
}

.docs-nav .nav-op:hover { color: var(--body); }

.docs-nav .nav-group { margin: 14px 0 0; }

/* --- head ------------------------------------------------------------------ */

.docs-head { scroll-margin-top: 92px; }

.eyebrow {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--brass);
}

.docs-head h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.lede {
  max-width: 62ch;
  margin: 16px 0 0;
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--body);
}

.docs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 0;
}

.docs-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin: 34px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line);
}

.docs-facts dt {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  margin-bottom: 4px;
}

.docs-facts dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--body);
  overflow-wrap: anywhere;
}

.docs-note {
  margin: 30px 0 0;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass);
  border-radius: 0 8px 8px 0;
  background: rgba(14, 31, 25, 0.55);
  color: var(--body);
  font-size: 13.5px;
  line-height: 1.7;
}

.docs-note p { margin: 0 0 10px; }
.docs-note p:last-child { margin-bottom: 0; }

/* --- sections and operations ---------------------------------------------- */

.docs-body section {
  margin-top: 60px;
  scroll-margin-top: 92px;
}

.docs-body h2 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.section-copy {
  max-width: 72ch;
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--body);
}

.docs-body a { color: var(--brass-bright); }
.docs-body a:hover { text-decoration: underline; text-underline-offset: 3px; }

.docs-body code {
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--text);
  background: rgba(233, 239, 231, 0.06);
  padding: 1px 5px;
  border-radius: 3px;
}

.op {
  border-top: 1px solid var(--line);
  padding: 24px 0 8px;
  scroll-margin-top: 92px;
}

.op h3 {
  margin: 12px 0 6px;
  font-size: 15.5px;
  line-height: 1.35;
  font-weight: 600;
}

.op > p {
  max-width: 76ch;
  margin: 6px 0 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--body);
}

.op-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.method {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.4;
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 4px;
}

.m-get { color: var(--mint); }
.m-post { color: var(--brass); }
.m-put,
.m-patch { color: var(--muted); }
.m-delete { color: var(--rust); }
.m-schema { color: var(--dim); }

.op-path {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.op-link {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  opacity: 0;
  transition: opacity 160ms ease;
}

.op:hover .op-link,
.op-link:focus-visible { opacity: 1; }

.op-auth {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

.op-auth span {
  color: var(--dim);
  margin-right: 8px;
}

.op-auth .none { color: var(--dim); font-style: italic; }

.op h4 {
  margin: 22px 0 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--dim);
}

.media { margin-left: 8px; }
.req {
  margin-left: 6px;
  padding: 0 4px;
  border: 1px solid rgba(216, 164, 74, 0.4);
  border-radius: 3px;
  font-size: 9.5px;
  color: var(--brass);
}

.where {
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 9.5px;
  color: var(--dim);
}

/* --- field tables ----------------------------------------------------------- */

.fields {
  margin: 0;
  border-top: 1px solid rgba(233, 239, 231, 0.07);
}

.field {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(233, 239, 231, 0.07);
}

.field dt {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.field dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--body);
}

.field dd p { margin: 4px 0 0; }

.fields .fields {
  margin-top: 10px;
  border-top: 1px solid rgba(233, 239, 231, 0.05);
}

.fields .fields .field {
  grid-template-columns: 170px minmax(0, 1fr);
  border-bottom-color: rgba(233, 239, 231, 0.05);
}

.type {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--mint);
}

.hint {
  margin: 8px 0 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
}

.status {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border: 1px solid currentColor;
  border-radius: 3px;
}

.s-2 { color: var(--mint); }
.s-4 { color: var(--brass); }
.s-5 { color: var(--rust); }
.s-d { color: var(--dim); }

/* --- credentials and plain lists -------------------------------------------- */

.credential {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 18px;
  padding: 14px 0;
  border-top: 1px solid rgba(233, 239, 231, 0.07);
}

.credential:last-child { border-bottom: 1px solid rgba(233, 239, 231, 0.07); }
.credential-name code { font-size: 12px; }
.credential p { margin: 0; font-size: 13px; line-height: 1.65; color: var(--body); }

.credential-type {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  margin-bottom: 4px !important;
}

.plain-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.plain-list li {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 18px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.6;
  color: var(--body);
}

.plain-list a {
  font-family: var(--mono);
  font-size: 12px;
}

.docs-foot {
  border-top: 1px solid var(--line);
  padding: 18px 0 28px;
}

/* The return link only exists for the narrow layout; see the responsive block. */
.docs-top { display: none; }

/* --- responsive ------------------------------------------------------------- */

/*
 * The index is a disclosure on small screens and the sidebar on wide ones.
 * `open` is left out of the markup so a phone starts with the route list
 * collapsed; the plain CSS below re-exposes it on desktop, where the summary is
 * hidden and there is nothing to toggle. Without a script, that is the whole
 * interaction.
 */
@media (min-width: 1001px) {
  .nav-all > summary { display: none; }
  .nav-all:not([open]) > .nav-group { display: block; }
}

@media (max-width: 1000px) {
  .docs-wrap {
    width: calc(100% - 64px);
    grid-template-columns: minmax(0, 1fr);
    gap: 30px;
  }

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

  .nav-all > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    margin-top: 4px;
    padding: 4px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font-family: var(--mono);
    font-size: 11.5px;
    cursor: pointer;
    list-style: none;
  }

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

  .nav-all > summary::after {
    content: "+";
    color: var(--brass);
    font-size: 15px;
    line-height: 1;
  }

  .nav-all[open] > summary::after { content: "\2212"; }

  .nav-all[open] { padding-bottom: 8px; }

  /* Touch: every index row is a target, and a route's own link is always
     visible because there is no hover to reveal it. */
  .docs-nav .nav-op {
    min-height: 40px;
    align-items: center;
    padding: 8px 0;
  }

  .docs-nav .nav-tag {
    display: flex;
    align-items: center;
    min-height: 40px;
  }

  .op-link { opacity: 1; }

  /* Once an operation is on screen the index is thousands of pixels above; a
     phone needs a way back that does not depend on a script. */
  .docs-top {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(7, 17, 14, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text);
    font-family: var(--mono);
    font-size: 11.5px;
  }

  .docs-top:hover { border-color: var(--brass); color: var(--brass-bright); }

  .docs-foot { padding-bottom: 84px; }

  .docs-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}

@media (max-width: 700px) {
  .docs-main { padding: 30px 0 72px; }

  .docs-wrap { width: calc(100% - 36px); }

  .field,
  .credential,
  .plain-list li {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .docs-head h1 { font-size: clamp(1.85rem, 8vw, 2.5rem); }
  .lede { font-size: 15.5px; line-height: 1.6; }
  .docs-note { padding: 16px; font-size: 14px; line-height: 1.7; }

  .docs-body h2 { font-size: 1.45rem; }
  .op { padding-top: 22px; }
  .op h3 { font-size: 17px; }
  .op > p { font-size: 14.5px; line-height: 1.75; }
  .op-path { font-size: 12.5px; }
  .op-auth { font-size: 11.5px; }
  .section-copy { font-size: 14.5px; line-height: 1.75; }

  .field dt { font-size: 12.5px; }
  .field dd { font-size: 14px; line-height: 1.7; }
  .credential p { font-size: 14px; }
  .plain-list li { font-size: 14px; }

  .docs-body code { overflow-wrap: anywhere; }

  .docs-nav { font-size: 12.5px; }
  .docs .brand-logo { height: 18px; }
}

/* --- sandbox testing page --------------------------------------------------- */

.sandbox-main { padding: 44px 0 100px; }

.sandbox-wrap {
  width: min(960px, 100% - 64px);
  margin-inline: auto;
}

.sandbox-wrap section {
  margin-top: 60px;
  scroll-margin-top: 92px;
}

.sandbox-wrap h2 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.sandbox-wrap h3 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.35;
  font-weight: 600;
}

.scenario {
  border-top: 1px solid var(--line);
  padding: 22px 0 18px;
}

.scenario-proves {
  margin: 0 0 12px;
  max-width: 72ch;
  font-size: 14px;
  line-height: 1.7;
  color: var(--body);
}

.scenario-steps {
  margin: 0 0 14px;
  padding-left: 20px;
  max-width: 72ch;
  font-size: 14px;
  line-height: 1.75;
  color: var(--body);
}

.scenario-steps li { margin-bottom: 6px; }

.expect {
  margin: 0;
  padding: 12px 14px;
  border-left: 2px solid var(--brass);
  background: rgba(14, 31, 25, 0.55);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--body);
}

.expect span {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
}

.codeblock {
  margin: 12px 0 0;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 10, 8, 0.7);
  color: var(--body);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  -webkit-overflow-scrolling: touch;
}

.codeblock code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre;
}

.table-scroll {
  margin-top: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.test-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.55;
  color: var(--body);
}

.test-table th {
  padding: 0 14px 8px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--dim);
}

.test-table td {
  padding: 11px 14px 11px 0;
  border-bottom: 1px solid rgba(233, 239, 231, 0.07);
  vertical-align: top;
}

.test-table code { white-space: nowrap; }

.sandbox-summary {
  font-size: 13px;
  color: var(--body);
}

.sandbox-op summary { cursor: pointer; list-style: none; }
.sandbox-op summary::-webkit-details-marker { display: none; }
.sandbox-op[open] summary { margin-bottom: 6px; }
.sandbox-op .op-body { padding-bottom: 8px; }

.sandbox-params {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 1.8;
  color: var(--body);
}

.sandbox-group { margin-top: 34px; }

.sandbox-group > h3 {
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
}

@media (max-width: 700px) {
  .sandbox-main { padding: 30px 0 72px; }
  .sandbox-wrap { width: calc(100% - 36px); }
  .codeblock { font-size: 11px; padding: 12px; }
  .sandbox-wrap h3 { font-size: 17px; }
  .scenario-props, .scenario-proves, .scenario-steps, .expect { font-size: 14.5px; }
}

@media (max-width: 480px) {
  .docs-wrap { width: calc(100% - 32px); }
  .docs-facts { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .docs-actions { gap: 8px; }
  .docs-actions .btn { flex: 1 1 100%; justify-content: center; }
  .op .field { padding: 12px 0; }
}
