/* Disintegration (js/ui/motion.js disintegrate): a removed row comes apart top-down in motes of its own
   colours. The layer is FIXED because the row underneath collapses at the same moment. */
.disintegrate-host {
    position: fixed;
    z-index: 100010;
    pointer-events: none;
    overflow: visible;
}
/* One canvas per cloud (js/ui/dust/cloud.js): a window-sized cloud is one layer, not one per mote. */
.disintegrate-host > canvas { position: absolute; display: block; }
/* Under a docked chat panel (chat/panel.css 90000): the folds leave beneath the chat, not across it. */
.disintegrate-host.dust-below-chat { z-index: 89990; }
@media (prefers-reduced-motion: reduce) {
    .disintegrate-host { display: none; }
}

/* Materializing (js/ui/motion.js materialize): the leave reversed. --enter-h is the row's measured
   natural height. */
.materializing {
    pointer-events: none;
    overflow: hidden;
    animation: rowMaterialize 0.22s cubic-bezier(0, 0, 0.6, 1) both;
}
@keyframes rowMaterialize {
    from { opacity: 0; transform: translateX(-14px) scale(0.97);
           max-height: 0; margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
    40%  { opacity: 0; transform: translateX(-14px) scale(0.97); max-height: var(--enter-h, 200px); }
    to   { opacity: 1; transform: none; max-height: var(--enter-h, 200px); }
}
/* …and Sliding / Transition's arrivals, the leaves reversed (reveal.css rowSlideLeave / rowShrinkLeave). */
:where(:root[data-motion="slide"]) .materializing { animation: rowSlideIn 0.34s cubic-bezier(0.16, 1, 0.3, 1) both; }
:where(:root[data-motion="transition"]) .materializing { animation: rowGrowIn 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
/* …into a slot a held leave kept open (chatFx.js materialize inPlace): the box is already there. */
.materializing.materialize-in-place { animation-name: rowMaterializeInPlace; }
@keyframes rowMaterializeInPlace {
    from { opacity: 0; transform: translateX(-14px) scale(0.97); }
    40%  { opacity: 0; transform: translateX(-14px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}
:where(:root[data-motion="slide"]) .materializing.materialize-in-place { animation-name: rowSlideInPlace; }
:where(:root[data-motion="transition"]) .materializing.materialize-in-place { animation-name: rowGrowInPlace; }
@keyframes rowSlideInPlace { from { transform: translateX(-104%); } to { transform: none; } }
@keyframes rowGrowInPlace { from { opacity: 0; transform: scale(0.78); } to { opacity: 1; transform: none; } }
@keyframes rowSlideIn {
    from { transform: translateX(-104%); max-height: 0; margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
    35%  { transform: translateX(-104%); max-height: var(--enter-h, 200px); }
    to   { transform: none; max-height: var(--enter-h, 200px); }
}
@keyframes rowGrowIn {
    from { opacity: 0; transform: scale(0.78); max-height: 0; margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
    35%  { opacity: 0; transform: scale(0.78); max-height: var(--enter-h, 200px); }
    to   { opacity: 1; transform: none; max-height: var(--enter-h, 200px); }
}
/* !important: author !important beats rowMaterialize's keyframed opacity. */
.materialize-veil { opacity: 0 !important; }
/* A transition never starts on a property an animation holds: a dusted arrival animates no alpha. */
.materializing.materialize-veil { animation-name: rowMaterializeBox; }
.materializing.materialize-veil.materialize-in-place { animation-name: rowMaterializeBoxInPlace; }
@keyframes rowMaterializeBoxInPlace {
    from { transform: translateX(-14px) scale(0.97); }
    40%  { transform: translateX(-14px) scale(0.97); }
    to   { transform: none; }
}
@keyframes rowMaterializeBox {
    from { transform: translateX(-14px) scale(0.97);
           max-height: 0; margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
    40%  { transform: translateX(-14px) scale(0.97); max-height: var(--enter-h, 200px); }
    to   { transform: none; max-height: var(--enter-h, 200px); }
}
/* The row fades up under the landing motes; the transition lives on the LIFT alone, or the row is seen
   fading out at the start of its own arrival. */
.materialize-veil.materialize-lift { opacity: var(--rest-opacity, 1) !important; transition: opacity var(--veil-fade, 0ms) linear; }
/* Surfaces made of dust (motion.js surfaceIn / surfaceOut). `.dust-driven` is permanent: dropping it
   after the flight would restart the element's own entrance. */
.dust-driven { animation: none !important; }
.dust-driven.surface-forming { animation: surfaceForm var(--dust-ms, 420ms) linear both !important; }
.dust-driven.surface-leaving { animation: surfaceLeave var(--dust-ms, 340ms) linear both !important; }
@keyframes surfaceForm  { 0%, 55% { opacity: 0; } 100% { opacity: 1; } }
/* The cloud starts as an exact copy of the box: the hand-over is a one-beat cross-fade, not a cut. */
@keyframes surfaceLeave { 0% { opacity: 1; } 16%, 100% { opacity: 0; } }
@keyframes dustHostIn   { 0% { opacity: 0; } 16%, 100% { opacity: 1; } }
@keyframes dustHostOut  { 0%, 58% { opacity: 1; } 100% { opacity: 0; } }
.disintegrate-host.dust-leaving { animation: dustHostIn var(--dust-ms, 340ms) linear both; }
/* The host lives the WHOLE span (--host-ms): fading on one leg cut every late mote off. */
.disintegrate-host.dust-forming { animation: dustHostOut var(--host-ms, var(--gather-ms, 420ms)) linear both; }
/* A grain is hidden until it leaves (cloud.js `cut`), so the cloud is whole from the start — ramped,
   it was a dim field that blinked out (user report). */
@keyframes dustHostSettle { 0%, 55% { opacity: 1; } 80%, 100% { opacity: 0; } }
.disintegrate-host.dust-leaving.dust-over-picture { animation: none; }
.disintegrate-host.dust-forming.dust-over-picture { animation-name: dustHostSettle; }
/* A pure `:hover` popup is display:none by pointerleave: held one beat for its motes (motion.js wireHoverDust). */
.hints-popup.dust-hold { display: block; }
@media (prefers-reduced-motion: reduce) {
    /* The preference flipped mid-flight: land at the true opacity. */
    .dust-driven, .dust-driven.surface-forming, .dust-driven.surface-leaving { animation: none !important; }
}

/* A control's mark made of dust (motion.js markIn / markOut): the box never moves, only what it shows. */
.mark-forming { animation: markForm var(--mark-ms, 320ms) linear both; }
/* `.mark-leaving`: the real buttons vanish as their motes set off, or they are seen squeezing shut
   through the cloud (user report). */
.mark-leaving { opacity: 0 !important; }
@keyframes markForm { 0%, 62% { opacity: 0; } 100% { opacity: 1; } }
input[type=checkbox].mark-forming:checked, input[type=radio].mark-forming:checked,
.ctx-check.mark-forming {
    animation: none;
    background-color: transparent;
    background-image: none;
}
@media (prefers-reduced-motion: reduce) {
    .mark-forming { animation: none; }
}

/* The cleared editor stays hidden while the dust falls, or the idle state reads as a second clear. */
.canvas-viewport.canvas-clearing .idle-create,
.canvas-viewport.canvas-clearing #canvas,
.canvas-viewport.canvas-clearing #canvas-overlay { opacity: 0; }
/* …and goes out INSTANTLY: a fade on the hide was the blink in "appears, vanishes, then animates in". */
.canvas-viewport.canvas-assembling #canvas,
.canvas-viewport.canvas-assembling #canvas-overlay { opacity: 0; transition: none; }
.canvas-viewport .idle-create, .canvas-viewport #canvas,
.canvas-viewport #canvas-overlay { transition: opacity 0.28s ease; }

/* Canvas dust (js/ui/motion.js ghostOut): one element, because thousands of DOM motes drop frames. */
.canvas-dust {
    position: absolute;
    z-index: 5;
    pointer-events: none;
}

/* Drop landing: the overlay animates out and the canvas scales into place with one accent pulse. */
@keyframes dropOverlayOut { from { opacity: 1; } to { opacity: 0; transform: scale(1.02); } }
#global-drop-overlay.drop-closing {
    pointer-events: none;
    animation: dropOverlayOut 0.22s ease both;
}
@keyframes canvasLand {
    from { opacity: 0; transform: scale(0.94) translateY(14px); }
    to   { opacity: 1; transform: none; }
}
@keyframes canvasLandGlow {
    from { box-shadow: 0 0 0 3px var(--accent), 0 18px 46px var(--shadow); }
    to   { box-shadow: 0 0 0 0 transparent; }
}
.canvas-container.drop-landing {
    animation: canvasLand 0.56s cubic-bezier(0.16, 1, 0.3, 1) both,
               canvasLandGlow 0.7s ease both;
}
/* Dropped at a point (motion.js arriveFrom): the flight is an inline FLIP transform, so this variant
   animates the glow only — a CSS transform animation would win and snap the flight away. */
.canvas-container.drop-arriving { animation: canvasLandGlow 0.7s ease both; }
/* Transition's picture (canvasSlide.js): wiped in from the view's bottom edge upward, away from the top down.
   --wipe-top / --wipe-bottom put the start at the VISIBLE bottom of a picture taller than the view. */
@keyframes canvasRise {
    from { clip-path: inset(var(--wipe-top, 100%) 0 var(--wipe-bottom, 0px) 0); }
    to   { clip-path: inset(0 0 0 0); }
}
@keyframes canvasSink { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(100% 0 0 0); } }
.canvas-container.canvas-rise { animation: canvasRise 0.413s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.canvas-sink { animation: canvasSink 0.413s cubic-bezier(0.45, 0.05, 0.6, 0.9) both; }
.canvas-container.arrive-active {
    will-change: transform;
    position: relative;
    z-index: 3;
}
@media (prefers-reduced-motion: reduce) {
    #global-drop-overlay.drop-closing, .canvas-container.drop-landing, .canvas-container.canvas-rise, .canvas-sink,
    .canvas-container.drop-arriving { animation: none; }
    .canvas-container.arrive-active { will-change: auto; }
}
