/* ===========================================================================
 * MOTION — the small amount of animation this app is allowed to have
 * ===========================================================================
 *
 * Deliberately one file. Everything motion-related lives here and in
 * motion.js, so if it ever becomes irritating it is two <script>/<link> lines
 * to remove, not a hunt through twenty render functions.
 *
 * The rule applied throughout: motion is allowed where it carries
 * information (a number changed; a save is in flight) and not where it is
 * only decoration. This is a tool used for hours at a stretch, not a landing
 * page, and an animation you have to wait through is a tax charged on every
 * single use.
 *
 * Nothing here animates a figure while it is being read — only while it is
 * changing.
 * ------------------------------------------------------------------------ */

/* --- Save / confirm buttons ---------------------------------------------
 * The point is feedback between the click and the row appearing. Without it
 * the only evidence the click registered is that nothing has happened yet,
 * which is exactly what a failed click also looks like — hence double saves.
 */
.mo-busy {
  position: relative;
  cursor: progress;
  opacity: 0.85;
}

.mo-busy::after {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-left: 7px;
  vertical-align: -1px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: mo-spin 0.6s linear infinite;
}

@keyframes mo-spin { to { transform: rotate(360deg); } }

/* Held for about a second, then the button returns to its own label. Long
 * enough to be read, short enough not to block the next entry. */
.mo-done {
  background: #1b7f4b !important;
  border-color: #1b7f4b !important;
  color: #fff !important;
  transition: background 0.18s ease-out, color 0.18s ease-out;
}

/* --- Rows arriving -------------------------------------------------------
 * Applied by motion.js to a capped number of rows only. A 278-row Balance
 * Sheet animating every row at once stutters, and a stuttering table reads
 * worse than a static one.
 */
.mo-row-in {
  animation: mo-row-in 0.28s ease-out both;
}

@keyframes mo-row-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.mo-row-in { animation-fill-mode: both; }

/* --- A figure that moved, and which way ---------------------------------
 * Green up, red down, held for under a second. Applied to the card, not the
 * number, so the number itself never changes colour mid-read — only the
 * surface behind it. Up is not always good (liabilities, provisions), so
 * this says "changed, upward", not "improved".
 */
.mo-up, .mo-down { animation: mo-flash 1s ease-out; }

@keyframes mo-flash {
  0%   { box-shadow: inset 0 0 0 1px transparent; }
  18%  { box-shadow: inset 0 0 0 1px currentColor; }
  100% { box-shadow: inset 0 0 0 1px transparent; }
}

.mo-up   { color: rgba(27, 127, 75, 0.55); }
.mo-down { color: rgba(198, 40, 40, 0.55); }

/* --- Cards that respond to the cursor -----------------------------------
 * The app already raises a shadow on hover; a single pixel of lift is what
 * makes it read as the card moving rather than the shadow appearing. One
 * pixel deliberately — anything more and a grid of cards bounces as the
 * pointer crosses it.
 */
.rkpf-kpi {
  transition: box-shadow 0.2s ease-out, transform 0.2s ease-out;
}

.rkpf-kpi:hover { transform: translateY(-1px); }

.rkpf-kpi .rkpf-kpi-icon {
  transition: transform 0.2s ease-out;
}

.rkpf-kpi:hover .rkpf-kpi-icon { transform: scale(1.06); }

/* --- Icons inside buttons ------------------------------------------------
 * A 1px nudge in the direction the button sends you. Only on buttons that
 * move you somewhere or produce a file; not on destructive ones, where
 * playfulness is the wrong register.
 */
.rkpf-btn .ti { transition: transform 0.18s ease-out; }
.rkpf-btn:hover .ti { transform: translateX(1px); }
.rkpf-btn:hover .ti-download, .rkpf-btn:hover .ti-file-export { transform: translateY(1px); }
.rkpf-btn:hover .ti-refresh, .rkpf-btn:hover .ti-reload { transform: rotate(45deg); }
.rkpf-btn:hover .ti-trash, .rkpf-btn:hover .ti-x { transform: none; }

/* --- A count that is waiting on you -------------------------------------
 * Pending flags, unreconciled rows. Slow and low-contrast on purpose: it has
 * to survive being on screen all day without becoming something you resent.
 */
.mo-pending { animation: mo-pending 2.4s ease-in-out infinite; }

@keyframes mo-pending {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* --- Everything off, for anyone who has asked the OS for that ------------
 * Windows: Settings > Accessibility > Visual effects > Animation effects.
 * This is not politeness — vestibular disorders make motion genuinely
 * unpleasant, and the app must stay fully usable with every animation off.
 * motion.js reads the same signal and writes final values directly.
 */
@media (prefers-reduced-motion: reduce) {
  .mo-busy::after { animation: none; }
  .mo-row-in { animation: none; }
  .mo-done { transition: none; }
  .mo-up, .mo-down { animation: none; }
  .mo-pending { animation: none; }
  .rkpf-kpi, .rkpf-kpi .rkpf-kpi-icon, .rkpf-btn .ti { transition: none; }
  .rkpf-kpi:hover { transform: none; }
  .rkpf-kpi:hover .rkpf-kpi-icon { transform: none; }
  .rkpf-btn:hover .ti { transform: none; }
}
