/* 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. */

/* Block padding only: the sides are .wrap's gutter. */
.dev { padding-top: clamp(2rem, 5vw, 3.5rem); padding-bottom: 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); }
/* The clay a step darker on its own tint, so the current page clears AA. */
.dev-nav a[aria-current="page"] { color: var(--accent-hover); background: var(--accent-soft); font-weight: 600; }

/* On a phone the sidebar folds into one line above the title: "Docs menu", the
   page you are on, and the whole menu a tap away. The desktop sidebar and the
   folded one are the same links; only one is ever displayed. */
.dev-nav-fold { display: none; }
@media (max-width: 900px) {
  .dev-layout > .dev-nav { display: none; }
  .dev-nav-fold {
    display: block; margin: 0 0 var(--s-5);
    border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface);
  }
  .dev-nav-fold > summary {
    display: flex; align-items: center; gap: var(--s-3); min-height: 48px; padding: 0 var(--s-4);
    cursor: pointer; list-style: none; font-size: .95rem; color: var(--ink);
  }
  .dev-nav-fold > summary::-webkit-details-marker { display: none; }
  .dev-nav-fold > summary .eyebrow { flex: 0 0 auto; }
  .dev-nav-fold > summary strong { flex: 1 1 auto; min-width: 0; font-weight: 600;
                                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dev-nav-fold > summary::after {
    content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin: -4px 2px 0 0;
    border: solid var(--ink-soft); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
    transition: transform var(--t-state) var(--ease);
  }
  .dev-nav-fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
  .dev-nav-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-card); }
  .dev-nav-fold > nav { padding: 0 var(--s-4) var(--s-4); border-top: 1px solid var(--line); font-size: .95rem; }
  .dev-nav-fold .eyebrow { margin: var(--s-4) 0 var(--s-1); }
  .dev-nav-fold ul { list-style: none; margin: 0; padding: 0; }
  .dev-nav-fold a { display: block; padding: 9px 0; color: var(--ink-soft); text-decoration: none; }
  .dev-nav-fold a[aria-current="page"] { color: var(--accent-hover); font-weight: 600; }
}

/* ---- 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; flex-wrap: wrap; align-items: center; gap: 0 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; }
/* A group's name has a row of its own above the tabs, whole: it never
   squeezes the tabs, and the tabs never cut it to "Reward a surv…". */
.code-group > .code-head > .code-label {
  /* The head's padding bleeds out (the negative margins), and the basis adds it back, so the label's outer
     size is exactly the row: nothing else ever fits beside it. */
  flex: 0 0 calc(100% + var(--s-4) + var(--s-2)); white-space: normal; line-height: 1.45; padding: .6rem 0 .55rem;
  margin: 0 calc(-1 * var(--s-2)) 0 calc(-1 * var(--s-4)); padding-left: var(--s-4); padding-right: var(--s-2);
  border-bottom: 1px solid var(--code-border);
}

/* Every language is always in sight: on a narrow block the tabs wrap onto a
   second row rather than scrolling some of them out of view. */
.code-tablist {
  display: flex; flex-wrap: wrap; flex: 1 1 0; min-width: 0; gap: 0 var(--s-4);
}
.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; }
/* With JavaScript the button is coming (docs.js shows it once it works): hold its room, so the tabs never
   reflow around it as it appears. */
.has-js .code-copy[hidden] { display: block; visibility: hidden; }
.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; }
/* Beside tabs that wrap to a second row, the button stays level with the first. */
.code-group > .code-head > .code-copy { align-self: flex-start; margin-top: 4px; }
.code-copy.is-copied { color: var(--code-tab-active); }

/* A panel's language, named: shown only without JavaScript, when the tabs
   cannot work and only the first language is there (_base.html's <noscript>). */
.code-caption {
  display: none; 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-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); }
  .code-group > .code-head > .code-label { flex-basis: calc(100% + var(--s-3) + var(--s-2));
                                           margin-left: calc(-1 * var(--s-3)); padding-left: var(--s-3); }
  .code-tablist { gap: 0 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);
}
/* Each verb's ink a step darker than its tint's hue, so the small caps clear AA. */
.verb.is-post { background: var(--accent-soft); color: var(--accent-hover); }
.verb.is-patch, .verb.is-put { background: var(--warning-soft); color: color-mix(in srgb, var(--warning) 80%, var(--ink)); }
.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); line-height: 1.35; }
/* Six cards sit three and three, never four and an orphaned two. */
.dev-cards.is-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .dev-cards.is-three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .dev-cards.is-three { grid-template-columns: minmax(0, 1fr); } }
.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; }
/* On a phone a step's code takes the column's whole width, not the width
   left beside the step's number. */
@media (max-width: 600px) {
  /* Out past the number's gutter and the list's own indent, to the text column's edge. */
  .dev-body .dev-steps > li > :is(.code-block, .scene) {
    --step-indent: calc(2.6rem + 1.25rem);
    margin-left: calc(-1 * var(--step-indent)); width: calc(100% + var(--step-indent)); max-width: none;
  }
}

.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; }

/* ---- the docs sidebar: a trace down to the page you are on --------------------------- */
@media (min-width: 901px) {
  .dev-nav[data-trace] { --trace-to: 0px; position: sticky; padding-left: 18px; }
  .dev-nav[data-trace]::before {
    content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 1px;
    background: linear-gradient(to bottom, rgba(180, 67, 31, .5) 0, rgba(180, 67, 31, .5) var(--trace-to),
                                var(--line-strong) var(--trace-to));
  }
  .dev-nav[data-trace] a { position: relative; }
  .dev-nav[data-trace] a[aria-current="page"]::before {
    content: ""; position: absolute; left: -8px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px;
    border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--ground);
  }
  .dev-nav[data-trace] a:hover::before {
    content: ""; position: absolute; left: -6px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px;
    border-radius: 50%; background: var(--accent-line);
  }
  .dev-nav[data-trace] a[aria-current="page"]:hover::before { left: -8px; width: 9px; height: 9px; margin-top: -4.5px;
                                                              background: var(--accent); }
  .dev-nav.has-trace::after {
    content: ""; position: absolute; left: 3px; top: 0; width: 3px; height: 26px; border-radius: 2px;
    background: linear-gradient(to bottom, transparent, var(--accent)); opacity: 0; pointer-events: none;
  }
}
@media (min-width: 901px) and (prefers-reduced-motion: no-preference) {
  .dev-nav.has-trace::after { animation: sc-trace 1100ms cubic-bezier(.45, 0, .2, 1) 200ms both; }
}
@keyframes sc-trace {
  0% { opacity: 0; transform: translateY(0); }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translateY(calc(var(--trace-to) - 22px)); }
}
