/* AUTOMOTO interface feel, shared by CODINT ADMIN (the cockpit) and the staff app (AUTOMOTO Workshop). Both keep their own look; this only adds the behaviour people expect from a
   good app: a button answers at once when pressed and shows work in progress, a pop-up eases in and out instead of blinking, a new screen fades in, and a thin bar at
   the top shows that something is being loaded or saved. Everything here is switched off for people who asked their device for reduced motion. */

/* ---- buttons answer at once ---- */
.btn, button.chip, nav a, .tab, [data-act], [data-go] { -webkit-tap-highlight-color: transparent; }
.btn { transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease, opacity .2s ease, filter .2s ease; }
.btn:active:not([disabled]):not(.busy), nav a:active { transform: scale(.965); filter: brightness(.94); }
.btn.busy { position: relative; pointer-events: none; cursor: progress; opacity: .88; }
.btn.busy::before { content: ""; display: inline-block; flex: none; width: 13px; height: 13px; margin-right: 8px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: uifxSpin .7s linear infinite; }
nav a.busy { position: relative; }
nav a.busy::after { content: ""; position: absolute; right: 12px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border: 2px solid var(--gold, #ffcf1f); border-right-color: transparent; border-radius: 50%; animation: uifxSpin .7s linear infinite; }
@keyframes uifxSpin { to { transform: rotate(360deg); } }

/* ---- pop-ups ease in and out ---- */
.modal { display: grid !important; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .22s ease, visibility 0s linear .22s; }
.modal.on { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .22s ease, visibility 0s; }
.modal .box { transform: translateY(16px) scale(.98); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.modal.on .box { transform: none; }
@media (max-width: 820px) {   /* on a phone the pop-up is a sheet that slides up from the bottom */
  .modal .box { transform: translateY(100%); }
  .modal.on .box { transform: none; }
}

/* ---- a new screen fades in (only when the screen changes, never on each keystroke) ---- */
#content.view-enter > * { animation: uifxIn .3s cubic-bezier(.2, .8, .2, 1) both; }
#content.view-enter > *:nth-child(2) { animation-delay: .04s; }
#content.view-enter > *:nth-child(3) { animation-delay: .08s; }
#content.view-enter > *:nth-child(n+4) { animation-delay: .12s; }
@keyframes uifxIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- toast slides in ---- */
.toast { transition: opacity .25s ease, transform .3s cubic-bezier(.2, .8, .2, 1); }

/* ---- thin progress bar at the top while something is loading or saving ---- */
#uifxBar { position: fixed; left: 0; top: 0; height: 3px; width: 100%; z-index: 9999; pointer-events: none; opacity: 0; transition: opacity .25s ease; overflow: hidden; }
#uifxBar.on { opacity: 1; }
#uifxBar i { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: linear-gradient(90deg, transparent, var(--gold, #ffcf1f), var(--red, #c4161c), transparent); animation: uifxSlide 1.1s ease-in-out infinite; }
@keyframes uifxSlide { 0% { left: -40%; } 100% { left: 100%; } }

@media (prefers-reduced-motion: reduce) {
  .btn, .modal, .modal .box, .toast, #uifxBar { transition: none !important; }
  .btn:active:not([disabled]):not(.busy), nav a:active { transform: none; }
  #content.view-enter > * { animation: none !important; }
  .btn.busy::before, nav a.busy::after, #uifxBar i { animation-duration: 1.6s; }
  .modal .box { transform: none !important; }
}
