/* apron.chat: shared by the landing page (index.html) and the spec (protocol.html). */

:root {
  --paper: #fafaf8;
  --ink: #1a1a1a;
  --muted: #55554f;
  --code-bg: #f1f0ea;
  --chip: #eceae2;
  --rule: #d9d7ce;
  --accent: #a33e0c;
  --server: #1f5a9e;
  --scaffold: #6e6c64;
  --id-bg: #e0ddd0;
  /* The spec's tiers: optional sections on blue paper, informative on grey. */
  --required-tint: #f2e2d8;
  --optional-paper: #edf1f6;
  --optional-tint: #dce5ef;
  --informative-paper: #f1f0eb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.65 "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
a { color: var(--accent); }
a:hover { color: var(--ink); }
code { background: var(--chip); padding: 1px 5px; font: inherit; font-size: 0.92em; }
h1, h2, h3, p { margin: 0; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

header.top { border-bottom: 2px solid var(--ink); }
/* The gap narrows with the screen, so the links stay on one line on phones. */
header.top nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px clamp(12px, 3.5vw, 28px); padding: 14px 16px; font-size: 14px; }
header.top nav a { color: var(--ink); }
header.top nav a.strong { color: var(--accent); font-weight: 700; }

footer { margin-top: 88px; border-top: 2px solid var(--ink); }
footer .wrap { padding: 20px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font-size: 13px; color: var(--muted); }
footer a { color: var(--muted); }

a.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
}
a.button:hover { background: var(--ink); color: #fff; }

/* Protocol frames. Write each frame as plain JSON on its own line, wrapped in
   <span class="client"> or <span class="server">, and mark what matters:
   <b> the method, <mark> a request id, <strong> what the user sees.
   Everything else is dimmed. */
.code {
  background: var(--code-bg);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--rule);
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
  margin: 0;
  color: var(--scaffold);
}
.code .client::before,
.code .server::before { display: inline-block; min-width: 10ch; margin-right: 1ch; font-weight: 700; }
.code .client::before { content: "client ->"; color: var(--accent); }
.code .server::before { content: "<- server"; color: var(--server); }
.code b { color: var(--server); }
.code .client b { color: var(--accent); }
.code mark { background: var(--id-bg); color: var(--ink); font-weight: 700; padding: 0 3px; }
.code strong { color: var(--ink); }

/* Landing page */

/* The logo centers only when it wraps onto a line of its own; beside the
   text, the text fills the rest of the line. */
.hero { padding: 64px 0 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 32px 48px; }
.hero img { width: 160px; height: 160px; flex: 0 0 auto; }
.hero div { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.hero h1 { font-size: clamp(30px, 4.6vw, 46px); line-height: 1.1; }
.hero .lead { font-size: 17px; max-width: 640px; }
/* Where it fits, the lead breaks between its phrases, one to a line. */
@media (min-width: 900px) { .hero .lead span { display: inline-block; } }

section.part { padding-top: 88px; display: flex; flex-direction: column; gap: 20px; scroll-margin-top: 16px; }
section.part:first-of-type { padding-top: 72px; }
section.part h2 { font-size: 22px; line-height: 1.3; display: flex; gap: 14px; }
section.part h2 span { color: var(--accent); }
section.part > p { max-width: 680px; }

/* The FAQ's questions, filled in by the build from FAQ.md. */
.faq { margin: 0; padding-left: 20px; max-width: 680px; }
.faq li { margin-bottom: 6px; }
.faq li::marker { color: var(--accent); }
.faq a { color: var(--ink); }
.faq a:hover { color: var(--accent); }

.links { display: flex; flex-wrap: wrap; gap: 14px; padding-top: 6px; }
.links a:not(.button) { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; color: var(--ink); }

.demo { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.zoom { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
/* Screenshots: one at a time with thumbnails below (the script adds .one);
   without the script, all of them, one above the other. */
.gallery { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.gallery.one { gap: 16px; }
.shot { margin: 0; border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); background: #fff; }
.shot img { display: block; width: 100%; height: auto; }
.shot figcaption { padding: 10px 14px; border-top: 2px solid var(--ink); font-size: 13px; line-height: 1.5; }
.thumbs { display: flex; gap: 14px; }
.thumbs[hidden] { display: none; }
.thumbs button { flex: 1 1 0; min-width: 0; padding: 0; border: 1px solid var(--ink); background: #fff; font: inherit; text-align: left; cursor: pointer; opacity: 0.7; }
.thumbs button:hover, .thumbs button:focus-visible { opacity: 1; }
.thumbs button[aria-pressed="true"] { opacity: 1; outline: 2px solid var(--accent); outline-offset: 0; box-shadow: 4px 4px 0 var(--ink); }
.thumbs img { display: block; width: 100%; height: auto; }
.thumbs span { display: block; padding: 6px 10px; border-top: 1px solid var(--ink); font-size: 12px; }
.thumbs button[aria-pressed="true"] span { font-weight: 700; color: var(--accent); }
.lightbox { padding: 0; border: 2px solid var(--ink); background: #fff; max-width: 96vw; max-height: 96vh; }
.lightbox::backdrop { background: rgba(26, 26, 26, 0.8); }
.lightbox button { display: block; padding: 0; border: 0; background: none; cursor: zoom-out; }
.lightbox img { display: block; width: auto; height: auto; max-width: calc(96vw - 4px); max-height: calc(96vh - 4px); }
.demo aside { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.demo aside .label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }
.demo aside code { display: inline-block; font-size: 14px; padding: 6px 10px; border: 1px solid var(--rule); }

.cards { display: flex; flex-wrap: wrap; gap: 18px; align-items: stretch; }
.card { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--ink); background: #fff; color: var(--ink); text-decoration: none; }
a.card:hover { box-shadow: 4px 4px 0 var(--ink); color: var(--ink); }
.card .tag { align-self: flex-start; font-size: 12px; padding: 1px 8px; border: 1px solid var(--ink); }
.card .name { font-weight: 700; color: var(--accent); overflow-wrap: anywhere; }
.card .desc { font-size: 14px; }
/* The "your bot" example takes a row of its own, so its frames fit. */
.card.yours { flex: 1 1 100%; border-style: dashed; background: transparent; }
.card.yours .name { color: var(--ink); }
.card.yours .code { box-shadow: none; border: 0; padding: 12px 14px; font-size: 12px; }

/* The spec: /protocol, rendered from PROTOCOL.md */

.doc { padding-top: 48px; }

/* Contents, at the top of the spec and in the bar's dropdown: each top-level
   section with its subsections, in as many columns as fit (three at most). */
.toc { list-style: none; margin: 0; padding: 0; columns: 3 220px; column-gap: 36px; font-size: 13px; line-height: 1.55; }
.toc > li { break-inside: avoid; margin-bottom: 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--accent); text-decoration: underline; }
.toc > li > a { font-weight: 700; }
.toc .l3 { padding-left: 2ch; }
.toc .l4 { padding-left: 4ch; }
.toc .l4 a { color: var(--muted); }
.toc code { background: none; padding: 0; font-size: inherit; }
/* Each tier's name above its sections, and a rule down the side of each entry. */
.toc .label { break-after: avoid; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tier); border-top: 2px solid var(--tier); padding-top: 4px; }
.toc > li[data-tier]:not(.label) { border-left: 3px solid var(--tier); padding-left: 1ch; }
.toc > li[data-tier="informative"]:not(.label), .toc > li[data-tier="draft"]:not(.label) { border-left-style: dotted; }
.toc > li[data-tier="optional"] a { color: var(--server); }
.toc > li[data-tier="informative"] a, .toc > li[data-tier="draft"] a { color: var(--muted); }
.toc .folded { display: none; }

.prose .contents { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 14px 0 6px; margin: 0 0 32px; scroll-margin-top: 16px; }
.prose .contents-title { font-weight: 700; margin: 0 0 10px; }
/* The spec's own list styles don't apply to the contents. */
.prose .toc, .prose .toc ol { padding-left: 0; margin: 0; }
.prose .toc li { margin-bottom: 0; }
.prose .toc > li { margin-bottom: 10px; }
.prose .toc > li.label { margin-bottom: 6px; }

/* The bar: hidden until the contents above scroll away (the script shows it). */
.crumbs { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 10; background: var(--code-bg); border-bottom: 1px solid var(--ink); font-size: 13px; }
.crumbs.shown { display: block; }
.crumbs .wrap { display: flex; align-items: center; gap: 16px; min-height: 44px; position: relative; }
.crumbs details { flex: 1 1 auto; min-width: 0; }
.crumbs summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; min-height: 32px; max-width: 100%; padding: 2px 10px; border: 1px solid var(--ink); background: #fff; font-weight: 700; }
.crumbs summary::-webkit-details-marker { display: none; }
.crumbs summary::after { content: " ▾"; white-space: pre; }
.crumbs details[open] summary::after { content: " ▴"; }
.crumbs .where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs .top { color: var(--muted); white-space: nowrap; }
.crumbs .panel { position: absolute; top: calc(100% + 6px); left: 20px; right: 20px; max-height: calc(100vh - 72px); overflow-y: auto; background: #fff; border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); padding: 16px 20px 6px; }
.crumbs .panel a[aria-current] { color: var(--accent); font-weight: 700; background: var(--chip); }
/* The bar takes the color of the tier you're in, names it, and shows a meter
   of the page by tier with a mark where you are (the script sets these). */
.crumbs { transition: background-color 0.2s; }
[data-tier="required"] .crumbs { background: var(--required-tint); }
[data-tier="optional"] .crumbs { background: var(--optional-tint); }
[data-tier="informative"] .crumbs, [data-tier="draft"] .crumbs { background: var(--informative-paper); }
.crumbs .tier-pill:empty { display: none; }
.crumbs .tier-pill { flex: 0 0 auto; padding: 2px 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; background: var(--tier); border: 1px solid var(--ink); }
.crumbs .meter { display: flex; position: absolute; left: 0; right: 0; bottom: -1px; height: 5px; }
/* Each segment's color on a layer of its own, faded when you're not in it,
   and a notch of the bar's own color between segments. Draft shares
   informative's color, so it takes its hatching from the map. */
.crumbs .meter span { position: relative; }
.crumbs .meter span + span { border-left: 2px solid transparent; }
.crumbs .meter span::before { content: ""; position: absolute; inset: 0; background: var(--tier); opacity: 0.35; }
.crumbs .meter span[data-tier="informative"]::before { opacity: 0.6; }
.crumbs .meter span[data-tier="draft"]::before { background: repeating-linear-gradient(-45deg, var(--scaffold) 0 2px, #fff 2px 6px); }
.crumbs .meter span.on::before { opacity: 1; }
.crumbs .meter i { position: absolute; top: -3px; width: 3px; height: 11px; margin-left: -1px; background: var(--ink); }
@media (prefers-reduced-motion: reduce) { .crumbs { transition: none; } }

.doc .source { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.prose { max-width: 84ch; margin: 0 auto; }
.prose h1 { font-size: clamp(28px, 4vw, 38px); line-height: 1.15; margin: 0 0 20px; }
.prose h2 { font-size: 21px; line-height: 1.3; margin: 64px 0 16px; padding-bottom: 8px; border-bottom: 1px dashed #8a887f; }
.prose h3 { font-size: 17px; margin: 40px 0 12px; }
.prose h4 { font-size: 15px; margin: 32px 0 10px; }
.prose h2, .prose h3, .prose h4 { scroll-margin-top: 60px; }
.prose .up { float: right; margin-left: 2ch; font-size: 13px; font-weight: 400; color: var(--muted); }
.prose p, .prose ul, .prose ol, .prose table, .prose pre { margin: 0 0 14px; }
.prose ul, .prose ol { padding-left: 3ch; }
.prose li { margin-bottom: 4px; }
.prose hr { border: 0; border-top: 1px dashed #8a887f; margin: 48px 0; }
.prose .anchor { margin-left: 1ch; color: var(--rule); text-decoration: none; font-weight: 400; }
.prose .anchor:hover { color: var(--accent); }
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--rule);
  padding: 14px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
/* Long inline code, such as a link.apron.chat URL, breaks where it would
   overflow rather than widen the page on a phone. */
.prose code { overflow-wrap: break-word; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
/* Where the screen has room, code blocks reach a tenth of the prose's width
   past it on either side, so long lines scroll less. Those in a capability's
   fold reach past its border and padding too, to line up with the rest. */
@media (min-width: 980px) {
  .prose { --bleed: 76px; }
  .prose pre { margin-inline: calc(-1 * var(--bleed)); }
  .prose .fold pre { margin-inline: calc(-1 * var(--bleed) - 19px); }
}
/* Code highlighted at build time by highlight.js: values in color, keys in
   ink, punctuation and // comments dimmed, as in the frames on the landing page. */
.prose pre :is(.hljs-comment, .hljs-punctuation) { color: var(--scaffold); }
.prose pre .hljs-string { color: var(--server); }
.prose pre :is(.hljs-number, .hljs-literal, .hljs-keyword) { color: var(--accent); }
.prose pre .hljs-built_in { color: var(--server); }
.prose pre .hljs-title { font-weight: 700; }
.prose strong.must { color: var(--accent); }
/* A table is as wide as its content, up to the page, so no column is stretched
   to fill the line. */
.prose .table { width: fit-content; max-width: 100%; overflow-x: auto; margin: 0 0 14px; border: 1px solid var(--ink); background: #fff; }
.prose table { border-collapse: collapse; font-size: 13px; line-height: 1.5; margin: 0; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 6px 12px; border-bottom: 1px solid var(--rule); }
.prose th { background: var(--chip); border-bottom-color: var(--ink); white-space: nowrap; }
/* Code in a table: no chip in the header, which is already chip-colored, and
   a narrower one in cells, so a comma after it doesn't look spaced off. */
.prose th code { background: none; padding: 0; }
.prose td code { padding: 1px 3px; }
.prose tr:last-child td { border-bottom: 0; }

/* The spec's tiers: required, optional, informative and draft. Each sets
   --tier for its color, wherever data-tier is. */
[data-tier="required"] { --tier: var(--accent); }
[data-tier="optional"] { --tier: var(--server); }
[data-tier="informative"], [data-tier="draft"] { --tier: var(--scaffold); }
/* The full-width paper behind each tier would widen the page by a scrollbar. */
body.spec { overflow-x: clip; }

/* Above the contents: the tiers to scale, and a key. */
.map { margin: 0 0 22px; }
.map-bar { display: flex; height: 14px; border: 2px solid var(--ink); background: #fff; }
.map-bar a { min-width: 6px; background: var(--tier); border-right: 2px solid var(--ink); }
.map-bar a:last-child { border-right: 0; }
.map-bar a[data-tier="draft"] { background: repeating-linear-gradient(-45deg, var(--scaffold) 0 2px, #fff 2px 6px); }
.map-bar a:hover { filter: brightness(1.2); }
.prose .map ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 20px; font-size: 13px; line-height: 1.45; }
.prose .map li { position: relative; margin: 0; padding-left: 18px; }
.map li::before { content: ""; position: absolute; left: 0; top: 4px; width: 10px; height: 10px; background: var(--tier); border: 1px solid var(--ink); }
.map li a { color: var(--ink); text-decoration: none; }
.map li span { white-space: nowrap; }
.map li a:hover b { text-decoration: underline; }
.map li[data-tier="required"] b, .map li[data-tier="optional"] b { color: var(--tier); }

/* Each tier on its own paper, edge to edge, under a tab that names it. */
.prose .tier { position: relative; isolation: isolate; padding-bottom: 48px; }
.prose .tier::before { content: ""; position: absolute; inset: 0 auto 0 50%; width: 100vw; transform: translateX(-50%); z-index: -1; border-top: 2px solid var(--tier); }
.prose .tier[data-tier="optional"]::before { background: var(--optional-paper); }
.prose .tier[data-tier="informative"]::before { background: var(--informative-paper); }
.prose .tier[data-tier="draft"]::before { background: repeating-linear-gradient(-45deg, var(--informative-paper) 0 12px, var(--paper) 12px 24px); border-top-style: dashed; }
.prose .tier-tab { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 0; padding-top: 40px; font-size: 13px; line-height: 1.5; }
.tier-tab b { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: #fff; background: var(--tier); padding: 2px 10px; border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.tier-tab .share { margin-left: auto; color: var(--muted); }
.prose .tier-tab + h2 { margin-top: 28px; }
.prose .tier h2 { border-bottom-color: var(--tier); }
.prose .tier[data-tier="optional"] :is(h2, h3) { color: var(--server); }

/* Under the title: the newest protocol version, linking to HISTORY.md. */
.prose a.history { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 28px; padding: 10px 16px; background: #fff; border: 1px solid var(--ink); color: var(--ink); text-decoration: none; }
.prose a.history:hover { box-shadow: 4px 4px 0 var(--server); }
.history .label { font-size: 13px; color: var(--muted); }
.history .go { margin-left: auto; font-size: 13px; color: var(--server); text-decoration: underline; }

/* Optional capabilities: a line on what each adds, and folds (the script
   closes them; without it they stay open). */
.prose .capability { display: flex; flex-wrap: wrap; gap: 2px 20px; margin: -4px 0 16px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.capability i { font-style: normal; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--server); margin-right: 0.6ch; }
.capability .how { color: var(--ink); }
.capability .adds { flex-basis: 100%; }
.prose .fold-all { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0 14px; font-size: 13px; }
.fold-all button { font: inherit; min-height: 36px; padding: 0 12px; border: 1px solid var(--ink); background: #fff; cursor: pointer; }
.fold-all button:hover { background: var(--chip); }
.prose details.fold { margin: 0 0 14px; padding: 0 18px 6px; background: #fff; border: 1px solid var(--ink); }
.prose details.fold[open] { box-shadow: 4px 4px 0 var(--server); }
.fold summary { display: block; list-style: none; cursor: pointer; padding-bottom: 8px; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary:hover h3 { color: var(--ink); }
.fold summary:focus-visible { outline: 2px solid var(--server); outline-offset: 4px; }
.prose .fold summary h3 { margin-top: 16px; }
.prose .fold summary .capability { margin-bottom: 8px; }
.fold .bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; font-size: 13px; }
.fold .length { color: var(--muted); }
.fold .toggle { color: var(--server); text-decoration: underline; }
.fold .toggle::before { content: "▸ Show section"; }
.fold[open] .toggle::before { content: "▾ Hide section"; }
.fold[open] > summary { margin-bottom: 14px; border-bottom: 1px dashed var(--rule); }
