/* Overlays: modal, menu, tooltip, popup and chat-panel motion. */
/* Only the backdrop fades, the window inside it keeping its own entrance, and the SAME rule in every
   motion mode: a mode switch must never rename the open overlay's animation and so replay its fade. */
#settings-modal-overlay.modal-open,
.app-modal-overlay.modal-open {
    animation: scrimFadeIn 0.22s ease both;
}
/* The backdrop's blur; its scrim is in components/modalShell.css. */
:root[data-modal-backdrop] #settings-modal-overlay.modal-open,
:root[data-modal-backdrop] .app-modal-overlay.modal-open {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
/* The POPOVER shape keeps the page readable: no dim, no blur. The data-modal-backdrop prefix is needed
   or the blur rule above outranks this. */
:root[data-modal-backdrop] #settings-modal-overlay.modal-open.modal-popover,
:root[data-modal-backdrop] .app-modal-overlay.modal-open.modal-popover,
#settings-modal-overlay.modal-open.modal-popover,
.app-modal-overlay.modal-open.modal-popover {
    animation: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
/* easeOutCubic: the app's usual (0.16, 1, …) is ~50% done in 30 ms and hides the window leaving its icon.
   Transition plays it; Sliding flies the window's picture instead (motion/genie/window.js). */
#settings-modal-overlay.modal-open #settings-modal,
.app-modal-overlay.modal-open .app-modal {
    animation: modalFromIcon 0.42s cubic-bezier(0.22, 0.61, 0.36, 1) both;
    will-change: transform, opacity;
}
/* One unanimated beat, so ui/base.js measures where the box lands. */
#settings-modal-overlay.modal-measuring #settings-modal,
.app-modal-overlay.modal-measuring .app-modal {
    animation: none !important;
}
/* `modal-closing` is visual only, and pointer-transparent so it can't swallow the next click. */
#settings-modal-overlay.modal-closing,
.app-modal-overlay.modal-closing {
    animation: scrimFadeOut 0.34s ease both;
    pointer-events: none;
}
:root[data-modal-backdrop] #settings-modal-overlay.modal-closing,
:root[data-modal-backdrop] .app-modal-overlay.modal-closing {
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
:root[data-modal-backdrop] #settings-modal-overlay.modal-closing.modal-popover,
:root[data-modal-backdrop] .app-modal-overlay.modal-closing.modal-popover,
#settings-modal-overlay.modal-closing.modal-popover,
.app-modal-overlay.modal-closing.modal-popover {
    animation: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
/* A gentle ease-in: a strong one barely moves for 200 ms and then snaps. */
#settings-modal-overlay.modal-closing #settings-modal,
.app-modal-overlay.modal-closing .app-modal {
    animation: modalToIcon 0.34s cubic-bezier(0.45, 0.05, 0.6, 0.9) both;
    will-change: transform, opacity;
}
/* The genie (motion/genie/window.js): its CSS flight stilled while photographed, then hidden under the
   canvas that flies its picture. */
.genie-hold { animation: none !important; }
/* clip-path too: a running opacity transition outranks !important, and would show the box under its picture. */
.genie-driven { animation: none !important; opacity: 0 !important; clip-path: inset(50%) !important; }

/* Both floating menus grow out of the open point (motion.js menuPopOrigin stamps transform-origin). */
/* From a speck at the open point to full size, seen from its first frames (Transition grows it all the way). */
@keyframes menuPop { 0% { opacity: 0; transform: scale(0.05); } 8% { opacity: 1; } 100% { opacity: 1; transform: none; } }
#ctx-menu.ctx-open {
    /* No `both` fill: even an identity transform makes the menu the containing block of its fixed
       submenus, which then land off-screen. */
    animation: menuPop 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
    transform-origin: top left;   /* fallback — contextMenu.js sets the click point */
}
.chat-row-menu { animation: menuPop 0.26s cubic-bezier(0.22, 0.61, 0.36, 1); }
@media (prefers-reduced-motion: reduce) {
    #ctx-menu.ctx-open, .chat-row-menu { animation: none; }
}
.ctx-sub.ctx-sub-visible {
    animation: popIn 0.13s ease both;
    transform-origin: top left;
}
/* Transition: a flyout grows out of its row's arrow as the menu grows out of the click (nav.js stamps the
   origin), on the menu's clock; no fill, as above, or a nested flyout lands off-screen. */
:root[data-motion="transition"] .ctx-sub.ctx-sub-visible { animation: menuPop 0.26s cubic-bezier(0.22, 0.61, 0.36, 1); }
/* 14+14 → 17+11: the total width holds, or the widest nowrap row jitters the shrink-to-fit menu wider. */
.ctx-item { transition: background 0.12s, padding-left 0.12s, padding-right 0.12s; }
.ctx-item:hover, .ctx-item.ctx-kb { padding-left: 17px; padding-right: 11px; }

/* Tooltip: size-neutral, so JS positioning stays exact; it fires only on none→block. */
.tooltip {
    animation: tooltipIn 0.13s ease both;
    box-shadow: 0 6px 22px var(--shadow);
    /* No left/top transition: an eased position trails a fast cursor. */
}

#hints-btn:hover .hints-popup {
    animation: popIn 0.16s ease both;
}
/* Anchored menus scale from the anchor CORNER (an 8px rise on a 141×370 panel read as no motion);
   full opacity while still small, so the menu is seen growing. */
@keyframes menuFromAnchor {
    0%   { opacity: 0; transform: translateY(-6px) scale(0.05); }
    8%   { opacity: 1; }
    100% { opacity: 1; transform: none; }
}
@keyframes menuToAnchor {
    0%   { opacity: 1; transform: none; }
    60%  { opacity: 0.85; }
    100% { opacity: 0; transform: translateY(-6px) scale(0.05); }
}
/* Origin = the corner nearest the control; the logo copy and custom selects are left-aligned. */
.accent-dd-menu { transform-origin: right top; }
.logo-accent-menu, .cs-dd .accent-dd-menu { transform-origin: left top; }
/* A list flipped above its trigger (dropdownMenu.js placeMenu) grows out of its bottom edge. */
.accent-dd-menu.dd-above { transform-origin: left bottom; }
.accent-dd-menu:not([hidden]), .zoom-menu.dd-portal:not([hidden]) {
    animation: menuFromAnchor 0.26s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
/* The logo's copy shrinks back into the logo; toolbar.js hides it on animationend (fallback timer). */
.logo-accent-menu.dd-closing { animation: menuToAnchor 0.18s ease both; }
/* Transition's tip (motion/control/tips.js): it grows out of nothing at the control it describes to its full size,
   seen growing (opaque by a fifth of the run), and shrinks back into nothing there (user report). */
@keyframes tipGrowIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.05); }
    20%  { opacity: 1; }
    to   { opacity: 1; transform: none; }
}
@keyframes tipShrinkOut {
    from { opacity: 1; transform: none; }
    60%  { opacity: 0.85; }
    to   { opacity: 0; transform: translateY(-4px) scale(0.05); }
}
.tip-grow-in { animation: tipGrowIn 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) both; transform-origin: center top; }
.tip-shrink-out { animation: tipShrinkOut 0.18s cubic-bezier(0.4, 0, 0.6, 1) both; transform-origin: center top; }
/* A tip the dust once drove keeps .dust-driven, whose animation:none !important (animations/dust.css) outranks the grow. */
.dust-driven.tip-grow-in { animation: tipGrowIn 0.22s cubic-bezier(0.22, 0.61, 0.36, 1) both !important; }
.dust-driven.tip-shrink-out { animation: tipShrinkOut 0.18s cubic-bezier(0.4, 0, 0.6, 1) both !important; }
/* The canvas readout sits below and right of the pointer: it grows from its top-left corner. Its own
   tooltipIn stays off in Transition, or it replayed the moment the grow's name came off (a second fade). */
.tooltip:is(.tip-grow-in, .tip-shrink-out) { transform-origin: top left; }
:root[data-motion="transition"] .tooltip:not(.tip-grow-in, .tip-shrink-out) { animation: none; }
/* Transition's entrance for a menu with none of its own (motion/genie/window.js menuOpen): it grows out of the
   point it opened from, the origin set inline. */
.menu-grow-in { animation: menuFromAnchor 0.26s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
/* Transition's exit for a list hidden at once: its stand-in copy shrinks back (motion/surface/leaveCopy.js). */
.leave-copy.dd-leaving { animation: menuToAnchor 0.18s ease both !important; }
@media (prefers-reduced-motion: reduce) {
    .accent-dd-menu:not([hidden]), .zoom-menu.dd-portal:not([hidden]),
    .logo-accent-menu.dd-closing { animation: none; }
    .tip-grow-in, .tip-shrink-out, .dust-driven:is(.tip-grow-in, .tip-shrink-out) { animation: none !important; }
    .menu-grow-in { animation: none; }
}
.accent-dd-opt { transition: background 0.15s ease, transform 0.12s ease; }
/* `.dd-hover` latches hover (accentPicker.js): a preview's flood drops real :hover. */
.accent-dd-opt:hover, .accent-dd-opt.dd-hover { transform: translateX(2px); }

/* Chat panel: slides in from its dock edge, float pops; close cannot transition display:none. A mode picked while it is
   open swaps its entrance's name, which replays it: it is settled instead (chat/panel/openState.js). */
stencil-chat-panel.chat-open.chat-motion-settled:not(.chat-closing) { animation: none !important; }
@keyframes chatSlideLeft   { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes chatSlideRight  { from { opacity: 0; transform: translateX(28px); }  to { opacity: 1; transform: none; } }
@keyframes chatSlideTop    { from { opacity: 0; transform: translateY(-28px); } to { opacity: 1; transform: none; } }
@keyframes chatSlideBottom { from { opacity: 0; transform: translateY(28px); }  to { opacity: 1; transform: none; } }
stencil-chat-panel.chat-open.chat-dock-left   { animation: chatSlideLeft 0.51s cubic-bezier(0.16, 1, 0.3, 1) both; }
stencil-chat-panel.chat-open.chat-dock-right  { animation: chatSlideRight 0.51s cubic-bezier(0.16, 1, 0.3, 1) both; }
stencil-chat-panel.chat-open.chat-dock-top    { animation: chatSlideTop 0.51s cubic-bezier(0.16, 1, 0.3, 1) both; }
stencil-chat-panel.chat-open.chat-dock-bottom { animation: chatSlideBottom 0.51s cubic-bezier(0.16, 1, 0.3, 1) both; }
/* Float grows out of the toolbar icon like a modal (chatPanel.js feeds --modal-dx/dy/sx/sy). */
stencil-chat-panel.chat-open.chat-dock-float  { animation: modalFromIcon 0.63s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
/* chatPanel.js keeps .chat-open until the reverse slide finishes. */
@keyframes chatSlideOutLeft   { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(-28px); } }
@keyframes chatSlideOutRight  { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(28px); } }
@keyframes chatSlideOutTop    { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-28px); } }
@keyframes chatSlideOutBottom { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(28px); } }
@keyframes chatPopOut         { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.94) translateY(-6px); } }
stencil-chat-panel.chat-open.chat-closing.chat-dock-left   { animation: chatSlideOutLeft 0.39s ease both; }
stencil-chat-panel.chat-open.chat-closing.chat-dock-right  { animation: chatSlideOutRight 0.39s ease both; }
stencil-chat-panel.chat-open.chat-closing.chat-dock-top    { animation: chatSlideOutTop 0.39s ease both; }
stencil-chat-panel.chat-open.chat-closing.chat-dock-bottom { animation: chatSlideOutBottom 0.39s ease both; }
stencil-chat-panel.chat-open.chat-closing.chat-dock-float  { animation: modalToIcon 0.51s ease both; }
/* Transition (desktop DockChromeShow's extent slide): the docked panel is revealed from its window edge, its
   inner edge riding the page's padding on one clock and curve (components/chat/touch.css), never ahead of it. */
@keyframes chatRevealLeft   { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes chatRevealRight  { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }
@keyframes chatRevealTop    { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
@keyframes chatRevealBottom { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }
@media (min-width: 681px) {
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-dock-left   { animation: chatRevealLeft 0.51s cubic-bezier(0.33, 1, 0.68, 1) both; }
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-dock-right  { animation: chatRevealRight 0.51s cubic-bezier(0.33, 1, 0.68, 1) both; }
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-dock-top    { animation: chatRevealTop 0.51s cubic-bezier(0.33, 1, 0.68, 1) both; }
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-dock-bottom { animation: chatRevealBottom 0.51s cubic-bezier(0.33, 1, 0.68, 1) both; }
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-closing.chat-dock-left   { animation: chatRevealLeft 0.39s cubic-bezier(0.45, 0, 0.55, 1) reverse both; }
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-closing.chat-dock-right  { animation: chatRevealRight 0.39s cubic-bezier(0.45, 0, 0.55, 1) reverse both; }
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-closing.chat-dock-top    { animation: chatRevealTop 0.39s cubic-bezier(0.45, 0, 0.55, 1) reverse both; }
    :root[data-motion="transition"] stencil-chat-panel.chat-open.chat-closing.chat-dock-bottom { animation: chatRevealBottom 0.39s cubic-bezier(0.45, 0, 0.55, 1) reverse both; }
}
/* Phones show the panel as a CENTRED MODAL (components/chat/touch.css): modal motion, whatever the dock. */
@media (max-width: 680px) {
    stencil-chat-panel.chat-open.chat-dock-left,
    stencil-chat-panel.chat-open.chat-dock-right,
    stencil-chat-panel.chat-open.chat-dock-top,
    stencil-chat-panel.chat-open.chat-dock-bottom,
    stencil-chat-panel.chat-open.chat-dock-float {
        animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    stencil-chat-panel.chat-open.chat-closing.chat-dock-left,
    stencil-chat-panel.chat-open.chat-closing.chat-dock-right,
    stencil-chat-panel.chat-open.chat-closing.chat-dock-top,
    stencil-chat-panel.chat-open.chat-closing.chat-dock-bottom,
    stencil-chat-panel.chat-open.chat-closing.chat-dock-float {
        animation: chatPopOut 0.24s ease both;
    }
    body:has(stencil-chat-panel.chat-open) #chat-backdrop { animation: overlayFadeIn 0.22s ease both; }
    body:has(stencil-chat-panel.chat-closing) #chat-backdrop { animation: overlayFadeOut 0.24s ease both; }
}
@keyframes overlayFadeOut { from { opacity: 1; } to { opacity: 0; } }

