/* Joint-state HUD: an instrument panel in glass, all colour from theme tokens */
.telemetry { pointer-events: none; }
.tm {
  padding: 0.7rem 0.9rem 0.8rem; border-radius: 0.9rem;
  background: rgba(var(--veil-rgb), 0.62);
  box-shadow: 0 0 0 1px var(--hair), 0 14px 40px -18px var(--shadow);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-variant-numeric: tabular-nums; color: var(--ivory);
}
.tm-label { margin: 0 0 0.55rem; max-width: none !important; font-size: var(--fs-micro); line-height: 1.25; color: var(--caption); white-space: nowrap; }
.tm-cell { margin: 0 0 0.5rem; max-width: none !important; font-size: var(--fs-caption); font-weight: 650; color: var(--accent-text); min-height: 1.2em; }
.tm-rows { display: grid; gap: 0; }
.tm-rows li { display: grid; grid-template-columns: 6.6em 6.2ch; column-gap: 0.7rem; align-items: center; padding: 0.24rem 0; border-top: 1px solid var(--hair); font-size: 0.8125rem; line-height: 1.2; }
.tm-rows li:first-child { border-top: 0; }
.tm-name { color: var(--caption); white-space: nowrap; }
.tm-val { text-align: right; font-weight: 600; min-width: 6.2ch; white-space: nowrap; }
li[data-k="gripper"] .tm-val { min-width: 8ch; }

/* Gauges (full variant): zero-centred bars, filled toward the joint's side */
.telemetry--full .tm-rows li { grid-template-columns: 6.6em 8.4ch minmax(3.5rem, 1fr); }
.tm-gauge { position: relative; height: 0.3125rem; border-radius: 3px; background: rgba(var(--ivory-rgb), 0.12); overflow: hidden; }
.tm-gauge::after { content: ""; position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: rgba(var(--ivory-rgb), 0.45); }
/* --a is signed (-1..1): scaleX flips the bar to the left of zero for negative angles */
.tm-gauge i { position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; background: var(--noodle); border-radius: 3px; transform-origin: 0 50%; transform: scaleX(var(--a, 0)); }
.tm-gauge--one::after { display: none; }
.tm-gauge--one i { left: 0; width: 100%; background: var(--trained); }

/* Phase line: the pick-and-place in order, current step lit */
.tm-phase { display: flex; flex-wrap: wrap; gap: 0.15rem 0; margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px solid var(--hair); font-size: var(--fs-micro); }
.tm-phase li { color: var(--caption); opacity: 0.72; transition: color 0.2s, opacity 0.2s; }
.tm-phase li + li::before { content: "→"; margin: 0 0.4em; opacity: 0.5; }
.tm-phase li.is-on { color: var(--accent-text); opacity: 1; font-weight: 700; }

/* Placement */
.telemetry--hero { position: absolute; right: var(--gutter); bottom: 3.5rem; z-index: 2; width: 21rem; }
.telemetry--hero .tm { padding: 0.55rem 0.75rem 0.6rem; }
.telemetry--hero .tm-label { white-space: normal; font-size: 0.6875rem; }
.telemetry--hero .tm-rows { grid-template-columns: 1fr 1fr; column-gap: 1rem; }
.telemetry--hero .tm-rows li { font-size: var(--fs-micro); padding: 0.16rem 0; grid-template-columns: 1fr auto; column-gap: 0.4rem; }
.telemetry--hero .tm-rows li:nth-child(2) { border-top: 0; }
.telemetry--hero .tm-val { min-width: 0; }
.telemetry--compact { margin: 0 0 1.2rem; max-width: 24rem; pointer-events: auto; }
.telemetry--compact .tm-rows li { grid-template-columns: 1fr auto; }
.telemetry--compact .tm-rows { grid-template-columns: 1fr 1fr; column-gap: 1.2rem; }
.telemetry--compact .tm-rows li { grid-template-columns: 1fr auto; font-size: var(--fs-caption); }
.telemetry--compact .tm-rows li:nth-child(2) { border-top: 0; }
.telemetry--full { flex: 1; min-width: 0; pointer-events: auto; }
.telemetry--full .tm-label { white-space: normal; }

/* Sandbox row: picker left, panel right */
@media (max-width: 1100px) and (min-width: 821px) and (orientation: landscape) { .sandbox-row { flex-direction: column; } }
@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) {
  .telemetry--hero, .telemetry--compact { display: none; }   /* phones: sandbox only */
  .sandbox-row { flex-direction: column; gap: 0.8rem; }
  .telemetry--full .tm-rows li { grid-template-columns: 6.2em 8.4ch minmax(3rem, 1fr); font-size: var(--fs-caption); }
  .telemetry--full .tm-label { white-space: normal; }
}
.no-stage .telemetry, .is-loading .telemetry { display: none; }
@media (max-height: 760px) and (min-width: 821px) and (orientation: landscape), (max-height: 760px) and (min-width: 1101px) { .telemetry--hero { display: none; } }

/* ---- Round 7: phase buttons, timeline scrubber ---- */
.tm-phase { display: flex; flex-wrap: wrap; gap: 0.15rem 0; margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px solid var(--hair); font-size: var(--fs-micro); }
.tm-phase li { opacity: 1; color: inherit; transition: none; }
.tm-phase li + li::before { content: "→"; margin: 0 0.15em; opacity: 0.5; color: var(--caption); }
.tm-phase button { padding: 0.35rem 0.3rem; min-height: 1.75rem; border-radius: 0.4rem; font-size: inherit; color: var(--caption); opacity: 0.78; transition: color 0.2s, opacity 0.2s, background-color 0.2s; pointer-events: auto; }
.tm-phase button[aria-disabled="true"] { cursor: default; opacity: 0.5; }
.tm-phase button:not([aria-disabled="true"]):hover { background: rgba(var(--ivory-rgb), 0.1); color: var(--ivory); opacity: 1; }
.tm-phase button.is-on { color: var(--accent-text); opacity: 1; font-weight: 700; }

.tm-scrub { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; pointer-events: auto; }
.tm-scrub[data-off="true"] { opacity: 0.5; }
.tm-play { flex: none; width: 2.75rem; height: 2.75rem; margin: -0.3rem 0 -0.3rem -0.55rem; display: grid; place-items: center; border-radius: 50%; }
.tm-play svg { width: 1.7rem; height: 1.7rem; padding: 0.4rem; border-radius: 50%; fill: var(--on-accent); background: var(--noodle); }
.tm-play[aria-disabled="true"] svg { background: rgba(var(--ivory-rgb), 0.25); fill: var(--ivory); }
.tm-play[aria-disabled="true"], .tm-track[aria-disabled="true"] { cursor: default; }
.tm-track { position: relative; flex: 1; height: 2.75rem; margin: -0.3rem 0; display: flex; align-items: center; cursor: pointer; touch-action: none; border-radius: 0.4rem; }
.tm-segs { position: relative; display: flex; gap: 2px; width: 100%; height: 0.5rem; }
.tm-segs span { flex-basis: 0; min-width: 4px; border-radius: 2px; background: rgba(var(--ivory-rgb), 0.16); transition: background-color 0.2s; }
.tm-segs span:nth-child(odd) { background: rgba(var(--ivory-rgb), 0.24); }
.tm-segs span.is-on { background: rgba(var(--noodle-rgb), 0.85); }
.tm-segs:empty::before { content: ""; flex: 1; background: rgba(var(--ivory-rgb), 0.16); border-radius: 2px; }
.tm-head { position: absolute; top: 50%; left: 0; width: 0.8rem; height: 0.8rem; margin: -0.4rem 0 0 -0.4rem; border-radius: 50%; background: var(--ivory); box-shadow: 0 0 0 2px rgba(var(--veil-rgb), 0.9), 0 0 14px rgba(var(--noodle-rgb), calc(var(--glow-a) * 0.9)); pointer-events: none; }
.tm-track[aria-disabled="true"] .tm-head { opacity: 0.4; }
.tm-track:focus-visible { outline: 2px solid var(--noodle); outline-offset: 2px; }

/* Phones: the sandbox HUD is compact — two columns, no gauges — with the phase line and scrubber under it */
@media (max-width: 820px), (orientation: portrait) and (max-width: 1100px) {
  .telemetry--full .tm { padding: 0.55rem 0.7rem 0.6rem; }
  .telemetry--full .tm-label { font-size: 0.6875rem; margin-bottom: 0.35rem; }
  .telemetry--full .tm-cell { margin-bottom: 0.3rem; }
  .telemetry--full .tm-rows { grid-template-columns: 1fr 1fr; column-gap: 0.9rem; }
  .telemetry--full .tm-rows li { grid-template-columns: 1fr auto; font-size: var(--fs-micro); padding: 0.16rem 0; }
  .telemetry--full .tm-rows li:nth-child(2) { border-top: 0; }
  .telemetry--full .tm-val { min-width: 0; }
  .telemetry--full .tm-gauge { display: none; }
  .telemetry--full .tm-phase { margin-top: 0.4rem; padding-top: 0.35rem; }
  .telemetry--full .tm-phase button { padding: 0.35rem 0.15rem; }
}

/* ---- Portrait tablets (stacked layout, >= 600px wide): the phone composition with tablet-sized type and panels. Query = stacked.js isTabletStacked ---- */
@media (min-width: 600px) and (max-width: 820px) and (min-height: 700px), (orientation: portrait) and (min-width: 821px) and (max-width: 1100px) {
  .telemetry--full { display: flex; flex: 1; }
  .telemetry--full .tm { flex: 1; padding: 0.8rem 1rem 0.9rem; }
  .telemetry--full .tm-label { font-size: 0.8125rem; }
  .telemetry--full .tm-rows li { font-size: 0.875rem; padding: 0.24rem 0; }
  .telemetry--full .tm-phase { font-size: 0.8125rem; }
}
