/* Motion, aligned (M1; frontend/notes/motion-survey.md §1 and §2, the owner's
 * motion design). What snapped, and what moved on its own curve, now eases on
 * F-LP2's tokens in app.css's :root: one curve (--ease, and --spring for a
 * press that releases), two durations, one rise. Existing rules were moved
 * onto the tokens where they are (app.css, chunky.css, ember.css); what's
 * new is here, so one file shows the lot.
 *
 * §3 holds in all of it:
 * - a figure is never tweened: .settle fades a whole figure, it never counts;
 * - red stays for a sync or backend failure: no error flash, no shake;
 * - stale looks go cool, they don't come alive: the sprites stay frozen;
 * - what's read never moves under the reader: only opacity and a small
 *   transform, never a height, so no line below shifts;
 * - the pixel art and the pixel face keep their steps.
 *
 * Reduced motion is app.css's one block: it stops every animation and
 * transition here (and js/settle.js plays nothing). Linked last, so these
 * rules sit over the older ones at equal weight. */

@keyframes fadein { from { opacity: 0; } }
/* What leaves goes the way it came: down the rise, fading (the scenario
 * screen, the toast). */
@keyframes riseout { to { opacity: 0; transform: translateY(var(--rise)); } }
/* A figure's new words arrive whole: a quiet fade, nothing counted. */
@keyframes settle { from { opacity: .55; } }
/* The room warms back from stale, and cools into it, in a fade of its own
 * colour (the keyframe is where it was; where it ends is its CSS). */
@keyframes thaw { from { filter: saturate(.55) brightness(.85); } }
@keyframes cool { from { filter: saturate(1) brightness(1); } }
/* One coal lights when a change is kept: a glow and back, once. */
@keyframes coalglow {
  0% { box-shadow: 0 0 0 0 rgba(255, 140, 66, 0); }
  35% { box-shadow: 0 0 12px 4px rgba(255, 140, 66, .85); }
  100% { box-shadow: 0 0 8px 1px rgba(255, 140, 66, .7); }
}

/* ---- the stamp ----
 * Its colours ease a beat (--dur-fast) as a tab's do; going stale is weather
 * (--dur) and the as-of flash is quicker (three quarters of that): colour only,
 * the words never move. The bar's children already carry a transform and
 * opacity transition for the full sheet (ember.css, `body > .bar > *`), which
 * outweighs a bare `.stamp`, so the stamp's whole list is here, as heavy, in
 * that order: transform, opacity, color, background-color, border-color.
 * (The dot inside it is `.stamp i`, in app.css.) */
body > .bar > .stamp {
  transition: transform var(--dur) var(--ease), opacity var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
body > .bar > .stamp.stale {
  transition-duration: var(--dur), var(--dur-fast), var(--dur), var(--dur), var(--dur);
}
body > .bar > .stamp.flash {
  transition-duration: var(--dur), var(--dur-fast), calc(var(--dur) * .75), calc(var(--dur) * .75), calc(var(--dur) * .75);
}

/* A palette change (Ember's dark bars to a page's, Plaster to Lamplit) isn't
 * eased: js/settle.js puts .cut on the page while it computes the new
 * colours, so the bars and their labels change together. */
.cut *, .cut *::before, .cut *::after { transition: none !important; }

/* ---- the tab bar ----
 * Colour and icon ease (they flipped); a press dips to 94%, as the room's
 * objects do (touch.js SQUASH), and springs back on release. */
.tab { transition: color var(--dur-fast) var(--ease), transform calc(var(--dur-fast) * .75) var(--spring); }
.tab svg { transition: opacity var(--dur-fast) var(--ease); }
.tab:active { transform: scale(.94); }

/* A page swapped in (a tab, a Settings page or form) fades in. Opacity only:
 * nothing is measured mid-move, and the room's canvas never shifts. */
.pager.swap, .settings.swap { animation: fadein var(--dur-fast) var(--ease); }

/* ---- stale, and back ----
 * The room's canvases go cool over --dur and warm over a beat longer; the
 * coals and the stamp ease their own colours (app.css). js/app.js puts
 * .cooling or .thawing on the stage for the length of the change. */
.stage.cooling .room canvas.roomart, .stage.cooling .room canvas.roomlive { animation: cool var(--dur) var(--ease); }
.stage.thawing .room canvas.roomart, .stage.thawing .room canvas.roomlive { animation: thaw calc(var(--dur) * 1.5) var(--ease); }

/* ---- a figure that changed ---- */
.big.settle, .acc-big.settle { animation: settle calc(var(--dur) * .75) var(--ease); }

/* ---- the toast ----
 * It rises in and fades (--dur-fast), and goes the other way a little
 * slower (--dur * .6, 240ms) when its time's up. A kept change lights one
 * coal beside "Saved." (.saved): quiet, cream, no tick and no green. */
.toast:not([hidden]) { animation: toastin var(--dur-fast) var(--ease); }
/* Drawn while it goes though it's [hidden] already; app.css's `[hidden] { display: none !important }` is why this needs !important. */
.toast.leaving { display: block !important; animation: toastout calc(var(--dur) * .6) var(--ease) forwards; pointer-events: none; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, var(--rise)); } }
@keyframes toastout { to { opacity: 0; transform: translate(-50%, var(--rise)); } }
.toast.saved #toasttext::before {
  content: ''; display: inline-block; vertical-align: middle; width: 7px; height: 7px; margin: -2px 8px 0 0;
  border-radius: 50%; background: var(--ember); box-shadow: 0 0 8px 1px rgba(255, 140, 66, .7);
  animation: coalglow calc(var(--dur) * 2.75) var(--ease) 1;
}

/* ---- the scenario screen ----
 * It rises in (plans.css) and, when it's closed, goes the same way back.
 * plans.js leaves it a moment, taking no taps. */
.scenscreen.leaving { animation: riseout var(--dur-fast) var(--ease) forwards; pointer-events: none; }

/* ---- lines that appear: a form's error, a notice, a refusal ----
 * A 6 px rise and fade, in the line's own colour (never a flash of red, and
 * never a shake): the line takes its place in the page's flow as before, only
 * it arrives. */
.settings .ferr:not([hidden]), .settings .gate:not([hidden]), .settings .notice { animation: rise var(--dur-fast) var(--ease); }

/* ---- what opens by losing [hidden] ----
 * A receipt's pop, a card's menu, the voice bar, its note: a fast fade in
 * (they snapped). Opacity only, so the thing they sit on doesn't move. */
.planpop:not([hidden]), .convo .rpop:not([hidden]), .ecard .menu:not([hidden]),
.convo .vbar:not([hidden]), .convo .vnote:not([hidden]) { animation: fadein var(--dur-fast) var(--ease); }

/* The pair sheet and the details sheet: the dark ground fades up with its
 * card (a fade, not a rise: the card is measured the moment it opens). */
.sheet:not([hidden]) { animation: fadein var(--dur-fast) var(--ease); }

/* ---- M3: the hold-to-ask fuse (js/fuse.js) ----
 * A thin line in the page's money colour (--fuse-c, read off the held
 * figure) burns along under the figure's words, one of Ember's sparks at its
 * tip; the figure warms with it. JS sets --p; nothing here transitions. */
.fuse { position: fixed; z-index: 30; height: 3px; pointer-events: none; opacity: var(--fade, 1); }
.fuse i {
  position: absolute; left: 0; top: 0; height: 3px; width: calc(var(--p, 0) * 100%); border-radius: 2px;
  background: var(--fuse-c);
  box-shadow: 0 0 6px color-mix(in srgb, var(--fuse-c) 60%, transparent);
}
.fuse canvas { position: absolute; top: -3px; image-rendering: pixelated; image-rendering: crisp-edges; }
/* F-M3b: in the stage, under the conversation sheet (.convo, z-index 8), so
 * its pop never draws over the sheet as it rises. */
.fuse.hosted { position: absolute; z-index: 7; }
/* F-M3b: what a hold asks about can't be selected. Android's long press
 * otherwise selects the figure's words as the hold closes, puts up its Copy
 * bar and Google's Touch to Search panel, and scrolls the app to make room.
 * The figures (ask.js's FIGURES) and the cards a hold is held on (Money,
 * Plans and Records' cards, a detail page's panels): a hold on any of their
 * words asks Ember, so their words were never a long press's to select.
 * Left selectable: Settings (its values are for copying), the conversation
 * (her replies), the fields, the room (its own hold pets her), and the rest. */
:is(.lpage, .lpdetail) :is(.big, .acc-big, .lcard, .screen.panel) {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.fusing { text-shadow: 0 0 calc(var(--fuse-p, 0) * 10px) color-mix(in srgb, var(--fuse-c) 55%, transparent); }

/* ---- M3: Ember in the pull (js/spark.js) ----
 * She and the words share one dark capsule (the pill's own --dark), so her
 * art never sits on the page's words; she stays while the refresh runs. */
.ptr { height: auto; flex-direction: column; transform: translateY(-100%); } /* put away: its own height above the stage */
.ptrcap { display: flex; flex-direction: column; align-items: center; background: var(--dark); border-radius: 14px; padding: 2px 14px 6px; }
.ptr .ptrcap span { background: none; border-radius: 0; padding: 0; }
#ptrember { display: block; image-rendering: pixelated; image-rendering: crisp-edges; transform-origin: 50% 100%; }
