/* M1 Studia Assistant motion (flag STUDIA_M1_MOTION_ENABLED, students only).
   Part 1 is the approved run 3 rig CSS, unchanged (docs/mascot_motion/m1-poc/lib/studia-assistant-rig.css).
   Part 2 is the scoped dock. Everything is under .m1-motion-dock or .sa-*; no global rules. */

/* ---------- 1. Rig (run 3, verbatim) ---------- */
.sa-rig { position: relative; container-type: size; }
/* Keep both the animated rig and static fallback clear on every host surface. */
.sa-rig, .sa-frame, .sa-body, .sa-rig .sa-static, .sa-rig .sa-part { background: transparent; }
.sa-rig .sa-static { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.sa-frame {
  position: absolute; inset: 0; margin: auto;
  /* Same box as object-fit: contain for a 1536 x 1024 image. */
  width: min(100cqw, 150cqh); height: min(100cqh, 66.6667cqw);
  pointer-events: none; user-select: none; visibility: hidden;
}
.sa-body { position: absolute; inset: 0; transform-origin: 50% 70%; }
.sa-part { position: absolute; max-width: none; pointer-events: none; -webkit-user-drag: none; will-change: transform; }
.sa-rig[data-pose="rig"] .sa-frame { visibility: visible; }
.sa-rig[data-pose="rig"] .sa-static { visibility: hidden; }
/* Reduced motion and any failure: the original only. */
.sa-rig[data-reduced-motion="true"] .sa-frame { visibility: hidden !important; }
.sa-rig[data-reduced-motion="true"] .sa-static { visibility: visible !important; }
.sa-rig, .sa-rig * { pointer-events: none; }

/* ---------- 2. Dock ---------- */
/* Decorative, click-through, never mirrored. It sits at the inline end, above every
   bar attached to the bottom of the viewport (the tab bar, the sticky chat composer);
   the controller measures those and sets --m1-dock-bottom. */
.m1-motion-dock {
  position: fixed;
  inset-inline-end: max(12px, env(safe-area-inset-right, 0px));
  bottom: var(--m1-dock-bottom, calc(3.5rem + env(safe-area-inset-bottom, 0px)));
  z-index: 40; /* below the tab bar (z-50) */
  width: 72px;
  height: 48px;
  pointer-events: none;
  transition: opacity 160ms ease-out;
}
/* Yield: when the dock would cover text, media or a control, it fades out of the way.
   State changes continue; only the drawing steps aside. */
.m1-motion-dock[data-yield="true"] { opacity: 0; visibility: hidden; transition: opacity 120ms ease-in, visibility 0s 120ms; }
.m1-motion-dock[data-assistant-state="hidden"] { visibility: hidden; }
.m1-motion-dock[data-assistant-state="minimized"] { transform: scale(0.75); transform-origin: bottom right; opacity: 0.85; }
[dir="rtl"] .m1-motion-dock[data-assistant-state="minimized"] { transform-origin: bottom left; }
@media (prefers-reduced-motion: reduce) {
  .m1-motion-dock, .m1-motion-dock[data-yield="true"] { transition: none; }
}
@media (min-width: 768px) {
  .m1-motion-dock { width: 96px; height: 64px; }
}

/* Separate message card, never baked into the approved bird artwork. */
.m1-motion-message {
  position: absolute; inset-inline-end: 0; bottom: 100%;
  width: max-content; max-width: min(230px, calc(100vw - 32px));
  padding: 8px 12px; margin: 0 0 6px; border: 1px solid #dbeafe;
  border-radius: 12px; background: #fff; color: #172554;
  font-size: 14px; line-height: 1.7; box-shadow: 0 2px 8px #17255412;
  pointer-events: none;
}
.m1-motion-message[hidden] { display: none; }
/* Second place for the card: beside the bird. If both places would cover something,
   only the card steps aside and the bird stays. */
.m1-motion-dock[data-card="beside"] .m1-motion-message {
  bottom: 0; inset-inline-end: calc(100% + 8px); margin: 0; max-width: min(230px, calc(100vw - 136px));
}
.m1-motion-dock[data-card="none"] .m1-motion-message { visibility: hidden; }
/* Small screens: feedback that would cover content gets its own empty strip in the page. */
.m1-motion-strip { flex: none; width: 100%; height: 72px; pointer-events: none; }
.m1-motion-dock[data-place="strip"] { position: absolute; inset-inline-end: auto; bottom: auto; left: var(--m1-strip-left); top: var(--m1-strip-top); }
/* Preferences remain in document flow even when the decorative dock is hidden. */
.m1-motion-settings { margin: 12px 16px; padding: 12px; color: #334155; font-size: 14px; }
.m1-motion-settings summary { cursor: pointer; min-height: 44px; width: fit-content; }
.m1-motion-settings [role="group"] { display: flex; flex-wrap: wrap; gap: 8px; }
.m1-motion-settings button { min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid #cbd5e1; background: white; }
.m1-motion-settings button[aria-pressed="true"] { border-color: #1d4ed8; background: #eff6ff; color: #1e3a8a; }
.m1-motion-settings button:focus-visible, .m1-motion-settings summary:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 3px; }
