/**
 * Shared chrome for the CircleKey example pages.
 *
 * Both examples render the same furniture — header, property checklist,
 * device panels, document slots, and the fixed backend bar — so it lives
 * here rather than being copy-pasted into each page. The two pages had
 * already drifted (a `.doc-slot.denied` state in one and not the other,
 * a stray `letter-spacing`) which is exactly what this file prevents.
 *
 * Page-specific rules stay inline in that page's own <style>.
 */

:root {
  --navy: #01122D; --navy-2: #0A1F42; --line: #d8dee8; --dim: #5b6a80;
  --accent: #1B7BFF; --ok: #0a7a3d; --bad: #b42318; --card: #ffffff;
}
* { box-sizing: border-box; }

/* Room for the fixed backend bar, so no page ever scrolls to reach it. */
body {
  font: 14px/1.5 system-ui, "Segoe UI", sans-serif; margin: 0;
  /* Clears the fixed backend bar. The bar is ~135px once every slot is
     filled, and its status line wraps to a second row on narrow viewports,
     so this keeps a real margin rather than the few pixels that were left
     after the bar gained its title. */
  background: #f2f5f9; color: #16233a; padding-bottom: 190px;
}

/* ---------- header ---------- */
header { background: var(--navy); color: #dbe6f5; display: flex; align-items: center; gap: 20px; padding: 10px 24px; }
header img { height: 64px; display: block; }
header .head-text h1 { font-size: 17px; margin: 0; color: #fff; font-weight: 600; }
header .head-text p { margin: 2px 0 0; font-size: 12.5px; color: #8fa5c4; }
header .badge { margin-left: auto; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; border: 1px solid #35507e; color: #a9c1e6; border-radius: 999px; padding: 5px 12px; white-space: nowrap; }

main { max-width: 1240px; margin: 0 auto; padding: 18px 24px 8px; }

/* ---------- the property checklist ---------- */
/* The checklist sits *below* the narration: it is a scorecard you consult
   after a step lands, not something to read before the page has done
   anything. Keeping it out of the top slot leaves the balloon and the step
   controls as the first thing a visitor meets. */
.props { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.prop { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; display: flex; gap: 8px; align-items: baseline; }
.prop .mark { font-weight: 700; color: #b3bfd0; }
.prop.done .mark { color: var(--ok); }
.prop .ref { color: var(--dim); font-size: 11px; }

/* ---------- device panels ---------- */
/* `stretch`, not `start`: the two devices are peers, and a short panel next
   to a tall one reads as one of them being less important. Both cards now
   share the row's height whatever their content. */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: stretch; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.panel h2 { font-size: 13.5px; margin: 0 0 4px; letter-spacing: .02em; }
.panel .role { font-size: 12px; color: var(--dim); margin: 0 0 10px; }

/* A device that has been lost: greyed out, its documents no longer readable. */
.panel.lost { opacity: .45; filter: grayscale(1); }
.panel.lost h2::after { content: " — LOST"; color: var(--bad); }
.panel.lost .doc-slot.filled { border-color: var(--line); background: none; }

/* ---------- controls ---------- */
button { display: block; width: 100%; margin: 7px 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #f4f7fb; cursor: pointer; font: inherit; font-size: 13px; text-align: left; }
button:enabled { border-color: #b9cdf2; background: #eaf1fd; }
button:enabled:hover { background: #dce9fc; }
button:disabled { opacity: .45; cursor: default; }
button.done { border-color: #bfe3cd; background: #f0faf4; color: #33543f; }

input[type=text] { width: 100%; font: 12px/1.4 ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-radius: 8px; padding: 7px; }
label { font-size: 12px; color: var(--dim); }

/* ---------- output ---------- */
pre { font: 11px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; background: rgba(90,110,140,.08); border-radius: 8px; padding: 8px 10px; max-height: 190px; overflow: auto; margin: 6px 0; }
.credential { font: 15px/1.4 ui-monospace, Consolas, monospace; letter-spacing: .04em; background: #fff7e6; border: 1px dashed #e0b95a; border-radius: 8px; padding: 10px; margin: 6px 0; text-align: center; }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.dim { color: var(--dim); font-size: 12px; }
.event { border-top: 1px dashed rgba(120,140,170,.35); margin-top: 10px; padding-top: 8px; }

footer { max-width: 1240px; margin: 6px auto 0; padding: 12px 24px 26px; font-size: 12px; color: var(--dim); border-top: 1px solid var(--line); }

/* ---------- the stepper ---------- *
 * One Next, one Back, and a balloon saying what the next step does.
 * Replaces the per-panel button stacks, which made the panels grow
 * downward as the story advanced.
 */
.stepbar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.stepbar button { width: auto; margin: 0; white-space: nowrap; }
.stepbar button.primary { border-color: #2f6fd6; background: #eaf1fd; color: #12447f; font-weight: 600; }
.stepbar button.primary:enabled:hover { background: #dce9fc; }
.step-counter { font-size: 12.5px; color: var(--dim); white-space: nowrap; min-width: 108px; }
.step-progress-track { flex: 1; height: 5px; background: #e2e8f1; border-radius: 999px; overflow: hidden; }
.step-progress { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }

/* Amber, not blue: the balloon is the one thing on the page a first-time
   visitor must read before pressing the button, and it was losing that
   fight against the blue panels and buttons around it. */
.balloon { position: relative; background: #fff6dc; border: 1px solid #e6c66a; border-radius: 10px; padding: 11px 14px; font-size: 13px; line-height: 1.6; color: #4a3a0d; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(146, 110, 20, .10); }
.balloon::after { content: ""; position: absolute; top: -7px; right: 46px; width: 12px; height: 12px; background: #fff6dc; border-left: 1px solid #e6c66a; border-top: 1px solid #e6c66a; transform: rotate(45deg); }
.balloon-actor { font-weight: 600; color: #7a5a05; }

/* ---------- device state inspector ---------- *
 * The panels show what each device *holds*, not a transcript. Fixed
 * rows, changing values: the protocol's whole argument is who knows what.
 */
/* Two attributes per line rather than five stacked rows. The first item —
   always the identity key, whose value is a truncated hex string — spans the
   full width; the remaining four pair up. Five lines become three, and the
   panel's actual subject (the documents) rises into view. */
.state-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px; font-size: 12px; margin-bottom: 10px;
}
.state-item {
  display: flex; align-items: baseline; gap: 8px; min-width: 0;
  padding: 3px 0; border-bottom: 1px dotted rgba(120, 140, 170, .22);
}
.state-item:first-child { grid-column: 1 / -1; }
/* An orphaned last item would leave its underline stopping halfway across,
   which reads as a rendering fault. Note the parity: because the first item
   spans the full row, the ones that pair up are items 2..n, so the orphan
   case is an *even* total, not an odd one. (With today's five rows nothing
   is ever orphaned; this is here so adding a row cannot break the layout.) */
.state-item:last-child:nth-child(even) { grid-column: 1 / -1; }
.state-item .k { color: var(--dim); white-space: nowrap; }
.state-item .v {
  margin-left: auto; min-width: 0; text-align: right;
  font-family: ui-monospace, Consolas, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.state-item .v.ok { color: var(--ok); font-weight: 600; }
.state-item .v.muted { color: #a8b3c4; }
.state-item .v.warn { color: var(--bad); font-weight: 600; }

@media (max-width: 720px) {
  .state-grid { grid-template-columns: minmax(0, 1fr); }
  .state-item:last-child:nth-child(odd) { grid-column: auto; }
}

.panel.acting { border-color: #2f6fd6; box-shadow: 0 0 0 2px rgba(47,111,214,.16); }
.panel .acting-tag { display: none; font-size: 11px; color: var(--accent); font-weight: 600; }
.panel.acting .acting-tag { display: inline; }

/* ---------- narration ---------- */
.narration { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; margin-top: 12px; }
.narration-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); margin-bottom: 6px; }
.narration-list { max-height: 168px; overflow-y: auto; }
.narration-item { font-size: 12.5px; line-height: 1.65; padding: 3px 0; border-bottom: 1px dashed rgba(120,140,170,.18); }
.narration-item:last-child { border-bottom: 0; }
.narration-item .n { font-family: ui-monospace, Consolas, monospace; color: #a8b3c4; margin-right: 6px; }
.narration-item.latest { background: #f4f8ff; border-radius: 6px; padding-left: 6px; padding-right: 6px; }
.narration-empty { font-size: 12.5px; color: var(--dim); }

/* Older lines recede, so the line that just appeared is the one the eye
   lands on. The floor is 0.4 rather than 0 — this is a record of what the
   protocol did, and it has to stay readable; hovering the list brings every
   row back to full strength for anyone actually reading back through it. */
.narration-item { transition: opacity .28s ease; }
.narration-item.age-1 { opacity: .82; }
.narration-item.age-2 { opacity: .68; }
.narration-item.age-3 { opacity: .58; }
.narration-item.age-4 { opacity: .5; }
.narration-list:hover .narration-item,
.narration-list:focus-within .narration-item { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .narration-item { transition: none; }
}

/* ---------- document slots ---------- *
 * The plaintext each device holds. One device's slots fill when it
 * encrypts; the other's fill only when it independently decrypts, so
 * "identical" is a real claim rather than a display trick.
 * auto-fit means a page with two documents and a page with three both
 * lay out correctly without a per-page override.
 */
.doc-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.doc-slot { border: 1px dashed var(--line); border-radius: 8px; padding: 7px 8px; min-height: 54px; }
.doc-slot-label { font-size: 10.5px; font-weight: 700; letter-spacing: .03em; color: var(--dim); text-transform: uppercase; margin-bottom: 4px; }
.doc-slot.filled { border-style: solid; border-color: #bfe3cd; background: #f0faf4; }
.doc-slot.filled .doc-slot-label { color: #33543f; }
.doc-slot.denied { border-style: solid; border-color: #f3c6bd; background: #fdf2f0; }
.doc-slot .doc-slot-body pre { margin: 0; max-height: 110px; font-size: 10px; }
.doc-slot .doc-slot-body.dim { font-size: 11px; color: var(--dim); }

/* ---------- the fixed backend bar ---------- *
 * Four tables — groups, transitions, records, backup_blobs — matching the
 * relay schema the protocol actually requires (spec §10.3). It never
 * grows: slots are pre-rendered empty and fill in place, so the bar has a
 * fixed height and the page never scrolls to reveal it.
 */
.backend-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--navy-2); border-top: 2px solid #1c355e; box-shadow: 0 -6px 18px rgba(10,20,40,.25); }
/* The bar was readable as "some tables" without being readable as "this is
   the server". The title says whose side of the wire this is; it is a
   sibling of .backend-bar-inner rather than a child, because that element
   scrolls horizontally and the title must not scroll out of view. */
.backend-title {
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 24px 0; font-size: 11px; min-width: 0;
}
.be-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: #3b7cff; box-shadow: 0 0 0 3px rgba(59, 124, 255, .22);
}
.be-title-main {
  text-transform: uppercase; letter-spacing: .1em;
  font-weight: 700; color: #dbe6f5; white-space: nowrap; flex: none;
}
/* Truncates rather than wrapping: the bar is fixed-height, and a second
   line here would push the tables under the viewport edge. */
.be-title-sub {
  color: #8fa5c4; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.backend-bar-inner { max-width: 1240px; margin: 0 auto; display: flex; gap: 22px; overflow-x: auto; padding: 7px 24px 4px; }
.be-table { min-width: 150px; flex: none; }
.be-table-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: #8fa5c4; margin-bottom: 4px; white-space: nowrap; }
.be-slots { display: flex; gap: 6px; flex-wrap: wrap; position: relative; }
.be-slot { background: rgba(255,255,255,.05); border: 1px dashed #35507e; border-radius: 6px; padding: 5px 9px; font-size: 10.5px; min-width: 60px; text-align: center; color: #62779c; white-space: nowrap; }
.be-slot.filled { border-style: solid; border-color: #2f6fd6; background: rgba(59,124,255,.18); color: #eaf1fd; cursor: pointer; }
.be-slot.filled:hover { background: rgba(59,124,255,.3); }
.be-slot.filled.open { background: #1B7BFF; color: #fff; }
.be-slot.empty { font-style: italic; cursor: default; }
.backend-status { max-width: 1240px; margin: 0 auto; font-size: 11.5px; color: #a9c1e6; padding: 5px 24px 9px; border-top: 1px dashed rgba(255,255,255,.08); }

/* Sits above the bar, and is a sibling of .backend-bar-inner rather than
   a child: that element scrolls horizontally, and per the CSS overflow
   spec setting one axis to `auto` promotes the other away from
   `visible`, which would clip this popover. */
.backend-detail { position: absolute; left: 24px; right: 24px; bottom: 100%; margin: 0 auto 8px; max-width: 1192px;
  font: 11px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
  background: #01122D; color: #cfe0f7; border: 1px solid #2f6fd6; border-radius: 8px; padding: 10px 12px; max-height: 40vh; overflow: auto; }
.backend-detail[hidden] { display: none; }

/* ---- added by scripts/build-demo.mjs -----------------------------------
   The published copy carries no inline style attributes, so the site's
   Content-Security-Policy can keep style-src at 'self'. Rendering is
   identical to the examples/ original. */
.gap-xs { margin-top: 4px; }

/* Back-link to the demo index. The examples are standalone pages locally;
   on the site they need a way out. */
header .demo-back {
  margin-left: auto;
  color: #a9c1e6;
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
}
header .demo-back:hover { color: #fff; text-decoration: underline; }
header .demo-back + .badge { margin-left: 14px; }

/* Narrow screens: the header is a single nowrap flex row, so the added
   back-link would widen it and make the page's existing horizontal overflow
   noticeably worse. Wrapping confines that to the header itself. The demo
   body is a three-column inspector layout and is still not built for phones —
   that is pre-existing and deliberately left alone. */
@media (max-width: 700px) {
  header { flex-wrap: wrap; row-gap: 8px; }
  header .demo-back { margin-left: 0; }
  header .demo-back + .badge { margin-left: 8px; }
}
