/* Interactive figures for "Ask Badge" (ry-ops.dev, 2026-10-24).
   Self-contained: everything is scoped under .abx and draws as a dark
   "console" card, so it reads the same in the blog's light and dark themes. */
.abx {
  --bg: #0c1a2e; --bg2: #13294a; --bg3: #1e3a5f; --line: #2b4a72;
  --ink: #e6eefb; --mute: #9fb3cf; --blue: #60a5fa; --sky: #93c5fd;
  --orange: #f97316; --amber: #fb923c; --ok: #34d399; --no: #f87171; --warn: #facc15;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 2rem 0; padding: 16px; border-radius: 16px; background: var(--bg);
  color: var(--ink); border: 1px solid var(--line); font-size: 15px; line-height: 1.45;
  box-shadow: 0 10px 30px rgba(2, 8, 20, .25); overflow: hidden;
}
.abx * { box-sizing: border-box; }
.abx { max-width: 100%; }
.abx-steps li, .abx-kv, .abx-log div { overflow-wrap: anywhere; }
.abx p { margin: 0; color: inherit; font-size: inherit; line-height: inherit; }
.abx-top { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.abx-title { font-weight: 700; font-size: 16px; }
.abx-tag { font: 12px/1 var(--mono); color: var(--sky); background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; }
.abx p.abx-note { color: var(--mute); font-size: 13px; margin-top: 10px !important; }
.abx-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.abx button { font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; transition: background .15s, border-color .15s, transform .1s; }
.abx button:hover { border-color: var(--blue); }
.abx button:active { transform: scale(.97); }
.abx button[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); color: #1a0d03; font-weight: 600; }
.abx button.abx-bad { border-color: #7f2a2a; }
.abx button.abx-bad[aria-pressed="true"] { background: var(--no); border-color: var(--no); }
.abx button:disabled { opacity: .5; cursor: default; }
.abx button:focus-visible, .abx a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.abx a { color: var(--sky); }
.abx pre, .abx code { font-family: var(--mono); }
.abx pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.5; background: none; padding: 0; color: var(--ink); }
.abx-pane { background: #081322; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.abx-pane h4 { margin: 0 0 6px !important; font: 600 11px/1.2 var(--mono) !important; letter-spacing: .06em; text-transform: uppercase; color: var(--mute) !important; }

/* 1. Request path */
.abx-stages { list-style: none; margin: 0 0 12px !important; padding: 0 !important; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; counter-reset: st; }
.abx-stages li { margin: 0 !important; position: relative; padding: 8px 9px 9px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); transition: background .25s, border-color .25s, opacity .25s; counter-increment: st; }
.abx-stages li::before { content: counter(st); position: absolute; right: 8px; top: 7px; font: 10px var(--mono); color: var(--mute); }
.abx-stages b { display: block; font-size: 13px; }
.abx-stages small { display: block; font: 11px/1.3 var(--mono); color: var(--mute); }
.abx-stages em { display: block; font: normal 11px var(--mono); color: var(--mute); min-height: 14px; margin-top: 3px; }
.abx-stages li.run { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(249, 115, 22, .25); animation: abx-pulse .6s ease-in-out infinite alternate; }
.abx-stages li.ok { border-color: #1f7a5c; background: #0f2e2a; }
.abx-stages li.ok em { color: var(--ok); }
.abx-stages li.no { border-color: var(--no); background: #3a1414; }
.abx-stages li.no em { color: var(--no); }
.abx-stages li.skip { opacity: .35; }
@keyframes abx-pulse { to { box-shadow: 0 0 0 6px rgba(249, 115, 22, .08); } }
.abx-grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.abx-grid3 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; }
.abx-status { font: 700 12px var(--mono); padding: 2px 7px; border-radius: 6px; margin-left: 6px; }
.abx-s2 { background: #0f3b2d; color: var(--ok); } .abx-s4 { background: #3a1414; color: var(--no); }
.abx-meter { height: 10px; border-radius: 99px; background: var(--bg3); overflow: hidden; margin: 6px 0 4px; }
.abx-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--amber)); transition: width .5s; }
.abx-pips { display: flex; gap: 5px; margin: 6px 0 4px; }
.abx-pips i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); transition: background .2s, border-color .2s; }
.abx-pips i.on { background: var(--amber); border-color: var(--amber); }
.abx-pips.full i.on { background: var(--no); border-color: var(--no); }
.abx-kv { font: 12px var(--mono); color: var(--mute); }
.abx-kv b { color: var(--ink); font-weight: 600; }
.abx-log { font: 12px/1.6 var(--mono); color: var(--mute); max-height: 120px; overflow: auto; }
.abx-log div { white-space: pre-wrap; }
.abx-log .g { color: var(--ok); } .abx-log .r { color: var(--no); } .abx-log .y { color: var(--warn); } .abx-log .o { color: var(--amber); }
@media (max-width: 760px) {
  .abx-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .abx-grid2, .abx-grid3 { grid-template-columns: minmax(0, 1fr); }
}

/* 2. Vector map */
.abx-vec { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 10px; }
.abx-vec svg { width: 100%; height: auto; display: block; background: #081322; border: 1px solid var(--line); border-radius: 12px; }
.abx-vec .dot { transition: opacity .3s, r .3s; }
.abx-vec .lbl { font: 11px var(--mono); fill: var(--mute); }
.abx-vec .ring { fill: rgba(249, 115, 22, .07); stroke: var(--orange); stroke-dasharray: 4 5; stroke-width: 1.5; transition: r .5s, opacity .3s; }
.abx-vec .edge { stroke-width: 1.6; transition: opacity .3s; }
.abx-vec .q { fill: #fff; stroke: var(--orange); stroke-width: 3; transition: cx .6s, cy .6s; }
.abx-rank { list-style: none; margin: 0 !important; padding: 0 !important; font: 12px/1.35 var(--mono); }
.abx-rank li { margin: 0 0 5px !important; display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: baseline; padding: 5px 7px; border-radius: 8px; background: var(--bg2); }
.abx-rank li.hit { background: #0f2e2a; } .abx-rank li.miss { opacity: .55; }
.abx-rank .sc { color: var(--ok); } .abx-rank li.miss .sc { color: var(--no); }
.abx p.abx-verdict { margin-top: 8px !important; font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--bg2); border-left: 3px solid var(--amber); }
@media (max-width: 760px) { .abx-vec { grid-template-columns: minmax(0, 1fr); } }

/* 3. GitHub + Cloudflare re-index */
.abx-lanes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 10px; }
.abx-lane { border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); background: var(--bg2); }
.abx-lane.gh { border-top: 3px solid #a78bfa; } .abx-lane.cf { border-top: 3px solid var(--orange); }
.abx-steps { list-style: none; margin: 6px 0 0 !important; padding: 0 !important; font: 12px/1.4 var(--mono); }
.abx-steps li { margin: 0 0 4px !important; padding: 3px 6px 3px 22px; position: relative; border-radius: 6px; color: var(--mute); transition: background .2s, color .2s; }
.abx-steps li::before { content: "○"; position: absolute; left: 6px; }
.abx-steps li.run { color: var(--ink); background: rgba(249, 115, 22, .16); }
.abx-steps li.run::before { content: "◉"; color: var(--amber); }
.abx-steps li.done { color: var(--ink); } .abx-steps li.done::before { content: "✓"; color: var(--ok); }
.abx-tiles { display: grid; grid-template-columns: repeat(17, minmax(0, 1fr)); gap: 4px; margin: 4px 0 10px; }
.abx-tile { position: relative; aspect-ratio: 1 / 1.35; border-radius: 6px; background: var(--bg3); border: 1px solid var(--line); display: grid; place-items: end center; padding-bottom: 2px; font: 10px var(--mono); color: var(--mute); overflow: hidden; transition: background .25s, border-color .25s; }
.abx-tile i { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(147, 197, 253, .18); }
.abx-tile.dirty { border-color: var(--amber); }
.abx-tile.dirty i { background: rgba(251, 146, 60, .35); }
.abx-tile.skip { background: #10233d; }
.abx-tile.emb { background: var(--orange); color: #1a0d03; border-color: var(--orange); }
.abx-tile.fetch { outline: 2px solid var(--sky); }
.abx-clock { font: 600 13px var(--mono); color: var(--amber); }
@media (max-width: 760px) {
  .abx-lanes { grid-template-columns: minmax(0, 1fr); }
  .abx-tiles { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}

/* 4. Ask Badge replay */
.abx-chat { max-width: 400px; margin: 34px auto 0; background: #1a1d1b; border-radius: 18px; border: 1px solid #343a36; overflow: visible; color: #ece7dc; }
.abx-chat header { display: flex; align-items: flex-end; gap: 10px; padding: 10px 14px; background: #a93a2e; border-radius: 17px 17px 0 0; color: #f6f2e8; }
.abx-chat header .abx-head { width: 62px; height: 76px; margin: -42px 0 -8px; flex: none; }
.abx-chat header div { align-self: center; display: grid; line-height: 1.2; }
.abx-chat header small { opacity: .85; font-size: 12px; }
.abx-chatlog { height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 12px; scroll-behavior: smooth; }
.abx-m { max-width: 88%; padding: 9px 12px; border-radius: 14px; background: #2a2e2b; font-size: 14.5px; animation: abx-in .25s ease-out; }
.abx .abx-m p { white-space: pre-wrap; }
.abx-m.you { align-self: flex-end; background: #43362a; border-top-right-radius: 4px; }
.abx-m.badge { align-self: flex-start; border-top-left-radius: 4px; }
.abx-m.nudge { border-left: 3px solid var(--amber); }
.abx-m ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 !important; padding: 0 !important; }
.abx-m li { margin: 0 !important; }
.abx-m li a { display: inline-block; font-size: 12.5px; padding: 3px 9px; border-radius: 99px; background: #3a3f3b; color: #f3c7a2; text-decoration: none; border: 1px solid #4a514c; }
.abx-m li a:hover { border-color: var(--amber); }
.abx-think { display: flex; align-items: center; gap: 8px; }
.abx-think .abx-head { width: 28px; height: 34px; }
.abx-dots { display: inline-flex; gap: 4px; } .abx-dots i { width: 7px; height: 7px; border-radius: 50%; background: #c9c2b4; animation: abx-dot 1s infinite; }
.abx-dots i:nth-child(2) { animation-delay: .15s; } .abx-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes abx-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes abx-in { from { opacity: 0; transform: translateY(6px); } }
.abx-chatform { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid #343a36; }
.abx-chatform span { flex: 1; min-height: 38px; border-radius: 10px; border: 1px solid #3a403c; background: #121412; padding: 8px 10px; font-size: 14px; color: #ece7dc; }
.abx-chatform span:empty::before { content: "Ask about parks, passes, seasons…"; color: #7d837e; }
.abx-chatform b { border-radius: 99px; background: #e8845a; color: #1a0d03; padding: 8px 14px; font-size: 14px; }
.abx p.abx-chatnote { font-size: 11.5px; color: #9aa09b; padding: 0 12px 12px; }
.abx-ctrl { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.abx-ctrl a { display: inline-block; border-radius: 999px; padding: 6px 14px; font-size: 13px; background: var(--orange); color: #1a0d03; text-decoration: none; font-weight: 600; }
/* Badge's head antics, borrowed from the site */
.abx-head .bh { transform-box: fill-box; transform-origin: 50% 90%; animation: abx-bob 4.2s ease-in-out infinite; }
.abx-head .lid { opacity: 0; animation: abx-wink 6s infinite; }
.abx-head .pom { transform-box: fill-box; transform-origin: 50% 100%; animation: abx-pom 2.1s ease-in-out infinite; }
.abx-head .ear { transform-box: fill-box; transform-origin: center; animation: abx-ear 5s ease-in-out infinite; }
@keyframes abx-bob { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(4deg); } }
@keyframes abx-wink { 0%, 70%, 76%, 100% { opacity: 0; } 71%, 75% { opacity: 1; } }
@keyframes abx-pom { 50% { transform: translateY(-3px) scale(1.08); } }
@keyframes abx-ear { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-14deg); } 90% { transform: rotate(10deg); } }

.abx-fig { margin: 2rem auto; text-align: center; }
.abx-fig img { max-width: 360px; width: 100%; height: auto; border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.abx-fig figcaption { font-size: 14px; opacity: .8; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .abx *, .abx *::before { animation: none !important; transition: none !important; }
}

/* Readable text: white everywhere inside the figures.
   The post page's `.post-content .prose p` rule is more specific than the
   `.abx p` rules above and turned figure paragraphs dark gray on the dark
   cards, so this block wins with !important. Fills that sat behind dark
   text are darkened so white stays readable on them. */
.abx, .abx *, .abx *::before, .abx *::after, .abx .abx-pane h4 { color: #fff !important; }
.abx svg text, .abx-vec .lbl { fill: #fff !important; }
.abx button[aria-pressed="true"] { background: #c2410c; border-color: #c2410c; }
.abx button.abx-bad[aria-pressed="true"] { background: #b91c1c; border-color: #b91c1c; }
.abx-tile.emb { background: #c2410c; border-color: #c2410c; }
.abx-chatform b { background: #b4532a; }
.abx-ctrl a { background: #c2410c; }
/* The post page gives <pre> a light fill, so the request, response and KV
   panes keep black text. */
.abx pre, .abx pre * { color: #000 !important; }
