/* Motion and the approved homepage light field. Existing geometry, typography
   and hit targets stay application-owned. No hidden initial content state. */
:root {
  --dsh-m-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --dsh-m-exit: cubic-bezier(0.7, 0, 0.84, 0);
  --dsh-m-state: cubic-bezier(0.65, 0, 0.35, 1);
  --dsh-m-micro: 180ms;
  --dsh-m-press: 150ms;
  --dsh-m-switch: 240ms;
  --dsh-m-layer: 260ms;
  --dsh-m-reveal: 560ms;
  --dsh-m-stagger: 60ms;
  --dsh-m-distance: 20px;
  --dsh-m-ambient: 18s;
  --dsh-m-ambient-long: 24s;
  --dsh-m-drift: cubic-bezier(.45, 0, .55, 1);
}

/* The homepage's approved pink/blue light field. These are new decorative
   layers inside the existing isolated stage, never layout or hit targets.
   Soft gradients are rasterised once; only transform and opacity move. */
html[data-dsh-motion][data-owner-home] #root .dsh-home-atmosphere {
  position: absolute;
  inset: 0 0 auto;
  height: 350px;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  contain: paint;
  isolation: isolate;
  border-radius: 0;
  /* The radial mask reaches full transparency before all three visible edges. */
  mask-image: radial-gradient(ellipse 70% 100% at 50% 0%, #000 18%, #000 35%, transparent 70%);
  background: radial-gradient(ellipse at 28% 0%, #d98da51b, transparent 60%),
    radial-gradient(ellipse at 73% 0%, #7fa8d51b, transparent 60%);
}
.dsh-home-atmosphere > i {
  position: absolute;
  display: block;
  width: 82%;
  height: 390px;
  top: -150px;
  opacity: .88;
  animation: dsh-m-pink var(--dsh-m-ambient) var(--dsh-m-drift) infinite alternate;
}
.dsh-home-atmosphere > .dsh-home-light--rose {
  left: -12%;
  background: radial-gradient(ellipse at 50% 42%, #ed9bb969 0%, #cc7da938 32%, #b7739820 48%, transparent 72%);
}
.dsh-home-atmosphere > .dsh-home-light--blue {
  right: -12%;
  background: radial-gradient(ellipse at 50% 42%, #89b9ed70 0%, #759fc63d 32%, #7186b020 48%, transparent 72%);
  animation-name: dsh-m-blue;
  animation-duration: var(--dsh-m-ambient-long);
}
.dsh-home-atmosphere > .dsh-home-light--pearl {
  left: 20%;
  top: -178px;
  width: 60%;
  height: 290px;
  background: radial-gradient(ellipse at 50% 50%, #efdeef26 0%, #d6b4de12 38%, transparent 70%);
  animation-name: dsh-m-pearl;
  animation-duration: var(--dsh-m-ambient-long);
}
@keyframes dsh-m-pink {
  from { transform: translate3d(-3%, -3%, 0) rotate(-8deg) scale(1); opacity: .76; }
  to { transform: translate3d(20%, 7%, 0) rotate(5deg) scale(1.12); opacity: 1; }
}
@keyframes dsh-m-blue {
  from { transform: translate3d(4%, 4%, 0) rotate(8deg) scale(1.08); opacity: .95; }
  to { transform: translate3d(-19%, -2%, 0) rotate(-5deg) scale(.96); opacity: .72; }
}
@keyframes dsh-m-pearl {
  from { transform: translate3d(-9%, 0, 0) scale(.94); opacity: .45; }
  to { transform: translate3d(9%, 5%, 0) scale(1.08); opacity: .8; }
}
html[data-dsh-motion][data-web-theme=light] #root .dsh-home-atmosphere { opacity: .65; }
html[data-dsh-motion]:not([data-dsh-motion-hidden]):not([data-dsh-motion-still])
 .dsh-home-atmosphere:not([data-dsh-motion-paused]) > i { will-change: transform, opacity; }
html[data-dsh-motion-hidden] .dsh-home-atmosphere > i,
html[data-dsh-motion] .dsh-home-atmosphere[data-dsh-motion-paused] > i {
  animation-play-state: paused;
  will-change: auto;
}
html[data-dsh-motion-still] .dsh-home-atmosphere > i { animation: none; will-change: auto; }
@media (prefers-reduced-motion: reduce) {
  html[data-dsh-motion] .dsh-home-atmosphere > i { animation: none; will-change: auto; }
}
@media (max-width: 760px) {
  html[data-dsh-motion][data-owner-home] #root .dsh-home-atmosphere { height: 280px; }
  .dsh-home-atmosphere > i { width: 100%; height: 330px; top: -125px; }
  .dsh-home-atmosphere > .dsh-home-light--pearl { display: none; }
}
@media (forced-colors: active) {
  html[data-dsh-motion][data-owner-home] #root .dsh-home-atmosphere { display: none; }
}
@supports not (mask-image: linear-gradient(#000, transparent)) {
  html[data-dsh-motion][data-owner-home] #root .dsh-home-atmosphere {
    background: radial-gradient(ellipse 32% 60% at 35% 0%, #ed9bb938, transparent 95%),
      radial-gradient(ellipse 32% 60% at 65% 0%, #89b9ed38, transparent 95%);
  }
  .dsh-home-atmosphere > i { display: none; }
}

/* Replace existing CSS entrances, never add a second controller to a surface
   already animated by cutlib-experience.js. Anchored surfaces only fade: their
   measuring code and fixed-position descendants keep their original geometry. */
html[data-dsh-motion] body :is(.oh-project-menu,.oh-dialog[open],.oh-option-surface,
 .ct-panel,.ct-task-menu,.ct-confirm,.ct-toast,.drs-modal[open],
 .drs-more-panel[popover],.drs-episode-list[popover]) {
  animation: dsh-m-surface var(--dsh-m-layer) var(--dsh-m-enter) !important;
}
html[data-dsh-motion][data-lz-canvas][data-cutlib-polish] body #root
 :is(.ds-node-editor,.ds-immersive-menu,.ds-media-toolbar,.ds-selection-tools) {
  animation-duration: var(--dsh-m-switch) !important;
  animation-timing-function: var(--dsh-m-enter) !important;
}
/* These two native surfaces retain an identity translate after their entrance.
   Preserve it: removing it changes final text rasterisation on Chromium. */
html[data-dsh-motion] body :is(.drs-layout,.drs-setup) {
  animation-duration: var(--dsh-m-switch) !important;
  animation-timing-function: var(--dsh-m-enter) !important;
}
html[data-dsh-motion] body :is(.drs-asset-canvas,
 .drs-script-workspace>.drs-author-scroll,.drs-layout>.drs-chat-panel) {
  animation: dsh-m-surface var(--dsh-m-switch) var(--dsh-m-enter) !important;
}
html[data-dsh-motion] body .drs-backdrop,
html[data-dsh-motion] body .oh-dialog::backdrop {
  animation: dsh-m-surface var(--dsh-m-micro) var(--dsh-m-enter) !important;
}
@keyframes dsh-m-surface { from { opacity: .65; } to { opacity: 1; } }

/* Keep each control's existing end states. Only transform/opacity interpolate;
   borders, colours and shadows keep the original application's state styles. */
html[data-dsh-motion][data-owner-home] #root
 :is(.oh-canvas-choice,.oh-template-scene,
 .oh-new-plus,.cl-home-add) {
  transition-property: transform, opacity !important;
  transition-duration: var(--dsh-m-micro) !important;
  transition-timing-function: var(--dsh-m-enter) !important;
}
html[data-dsh-motion][data-owner-home] #root .oh-view-tabs::before {
  transition: transform var(--dsh-m-switch) var(--dsh-m-state) !important;
}
html[data-dsh-motion][data-owner-home] #root .oh-canvas-new::before {
  transition: opacity var(--dsh-m-micro) var(--dsh-m-enter) !important;
}
html[data-dsh-motion] body :is(.oh-setting-arrow svg,.oh-upload-tile svg,
 .drs-primary,.drs-secondary,.drs-rail>button,.ct-panel button,.ct-confirm button) {
  transition-property: transform, opacity !important;
  transition-duration: var(--dsh-m-micro) !important;
  transition-timing-function: var(--dsh-m-enter) !important;
}
html[data-dsh-motion] body :is(.oh-canvas-choice,.drs-primary,.drs-secondary):active {
  transition-duration: var(--dsh-m-press) !important;
  transition-timing-function: var(--dsh-m-exit) !important;
}

/* A small response on existing tool glyphs leaves the button and its focus
   outline in place. Touch users retain the application's native press state. */
@media (hover: hover) and (pointer: fine) {
  html[data-dsh-motion] body :is(.ds-canvas-rail,.ds-canvas-toolbar,.ds-viewport-tools) button>svg:not(.ds-spin) {
    transition: transform var(--dsh-m-micro) var(--dsh-m-enter);
  }
  html[data-dsh-motion]:not([data-dsh-motion-still]) body :is(.ds-canvas-rail,.ds-canvas-toolbar,.ds-viewport-tools) button:enabled:active>svg:not(.ds-spin) {
    transform: scale(.92);
  }
}

/* Pause existing decorative loops outside the viewport and in background tabs.
   The shared observer owns these markers and removes them when disposed. */
html[data-dsh-motion] [data-dsh-motion-paused],
html[data-dsh-motion] [data-dsh-motion-paused] *,
html[data-dsh-motion-hidden] :is(.oh-input-motion i,.cl-home-add,.lz-canvas-welcome svg) {
  animation-play-state: paused !important;
  will-change: auto !important;
}

/* Both the operating system and the existing in-app preference are live. */
:root[data-dsh-motion-still] {
  --dsh-m-micro: 0ms;
  --dsh-m-press: 0ms;
  --dsh-m-switch: 0ms;
  --dsh-m-layer: 0ms;
  --dsh-m-reveal: 0ms;
}
html[data-dsh-motion-still] body :is(.oh-project-menu,.oh-dialog,.oh-option-surface,
 .ct-panel,.ct-task-menu,.ct-confirm,.ct-toast,.drs-root,.drs-root *,
 .drs-modal,.drs-modal *,.drs-backdrop,.drs-more-panel,.drs-episode-list,
 .oh-canvas-choice,.oh-template-scene,.oh-campaign>img,.oh-featured-media>img,
 .oh-new-plus,.cl-home-add,.oh-setting-arrow svg,.oh-upload-tile svg,
 .ds-node-editor,.ds-immersive-menu,.ds-media-toolbar,.ds-selection-tools,
 .ds-canvas-rail button>svg,.ds-canvas-toolbar button>svg,.ds-viewport-tools button>svg) {
  animation: none !important;
  transition: none !important;
}
html[data-dsh-motion-still] body .oh-view-tabs::before,
html[data-dsh-motion-still] body .oh-canvas-new::before,
html[data-dsh-motion-still] body .oh-dialog::backdrop {
  animation: none !important;
  transition: none !important;
}
html[data-dsh-motion-still] body :is(.oh-input-motion i,.lz-canvas-welcome svg) {
  animation: none !important;
  will-change: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  :root[data-dsh-motion] {
    --dsh-m-micro: 0ms;
    --dsh-m-press: 0ms;
    --dsh-m-switch: 0ms;
    --dsh-m-layer: 0ms;
    --dsh-m-reveal: 0ms;
  }
  html[data-dsh-motion] body :is(.oh-project-menu,.oh-dialog,.oh-option-surface,
   .ct-panel,.ct-task-menu,.ct-confirm,.ct-toast,.drs-root,.drs-root *,
   .drs-modal,.drs-modal *,.drs-backdrop,.drs-more-panel,.drs-episode-list,
   .oh-canvas-choice,.oh-template-scene,.oh-campaign>img,.oh-featured-media>img,
   .oh-new-plus,.cl-home-add,.oh-setting-arrow svg,.oh-upload-tile svg,
   .ds-node-editor,.ds-immersive-menu,.ds-media-toolbar,.ds-selection-tools,
   .ds-canvas-rail button>svg,.ds-canvas-toolbar button>svg,.ds-viewport-tools button>svg),
  html[data-dsh-motion] body .oh-view-tabs::before,
  html[data-dsh-motion] body .oh-canvas-new::before,
  html[data-dsh-motion] body .oh-dialog::backdrop {
    animation: none !important;
    transition: none !important;
  }
}
