/* Jusa for Developers: the docs site (templates/developers/).
 *
 * ON THE DAY throughout: the grey paper ground, clay for links and the one
 * primary action, Fraunces only on page titles, IBM Plex Mono for every
 * path, code and numeral. Outside the code blocks no colour is declared here
 * that airtime.css does not already name; the blocks' token colours are their
 * own custom properties (below), light and dark. */

.dev { padding: clamp(2rem, 5vw, 3.5rem) 0 var(--section-pad); }
.dev-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}
@media (max-width: 900px) {
  /* minmax(0, …): a wide code sample scrolls inside itself, never widens the page. */
  .dev-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---- the sidebar ------------------------------------------------------------ */
.dev-nav {
  position: sticky; top: var(--s-5);
  font-size: var(--t-sm, .92rem);
  max-height: calc(100vh - 2 * var(--s-5)); overflow-y: auto;
  padding-right: var(--s-2);
}
.dev-nav .eyebrow { margin: var(--s-5) 0 var(--s-2); }
.dev-nav .eyebrow:first-child { margin-top: 0; }
.dev-nav ul { list-style: none; margin: 0; padding: 0; }
.dev-nav a {
  display: block; padding: 5px 10px; margin-left: -10px;
  border-radius: var(--r-ctl);
  color: var(--ink-soft); text-decoration: none;
}
.dev-nav a:hover { color: var(--accent); background: var(--accent-soft); }
.dev-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
@media (max-width: 900px) {
  .dev-nav { position: static; max-height: none; border-bottom: 1px solid var(--line); padding-bottom: var(--s-4); }
  .dev-nav ul { display: flex; flex-wrap: wrap; gap: 2px 12px; }
  .dev-nav a { margin-left: 0; padding: 4px 0; }
}

/* ---- the page ------------------------------------------------------------------ */
.dev-head { margin-bottom: var(--s-6); max-width: 46rem; }
.dev-head h1 {
  font-family: var(--f-display);
  font-variation-settings: 'opsz' 72, 'SOFT' 20, 'WONK' 0;
  font-weight: 600; font-size: clamp(2rem, 4.2vw, 3rem);
  line-height: 1.04; letter-spacing: -.024em;
  margin: var(--s-2) 0 var(--s-3); color: var(--ink);
}
.dev-head .lede { margin: 0; color: var(--ink-soft); font-size: 1.125rem; line-height: 1.55; }

.dev-body { max-width: 46rem; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.68; }
.dev-body.is-wide { max-width: 64rem; }
.dev-body h2 {
  font-family: var(--f-body); font-weight: 600; font-size: 1.4rem; letter-spacing: -.012em;
  color: var(--ink); margin: var(--s-7) 0 var(--s-3); scroll-margin-top: var(--s-5);
}
.dev-body h3 {
  font-family: var(--f-body); font-weight: 600; font-size: 1.1rem;
  color: var(--ink); margin: var(--s-5) 0 var(--s-2); scroll-margin-top: var(--s-5);
}
.dev-body h2:first-child, .dev-body h3:first-child { margin-top: 0; }
.dev-body p { margin: 0 0 var(--s-4); }
.dev-body ul, .dev-body ol { margin: 0 0 var(--s-4); padding-left: 1.25rem; }
.dev-body li { margin: 0 0 var(--s-2); }
.dev-body li::marker { color: var(--accent); }
.dev-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
              text-decoration-color: var(--accent-line); }
.dev-body strong { color: var(--ink); font-weight: 600; }
.dev-body code {
  font-family: var(--f-num); font-size: .86em;
  background: var(--ground-2); border-radius: 5px; padding: 1px 5px; color: var(--ink);
}
/* A long event type or path breaks rather than widening a phone's page. */
.dev-body :not(pre) > code { overflow-wrap: anywhere; }

/* Tables: hairlines, mono keys. They scroll inside themselves on a phone. */
.dev-table { width: 100%; overflow-x: auto; margin: 0 0 var(--s-5); }
.dev-body table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.dev-body th, .dev-body td { text-align: left; padding: .55rem .6rem .55rem 0; border-bottom: 1px solid var(--line);
                             vertical-align: top; }
.dev-body th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
               font-weight: 700; border-bottom-color: var(--line-strong); }
.dev-body td:first-child code { white-space: nowrap; }
.dev-body tr:target td { background: var(--accent-soft); }

/* Callouts: the accent bar says "read this first", nothing else. */
.callout { border-left: 3px solid var(--accent); background: var(--surface); padding: var(--s-3) var(--s-4);
           border-radius: 0 var(--r-ctl) var(--r-ctl) 0; margin: 0 0 var(--s-5); }
.callout p:last-child { margin-bottom: 0; }
.callout.is-quiet { border-left-color: var(--line-strong); }

/* ---- code samples ---------------------------------------------------------------
 *
 * Highlighted on the server (developers/docs_highlight.py): each token is a
 * .tk-<class>, each line a .ln. Light: the paper, one step brighter than the
 * page. Dark (the reader's setting, or data-theme="dark"): the night ground.
 * Every token colour clears WCAG AA (4.5:1) on the block and on a marked
 * line, in both modes; developers/tests/test_docs_code.py measures it from
 * these variables. Keywords take the clay; green, which only ever means
 * "this is live", is never a token colour. */
:root {
  --code-bg:         #FAFBF9;
  --code-head-bg:    #EEF0EB;
  --code-border:     #E0E2DC;
  --code-ink:        #171C1A;   /* plain text             16.6:1 */
  --code-head-ink:   #5A6560;   /* tab names, the label    5.3:1 on the head */
  --code-tab-active: #B4431F;
  --code-mark-bg:    #F5EAE4;   /* a line a sample points at */
  --code-mark-bar:   #B4431F;
  --code-c: #5A6560;   /* comments                 5.8:1 */
  --code-k: #B4431F;   /* keywords: the clay       5.4:1 */
  --code-s: #84590C;   /* strings: ochre           5.9:1 */
  --code-n: #97213B;   /* numbers, true/null       7.8:1 */
  --code-f: #2A323B;   /* functions: logo navy    12.5:1 */
  --code-t: #2A323B;   /* types and classes       12.5:1 */
  --code-p: #3D5A73;   /* keys, attributes         7.0:1 */
  --code-v: #7B3B6E;   /* variables, ${…}          7.5:1 */
  --code-o: #4F5955;   /* operators, punctuation   7.0:1 */
  --code-m: #8F3317;   /* decorators, escapes      7.6:1 */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --code-bg:         #161B20;
    --code-head-bg:    #1E252B;
    --code-border:     #2E363E;
    --code-ink:        #E6E9E4;
    --code-head-ink:   #9AA3A8;
    --code-tab-active: #F0805A;
    --code-mark-bg:    #2B2321;
    --code-mark-bar:   #F0805A;
    --code-c: #9AA3A8;
    --code-k: #F0805A;
    --code-s: #E0B25A;
    --code-n: #EE8FA4;
    --code-f: #F2F3F0;
    --code-t: #F2F3F0;
    --code-p: #A9C1D6;
    --code-v: #D9A8CF;
    --code-o: #B7BFC2;
    --code-m: #F79274;
  }
}
:root[data-theme="dark"] {
  --code-bg:         #161B20;
  --code-head-bg:    #1E252B;
  --code-border:     #2E363E;
  --code-ink:        #E6E9E4;
  --code-head-ink:   #9AA3A8;
  --code-tab-active: #F0805A;
  --code-mark-bg:    #2B2321;
  --code-mark-bar:   #F0805A;
  --code-c: #9AA3A8;
  --code-k: #F0805A;
  --code-s: #E0B25A;
  --code-n: #EE8FA4;
  --code-f: #F2F3F0;
  --code-t: #F2F3F0;
  --code-p: #A9C1D6;
  --code-v: #D9A8CF;
  --code-o: #B7BFC2;
  --code-m: #F79274;
}

.code-block {
  margin: 0 0 var(--s-5); min-width: 0; max-width: 100%;
  border: 1px solid var(--code-border); border-radius: var(--r-card);
  background: var(--code-bg); overflow: hidden;
}
.dev-steps .code-block, li .code-block { margin-top: var(--s-3); }
.code-head {
  display: flex; align-items: center; gap: var(--s-3); min-width: 0;
  padding: 0 var(--s-2) 0 var(--s-4); min-height: 2.5rem;
  background: var(--code-head-bg); border-bottom: 1px solid var(--code-border);
  font: 500 .72rem/1 var(--f-num); letter-spacing: .06em; color: var(--code-head-ink);
}
.code-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
              padding: .85rem 0; }
.code-tablist + .code-label { flex: 0 1 auto; order: -1; padding-right: var(--s-2);
                              border-right: 1px solid var(--code-border); }

/* The tabs scroll sideways inside the head on a phone; the page never does. */
.code-tablist {
  display: flex; flex: 1 1 auto; min-width: 0; gap: var(--s-4);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.code-tablist::-webkit-scrollbar { display: none; }
.code-tablist[hidden] { display: none; }
.code-tablist [role="tab"] {
  appearance: none; background: none; border: 0; cursor: pointer; flex: 0 0 auto;
  padding: .85rem 0 calc(.85rem - 2px); border-bottom: 2px solid transparent;
  font: inherit; letter-spacing: inherit; color: var(--code-head-ink); white-space: nowrap;
}
.code-tablist [role="tab"]:hover { color: var(--code-ink); }
.code-tablist [role="tab"][aria-selected="true"] { color: var(--code-tab-active); border-bottom-color: var(--code-tab-active); }
.code-tablist [role="tab"]:focus-visible { outline: 2px solid var(--code-tab-active); outline-offset: -2px; border-radius: 4px; }

.code-copy {
  flex: 0 0 auto; margin-left: auto;
  appearance: none; cursor: pointer; border: 1px solid transparent; border-radius: var(--r-ctl);
  background: none; padding: 6px 10px; min-height: 32px;
  font: inherit; letter-spacing: inherit; color: var(--code-head-ink);
}
.code-copy[hidden] { display: none; }
.code-copy:hover { color: var(--code-ink); border-color: var(--code-border); }
.code-copy:focus-visible { outline: 2px solid var(--code-tab-active); outline-offset: 1px; }
.code-copy.is-copied { color: var(--code-tab-active); }

/* Without JavaScript every language shows, one after another, each named. */
.code-caption {
  margin: 0; padding: var(--s-3) var(--s-4) 0;
  font: 600 .68rem/1 var(--f-num); letter-spacing: .12em; text-transform: uppercase; color: var(--code-head-ink);
}
.code-group.is-tabbed .code-caption { display: none; }
.code-group:not(.is-tabbed) .code-panel + .code-panel { border-top: 1px solid var(--code-border); }
.code-panel[hidden] { display: none; }

/* No wrapping: a long line scrolls inside its block. */
pre.code {
  margin: 0; padding: var(--s-4) 0; background: var(--code-bg); color: var(--code-ink);
  font-family: var(--f-num); font-size: .8rem; line-height: 1.7; tab-size: 4;
  white-space: pre; overflow-x: auto; overscroll-behavior-x: contain;
}
pre.code:focus-visible { outline: 2px solid var(--code-tab-active); outline-offset: -2px; }
pre.code code {
  display: block; width: max-content; min-width: 100%;
  font: inherit; background: none; padding: 0; border-radius: 0; color: inherit;
}
pre.code .ln { display: block; padding: 0 var(--s-5); }
pre.code .ln.is-marked { background: var(--code-mark-bg); box-shadow: inset 3px 0 0 var(--code-mark-bar); }
.tk-c { color: var(--code-c); font-style: italic; }
.tk-k { color: var(--code-k); }
.tk-s { color: var(--code-s); }
.tk-n { color: var(--code-n); }
.tk-f { color: var(--code-f); font-weight: 500; }
.tk-t { color: var(--code-t); font-weight: 600; }
.tk-p { color: var(--code-p); }
.tk-v { color: var(--code-v); }
.tk-o { color: var(--code-o); }
.tk-m { color: var(--code-m); }
@media (max-width: 560px) {
  pre.code { font-size: .76rem; }
  pre.code .ln { padding: 0 var(--s-4); }
  .code-head { padding-left: var(--s-3); }
}

/* Verbs and paths. */
.verb {
  display: inline-block; min-width: 3.6rem; text-align: center;
  padding: 3px 6px; border-radius: 6px;
  font: 600 .66rem/1.2 var(--f-num); letter-spacing: .12em; text-transform: uppercase;
  background: var(--info-soft); color: var(--ink-2);
}
.verb.is-post { background: var(--accent-soft); color: var(--accent); }
.verb.is-patch, .verb.is-put { background: var(--warning-soft); color: var(--warning); }
.verb.is-delete { background: var(--danger-soft); color: var(--danger); }
.path { font-family: var(--f-num); font-size: .88rem; color: var(--ink); word-break: break-all; }

/* Cards: a grid of doors into the docs. */
.dev-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s-4);
             margin: 0 0 var(--s-6); }
.dev-card {
  display: block; padding: var(--s-4) var(--s-5); border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--surface); text-decoration: none; color: inherit;
  transition: border-color var(--t-state) var(--ease);
}
.dev-card:hover { border-color: var(--accent-line); }
.dev-card .eyebrow { margin-bottom: var(--s-2); }
.dev-card strong { display: block; color: var(--ink); font-size: 1.02rem; margin-bottom: 4px; }
.dev-card span { color: var(--ink-soft); font-size: .92rem; line-height: 1.5; }
.dev-body .dev-card { text-decoration: none; }

/* The reference: one row per operation. */
.op { border-top: 1px solid var(--line); padding: var(--s-5) 0; scroll-margin-top: var(--s-5); }
.op-head { display: flex; gap: var(--s-3); align-items: baseline; flex-wrap: wrap; }
.op-head h3 { margin: 0; font-size: 1.02rem; }
.op-meta { display: flex; gap: var(--s-2); flex-wrap: wrap; margin: var(--s-2) 0 var(--s-3); }
.op-meta .tag { font-family: var(--f-num); font-size: .66rem; letter-spacing: .08em; }
.fields { font-size: .9rem; }
.fields td:first-child { width: 34%; }
.req { color: var(--accent); font-family: var(--f-num); font-size: .7rem; letter-spacing: .08em;
       text-transform: uppercase; }

.dev-steps { counter-reset: step; list-style: none; padding: 0; }
.dev-steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin-bottom: var(--s-6); }
.dev-steps > li::before {
  content: counter(step); position: absolute; left: 0; top: .1rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; border: 1px solid var(--line-strong);
  display: grid; place-items: center; font: 600 .78rem/1 var(--f-num); color: var(--ink-2);
}
.dev-steps > li > h3 { margin-top: 0; }

.dev-foot-nav { display: flex; justify-content: space-between; gap: var(--s-4); margin-top: var(--s-8);
                padding-top: var(--s-5); border-top: 1px solid var(--line); }
.dev-foot-nav a { color: var(--accent); text-decoration: none; font-weight: 600; }
