/* The mesh layer replaces only the actor artwork; source geometry and the
   separate floor/deck shadows remain in the established UI layout. */
.rig-motion-canvas {
  position:absolute;
  inset:0;
  display:block;
  width:100%;
  height:100%;
  pointer-events:none;
}
.game>.rig-motion-canvas { z-index:4; }
.workshop-scene>.rig-motion-canvas { z-index:3; }
.admiral-portrait.rig-source-hidden,
.crew-portrait.rig-source-hidden,
.worker-sprite.rig-source-hidden { background-image:none!important; }
.threat-step .admiral-portrait.rig-source-hidden,
.threat-step .crew-portrait.rig-source-hidden { animation:none; }

/* A quiet breathing fallback for devices without the mesh renderer. Animate
   the worker's image, never its positioned host or its contact shadow. */
.admiral-portrait.rig-css-fallback,
.crew-portrait.rig-css-fallback,
.worker-sprite.rig-css-fallback {
  transform-origin:50% 95%;
  animation:rig-fallback-breath var(--rig-breath-duration,4.8s) ease-in-out infinite;
  animation-delay:var(--rig-breath-delay,0s);
}
.admiral-portrait.rig-css-fallback { --rig-breath-duration:4.9s; --rig-breath-delay:-1.1s; }
.crew-captain.rig-css-fallback { --rig-breath-duration:4.3s; --rig-breath-delay:-2.2s; }
.crew-mate.rig-css-fallback { --rig-breath-duration:4.7s; --rig-breath-delay:-.6s; }
.worker-carpenter .worker-sprite.rig-css-fallback { --rig-breath-duration:3.8s; --rig-breath-delay:-.8s; }
.worker-painter .worker-sprite.rig-css-fallback { --rig-breath-duration:4.2s; --rig-breath-delay:-2.1s; }
.worker-rigger .worker-sprite.rig-css-fallback { --rig-breath-duration:4.4s; --rig-breath-delay:-1.4s; }
.worker-foreman .worker-sprite.rig-css-fallback { --rig-breath-duration:4.8s; --rig-breath-delay:-3s; }
.rig-css-fallback.rig-source-hidden { animation:none; }
@keyframes rig-fallback-breath {
  0%,100% { transform:scale(1,1); }
  44% { transform:scale(1.004,1.014); }
}

/* Home uses its already composited boat: a slow, small swell keeps the hull
   afloat without repainting the scene or moving any button/hit geometry. */
.home-vessel>canvas {
  z-index:1;
  transform-origin:50% 84%;
  animation:home-harbor-swell 6.8s ease-in-out infinite;
  will-change:transform;
  pointer-events:none;
}
.home-vessel::after {
  content:'';
  position:absolute;
  left:50%;
  bottom:0;
  width:58%;
  height:9px;
  border:1px solid #b4f2e45c;
  border-radius:50%;
  box-shadow:0 0 0 4px #b4f2e415;
  transform:translateX(-50%);
  pointer-events:none;
  z-index:0;
}
@keyframes home-harbor-swell {
  0%,100% { transform:translateX(-50%) translate3d(0,0,0) rotate(-.25deg); }
  32% { transform:translateX(-50%) translate3d(1.4px,-3px,0) rotate(.8deg); }
  68% { transform:translateX(-50%) translate3d(-1.3px,1px,0) rotate(-.8deg); }
}

/* Pausing retains the current phase. Decorative aria-hidden crew wrappers do
   not pause their actors; only hidden/inert screens and app lifecycle do. */
.motion-paused .home-vessel>canvas,
.motion-paused .rig-css-fallback,
[inert] .rig-css-fallback,
.home-screen[inert] .home-vessel>canvas,
.home-screen[aria-hidden="true"] .home-vessel>canvas,
.game[aria-hidden="true"] .rig-css-fallback,
.meta-overlay[aria-hidden="true"] .rig-css-fallback,
.workshop-scene[aria-hidden="true"] .rig-css-fallback {
  animation-play-state:paused!important;
}
@media(prefers-reduced-motion:reduce) {
  .home-vessel>canvas,.rig-css-fallback { animation:none!important; }
  .home-vessel>canvas { transform:translateX(-50%); }
}
