/* Robot demo. Loaded after /styles.css and reuses its palette, type and keys.
   The page is one fixed viewport: a canvas with controls floating over it. */
.demo-page { --edge: clamp(.875rem, 2.2vw, 1.75rem); --header-height: 80px; --stick: 124px; --knob: 52px;
  scroll-snap-type: none; overflow: hidden; overscroll-behavior: none; }
.demo-page body { height: var(--panel-height); min-height: 0; overflow: hidden; }
.demo-page .site-header { width: auto; inset-inline: var(--edge); pointer-events: none; }
.demo-page .site-header > * { pointer-events: auto; }
.demo-page .brand { width: 148px; }

.demo { position: fixed; inset: 0; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.demo-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.demo-canvas:active { cursor: grabbing; }
.demo > :not(.demo-canvas) { position: absolute; z-index: 1; }

.demo-panel { border-radius: 16px; background: rgb(244 246 244 / .84); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 #fff, 0 0 0 1px rgb(33 35 33 / .07), 0 18px 40px -24px rgb(33 35 33 / .5); }
.demo kbd { display: inline-grid; place-items: center; min-width: 1.625rem; height: 1.625rem; padding-inline: .375rem; border-radius: 6px; background: var(--raised);
  box-shadow: inset 0 0 0 1px rgb(33 35 33 / .18), 0 1px 0 rgb(33 35 33 / .18); color: var(--muted); font: 550 .75rem/1 "Hubot Sans", sans-serif; }

/* Scene keys (the site's LED keys) and reset, centred between logo and nav. */
.demo-top { top: calc((var(--header-height) - 48px) / 2); left: 50%; display: flex; gap: .625rem; transform: translateX(-50%); }
.demo-top .vision-selectors { width: auto; }
.demo-top .vision-selectors button { flex: none; min-height: 48px; padding: .5rem 1.125rem .5rem 2.25rem; font-size: var(--body); }
.demo-reset { min-height: 48px; padding: .625rem 1.25rem; border: 0; border-radius: 12px; background: var(--ink); color: var(--raised); font-size: var(--body); font-weight: 550; line-height: 1.4; cursor: pointer;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .14), 0 3px 0 #000, 0 8px 14px -8px rgb(33 35 33 / .6); transition: transform 120ms ease, box-shadow 120ms ease; }
.demo-reset:hover { background: #2f3330; }
.demo-reset:active { transform: translateY(3px); box-shadow: inset 0 2px 4px rgb(0 0 0 / .4), 0 0 0 #000; }

/* Grippers: a lit point marks the arm being steered; the bar is contact force. */
.demo-status { top: var(--header-height); right: var(--edge); display: grid; gap: .5rem; width: 264px; padding: .875rem 1rem; }
.demo-arm { display: grid; grid-template-columns: 4.25rem 1fr 3.5rem; align-items: center; gap: .625rem; color: var(--muted); font-size: var(--small); line-height: 1.4; }
.demo-arm-name { display: flex; align-items: center; gap: .5rem; font-weight: 550; }
.demo-arm-name::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #aeb6b2; box-shadow: inset 0 1px 1px rgb(33 35 33 / .25); }
.demo-arm.is-active { color: var(--ink); }
.demo-arm.is-active .demo-arm-name::before { background: var(--copper); box-shadow: 0 0 0 3px rgb(202 110 66 / .22), 0 0 10px rgb(202 110 66 / .7); }
.demo-meter { height: 6px; border-radius: 3px; background: var(--gel); overflow: hidden; }
.demo-meter-fill { display: block; width: 100%; height: 100%; border-radius: 3px; background: var(--copper); transform: scaleX(var(--level, 0)); transform-origin: left; transition: transform 120ms linear; }
.demo-grip-state { text-align: right; font-variant-numeric: tabular-nums; }
.demo-arm.is-touching .demo-grip-state { color: var(--copper-deep); font-weight: 550; }

/* Keyboard legend. */
.demo-legend { left: var(--edge); bottom: var(--edge); display: grid; gap: .5rem; padding: .875rem 1rem; font-size: var(--small); line-height: 1.4; }
.demo-legend p { display: flex; align-items: center; gap: .75rem; }
.demo-keys { display: inline-flex; gap: .1875rem; min-width: 7.125rem; }
.demo-hint { color: var(--muted); }

/* Action keys, shared by keyboard and touch layouts. */
.demo-pad { right: var(--edge); bottom: var(--edge); }
.demo-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; width: 316px; }
.demo-key { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 48px; padding: .5rem .75rem .5rem .875rem; border: 1px solid rgb(33 35 33 / .14); border-radius: 12px; background: var(--raised); color: var(--ink);
  font-size: var(--small); font-weight: 550; line-height: 1.3; text-align: left; white-space: nowrap; cursor: pointer; touch-action: manipulation;
  box-shadow: inset 0 1px 0 #fff, 0 3px 0 var(--gel-deep), 0 6px 10px -6px rgb(33 35 33 / .35); transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease; }
.demo-key:hover { background: #fff; }
.demo-key:active, .demo-key[aria-pressed="true"] { transform: translateY(3px); background: #eceeec; box-shadow: inset 0 2px 4px rgb(33 35 33 / .16), 0 0 0 var(--gel-deep); }
.demo-toggle > span { display: flex; align-items: center; gap: .5rem; }
.demo-short { display: none; }
.demo-toggle > span::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: #aeb6b2; box-shadow: inset 0 1px 1px rgb(33 35 33 / .25); }
.demo-toggle[aria-pressed="true"] > span::before { background: var(--copper); box-shadow: 0 0 0 3px rgb(202 110 66 / .22), 0 0 10px rgb(202 110 66 / .7); }

/* Joysticks (touch layout only). */
.demo-stick { position: relative; flex: none; width: var(--stick); height: var(--stick); border-radius: 50%; background: rgb(244 246 244 / .7); touch-action: none;
  box-shadow: inset 0 0 0 1px rgb(33 35 33 / .14), inset 0 6px 14px rgb(33 35 33 / .1); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.demo-stick-knob { position: absolute; inset: calc((var(--stick) - var(--knob)) / 2); border-radius: 50%; background: var(--ink); pointer-events: none;
  transform: translate(calc(var(--x, 0) * (var(--stick) - var(--knob)) / 2), calc(var(--y, 0) * (var(--stick) - var(--knob)) / -2));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .18), 0 4px 10px -2px rgb(33 35 33 / .6); }
.demo-stick.is-held .demo-stick-knob { background: var(--copper-deep); }
.demo-stick-label { position: absolute; left: 0; right: 0; bottom: calc(100% + .375rem); text-align: center; color: var(--muted); font-size: .8125rem; font-weight: 550; pointer-events: none; }

/* Status of the demo itself. "Coming soon" is an unlit sensing point: a ring, no copper yet. */
.demo-wip { display: flex; flex-wrap: wrap; align-items: center; gap: .125rem .75rem; margin-top: .25rem; padding-top: .625rem; border-top: 1px solid rgb(33 35 33 / .1); font-size: .8125rem; line-height: 1.45; }
.demo-wip strong { font-weight: 550; }
.demo-soon { display: flex; align-items: center; gap: .4375rem; color: var(--muted); }
.demo-soon::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--muted); }
.demo-note { color: var(--muted); font-size: .8125rem; line-height: 1.45; }
.demo-loading { top: 50%; left: 50%; display: flex; align-items: center; gap: .75rem; max-width: calc(100% - 2rem); padding: 1rem 1.25rem; transform: translate(-50%, -50%); font-size: var(--body); font-weight: 500; }
.demo-loading-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--copper); box-shadow: 0 0 0 4px rgb(202 110 66 / .16); }
.demo-loading.is-error .demo-loading-dot { background: #aeb6b2; box-shadow: none; }

/* Controls appear once the simulation is running, in the layout for the input in use. */
.demo-page:not(.demo-ready) :is(.demo-top, .demo-status, .demo-legend, .demo-pad) { display: none; }
[data-input="keys"] .demo-stick, [data-input="touch"] .demo-legend, [data-input="touch"] .demo kbd { display: none; }

[data-input="touch"] .demo-pad { left: max(var(--edge), env(safe-area-inset-left)); right: max(var(--edge), env(safe-area-inset-right)); bottom: max(var(--edge), env(safe-area-inset-bottom));
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: .75rem; }
[data-input="touch"] .demo-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); width: auto; max-width: 420px; margin-inline: auto; }
[data-input="touch"] .demo-key { justify-content: center; min-height: 46px; padding-inline: .375rem; text-align: center; }
[data-input="touch"] .demo-toggle > span { gap: .375rem; }

@media (max-width: 820px) {
  /* Scene keys drop to a second row under the header. */
  .demo-page { --header-height: 64px; }
  .demo-page .brand { width: 124px; }
  .demo-top { top: var(--header-height); left: var(--edge); transform: none; }
  .demo-top .vision-selectors button, .demo-reset { min-height: 44px; }
  .demo-top .vision-selectors button { padding: .5rem .875rem .5rem 2.125rem; }
  .demo-reset { padding-inline: 1rem; }
  .demo-status { top: calc(var(--header-height) + 3.5rem); left: var(--edge); right: auto; width: 226px; padding: .625rem .75rem; gap: .375rem; }
  .demo-wip, .demo-note { font-size: .75rem; }
}
@media (orientation: portrait) {
  /* Phone held upright: actions in a row above the two joysticks. */
  [data-input="touch"] .demo-pad { grid-template-columns: 1fr 1fr; row-gap: 1.75rem; }
  [data-input="touch"] .demo-actions { grid-column: 1 / -1; grid-row: 1; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .375rem; max-width: none; margin: 0; }
  [data-input="touch"] .demo-key { padding-inline: .125rem; font-size: .8125rem; }
  [data-input="touch"] .demo-toggle > span { gap: .3125rem; }
  [data-input="touch"] .demo-long { display: none; }
  [data-input="touch"] .demo-short { display: inline; }
  /* Both grippers on one line, so the robot stays in view. */
  [data-input="touch"] .demo-status { right: var(--edge); width: auto; grid-template-columns: 1fr 1fr; column-gap: 1.25rem; }
  [data-input="touch"] .demo-arm { grid-template-columns: auto 1fr auto; }
  [data-input="touch"] :is(.demo-wip, .demo-note) { grid-column: 1 / -1; margin-top: 0; }
  [data-input="touch"] .demo-wip { padding-top: .5rem; }
  [data-input="touch"] .demo-stick[data-stick="hand"] { justify-self: end; }
}
@media (orientation: landscape) and (max-height: 520px) {
  /* Phone on its side: everything moves to the edges to keep the view clear. */
  .demo-page { --stick: 112px; --header-height: 56px; }
  .demo-page .brand { width: 108px; }
  .demo-top { top: calc((var(--header-height) - 44px) / 2); left: 50%; transform: translateX(-50%); }
  .demo-status { top: var(--header-height); }
  .demo-note { display: none; }
  [data-input="touch"] .demo-key { min-height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .demo-reset, .demo-key, .demo-meter-fill { transition: none; }
}

/* Tactile view (development preview, ?tactile=…): the two jaws of the arm being steered side by side,
   each a taxel map with the simulated tactile image under it when one is available. */
.demo-tactile { display: grid; gap: .4375rem; margin-top: .25rem; padding-top: .625rem; border-top: 1px solid rgb(33 35 33 / .1); font-size: .8125rem; line-height: 1.45; }
.demo-tactile-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.demo-tactile-head strong { font-weight: 550; }
.demo-tactile-head span, .demo-tactile-pad figcaption, .demo-tactile-scale { color: var(--muted); }
.demo-tactile-pads { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.demo-tactile-pad { display: grid; gap: .25rem; margin: 0; }
.demo-tactile canvas { display: block; width: 100%; height: auto; aspect-ratio: 52 / 25; border-radius: 6px; background: var(--silicone); box-shadow: inset 0 0 0 1px rgb(33 35 33 / .08); }
.demo-tactile canvas[hidden] { display: none; }
.demo-tactile-scale { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; font-variant-numeric: tabular-nums; }
.demo-tactile-ramp { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--line), var(--copper) 50%, var(--copper-deep)); }
.demo-tactile-on .demo-status { width: 340px; }
.demo-tactile-on :is(.demo-soon, .demo-note) { display: none; }
@media (max-width: 820px) {
  .demo-tactile-on .demo-status { width: 226px; }
}
@media (orientation: portrait) {
  .demo-tactile-on[data-input="touch"] .demo-status { width: auto; }
  [data-input="touch"] .demo-tactile { grid-column: 1 / -1; }
}
@media (orientation: landscape) and (max-height: 520px) {
  /* Phone on its side: maps only, so the panel ends above the joystick. */
  .demo-tactile-head, .demo-tactile-scale, .demo-tactile-pad figcaption, .demo-tactile .demo-gel { display: none; }
  .demo-tactile-on .demo-status { width: 226px; }
  .demo-tactile { margin-top: 0; padding-top: .375rem; }
}
