/* Antioch mode: its toggle (always there) and the overlay it switches on (see antioch.js). */
:root {
  --ink: #1c1c1c; --muted: #5b6b79; --steel: #3e6a93; --line: #b8d3e7; --fail: #e2742f;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.antioch #scene, .antioch #scene:active { cursor: default; }
.antioch.near #scene { cursor: grab; }
.antioch.near #scene:active { cursor: grabbing; }
#brand, #ax { font-family: var(--sans); color: var(--ink); }
/* The overlay fades in with the mode, and the home page's own controls step aside. */
#ax { opacity: 0; visibility: hidden; transition: opacity 350ms ease, visibility 0s linear 350ms; }
.antioch #ax { opacity: 1; visibility: visible; transition: opacity 450ms ease 150ms; }
#controls { transition: opacity 250ms ease; }
.antioch #controls { opacity: 0; pointer-events: none; }
.embed #brand, .embed #ax { display: none; }

/* The toggle: a pill like the home page's own controls. Switched on, it opens out into the
   path of the suite this simulation belongs to. */
#brand {
  position: fixed; top: max(16px, env(safe-area-inset-top)); left: 22px;
  display: flex; align-items: center; white-space: nowrap; overflow: hidden;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(251, 253, 255, 0.95); box-shadow: 0 2px 10px rgba(58, 118, 166, 0.10);
  font: 500 13px/16px var(--sans); color: #3a76a6; transition: border-color 160ms ease;
}
#brand:hover { border-color: #8fb7d7; }
#antioch-toggle {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px 9px 13px; border: 0; border-radius: 999px; background: transparent;
  font: inherit; color: inherit; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; transition: color 160ms ease, padding 450ms ease;
}
/* Keyboard focus rings the whole pill, not the word inside it. */
#antioch-toggle:focus-visible { outline: none; }
#brand:has(#antioch-toggle:focus-visible) { outline: 2px solid #6fa6cf; outline-offset: 2px; }
#antioch-toggle .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #b8d3e7; transition: background 160ms ease, box-shadow 160ms ease; }
#antioch-toggle[aria-pressed="true"] { color: var(--ink); padding-right: 0; }
#antioch-toggle[aria-pressed="true"] .dot { background: #6fc3ff; box-shadow: 0 0 0 3px rgba(111, 195, 255, 0.25); }
#brand .path { display: inline-flex; gap: 9px; max-width: 0; opacity: 0; font-weight: 400; color: var(--muted); transition: max-width 450ms ease, opacity 300ms ease, padding 450ms ease; }
.antioch #brand .path { max-width: 240px; opacity: 1; padding: 0 16px 0 9px; }
#brand i { font-style: normal; color: #a9c4d9; }

/* Run statistics, in the manner of a suite dashboard. Rows arrive with the stages. */
#stats {
  position: fixed; top: max(16px, env(safe-area-inset-top)); right: 22px; margin: 0;
  min-width: 224px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(251, 253, 255, 0.95);
  box-shadow: 0 2px 10px rgba(58, 118, 166, 0.10);
  font: 12px/1 var(--mono); font-variant-numeric: tabular-nums;
}
#stats div { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; overflow: hidden; max-height: 26px; padding: 6px 0; transition: max-height 400ms ease, opacity 400ms ease, padding 400ms ease; }
#stats dt { color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-size: 11px; }
#stats dd { margin: 0; color: var(--ink); font-weight: 500; }
/* What the tile colours mean, once tiles are being scored. */
#stats .key { justify-content: flex-start; gap: 14px; margin-top: 5px; padding-top: 10px; border-top: 1px solid #dbe8f2; color: var(--muted); font-size: 11px; }
#stats .key span { display: inline-flex; align-items: center; gap: 6px; }
#stats .key i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid #c6dbec; background: #ecf4fb; }
#stats .key .pass { border-color: #78acd8; background: #cfe4f6; }
#stats .key .fail { border-color: #ec803e; background: #ffd0b1; }
#s-note { margin: 0; overflow: hidden; max-height: 30px; padding-top: 8px; color: #b9561a; min-height: 21px; transition: max-height 400ms ease, opacity 400ms ease, padding 400ms ease, margin 400ms ease; }
#s-note.calm { color: var(--steel); }
#s-note:empty { min-height: 0; max-height: 0; padding-top: 0; } /* nothing to say: no gap */
/* Coverage: the configurations as scenario families, with their runs and pass rates. */
#coverage {
  list-style: none; margin: 8px 0 0; padding: 9px 0 0; border-top: 1px solid #dbe8f2; overflow: hidden; max-height: 260px;
  display: grid; grid-template-columns: 1fr auto auto; row-gap: 1px; font-size: 11.5px;
  transition: max-height 400ms ease, opacity 400ms ease, padding 400ms ease, margin 400ms ease;
}
#coverage li { display: contents; }
#coverage li > * { color: #4d5c69; font-weight: 400; padding: 4px 0 4px 14px; transition: color 250ms ease; }
#coverage li > :first-child { padding-left: 0; }
/* The scenario the current field report is about: coral while it is worked on, blue once fixed. */
#coverage .target > *, #coverage .target b { color: #b9561a; }
#coverage .fixed > *, #coverage .fixed b { color: #2f6ea3; }
#coverage li > :nth-child(n+2) { text-align: right; }
#coverage li b { color: var(--ink); font-weight: 500; }
#coverage .head > *, #coverage .head b { color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-size: 10.5px; font-weight: 400; padding-bottom: 1px; }
#coverage .weak > *, #coverage .weak b { color: #b9561a; }
[data-stage="0"] #stats [data-from="2"], [data-stage="1"] #stats [data-from="2"],
[data-stage="0"] #stats [data-from="3"], [data-stage="1"] #stats [data-from="3"], [data-stage="2"] #stats [data-from="3"] {
  max-height: 0; min-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; margin-top: 0; border-top-width: 0;
}

/* The story: one caption per stage, cross-fading in place. */
#story {
  position: fixed; left: 22px; bottom: max(22px, env(safe-area-inset-bottom)); width: min(400px, calc(100vw - 44px)); pointer-events: none;
  padding: 20px 22px; border: 1px solid var(--line); border-radius: 14px; background: rgba(251, 253, 255, 0.95); box-shadow: 0 2px 14px rgba(58, 118, 166, 0.12);
}
/* Only the current caption takes up room: the others collapse to nothing, so the card always
   fits its text with the same padding all round, and its height glides between stages. */
#story article { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 450ms ease, opacity 300ms ease; }
#story article > div { overflow: hidden; min-height: 0; }
[data-stage="0"] #story [data-step="0"], [data-stage="1"] #story [data-step="1"],
[data-stage="2"] #story [data-step="2"], [data-stage="3"] #story [data-step="3"], [data-stage="4"] #story [data-step="4"] { grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows 450ms ease, opacity 400ms ease 200ms; }
#story article .eyebrow { margin: 0 0 10px; font: 12px/16px var(--mono); color: var(--steel); }
#story h2 { margin: 0 0 8px; font-size: clamp(22px, 2vw, 26px); line-height: 1.15; font-weight: 500; letter-spacing: -0.025em; text-wrap: balance; }
#story article p { margin: 0; font-size: 15px; line-height: 1.5; color: #4d5c69; text-wrap: pretty; }
/* The closing card's way out: a button in the manner of Antioch's own. */
#story article .more { margin-top: 16px; }
#story .more a {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px 9px 16px; border-radius: 999px;
  background: var(--steel); color: #fff; font: 500 13px/16px var(--sans); text-decoration: none;
  transition: background 160ms ease;
}
#story .more a:hover { background: #335a80; }
#story .more a:focus-visible { outline: 2px solid #6fa6cf; outline-offset: 2px; }
#story .more svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 160ms ease; }
#story .more a:hover svg { transform: translateX(2px); }
[data-stage="4"] #story .more a { pointer-events: auto; }

/* Bottom right: the play button, the four stages, and the Antioch mark for the closing
   stage, each a piece of its own. */
#transport { position: fixed; right: 22px; bottom: max(22px, env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 24px); }
#steps, #play, #end {
  border: 1px solid var(--line); border-radius: 999px; background: rgba(251, 253, 255, 0.95); box-shadow: 0 2px 10px rgba(58, 118, 166, 0.10);
}
#steps { display: inline-flex; gap: 2px; padding: 3px; }
#steps button {
  position: relative; overflow: hidden; isolation: isolate;
  border: 0; border-radius: 999px; background: transparent; padding: 8px 13px; cursor: pointer; white-space: nowrap;
  font: 500 13px/1 var(--sans); color: var(--steel); transition: background 160ms ease, color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
#steps button b { font: 11px/1 var(--mono); font-weight: 400; opacity: 0.6; margin-right: 4px; }
#steps button:hover { background: rgba(184, 211, 231, 0.35); }
#steps button:focus-visible, #play:focus-visible, #end:focus-visible { outline: 2px solid #6fa6cf; outline-offset: 2px; }
#steps button[aria-current="true"] { background: var(--steel); color: #fff; }
/* While autoplay runs, the current stage's blue fills from left to right as its time passes. */
.playing #steps button[aria-current="true"] { background: #a3bfd8; }
.playing #steps button[aria-current="true"]::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--steel);
  transform-origin: left; transform: scaleX(var(--through, 0));
}
#play, #end {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; cursor: pointer; color: var(--steel);
  transition: background 160ms ease, border-color 160ms ease; -webkit-tap-highlight-color: transparent;
}
#play:hover, #end:hover { background: #fff; border-color: #8fb7d7; }
#end span { width: 21px; height: 21px; background: var(--ink); -webkit-mask: url(antioch-mark.svg) center / contain no-repeat; mask: url(antioch-mark.svg) center / contain no-repeat; transition: background 160ms ease; }
#end[aria-current="true"] { background: var(--steel); border-color: var(--steel); }
#end[aria-current="true"] span { background: #fff; }
#play svg { fill: currentColor; }
#play .go { transform: translateX(0.5px); }
#play .stop, #play[aria-pressed="true"] .go { display: none; }
#play[aria-pressed="true"] .stop { display: inline; }
#hint { position: fixed; right: 22px; bottom: max(74px, calc(env(safe-area-inset-bottom) + 54px)); margin: 0; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: rgba(251, 253, 255, 0.95); font: 12px/1 var(--mono); color: var(--muted); transition: opacity 500ms ease; }
#hint::after { content: " \2193"; }
.moved #hint { opacity: 0; }

/* Configuration labels over the nearest replicas (stage 2). */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#labels span {
  position: absolute; left: 0; top: 0; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(251, 253, 255, 0.94); font: 12px/1 var(--mono); color: var(--steel); white-space: nowrap; will-change: transform, opacity;
}
#labels > span { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; }
#labels > span span { position: static; padding: 0; border: 0; background: none; color: inherit; }
/* Each configuration's pass rate rides in its label; the weakest is picked out. */
#labels b { padding: 4px 7px; border-radius: 999px; background: #dcebf7; color: #1d5b8f; font-weight: 500; font-variant-numeric: tabular-nums; }
#labels span.base { background: var(--steel); border-color: var(--steel); color: #fff; }
#labels span.base b { background: rgba(255, 255, 255, 0.2); color: #fff; }
#labels span.weak { border-color: #f3c3a3; color: #a84f17; }
#labels span.weak b { background: #ffe1cd; color: #a84f17; }

/* A failure reported from the field (stage 4). */
#marker { position: fixed; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity 500ms ease; will-change: transform; }
#marker.on { opacity: 1; }
#marker i { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--fail); background: rgba(255, 255, 255, 0.7); }
#marker i::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--fail); animation: ping 1.6s ease-out infinite; }
#marker span {
  position: absolute; left: 18px; top: -13px; padding: 7px 10px; border-radius: 8px; white-space: nowrap;
  background: #fff; border: 1px solid #f3c3a3; box-shadow: 0 2px 10px rgba(226, 116, 47, 0.16); font: 12px/1 var(--mono); color: #a84f17;
}
#marker.flip span { left: auto; right: 18px; }
#marker.under span { top: 18px; }
#marker b { font-weight: 600; }
/* Pins and labels on the field stay under the panels. */
#labels, #marker { z-index: 0; }
#stats, #story, #transport, #hint { z-index: 1; }
#brand { z-index: 1; }
@keyframes ping { from { transform: scale(1); opacity: 0.9; } to { transform: scale(3.2); opacity: 0; } }

/* Narrower than the caption and the stage buttons side by side: stack them. */
@media (max-width: 900px) {
  #transport { right: auto; left: 50%; transform: translateX(-50%); width: max-content; }
  #story { bottom: max(76px, calc(env(safe-area-inset-bottom) + 70px)); }
  #hint { display: none; }
}
@media (max-width: 640px) {
  #brand { left: 12px; } #brand .path { display: none; } #antioch-toggle[aria-pressed="true"] { padding-right: 15px; }
  #stats { right: 12px; min-width: 184px; padding: 8px 12px; }
  #stats div { padding: 5px 0; }
  #story { left: 12px; width: calc(100vw - 24px); bottom: max(72px, calc(env(safe-area-inset-bottom) + 66px)); padding: 16px 18px; }
  #story p:last-child { font-size: 14px; }
  #steps button { padding: 8px 7px; font-size: 12px; } #steps button b { display: none; }
  #transport { gap: 5px; } #play, #end { width: 34px; height: 34px; } #end span { width: 19px; height: 19px; }
  #coverage { display: none; }
  #labels > span { font-size: 11px; gap: 6px; padding: 3px 3px 3px 8px; }
  /* A field report's label wraps to fit the screen. */
  #marker span { width: max-content; max-width: calc(100vw - 16px); white-space: normal; line-height: 1.4; }
  #labels b { padding: 3px 6px; }
  #hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { #marker i::after { animation: none; } }

/* A short window has no room for the coverage table under the other figures. */
@media (max-height: 640px) { #coverage { display: none; } }
