/* A small shared motion vocabulary. Layout changes stay immediate; only the
   arriving content and interactive surfaces move, without stretching canvases. */
:root {
  --motion-ease: cubic-bezier(.22, 1, .36, 1);
  --motion-quick: 160ms;
  --motion-enter: 280ms;
}

.tunnel :is(button, .project-cta),
#about .round-button {
  transition: transform var(--motion-quick) var(--motion-ease),
    box-shadow var(--motion-quick) var(--motion-ease),
    background-color var(--motion-quick) ease,
    border-color var(--motion-quick) ease;
}
.project-cta .link-arrow,
.services-jump span,
#controls-toggle .ui-icon {
  transition: transform 220ms var(--motion-ease);
}
#controls-toggle[aria-expanded="true"] .ui-icon { transform: rotate(90deg); }

/* Horizontal gestures orbit; vertical gestures and pinch remain native. */
.simulator-page :is(#scene-canvas, #skate-canvas) {
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

/* Playback stays reachable in the clean stage view as well as with controls. */
.visual-bay > #playback {
  position: absolute;
  z-index: 2;
  right: 8px;
  bottom: 8px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 10px;
  border-radius: 50%;
}
.visual-bay > #playback svg { width: 20px; height: 20px; }
.visual-bay > #playback:focus-visible {
  outline: 3px solid var(--control-blue);
  outline-offset: 3px;
}

.scene[data-loading="true"] .visual-bay { cursor: progress; }
.scene[data-loading="true"] .visual-bay canvas { cursor: progress; }
#random[data-loading="true"] .ui-icon {
  animation: shuffle-turn 420ms var(--motion-ease) both;
}
.scene .loading-note:not([hidden]) {
  animation: note-enter 180ms ease-out both;
}

/* Toggle data-ready off before loading, then on once a canvas has a frame. */
.visual-bay canvas[data-ready="true"] {
  animation: scene-enter 360ms var(--motion-ease) both;
}

/* The rail wrappers use display:contents on phones, so animate their boxes. */
#tunnel-details:not([hidden]) .console-rail > *,
#tunnel-details:not([hidden]) .scene-foot {
  animation: controls-enter var(--motion-enter) var(--motion-ease) both;
}
#tunnel-details:not([hidden]) .rail-right > * { animation-delay: 35ms; }
#tunnel-details:not([hidden]) .scene-foot { animation-delay: 60ms; }

#about[open] { animation: dialog-enter var(--motion-enter) var(--motion-ease) both; }
#about[open]::backdrop { animation: backdrop-enter 180ms ease-out both; }

@media (hover: hover) and (pointer: fine) {
  .project-cta:hover .link-arrow { transform: translate(2px, -2px); }
  .services-jump:hover span { transform: translateY(3px); }
  #controls-toggle:hover,
  .scene-toolbar #limits-button:hover { transform: translateY(-1px); }
}

.tunnel :is(#controls-toggle, #limits-button):active {
  transform: translateY(1px);
}
.tunnel :is(button, .project-cta):active { transition-duration: 80ms; }
.tunnel button:disabled { cursor: wait; }

/* Avoid sticky desktop hover lifts after a tap on a touch screen. */
@media (hover: none) {
  #random:hover:not(:active) {
    transform: rotate(1deg);
    box-shadow: 3px 4px 0 var(--ink);
  }
  .project-slot .project-cta:hover:not(:active) {
    transform: rotate(-2deg);
    box-shadow: 4px 5px 0 var(--ink);
  }
  .tunnel :is(.round-button, .surface-modes button):hover:not(:active) {
    transform: none;
  }
}

@keyframes scene-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes controls-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dialog-enter {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes note-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shuffle-turn {
  from { transform: rotate(-35deg); }
  to { transform: rotate(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tunnel *, .tunnel *::before, .tunnel *::after,
  #about, #about::backdrop, .services-jump span {
    animation: none !important;
    transition: none !important;
  }
  .project-cta .link-arrow, .services-jump span,
  #controls-toggle .ui-icon { transform: none !important; }
}
