/* /developers: the public API guide, set as a printed technical manual.
   Numbered chapters with the numeral hung in a ruled box, numbered sections
   (2.1), margin notes beside the text on wide screens, monospaced listings
   with a label tab, a live console (assets/js/developers.js), embed previews
   and revision notes. Builds on the tokens in site.css; dark mode comes
   from theme.css (the listings are dark in both themes). */

.dv {
  --dv-paper: #FCFBF8;
  --dv-rule: #2A1B45;
  --dv-note: #F6F1E4;
  --dv-note-edge: #C9A15A;
  --dv-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
  padding: var(--s-4) 0 var(--s-5);
  background: var(--dv-paper);
}
:root[data-theme="dark"] .dv { --dv-paper: #17121F; --dv-rule: #CDB8EA; --dv-note: #221B2E; --dv-note-edge: #B8954F; }

/* The manual's plate under the title. */
.dv-plate { display: flex; flex-wrap: wrap; gap: 0 1.2rem; margin: var(--s-2) 0 0; font: 600 0.72rem/1.8 var(--dv-mono, monospace); letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-ink-muted); }
.dv-plate span + span::before { content: "/"; margin-right: 1.2rem; opacity: 0.5; }

.dv-grid { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); gap: var(--s-4); align-items: start; }

/* Contents */
.dv-toc { position: sticky; top: calc(var(--header-h) + 1rem); font-size: 0.9rem; }
.dv-toc-h { margin: 0 0 0.6rem; padding-bottom: 0.4rem; font: 600 0.72rem/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink); border-bottom: 2px solid var(--dv-rule); }
.dv-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.dv-toc a { display: flex; gap: 0.6rem; padding: 0.3rem 0; color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--line); }
.dv-toc a:hover, .dv-toc a[aria-current="true"] { color: var(--ink); }
.dv-toc a[aria-current="true"] .dv-toc-n { color: var(--paper); background: var(--ink); }
.dv-toc-n { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; font: 600 0.74rem/1 var(--dv-mono); color: var(--ink); border: 1px solid var(--dv-rule); }

/* Chapters: the numeral in a box, a heavy rule, then a hairline. */
.dv-body { min-width: 0; max-width: 64rem; counter-reset: none; }
.dv-section {
  display: grid; grid-template-columns: minmax(0, 1fr) 13.5rem; column-gap: 2.25rem; align-content: start;
  padding-bottom: var(--s-3); margin-bottom: var(--s-4); scroll-margin-top: calc(var(--header-h) + 1rem);
}
.dv-section > * { grid-column: 1; min-width: 0; }
.dv-h {
  display: flex; align-items: stretch; gap: 0.9rem; margin: 0 0 1.1rem; padding: 0 0 0.6rem;
  font-family: var(--font-serif); font-weight: 500; font-size: clamp(1.5rem, 2.4vw, 2rem); letter-spacing: -0.01em; line-height: 1.15; color: var(--ink);
  border-bottom: 3px double var(--dv-rule);
}
.dv-section > .dv-h { grid-column: 1 / -1; }
.dv-h-n {
  display: inline-grid; place-items: center; flex: none; width: 2.6rem; min-height: 2.6rem;
  font: 600 1.35rem/1 var(--dv-mono); color: var(--dv-paper); background: var(--dv-rule);
}
.dv-sub { margin: 1.5rem 0 0.6rem; font: 600 0.98rem/1.3 var(--font); color: var(--ink); letter-spacing: 0; }
.dv-sub-n { margin-right: 0.35rem; font-family: var(--dv-mono); font-weight: 600; color: var(--accent-dark); }
.dv-section p, .dv-section li { font-size: 1rem; line-height: 1.65; }
.dv-section ul { padding-left: 1.2rem; }
.dv-section li + li { margin-top: 0.4rem; }
.dv-small { font-size: 0.9rem !important; color: var(--muted); }

/* Margin notes: in the right-hand column beside the text before them. */
.dv-section > .dv-margin {
  grid-column: 2; grid-row: span 3; align-self: start; margin: 0.2rem 0 1rem; padding: 0.7rem 0.85rem 0.75rem;
  font-size: 0.84rem; line-height: 1.5; color: var(--text);
  background: var(--dv-note); border-left: 3px solid var(--dv-note-edge);
}
.dv-margin-k { display: block; margin-bottom: 0.2rem; font: 700 0.66rem/1.2 var(--font); letter-spacing: 0.16em; text-transform: uppercase; color: #7A5A1C; }
:root[data-theme="dark"] .dv-margin-k { color: #D9B866; }
.dv-margin a { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

/* Monospaced text and listings. */
.dv code { font-family: var(--dv-mono); font-size: 0.86em; }
.dv p code, .dv li code, .dv td code { padding: 0.05em 0.3em; border-radius: 2px; background: var(--mist); color: var(--ink); overflow-wrap: anywhere; }
.dv-listing { position: relative; margin: 0.6rem 0 1.1rem; }
.dv-listing-label {
  display: inline-block; padding: 0.22rem 0.6rem 0.18rem; font: 600 0.66rem/1.2 var(--dv-mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: #EDE8F4; background: #3D2860; border-radius: 3px 3px 0 0;
}
.dv-code { margin: 0; padding: 0.95rem 1rem; overflow-x: auto; border-radius: 0 4px 4px 4px; background: #1E1430; color: #EDE8F4; font-size: 0.86rem; line-height: 1.6; border-left: 3px solid #6E42A6; }
.dv-code code { white-space: pre; }
.dv-listing:not([data-lang]) .dv-code { border-radius: 4px; }
.dv-copy {
  position: absolute; top: 0; right: 0; padding: 0.18rem 0.6rem; font: 600 0.7rem/1.3 var(--font); color: #EDE8F4;
  background: #3D2860; border: 0; border-radius: 3px 3px 0 0; cursor: pointer;
}
.dv-copy:hover { background: #4A3373; }
.dv-copy:focus-visible, .dv-try-preset:focus-visible, .dv-embed-modes button:focus-visible, .dv-try-send:focus-visible { outline: 2px solid #E8C877; outline-offset: 2px; }
/* JSON in the console */
.dv-code .j-k { color: #C9B2EA; }
.dv-code .j-s { color: #A8E0C2; }
.dv-code .j-n { color: #F0CE8C; }
.dv-code .j-b { color: #F2A6A6; }

/* Spec table */
.dv-table-wrap { overflow-x: auto; margin: 0.75rem 0; border: 1px solid var(--dv-rule); }
.dv-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--paper); }
.dv-table th, .dv-table td { padding: 0.6rem 0.75rem; vertical-align: top; text-align: left; border-bottom: 1px solid var(--line); }
.dv-table thead th { font: 600 0.72rem/1.3 var(--font); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dv-paper); background: var(--dv-rule); white-space: nowrap; }
.dv-table tbody th { font-weight: 400; white-space: nowrap; }
.dv-table tbody th a { color: var(--accent-dark); }
.dv-table tbody tr:nth-child(even) { background: var(--mist); }
.dv-table td:last-child { min-width: 11rem; }

/* The console */
.dv-try { margin: 0.5rem 0 1rem; padding: 1rem; border: 1px solid var(--dv-rule); background: var(--paper); }
.dv-try-label { display: block; margin-bottom: 0.45rem; font: 600 0.72rem/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.dv-try-row { display: flex; align-items: stretch; border: 1px solid var(--line); background: var(--mist); font-family: var(--dv-mono); font-size: 0.9rem; }
.dv-try-verb { display: grid; place-items: center; padding: 0 0.7rem; font-weight: 700; font-size: 0.78rem; letter-spacing: 0.08em; color: #fff; background: #1F5C4A; }
.dv-try-base { display: grid; place-items: center; padding: 0 0 0 0.6rem; color: var(--muted); white-space: nowrap; }
.dv-try-input { flex: 1; min-width: 0; padding: 0.6rem 0.4rem 0.6rem 0.1rem; font: inherit; color: var(--ink); background: transparent; border: 0; }
.dv-try-input:focus { outline: none; }
.dv-try-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110, 66, 166, 0.25); }
.dv-try-send { padding: 0 1.1rem; font: 600 0.88rem/1 var(--font); color: #fff; background: var(--accent); border: 0; cursor: pointer; }
.dv-try-send:hover { background: var(--accent-dark); }
:root[data-theme="dark"] .dv-try-send:hover { background: #7E50BC; }
.dv-try-send[disabled] { opacity: 0.7; cursor: progress; }
.dv-try-hint { margin: 0.6rem 0 0.35rem !important; font-size: 0.82rem !important; color: var(--muted); }
.dv-try-presets { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0 !important; list-style: none; }
.dv-try-presets li + li { margin-top: 0 !important; }
.dv-try-preset { padding: 0.2rem 0.55rem; font: 0.78rem/1.4 var(--dv-mono); color: var(--ink); background: var(--mist); border: 1px solid var(--line); border-radius: 2px; cursor: pointer; }
.dv-try-preset:hover { border-color: var(--accent); }
.dv-try-out { margin-top: 0.9rem; }
.dv-try-status { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin: 0 0 0.5rem !important; font: 0.82rem/1.5 var(--dv-mono) !important; color: var(--muted); }
.dv-try-status b { font-weight: 700; }
.dv-try-status .is-ok { color: #1F5C4A; }
.dv-try-status .is-err { color: var(--danger); }
:root[data-theme="dark"] .dv-try-status .is-ok { color: #8FD3AC; }
.dv-try-body { max-height: 26rem; overflow: auto; }

/* Embed previews */
.dv-embeds { list-style: none; padding: 0 !important; }
.dv-embeds li { display: flex; flex-wrap: wrap; gap: 0.2rem 0.75rem; }
.dv-embeds span { color: var(--muted); }
.dv-embed { margin: 1rem 0 1.6rem; border: 1px solid var(--dv-rule); background: var(--paper); }
.dv-embed-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); }
.dv-embed-fig { font: 700 0.7rem/1 var(--dv-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-dark); }
.dv-embed-name { flex: 1; min-width: 10rem; font-family: var(--font-serif); font-size: 1.02rem; color: var(--ink); }
.dv-embed-modes { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; }
.dv-embed-modes[hidden] { display: none; }
.dv-embed-modes button { min-height: 28px; padding: 0 0.75rem; font: 600 0.76rem/1 var(--font); color: var(--muted); background: none; border: 0; border-radius: 999px; cursor: pointer; }
.dv-embed-modes button[aria-pressed="true"] { color: #fff; background: var(--ink); }
:root[data-theme="dark"] .dv-embed-modes button[aria-pressed="true"] { color: #17121F; }
.dv-embed-frame { padding: 0.75rem; background: repeating-linear-gradient(45deg, transparent 0 8px, rgba(42, 27, 69, 0.035) 8px 9px); }
.dv-embed-frame iframe { display: block; width: 100%; border: 0; background: transparent; }
.dv-embed .dv-listing { margin: 0; padding: 0 0.75rem 0.75rem; }

/* Revision notes */
.dv-revs { list-style: none; margin: 0.5rem 0 0; padding: 0 !important; border-top: 1px solid var(--dv-rule); }
.dv-rev { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.2rem 1.2rem; margin: 0 !important; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.dv-rev-head { margin: 0 !important; font-size: 0.86rem !important; color: var(--muted); }
.dv-rev-n { display: block; font: 700 0.86rem/1.4 var(--dv-mono); color: var(--ink); }
.dv-rev ul { margin: 0; }
.dv-colophon { margin: 0; padding-top: 0.6rem; font: 600 0.7rem/1 var(--dv-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); text-align: center; border-top: 3px double var(--dv-rule); }

@media (max-width: 1180px) {
  .dv-section { grid-template-columns: minmax(0, 1fr); }
  .dv-section > .dv-margin { grid-column: 1; grid-row: auto; margin: 0.2rem 0 1rem; }
}
@media (max-width: 860px) {
  .dv-grid { grid-template-columns: 1fr; gap: var(--s-3); }
  .dv-toc { position: static; }
  .dv-toc ol { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); column-gap: 1rem; }
  .dv-rev { grid-template-columns: 1fr; }
  .dv-try-base { display: none; }
}
@media print {
  .dv-try, .dv-embed-frame, .dv-copy, .dv-embed-modes { display: none !important; }
  .dv-code { background: none !important; color: #000 !important; border: 0.5pt solid #999 !important; }
  .dv-listing-label { color: #000 !important; background: none !important; padding-left: 0; }
  .dv-h-n { color: #000 !important; background: none !important; border: 1pt solid #000; }
  .dv-section { display: block; }
  .dv-margin { border-left: 1pt solid #000 !important; background: none !important; }
}
