/* Shared motion and geometry; never fade or scale the scientific canvas. */
.motion-disclosure::details-content {
  transition: none;
  overflow: visible;
}
.motion-disclosure:not([open])::details-content {
  block-size: 0;
}
.motion-disclosure[open]::details-content {
  block-size: auto;
}
.ui-shell,
.space-shell {
  position: relative;
}
/* Shared parameter rail: same scroll surface and sticky header on every route. */
body .md-parameter-rail {
  isolation: isolate;
  contain: layout paint;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: var(--design-inset);
  border: 1px solid transparent;
  border-radius: var(--design-radius-surface);
}
.md-parameter-rail > .motion-menu-header {
  position: sticky;
  top: -12px;
  z-index: 6;
  flex-shrink: 0;
  margin: -12px -12px 8px;
  padding: 12px 12px 8px;
  background: var(--design-inset);
}
.motion-menu-header:not(:has(> :not([hidden]))) {
  display: none;
}
.motion-menu-header > .dt-rail-navigation {
  position: static;
  margin: 6px 0 0;
  padding: 0;
}
/* One icon/label component; state layers never replace the base container color. */
body :is(button.motion-menu-grip, button.motion-menu-edge) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  min-height: var(--md-sys-size-target);
  margin: 0;
  border: 1px solid var(--design-line);
  border-radius: var(--md-sys-shape-corner-large);
  color: var(--design-primary);
  background: var(--design-surface);
  font: 500 calc(13px * var(--ui-font-scale, 1))/1.4 var(--design-font);
  box-shadow: none;
  cursor: ew-resize;
}
body button.motion-menu-grip {
  width: 100%;
}
body button.motion-menu-edge {
  position: absolute;
  left: 2px;
  top: 48%;
  z-index: 8;
  width: var(--md-sys-size-target);
  min-width: var(--md-sys-size-target);
  height: 56px;
  padding: 0;
}
body :is(button.motion-menu-grip, button.motion-menu-edge) svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
body :is(button.motion-menu-grip, button.motion-menu-edge):hover {
  box-shadow: inset 0 0 0 999px var(--md-sys-state-hover);
}
body :is(button.motion-menu-grip, button.motion-menu-edge):active {
  box-shadow: inset 0 0 0 999px var(--md-sys-state-pressed);
}
body :is(button.motion-menu-grip, button.motion-menu-edge)[hidden] {
  display: none;
}
@media (min-width: 761px) {
  .ui-shell #uiParametersButton,
  body[data-page='space'] #spaceParameters {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--design-line);
    border-radius: 12px;
    background: var(--design-surface);
    color: var(--design-primary);
    font-size: calc(13px * var(--ui-font-scale, 1));
    white-space: nowrap;
  }
  .ui-shell .ui-grid,
  body[data-page='space'] .space-shell {
    transition: none;
  }
  .ui-shell .ui-parameters,
  .space-sidebar-host {
    transition:
      transform 360ms cubic-bezier(0.22, 1.12, 0.36, 1),
      opacity 200ms ease;
  }
  .ui-shell.motion-rail-collapsed .ui-grid,
  body[data-page='space'] .space-shell.motion-rail-collapsed {
    grid-template-columns: 0px minmax(0, 1fr);
    column-gap: 0;
  }
  .ui-shell.motion-rail-collapsed .ui-parameters,
  .space-shell.motion-rail-collapsed .space-sidebar-host {
    transform: translateX(-24px);
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    padding: 0;
    border: 0;
  }
}
.ui-parameters details > summary {
  transition:
    background-color 200ms ease,
    color 200ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .md-connected-choice > button,
  .motion-segments > button,
  .ui-shell .ui-grid,
  .ui-shell .ui-parameters,
  body[data-page='space'] .space-shell,
  .space-sidebar-host {
    transition: none !important;
  }
  .ui-parameters details[open] > :not(summary) {
    animation: none;
  }
}

/* Wide screens use the rail handle only; the heading button opens modal menus. */
#uiParametersButton[hidden],
#spaceParameters[hidden] {
  display: none !important;
}

/* Elastic feedback for interactive surfaces, never for physical celestial positions. */
:is(button, .page-action, .welcome-document-link, .document-links a, .page-nav a) {
  transition:
    transform 320ms cubic-bezier(0.22, 1.3, 0.36, 1),
    box-shadow 200ms ease;
}
:is(button, .page-action, .document-links a, .page-nav a):active {
  transform: scale(0.97);
}
.ui-parameters details > summary::after {
  transition: transform 320ms cubic-bezier(0.22, 1.3, 0.36, 1) !important;
}
@media (prefers-reduced-motion: reduce) {
  :is(button, .page-action, .welcome-document-link, .document-links a, .page-nav a) {
    transition: none !important;
  }
  :is(button, .page-action, .document-links a, .page-nav a):active {
    transform: none;
  }
  .ui-parameters details > summary::after {
    transition: none !important;
  }
}

.scene-tools[open] .scene-tools-panel {
  animation: motion-tools-pop 320ms cubic-bezier(0.2, 0, 0, 1);
  transform-origin: bottom right;
}
@keyframes motion-tools-pop {
  0% {
    opacity: 0.3;
    transform: translateY(10px) scale(0.94);
  }
  70% {
    opacity: 1;
    transform: translateY(-1px) scale(1.012);
  }
  87% {
    transform: translateY(0.3px) scale(0.997);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .scene-tools[open] .scene-tools-panel {
    animation: none;
  }
}
/* Allocate canvas space once; panel/content motion runs on compositor transforms. */
.motion-rail-animating {
  overflow: clip;
}
.ui-parameter-drawer[open],
body[data-page='space'] #spaceDrawer[open] {
  contain: layout paint;
  will-change: transform;
}

/* Do not blur a large scientific canvas for a parameter-only overlay. */
.ui-parameter-drawer::backdrop,
body[data-page='space'] #spaceDrawer::backdrop {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
