/* TSP services panels: the frame around a skill-built architecture diagram. Scoped under .tsp-arch; reads the
   homepage tokens (tokens.css). The diagram itself is drawn by <arch-diagram> in its own shadow root.
   Per figure, in its markup (README section 2): --arch-wide, the landscape diagram's width / height (1.982 for Cloud),
   and --arch-tall, the phone layout's height (603px for Cloud); tools/measure.html measures both after a rebuild.
   Never put a container, transform or filter on .tsp-arch or its stage: the engine's tooltip is position: fixed and
   would be placed (and clipped) by it. The stills' container is their own wrapper. */
.tsp-arch {
  --arch-stage: #070d1d;
  --arch-badge: #2e5ddf;   /* the engine's lit badge (assets/themes/dark.json: badgeLit) */
  position: relative; margin: 0; display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--arch-stage); color: var(--text); font-family: var(--f-body);
}
.tsp-arch *, .tsp-arch *::before, .tsp-arch *::after { box-sizing: border-box; }
.tsp-arch__vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* bar: the honesty label, the legend, Pause. The bar is its own size container (it holds no part of the diagram, so the
   engine's fixed tooltip is not affected): under 350px of content (a phone, or v3/svc beside its switch at 1024 x 768)
   the label and Pause share the first row and the legend takes the second, from the start, so the bar does not grow
   when Pause appears with the engine */
.tsp-arch__bar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; min-height: 38px; padding: 5px 8px 3px 14px; container: tsp-arch-bar / inline-size; }
@container tsp-arch-bar (max-width: 349px) {
  .tsp-arch__pause { order: 1; margin-left: auto; }
  .tsp-arch__legend { order: 2; flex: 1 0 100%; margin: 0; }
}
.tsp-arch__pill { display: inline-flex; align-items: center; gap: 7px; font: 500 12.5px var(--f-body); color: var(--text-3); white-space: nowrap; }
.tsp-arch__pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); }
.tsp-arch__legend { display: flex; align-items: center; gap: 14px; margin: 0 0 0 auto; padding: 0; list-style: none; font: 500 11.5px var(--f-mono); color: var(--text-3); white-space: nowrap; }
.tsp-arch__legend li { display: inline-flex; align-items: center; gap: 7px; }
.tsp-arch__legend svg { display: block; width: 24px; height: 8px; overflow: visible; }
.tsp-arch__pause {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 76px; padding: 4px 11px; border-radius: 6px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
  font: 500 12.5px var(--f-body); cursor: pointer; transition: border-color .2s, color .2s;
}
.tsp-arch__pause:hover { border-color: rgba(var(--cyan-rgb), .6); color: var(--text); }
.tsp-arch__pause[hidden] { display: none; }
/* with JS, Pause keeps its place before the engine is live (invisible, not focusable), so the bar doesn't re-lay out
   when it appears (the legend jumped 92px; a phone's bar grew 10px). .th-svc.is-js reserves it from the services
   section's first layout. Not under reduced motion, where Pause never shows. (2026-11-27 fix pass) */
@media (prefers-reduced-motion: no-preference) {
  .tsp-arch.is-js .tsp-arch__pause[hidden], .th-svc.is-js .tsp-arch__pause[hidden] { display: inline-flex; visibility: hidden; }
}
.tsp-arch__pause i { position: relative; width: 9px; height: 10px; }
.tsp-arch__pause i::before, .tsp-arch__pause i::after { content: ''; position: absolute; top: 0; bottom: 0; }
.tsp-arch__pause[data-mode="pause"] i::before, .tsp-arch__pause[data-mode="pause"] i::after { width: 3px; background: currentColor; border-radius: 1px; }
.tsp-arch__pause[data-mode="pause"] i::before { left: 0; }
.tsp-arch__pause[data-mode="pause"] i::after { right: 0; }
.tsp-arch__pause[data-mode="play"] i::before { left: 1px; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent currentColor; }

/* stage: the stills (JS off; with JS only while the engine is slow or failed) and the live diagram share one cell */
.tsp-arch__stage { position: relative; flex: none; display: grid; min-width: 0; }
.tsp-arch__stage > * { grid-area: 1 / 1; min-width: 0; }
.tsp-arch__live { display: block; width: 100%; justify-self: center; opacity: 0; transition: opacity .3s var(--ease-out, ease); }
.tsp-arch.is-live .tsp-arch__live { opacity: 1; }
.tsp-arch.has-still .tsp-arch__live { transition: none; }   /* it replaces a still at once: the two never show together */

/* The stills' cell: the sizing box (.tsp-arch__box, empty) and, without JS, the <noscript> with the two stills, in one
   grid cell. The box is the live diagram's size (the reservation below), so the first frame, also before
   arch-panel.js has run, already has the final height. Without JS the stills' own width picks one: the landscape still
   from 520px (the width arch-panel.js switches at), fitted in the same box; a browser without container queries shows
   the tall one. */
.tsp-arch__stills { display: grid; min-width: 0; container-type: inline-size; }
.tsp-arch__stills > * { grid-area: 1 / 1; min-width: 0; }
.tsp-arch__box { display: block; height: var(--arch-tall, 603px); }
.tsp-arch__still { display: block; width: 100%; height: var(--arch-tall, 603px); object-fit: contain; }
.tsp-arch__still--wide { display: none; }
@container (min-width: 520px) {
  .tsp-arch__box, .tsp-arch__still--wide { height: auto; aspect-ratio: var(--arch-wide, 1.982); max-height: var(--arch-wide-max, 368px); }
  .tsp-arch__still--wide { display: block; }
  .tsp-arch__still--tall { display: none; }
}
/* With JS: no still unless .has-still (arch-panel.js makes it from the <noscript> markup only then), never with the
   live diagram, and the one for the layout the script chose (data-layout: the same rule as the live diagram), filling
   the reserved stage */
.tsp-arch.is-js .tsp-arch__stills { display: none; }
.tsp-arch.is-js.has-still:not(.is-live) .tsp-arch__stills { display: grid; height: 100%; grid-template-rows: minmax(0, 1fr); }
.tsp-arch.is-js .tsp-arch__box { display: none; }
.tsp-arch.is-js .tsp-arch__still { display: none; width: 100%; height: 100%; max-height: none; aspect-ratio: auto; object-fit: contain; }
.tsp-arch.is-js[data-layout="wide"] .tsp-arch__still--wide, .tsp-arch.is-js[data-layout="tall"] .tsp-arch__still--tall { display: block; }
/* until the live diagram is in, its box is kept (no layout shift when it arrives): the landscape diagram's own
   proportions up to its 45.25rem layout, and from there its height, which stays 365 to 368px up to 1024px wide (the
   engine lays a wider stage out at more rem instead of scaling it; tools/measure.html); the phone layout's height (595
   to 608px at every phone width) */
.tsp-arch.is-js:not(.is-live):not(.is-fill)[data-layout="wide"] .tsp-arch__stage { aspect-ratio: var(--arch-wide, 1.982); max-height: var(--arch-wide-max, 368px); }
.tsp-arch.is-js:not(.is-live):not(.is-fill)[data-layout="tall"] .tsp-arch__stage { height: var(--arch-tall, 603px); }

/* Fill: a host box of fixed height (--tsp-arch-fill: 1, below for v3/svc). The diagram takes the height left by the
   bar and the list at its own proportions, centred; arch-panel.js narrows it when the height is short. */
.tsp-arch.is-fill .tsp-arch__stage { flex: 1 1 0; min-height: 0; align-content: center; }
.tsp-arch.is-fill .tsp-arch__stills { position: absolute; inset: 0; }

/* the numbered steps, under the figure; the number matches the circle on the line */
.tsp-arch > figcaption { flex: none; position: relative; border-top: 1px solid var(--line); background: rgba(6, 11, 24, .4); container-type: inline-size; }
.tsp-arch__steps {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, auto); grid-auto-flow: column;
  gap: 0 18px; margin: 0; padding: 6px 10px 7px; list-style: none;
}
.tsp-arch__steps li { min-width: 0; }
/* without JS (and until the engine is ready) the <li> is the step, a plain list; then its content moves into a button
   (.has-steps) of the same look */
.tsp-arch__step, .tsp-arch:not(.has-steps) .tsp-arch__steps li {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 26px; padding: 2px 6px; border: 0; border-radius: 6px;
  background: none; color: var(--text-3); font: 500 13.5px/1.3 var(--f-body); text-align: left;
}
button.tsp-arch__step { cursor: pointer; transition: color .25s, background-color .2s; }
button.tsp-arch__step:hover { color: var(--text-2); background: rgba(255, 255, 255, .03); }
.tsp-arch__n {
  flex: none; display: inline-grid; place-items: center; width: 19px; height: 19px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .45); background: rgba(0, 0, 0, .85); color: #fff; font: 600 10.5px/1 var(--f-mono);
  transition: background-color .25s, border-color .25s;
}
.tsp-arch__step[aria-current="step"] { color: var(--text); }
.tsp-arch__step[aria-current="step"] .tsp-arch__n { background: var(--arch-badge); border-color: var(--arch-badge); }
.tsp-arch__t { min-width: 0; }   /* titles wrap rather than lose their end */
.tsp-arch__now { display: none; }
/* a narrow figure: one column */
@container (max-width: 459px) {
  .tsp-arch__steps { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-flow: row; padding: 8px 8px 10px; }
}
/* compact (a short fill box): the numbers in one row, the current step's title beside them */
.tsp-arch.is-list-compact > figcaption { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px 0 6px; }
.tsp-arch.is-list-compact .tsp-arch__steps { display: flex; flex: none; gap: 0; padding: 0; }
.tsp-arch.is-list-compact .tsp-arch__step, .tsp-arch.is-list-compact:not(.has-steps) .tsp-arch__steps li { width: auto; min-height: 32px; padding: 2px 4px; }
.tsp-arch.is-list-compact .tsp-arch__t { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tsp-arch.is-list-compact .tsp-arch__now { display: block; flex: 1 1 auto; min-width: 0; font: 500 13.5px/1.3 var(--f-body); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* hidden (a very short fill box): the numbers on the diagram carry the steps */
.tsp-arch.is-list-hidden > figcaption { border-top: 0; }
.tsp-arch.is-list-hidden .tsp-arch__steps, .tsp-arch.is-list-hidden .tsp-arch__now { display: none; }

.tsp-arch button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

@media (max-width: 639px) {
  .tsp-arch__bar { padding: 8px 10px 4px 12px; }
  .tsp-arch__legend { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tsp-arch__live, .tsp-arch__n, .tsp-arch__step, .tsp-arch__pause { transition: none; }
}

/* ---- hosts ---------------------------------------------------------------------------------------------------- */
/* the current console (out/index.html): in place of .th-console__stage, it takes the same grid cell */
.th-console__panel > .tsp-arch { grid-area: viz; }
/* v3/svc: inside the panel's .th-svc__demo (README section 3), which keeps the Simulation | Code switch. The media box
   draws the frame; the switch sits over the left of the bar; the pinned slot has a fixed height: fill it. */
.th-svc__demo > .tsp-arch { flex: 1 1 auto; border: 0; border-radius: 0; background: transparent; }
.th-svc.is-js .th-svc__demo > .tsp-arch > .tsp-arch__bar { min-height: 46px; padding: 7px 10px 7px 212px; }
.th-svc.is-pin .th-svc__demo > .tsp-arch { --tsp-arch-fill: 1; flex: 1 1 0; min-height: 0; }
/* short pinned windows: the 42px bar of the other five demos (2026-11-27 fix pass) */
@media (max-height: 819px) {
  .th-svc.is-pin .th-svc__demo > .tsp-arch > .tsp-arch__bar { min-height: 42px; padding-top: 5px; padding-bottom: 5px; }
}
@container th-svc-media (max-width: 520px) {
  .th-svc.is-js .th-svc__demo > .tsp-arch > .tsp-arch__bar { padding-left: 14px; }
}
