/* ============================================================
   CloudRaya API Reference
   Three-column reference layout: fixed TOC · prose · dark code rail
   Brand: #1A9FDA (raya blue) · #202E60 (raya navy)
   ============================================================ */

:root {
  --brand:       #1a9fda;
  --brand-600:   #1189c0;
  --brand-700:   #0d6f9d;
  --navy:        #202e60;

  /* dark rail */
  --rail:        #16255a;
  --rail-2:      #1f3473;   /* code blocks sitting on the rail */
  --rail-text:   #c8d4ec;
  --rail-dim:    #8ea0c8;
  --rail-line:   rgba(255, 255, 255, .1);

  /* light side */
  --page:        #ffffff;
  --text:        #46505f;
  --heading:     #1d2735;
  --muted:       #78849a;
  --faint:       #9aa5b7;
  --line:        #e6e9ef;
  --line-soft:   #f0f2f6;
  --chip:        #f3f5f9;

  --get:    #1a9fda;
  --post:   #12a06f;
  --put:    #d1861c;
  --patch:  #7458d0;
  --delete: #d24545;
  --head:   #6b7b93;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --toc-w:  248px;
  --code-w: 480px;
  --gutter: 44px;

  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 62px; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px;
  border-radius: 0 0 8px 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ── the dark rail ─────────────────────────────────────────── */

.dark-rail {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--code-w);
  background: var(--rail);
  z-index: 0;
}

/* ── table of contents ─────────────────────────────────────── */

.toc {
  position: fixed; inset: 0 auto 0 0;
  width: var(--toc-w);
  background: #fbfcfd;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  z-index: 30;
}

.toc-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 20px 20px 16px;
}
.toc-brand:hover { text-decoration: none; }
.toc-brand img { display: block; height: 24px; width: auto; }
.toc-brand-tag {
  font-size: 9.5px; font-weight: 700; letter-spacing: .12em;
  color: var(--muted); background: var(--chip);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 2px 6px;
}

.toc-search { position: relative; padding: 0 16px 14px; }
.toc-search svg {
  position: absolute; left: 27px; top: 9px;
  width: 14px; height: 14px; color: var(--faint); pointer-events: none;
}
.toc-search input {
  width: 100%; padding: 7px 10px 7px 30px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 6px; color: var(--heading);
  font-family: var(--sans); font-size: 13px;
}
.toc-search input::placeholder { color: var(--faint); }
.toc-search input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 159, 218, .13);
}

.toc-nav { flex: 1; overflow-y: auto; padding-bottom: 20px; }
.toc-nav::-webkit-scrollbar { width: 7px; }
.toc-nav::-webkit-scrollbar-thumb { background: #dfe4ec; border-radius: 4px; }

.toc-group {
  padding: 14px 20px 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
}
.toc-group + .toc-group { padding-top: 6px; }

/* top-level entry (guide page or service) */
.toc-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 20px 7px 20px;
  background: none; border: 0; border-left: 2px solid transparent;
  color: var(--text); font-family: var(--sans); font-size: 13.5px;
  text-align: left; cursor: pointer;
}
.toc-item:hover { background: #f2f5f9; color: var(--heading); text-decoration: none; }
.toc-item.active {
  background: #eaf5fc; border-left-color: var(--brand);
  color: var(--brand-700); font-weight: 600;
}
.toc-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-count {
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  color: var(--faint); background: var(--chip);
  padding: 1px 5px; border-radius: 10px;
}
.toc-item.active .toc-count { background: rgba(26, 159, 218, .16); color: var(--brand-700); }

/* the expanded operation list under the active service */
.toc-sub { padding: 2px 0 8px; }
.toc-sub-group {
  padding: 8px 20px 3px 26px;
  font-size: 10px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint);
}
.toc-op {
  display: block; padding: 4px 18px 4px 32px;
  color: var(--muted); font-size: 12.5px;
  border-left: 2px solid transparent;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toc-op:hover { color: var(--heading); background: #f2f5f9; text-decoration: none; }
.toc-op.current {
  color: var(--brand-700); background: #eaf5fc;
  border-left-color: var(--brand); font-weight: 500;
}

/* search results replace the tree */
.toc-hit-meta {
  display: block; font-size: 10.5px; color: var(--faint);
  font-family: var(--mono); margin-top: 1px;
}
.toc-empty { padding: 18px 20px; color: var(--faint); font-size: 12.5px; }

.toc-foot {
  padding: 12px 20px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--faint);
  display: flex; gap: 6px;
}
.toc-foot a { color: var(--muted); }

.toc-scrim {
  position: fixed; inset: 0; background: rgba(20, 30, 50, .4);
  z-index: 25;
}

/* ── mobile bar ────────────────────────────────────────────── */

.mobile-bar {
  display: none;
  position: sticky; top: 0; z-index: 20;
  align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mobile-menu {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 7px; color: var(--text); cursor: pointer;
}
.mobile-menu svg { width: 18px; height: 18px; }
.mobile-logo { display: block; width: auto; }

/* ── page ──────────────────────────────────────────────────── */

.page {
  position: relative; z-index: 1;
  margin-left: var(--toc-w);
}

/* the floating language switcher, pinned over the rail */
.lang-bar {
  position: fixed; top: 0; right: 0; z-index: 10;
  width: var(--code-w);
  display: flex; gap: 2px;
  padding: 10px 20px;
  background: var(--rail);
  border-bottom: 1px solid var(--rail-line);
}
.lang-btn {
  padding: 4px 10px;
  background: none; border: 0; border-radius: 5px;
  color: var(--rail-dim); font-family: var(--sans);
  font-size: 12px; font-weight: 500; cursor: pointer;
}
.lang-btn:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.lang-btn.active { color: #fff; background: var(--brand); }

/* ── a documentation row: prose left, code right ───────────── */

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--code-w);
  align-items: start;
}
.row > .prose { padding: 0 var(--gutter) 0 var(--gutter); min-width: 0; }
.row > .code   { padding: 0 20px; min-width: 0; }

/* first row on a page needs headroom for the language bar */
.page > .content > .row:first-child > .code { padding-top: 54px; }
.page > .content > .row:first-child > .prose { padding-top: 40px; }

/* ── prose ─────────────────────────────────────────────────── */

.prose h1 {
  margin: 34px 0 14px; font-size: 26px; font-weight: 650;
  letter-spacing: -.4px; color: var(--heading);
}
.page > .content > .row:first-child .prose h1 { margin-top: 0; }
.prose h2 {
  margin: 44px 0 12px; padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 20px; font-weight: 650; letter-spacing: -.3px; color: var(--heading);
}
.prose h3 { margin: 26px 0 8px; font-size: 15px; font-weight: 650; color: var(--heading); }
.prose h4 {
  margin: 22px 0 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 20px; }
.prose li { margin-bottom: 5px; }
.prose strong { color: var(--heading); font-weight: 600; }

.prose code, .inline-code {
  font-family: var(--mono); font-size: 12px;
  background: var(--chip); color: #3f4a5c;
  padding: 1.5px 5px; border-radius: 4px;
  border: 1px solid var(--line-soft);
}

.note {
  margin: 16px 0; padding: 12px 15px;
  background: #f4fafe; border-left: 3px solid var(--brand);
  border-radius: 0 7px 7px 0; font-size: 13.5px;
}
.note strong { color: var(--brand-700); }
.note.warn { background: #fff8f2; border-left-color: var(--put); }
.note.warn strong { color: #a9650f; }

/* ── endpoint heading ──────────────────────────────────────── */

/* An operation occupies one whole row so the prose and the code column
   always start on the same line, so deep links land cleanly in both. */
.row.op-row { scroll-margin-top: 62px; }
.row.op-row > .prose { border-top: 1px solid var(--line); padding-top: 30px; }
.row.op-row > .code { padding-top: 30px; }

/* a tag heading is its own prose-only row */
.row.tag-row > .prose { padding-top: 48px; }
.row.tag-row + .row.op-row > .prose { border-top: 0; padding-top: 12px; }
.row.tag-row + .row.op-row > .code { padding-top: 12px; }

.prose h2.op-title {
  margin: 0 0 12px; padding-top: 0; border-top: 0;
  font-size: 19px; font-weight: 650; letter-spacing: -.3px; color: var(--heading);
}
.prose h3.tag-head {
  margin: 0; padding: 0 0 2px; border-top: 0;
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--brand-700);
}

.endpoint {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 16px; padding: 8px 12px;
  background: #fafbfd; border: 1px solid var(--line); border-radius: 7px;
  font-family: var(--mono); font-size: 12.5px; color: var(--heading);
  overflow-x: auto;
}
.endpoint .path { white-space: nowrap; }
.endpoint .auth-free {
  margin-left: auto; flex: none;
  font-family: var(--sans); font-size: 10px; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--post); background: rgba(18, 160, 111, .1);
  padding: 2px 7px; border-radius: 10px;
}

.m {
  flex: none; display: inline-block; min-width: 54px; text-align: center;
  padding: 3px 8px; border-radius: 5px;
  font-family: var(--sans); font-size: 10.5px; font-weight: 700;
  letter-spacing: .05em; color: #fff;
}
.m-get { background: var(--get); }
.m-post { background: var(--post); }
.m-put { background: var(--put); }
.m-patch { background: var(--patch); }
.m-delete { background: var(--delete); }
.m-head, .m-options { background: var(--head); }

/* ── parameter tables ──────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; margin: 0 0 16px; }
th {
  padding: 0 10px 7px 0; text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
td {
  padding: 9px 10px 9px 0; vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
tr:last-child td { border-bottom: 0; }
td:last-child, th:last-child { padding-right: 0; }

.p-name {
  font-family: var(--mono); font-size: 12.5px;
  color: var(--heading); font-weight: 500; word-break: break-word;
}
.p-name .depth { color: var(--faint); }
.p-type { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.p-req {
  display: block; font-family: var(--sans); font-size: 10px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--delete); margin-top: 2px;
}
.p-desc { color: var(--text); }
.p-example { display: block; margin-top: 3px; font-family: var(--mono); font-size: 11.5px; color: var(--faint); }

.status-code { font-family: var(--mono); font-weight: 600; color: var(--heading); }
.status-2xx { color: var(--post); }
.status-4xx { color: var(--delete); }

/* ── code column ───────────────────────────────────────────── */

.code-label {
  margin: 22px 0 7px;
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--rail-dim);
}
.code-label:first-child { margin-top: 0; }

.code-block { position: relative; margin: 0 0 6px; }
.code-block pre {
  margin: 0; padding: 13px 15px;
  background: var(--rail-2); border-radius: 7px;
  overflow-x: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.75;
  color: var(--rail-text);
}
.code-block pre::-webkit-scrollbar { height: 7px; }
.code-block pre::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 4px; }
.code-block code { font-family: inherit; }

.copy-btn {
  position: absolute; top: 7px; right: 7px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, .1); border: 0; border-radius: 5px;
  color: var(--rail-dim); font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  cursor: pointer; opacity: 0; transition: opacity .13s, color .13s;
}
.code-block:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: #fff; background: rgba(255, 255, 255, .18); }
.copy-btn.done { color: #7fe0b4; opacity: 1; }

/* status tabs above a response sample */
.code-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.code-tab {
  padding: 2px 8px; background: rgba(255, 255, 255, .07);
  border: 0; border-radius: 4px;
  color: var(--rail-dim); font-family: var(--mono); font-size: 10.5px; cursor: pointer;
}
.code-tab:hover { color: #fff; }
.code-tab.active { background: var(--brand); color: #fff; }

.code-note {
  margin: 0 0 14px; padding: 11px 14px;
  background: rgba(255, 255, 255, .05);
  border-left: 2px solid var(--brand);
  border-radius: 0 6px 6px 0;
  font-size: 12.5px; line-height: 1.6; color: var(--rail-text);
}
.code-note code {
  font-family: var(--mono); font-size: 11.5px;
  background: rgba(255, 255, 255, .1); color: #e2ebff;
  padding: 1px 4px; border-radius: 3px;
}

/* ── highlight.js palette tuned for the rail ───────────────── */

.hljs-comment, .hljs-quote { color: #7f90b8; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-type { color: #8fc4ff; }
.hljs-string, .hljs-attr, .hljs-meta .hljs-string { color: #8ee0b0; }
.hljs-number, .hljs-symbol, .hljs-bullet { color: #f5b97a; }
.hljs-attribute, .hljs-name, .hljs-title, .hljs-section { color: #7fd6f0; }
.hljs-variable, .hljs-template-variable { color: #e7bdf0; }
.hljs-built_in, .hljs-class .hljs-title { color: #9ed3ff; }
.hljs-meta { color: #a4b3d6; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

/* ── footer ────────────────────────────────────────────────── */

.page-foot {
  grid-column: 1 / 2;
  margin: 60px var(--gutter) 0;
  padding: 22px 0 60px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--faint);
}

.loading { padding: 60px var(--gutter); color: var(--faint); }

/* ── responsive ────────────────────────────────────────────── */

@media (max-width: 1180px) {
  :root { --code-w: 380px; --toc-w: 228px; --gutter: 32px; }
}

/* stack the code column under the prose and drop the rail */
@media (max-width: 950px) {
  .dark-rail { display: none; }
  .toc {
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: 280px;
  }
  body.nav-open .toc { transform: none; }
  .mobile-bar { display: flex; }
  .page { margin-left: 0; }

  .lang-bar {
    position: sticky; top: 55px; width: auto;
    margin: 0 0 4px; border-radius: 0;
    border-bottom: 1px solid var(--rail-line);
  }

  .row { display: block; }
  .row > .prose { padding: 0 20px; }
  .row > .code {
    padding: 0; margin: 4px 0 8px;
  }
  .row > .code:not(:empty) {
    background: var(--rail); border-radius: 10px;
    padding: 16px 16px 18px; margin: 10px 20px 22px;
  }
  .page > .content > .row:first-child > .code,
  .page > .content > .row:first-child > .prose { padding-top: 22px; }
  .page > .content > .row:first-child > .code { margin-top: 10px; }

  .page-foot { margin: 40px 20px 0; }
  .row.op-row { scroll-margin-top: 100px; }
  .row.op-row > .code, .row.tag-row + .row.op-row > .code { padding-top: 16px; }
}

@media (max-width: 560px) {
  .prose h1 { font-size: 22px; }
  .op-title { font-size: 17px; }
  th, td { font-size: 12.5px; }
  .endpoint { font-size: 11.5px; }
}
