/* Labels rendered by the 3D stage (CSS2DRenderer). The stage owns positioning; this owns looks. */
.stage-label {
  pointer-events: none; white-space: nowrap;
  font-family: "Archivo", system-ui, sans-serif; font-stretch: 100%; font-weight: 500;
  font-size: 0.75rem; line-height: 1; letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
  color: rgba(var(--ivory-rgb), 0.8);
  background: rgba(var(--veil-rgb), 0.6); padding: 0.32rem 0.6rem; border-radius: 999px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  -webkit-user-select: none; user-select: none;
}
.stage-label--held {
  color: var(--held-text); font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(var(--held-rgb), 0.7);
}
.stage-label--joint {
  position: relative; font-size: 0.8125rem; padding: 0.4rem 0.7rem 0.4rem 1.9rem; border-radius: 3px;
  background: rgba(var(--veil-rgb), 0.72);
  box-shadow: 0 0 0 1px rgba(var(--ivory-rgb), 0.12);
}
.stage-label--joint::before { /* leader line ending in a dot */
  content: ""; position: absolute; left: 0.5rem; top: 50%; width: 0.85rem; height: 1px;
  background: var(--ivory); opacity: 0.7;
}
.stage-label--joint::after {
  content: ""; position: absolute; left: 0.3rem; top: 50%; width: 5px; height: 5px; margin-top: -2.5px;
  border-radius: 50%; background: var(--noodle);
}
@media (max-width: 640px) {
  .stage-label { font-size: 0.6875rem; padding: 0.28rem 0.5rem; }
  .stage-label--joint { font-size: 0.72rem; padding-left: 1.7rem; }
}

/* 3D phase words pinned along the gripper's path (Approach ... Return). Layer is aria-hidden; the stage
   turns pointer events on in the sandbox only. Dark themes glow in the accent; light themes use ink. */
.stage-phase {
  white-space: nowrap; user-select: none; -webkit-user-select: none;
  font-family: "Archivo", system-ui, sans-serif; font-stretch: 112%; font-weight: 700;
  font-size: 1rem; line-height: 1; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums;
  color: var(--ivory);
  text-shadow: 0 0 10px rgba(var(--noodle-rgb), calc(var(--glow-a) * 0.7)), 0 1px 3px rgba(var(--veil-rgb), 0.9);
  transition: color 0.25s, text-shadow 0.25s, opacity 0.25s, transform 0.25s var(--ease-out);
}
.stage-phase--done { color: rgba(var(--ivory-rgb), 0.6); text-shadow: 0 1px 3px rgba(var(--veil-rgb), 0.8); }
.stage-phase--active {
  color: var(--accent-text);
  text-shadow: 0 0 16px rgba(var(--noodle-rgb), calc(var(--glow-a) + 0.25)), 0 0 34px rgba(var(--noodle-rgb), calc(var(--glow-a) * 0.7)), 0 1px 3px rgba(var(--veil-rgb), 0.9);
}
body[data-chapter="sandbox"] .stage-phase { cursor: pointer; }
body[data-chapter="sandbox"] .stage-phase:hover { color: var(--accent-text); }
html[data-mode="light"] .stage-phase { text-shadow: 0 0 8px rgba(var(--wall-rgb), 0.85), 0 0 2px rgba(var(--wall-rgb), 0.9); }
html[data-mode="light"] .stage-phase--done { color: rgba(var(--ivory-rgb), 0.72); }
html[data-mode="light"] .stage-phase--active { color: var(--ivory); text-shadow: 0 0 10px rgba(var(--noodle-rgb), 0.9), 0 0 3px rgba(var(--wall-rgb), 0.95); font-weight: 800; }
@media (max-width: 640px) { .stage-phase { font-size: 0.875rem; } }

/* ---- 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) {
  .stage-phase { font-size: 1.125rem; }
  .stage-label { font-size: 0.875rem; }
}
