/* ===========================================================================
   Skylens Developer Portal
   ---------------------------------------------------------------------------
   Self-contained: no CDN, no font download, no build step (ADR 0025 forbids a
   deploy-time build). Firebase Hosting serves this file directly.

   Theme: the viewer is a dark product, so dark is the default. Light is offered
   because API docs are read in daylight, in an IDE, and printed.
   =========================================================================== */

:root {
  color-scheme: dark;

  --bg:            #0a0f1a;
  --bg-elev:       #101827;
  --bg-sunken:     #070c16;
  --panel:         #0e1626;
  --border:        rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.30);

  --text:          #e6edf7;
  --text-dim:      #9fb0c7;
  --text-faint:    #6b7d96;

  --accent:        #38bdf8;
  --accent-soft:   rgba(56, 189, 248, 0.14);
  --accent-line:   rgba(56, 189, 248, 0.45);

  --get:     #34d399;
  --post:    #38bdf8;
  --put:     #fbbf24;
  --patch:   #c084fc;
  --delete:  #f87171;

  --stable:  #34d399;
  --beta:    #fbbf24;
  --planned: #94a3b8;

  --radius:   10px;
  --radius-sm: 6px;
  --header-h: 60px;
  --sidebar-w: 274px;
  --maxw: 1000px;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo,
          Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg:            #ffffff;
  --bg-elev:       #f6f8fb;
  --bg-sunken:     #f1f5f9;
  --panel:         #ffffff;
  --border:        rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.24);
  --text:          #0f172a;
  --text-dim:      #475569;
  --text-faint:    #64748b;
  --accent:        #0369a1;
  --accent-soft:   rgba(3, 105, 161, 0.09);
  --accent-line:   rgba(3, 105, 161, 0.40);
  --get:     #047857;
  --post:    #0369a1;
  --put:     #b45309;
  --patch:   #7c3aed;
  --delete:  #b91c1c;
  --stable:  #047857;
  --beta:    #b45309;
  --planned: #64748b;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

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

/* Paths, JSON, code and identifiers are LTR regardless of surrounding prose.
   `isolate` keeps a Hebrew sentence from reordering an embedded path. */
code, pre, .path, .method, .mono, kbd, input[type="text"], input[type="url"] {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: var(--mono);
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: #04121f; padding: 10px 16px;
  border-radius: var(--radius-sm); font-weight: 650;
  transition: top .15s;
}
.skip-link:focus { top: 8px; }

/* ---------------------------------------------------------------- header -- */

.hdr {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: baseline; gap: 9px; text-decoration: none; color: inherit; flex: none; }
.brand:hover { text-decoration: none; }
.brand b { font-size: 16px; font-weight: 680; letter-spacing: -0.01em; }
.brand .mark { color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 11px; line-height: 1;
  padding: 4px 7px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-dim);
  white-space: nowrap;
}

.hdr-search { flex: 1 1 auto; max-width: 420px; margin-left: auto; position: relative; }
.hdr-search input {
  width: 100%; height: 34px; padding: 0 62px 0 11px;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--sans);
}
.hdr-search input::placeholder { color: var(--text-faint); }
.hdr-search input:focus { border-color: var(--accent-line); outline: none; }
.hdr-search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; padding: 2px 5px; border-radius: 4px;
  border: 1px solid var(--border-strong); color: var(--text-faint);
  pointer-events: none;
}

.hdr-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 10px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 12.5px; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.btn.primary { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

select.env {
  height: 30px; padding: 0 8px;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 12.5px; cursor: pointer; max-width: 190px;
}

#navToggle { display: none; }

/* ----------------------------------------------------------------- shell -- */

.shell { display: flex; align-items: flex-start; }

#sidebar {
  position: sticky; top: var(--header-h);
  width: var(--sidebar-w); flex: none;
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 10px 60px 16px;
  border-right: 1px solid var(--border);
}
#sidebar h2 {
  margin: 18px 0 6px; padding: 0 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-faint);
}
#sidebar h2:first-child { margin-top: 0; }
#sidebar a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px; line-height: 1.4;
}
#sidebar a:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
#sidebar a[aria-current="true"] {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
#sidebar .count {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-faint);
  background: var(--bg-sunken); border-radius: 999px; padding: 1px 6px;
  flex: none;
}

main {
  flex: 1 1 auto; min-width: 0;
  padding: 30px 34px 140px;
}
.wrap { max-width: var(--maxw); }

/* ---------------------------------------------------------------- typo ---- */

h1 { font-size: 30px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 10px; font-weight: 700; }
h2.section {
  font-size: 21px; letter-spacing: -0.01em; font-weight: 670;
  margin: 54px 0 8px; padding-top: 14px; border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-h) + 16px);
}
h2.section:first-of-type { border-top: 0; margin-top: 26px; padding-top: 0; }
h3 { font-size: 15.5px; font-weight: 650; margin: 24px 0 6px; }
p { margin: 0 0 12px; }
.lede { color: var(--text-dim); font-size: 16px; max-width: 68ch; }
.muted { color: var(--text-dim); }
.small { font-size: 13px; }
ul, ol { margin: 0 0 12px; padding-left: 20px; }
li { margin: 3px 0; }

p code, li code, td code, .note code {
  background: var(--bg-sunken); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; font-size: 0.88em;
}

table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 13.5px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.scroll-x { overflow-x: auto; max-width: 100%; }

.note {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--bg-elev); border-radius: var(--radius);
  padding: 12px 14px; margin: 14px 0; font-size: 13.5px;
}
.note.warn { border-left-color: var(--put); }
.note.stop { border-left-color: var(--delete); }
.note strong { display: block; margin-bottom: 3px; }

/* --------------------------------------------------------------- badges --- */

.method {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; padding: 2px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  border: 1px solid currentColor; background: transparent; flex: none;
}
.m-get    { color: var(--get); }
.m-post   { color: var(--post); }
.m-put    { color: var(--put); }
.m-patch  { color: var(--patch); }
.m-delete { color: var(--delete); }

.status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; border: 1px solid currentColor;
}
.s-stable  { color: var(--stable); }
.s-beta    { color: var(--beta); }
.s-planned { color: var(--planned); }

.tagline { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 0; }
.chip {
  font-size: 11.5px; font-family: var(--mono);
  padding: 2px 7px; border-radius: 5px;
  background: var(--bg-sunken); border: 1px solid var(--border); color: var(--text-dim);
}
.chip b { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------- endpoints -- */

.op {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); margin: 12px 0; overflow: hidden;
  scroll-margin-top: calc(var(--header-h) + 16px);
}
.op:target, .op.is-linked { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line); }

.op-head {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 11px 14px; text-align: left;
  background: transparent; border: 0; color: inherit;
  font: inherit; cursor: pointer;
}
.op-head:hover { background: var(--bg-elev); }
.op-head .path {
  font-size: 13.5px; font-weight: 550; overflow-wrap: anywhere; flex: 1 1 auto; min-width: 0;
}
.op-head .path .var { color: var(--accent); }
.op-head .caret { flex: none; color: var(--text-faint); transition: transform .16s; }
.op-head[aria-expanded="true"] .caret { transform: rotate(90deg); }
.op-summary {
  padding: 0 14px 10px 80px; margin-top: -4px;
  color: var(--text-dim); font-size: 13px;
}
.op-body { padding: 4px 14px 16px; border-top: 1px solid var(--border); }
.op-body[hidden] { display: none; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 14px; font-size: 13.5px; margin: 12px 0; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; }

/* ----------------------------------------------------------------- code --- */

.code {
  position: relative; margin: 8px 0 4px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.code pre {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  font-size: 12.5px; line-height: 1.62; tab-size: 2;
}
.code .copy {
  position: absolute; top: 7px; right: 7px;
  height: 26px; padding: 0 9px; font-size: 11.5px;
  background: var(--panel); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; opacity: 0; transition: opacity .12s;
}
.code:hover .copy, .code .copy:focus-visible { opacity: 1; }
.code .copy.ok { color: var(--get); border-color: var(--get); opacity: 1; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 16px 0 0; flex-wrap: wrap; }
.tabs button {
  padding: 6px 12px; background: transparent; border: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-faint); font: inherit; font-size: 13px; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* token colours — deliberately low-contrast-safe in both themes */
.t-str  { color: #7ee2b8; }
.t-num  { color: #f0b072; }
.t-key  { color: #7cc7f5; }
.t-kw   { color: #c9a3f8; }
.t-com  { color: var(--text-faint); font-style: italic; }
.t-fn   { color: #f5d67c; }
:root[data-theme="light"] .t-str { color: #0f766e; }
:root[data-theme="light"] .t-num { color: #b45309; }
:root[data-theme="light"] .t-key { color: #0369a1; }
:root[data-theme="light"] .t-kw  { color: #7c3aed; }
:root[data-theme="light"] .t-fn  { color: #a16207; }

/* --------------------------------------------------------------- try it --- */

.tryit { margin: 18px 0 0; padding: 13px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.tryit h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); }
.tryit .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.tryit label { font-size: 12.5px; color: var(--text-dim); min-width: 108px; }
.tryit input {
  flex: 1 1 220px; min-width: 0; height: 30px; padding: 0 9px;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.tryit .out { margin-top: 10px; }
.tryit .disabled-reason { color: var(--text-dim); font-size: 13px; }

/* ------------------------------------------------------------ utilities --- */

.hidden { display: none !important; }
.searching .guide-only { display: none; }
#noResults { padding: 30px 0; color: var(--text-dim); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- mobile -- */

@media (max-width: 900px) {
  /* Two rows: controls, then a full-width search. One row cannot hold the
     brand, the environment picker and a usable search field at 375px — the
     search ends up ~50px wide and the actions push the document sideways. */
  :root { --header-h: 100px; }
  #navToggle { display: inline-flex; order: -1; }
  .hdr {
    height: auto; min-height: var(--header-h);
    flex-wrap: wrap; align-content: center;
    gap: 8px; padding: 8px 12px;
  }
  .brand b { font-size: 15px; }
  .hdr .pill.version, .hdr .desktop-only { display: none; }
  .hdr-actions { margin-left: auto; }
  .hdr-search { order: 10; flex: 1 0 100%; max-width: none; margin-left: 0; min-width: 0; }
  .hdr-search kbd { display: none; }
  select.env { max-width: 150px; }

  .shell { display: block; }
  #sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0;
    width: min(86vw, 320px); height: auto; z-index: 39;
    background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-102%); transition: transform .18s ease;
  }
  #sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .5); }
  main { padding: 22px 16px 120px; }
  h1 { font-size: 24px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dt { margin-top: 8px; }
  .op-head { flex-wrap: wrap; }
  .op-summary { padding-left: 14px; }
  #scrim.open {
    position: fixed; inset: var(--header-h) 0 0 0; z-index: 38;
    background: rgba(0, 0, 0, .5);
  }
}

@media print {
  .hdr, #sidebar, .tryit, .copy, #scrim { display: none !important; }
  .op-body { display: block !important; }
  main { padding: 0; }
  body { background: #fff; color: #000; }
}
