/* GCITPs API guide (/api/). Scoped under .apig so nothing leaks into other pages.

   Three surface levels, and no more:
     L1  the site background            - the page itself, never painted here
     L2  --apig-surface (white)         - one panel per major section
     L3  --apig-subtle / --apig-code-bg - examples, notes, detail panels, table headers
   Nothing nests deeper than L2 > L3, borders stay hairline, radii and padding are shared
   tokens, and code blocks stay light. */

.apig {
  --apig-ink: var(--ink, #0f172a);
  --apig-muted: rgba(15, 23, 42, 0.62);
  --apig-line: rgba(18, 38, 63, 0.12);
  --apig-line-soft: rgba(18, 38, 63, 0.07);
  --apig-blue: var(--brand-blue, #2880c2);
  --apig-green: var(--brand-green, #81c241);
  --apig-surface: #fff;             /* L2: a major section panel */
  --apig-subtle: #f8fafd;           /* L3: supporting blocks on a section panel */
  --apig-code-bg: #e9eff8;          /* L3: examples - one clear step below the detail panel */
  --apig-code-ink: #16233a;
  --apig-radius: 14px;              /* L2 */
  --apig-radius-sm: 10px;           /* L3 */
  --apig-pad: 18px 20px;            /* L2 */
  color: var(--apig-ink);
  margin: 0 0 2.5rem;
  font-size: 0.95rem;
}

.apig h2,
.apig h3,
.apig h4 { letter-spacing: -0.01em; }

.apig code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
  color: #0b4f86;
  background: rgba(40, 128, 194, 0.07);
  border-radius: 5px;
  padding: 0.06em 0.34em;
  overflow-wrap: anywhere;
}

.apig a { color: var(--apig-blue); }

.apig :focus-visible {
  outline: 2px solid var(--apig-blue);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Hero: compact, no marketing panel ---------- */
.apig-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 18px;
  margin: 8px 0 0;
  border-bottom: 1px solid var(--apig-line);
}

.apig-hero__main { min-width: 0; }

.apig-title {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(1.6rem, 3.2vw, 2.05rem);
  margin: 0 0 4px;
  color: var(--apig-ink);
}

.apig-lead {
  color: var(--apig-muted);
  margin: 0 0 10px;
  max-width: 62ch;
}

.apig-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }

.apig-badge {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--apig-blue);
  background: rgba(40, 128, 194, 0.08);
  border: 1px solid rgba(40, 128, 194, 0.18);
  border-radius: 999px;
  padding: 0.16rem 0.62rem;
}

.apig-hero__base {
  margin: 0;
  padding: 8px 14px;
  border: 1px solid var(--apig-line-soft);
  border-radius: var(--apig-radius-sm);
  background: var(--apig-subtle);
}

.apig-hero__base dt {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--apig-muted);
}

.apig-hero__base dd { margin: 2px 0 0; }
.apig-hero__base code { background: none; padding: 0; font-size: 0.92rem; }

/* ---------- Buttons ---------- */
.apig-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }

.apig .apig-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.44rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--apig-ink);
  background: var(--apig-surface);
  border: 1px solid var(--apig-line);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.apig .apig-btn:hover { border-color: rgba(40, 128, 194, 0.42); color: var(--apig-ink); text-decoration: none; }

.apig .apig-btn--primary {
  color: #fff;
  background: var(--apig-blue);
  border-color: var(--apig-blue);
}

.apig .apig-btn--primary:hover { color: #fff; background: #226fa8; border-color: #226fa8; }

/* ---------- Notice ---------- */
.apig-notice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 10px 14px;
  margin: 14px 0 0;
  border: 1px solid var(--apig-line-soft);
  border-radius: var(--apig-radius-sm);
  background: var(--apig-subtle);
  font-size: 0.9rem;
}

.apig-notice--warn {
  border-color: rgba(214, 158, 46, 0.42);
  background: rgba(250, 204, 21, 0.10);
}

/* ---------- Layout: narrow sticky sidebar + one content column ---------- */
.apig-layout {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  margin-top: 18px;
}

.apig-toc { position: sticky; top: 88px; }

.apig-toc__title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--apig-muted);
  margin: 0 0 8px;
}

.apig-toc ul { list-style: none; padding: 0; margin: 0; }

.apig-toc li + li { margin-top: 1px; }

.apig .apig-toc a {
  display: block;
  padding: 5px 10px;
  border-left: 2px solid var(--apig-line-soft);
  border-radius: 0 6px 6px 0;
  font-size: 0.87rem;
  color: var(--apig-muted);
  text-decoration: none;
}

.apig .apig-toc a:hover { color: var(--apig-ink); background: var(--apig-code-bg); }

.apig .apig-toc a[aria-current="true"] {
  color: var(--apig-blue);
  border-left-color: var(--apig-blue);
  font-weight: 600;
}

.apig-body { min-width: 0; }

/* ---------- L2: one panel per major section ---------- */
.apig-section {
  background: var(--apig-surface);
  border: 1px solid var(--apig-line);
  border-radius: var(--apig-radius);
  padding: var(--apig-pad);
  margin-top: 14px;
}

.apig-section > h2 {
  font-size: 1.22rem;
  font-weight: 700;
  margin: 0 0 8px;
  scroll-margin-top: 90px;
}

.apig-section[id] { scroll-margin-top: 78px; }

.apig-section__lead {
  color: var(--apig-muted);
  margin: 0 0 14px;
  max-width: 78ch;
}

.apig-muted { color: var(--apig-muted); font-size: 0.88rem; }
.apig-muted--inline { font-weight: 400; }

.apig-note {
  margin: 0 0 12px;
  padding: 9px 12px;
  color: var(--apig-muted);
  font-size: 0.88rem;
  background: var(--apig-subtle);
  border: 1px solid var(--apig-line-soft);
  border-left: 3px solid rgba(40, 128, 194, 0.35);
  border-radius: var(--apig-radius-sm);
}

.apig-note:last-child { margin-bottom: 0; }

.apig-list { margin: 0 0 12px; padding-left: 1.15rem; }
.apig-list li + li { margin-top: 5px; }
.apig-list--tight { font-size: 0.9rem; }

.apig-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 14px;
  align-items: start;
}

/* ---------- Endpoint rows: on the section panel, separated by hairlines ---------- */
.apig-endpoints { border-top: 1px solid var(--apig-line-soft); }

.apig-endpoint { padding: 12px 2px; }
.apig-endpoint + .apig-endpoint { border-top: 1px solid var(--apig-line-soft); }
.apig-endpoint:target { background: rgba(40, 128, 194, 0.05); border-radius: var(--apig-radius-sm); }
.apig-endpoint[id] { scroll-margin-top: 78px; }

.apig-ep__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

/* The method is never signalled by colour alone: it is always the literal word. */
.apig-method {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #0b5f3a;
  background: rgba(129, 194, 65, 0.16);
  border: 1px solid rgba(129, 194, 65, 0.4);
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
}

/* Beats the generic ".apig code" tint: the path is the row's plain, primary text. */
.apig .apig-ep__path {
  font-size: 0.88rem;
  color: var(--apig-ink);
  background: none;
  padding: 0;
  overflow-wrap: anywhere;
}

.apig-ep__name {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--apig-muted);
  margin-left: auto;
}

.apig-ep__summary {
  margin: 5px 0 0;
  font-size: 0.89rem;
  color: var(--apig-muted);
}

.apig-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--apig-muted);
  background: var(--apig-code-bg);
  border: 1px solid var(--apig-line);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  margin-left: 4px;
  white-space: nowrap;
}

.apig-pill--off {
  color: #9a3412;
  background: rgba(249, 115, 22, 0.10);
  border-color: rgba(249, 115, 22, 0.32);
}

/* ---------- details / summary ---------- */
.apig-details { margin-top: 8px; }

.apig-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--apig-blue);
  padding: 6px 4px 6px 0;         /* a comfortable tap target, not just the text */
  min-height: 34px;
  width: fit-content;
}

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

.apig-details > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}

.apig-details[open] > summary::before { transform: rotate(90deg); }
.apig-details[open] > summary { margin-bottom: 6px; }

.apig-details__label { text-decoration: underline; text-underline-offset: 3px; }

.apig-details__body {
  padding: 12px 14px;
  background: var(--apig-subtle);
  border: 1px solid var(--apig-line-soft);
  border-radius: var(--apig-radius-sm);
}

.apig-details__body > h4 {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--apig-muted);
  margin: 14px 0 6px;
}

.apig-details__body > h4:first-child { margin-top: 4px; }

.apig-details--plain > summary { font-size: 0.86rem; }

.apig-status {
  font-size: 0.68rem;
  font-weight: 700;
  color: #0b5f3a;
  background: rgba(129, 194, 65, 0.16);
  border-radius: 4px;
  padding: 0.05rem 0.34rem;
  letter-spacing: 0.02em;
}

.apig-field-group {
  margin: 10px 0 4px;
  font-size: 0.8rem;
  color: var(--apig-muted);
}

.apig-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }

.apig .apig-chips a {
  display: inline-block;
  font-size: 0.76rem;
  text-decoration: none;
  color: var(--apig-muted);
  background: var(--apig-code-bg);
  border: 1px solid var(--apig-line);
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
}

.apig .apig-chips a:hover { color: var(--apig-ink); border-color: rgba(40, 128, 194, 0.4); }
.apig-chips strong { color: var(--apig-ink); }

/* ---------- Code blocks: light, bordered, quiet ---------- */
.apig-code {
  margin: 0 0 10px;
  border: 1px solid var(--apig-line);
  border-radius: var(--apig-radius-sm);
  background: var(--apig-code-bg);
  overflow: hidden;
}

.apig-code__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--apig-line-soft);
  background: rgba(255, 255, 255, 0.6);
}

.apig-code__label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--apig-muted);
}

.apig-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--apig-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.1rem 0.42rem;
  cursor: pointer;
}

.apig-copy:hover { color: var(--apig-blue); border-color: var(--apig-line); background: #fff; }
.apig-copy.is-copied { color: #0b5f3a; }

.apig-pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;              /* long URLs scroll inside the block, never the page */
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--apig-code-ink);
  background: none;
  tab-size: 2;
}

.apig-pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
  white-space: pre;
  overflow-wrap: normal;
}

.apig-origin { color: #7a3ea3; }   /* the placeholder host the script replaces */
.apig-code--json .apig-pre { max-height: 22rem; overflow-y: auto; }

/* ---------- Tables ---------- */
.apig-table-wrap {
  overflow-x: auto;              /* wide tables scroll inside their own box */
  border: 1px solid var(--apig-line-soft);
  border-radius: var(--apig-radius-sm);
  margin: 0 0 12px;
  background: transparent;       /* sits on whatever surface holds it */
}

.apig-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0;
}

.apig-caption {
  caption-side: top;
  text-align: left;
  padding: 8px 12px 0;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--apig-muted);
}

.apig-table th,
.apig-table td {
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--apig-line-soft);
  vertical-align: top;
}

.apig-table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--apig-muted);
  /* translucent, so one rule reads correctly on both the white panel and the subtle one */
  background: rgba(18, 38, 63, 0.045);
  white-space: nowrap;
}

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

/* A field or parameter name is one token: let the table scroll rather than break "inchikey". */
.apig-table td:first-child code { white-space: nowrap; overflow-wrap: normal; }
.apig-table--compact th, .apig-table--compact td { padding: 6px 10px; }
.apig-table tr:target { background: rgba(40, 128, 194, 0.07); }
.apig-table tr[id] { scroll-margin-top: 80px; }

/* ---------- Closing action ---------- */
.apig-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--apig-line);
}

.apig-end__text { margin: 0; color: var(--apig-muted); font-size: 0.9rem; }

/* ---------- Tablet and below: the sidebar becomes a compact chip row ---------- */
@media (max-width: 991.98px) {
  .apig-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }

  .apig-toc {
    position: static;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--apig-line-soft);
  }

  .apig-toc ul { display: flex; flex-wrap: wrap; gap: 6px; }

  .apig .apig-toc a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;               /* a finger-sized chip, not just the text */
    border: 1px solid var(--apig-line);
    border-radius: 999px;
    padding: 4px 13px;
    font-size: 0.82rem;
  }

  .apig .apig-toc a[aria-current="true"] { border-color: var(--apig-blue); background: rgba(40, 128, 194, 0.07); }

  .apig-hero { align-items: flex-start; }

  /* Touch-capable widths: comfortable targets without growing the rows much.
     >= 992px keeps the compact desktop sizes, where a pointer is precise. */
  .apig-details > summary { min-height: 40px; }
  .apig .apig-btn { min-height: 40px; }
}

/* ---------- Phones: stacked tables, no horizontal page scroll ---------- */
@media (max-width: 575.98px) {
  .apig { font-size: 0.92rem; }
  .apig-hero { padding-top: 14px; }
  .apig-hero__base { width: 100%; }
  .apig-section { padding: 14px 15px; }
  .apig-details__body { padding: 10px 11px; }
  .apig .apig-btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }
  .apig .apig-toc a { min-height: 44px; }
  .apig-copy { min-height: 40px; padding: 0.3rem 0.6rem; }
  .apig .apig-chips a { display: inline-flex; align-items: center; min-height: 32px; }
  .apig-ep__name { margin-left: 0; }
  .apig-details > summary { min-height: 44px; }   /* full touch target on a phone */

  .apig-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .apig-table--stack tr { display: block; border-bottom: 1px solid var(--apig-line-soft); padding: 4px 0; }
  .apig-table--stack tr:last-child { border-bottom: 0; }
  /* The label sits above its value. A flex/grid cell would turn every inline <code> in a
     description into its own column, which shreds names like next_cursor one letter per line. */
  .apig-table--stack td { display: block; border: 0; padding: 4px 10px; }

  .apig-table--stack td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--apig-muted);
  }

  .apig-table--stack td:empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .apig-details > summary::before { transition: none; }
}
