/* ===========================================================================
   OneScan - motion
   ---------------------------------------------------------------------------
   Every duration and easing in the app comes from here.
   Nobody invents a timing inside a screen.

   Full reasoning in MOTION.md. The short version:

     Gear 1  SHOWPIECE   sign-in, dashboard, wizard, floor plan, report
                         -> go all out
     Gear 2  WORKING     lists, forms, settings, uploads
                         -> lively, quick, never in the way
     Gear 3  CRITICAL    check-in station, live arrivals
                         -> instant, informative, no flourish
                         (the 80% alert is the one dramatic exception)

   Two hard rules:
     - Only transform and opacity are ever animated. Anything else makes the
       door tablet stutter, and a stuttering door screen is a broken one.
     - "Reduce motion" is honoured. Movement becomes a fade. Always.
   =========================================================================== */

:root {

  /* --- how long ----------------------------------------------------------- */
  --m-instant: 90ms;    /* door confirmations, button presses, under pressure  */
  --m-quick:   140ms;   /* hovers, chips, small state changes                  */
  --m-base:    220ms;   /* panels, rows, dropdowns - most things               */
  --m-slow:    340ms;   /* page sections arriving, modals                      */
  --m-grand:   520ms;   /* showpiece screens only. Nothing is ever longer.     */

  --m-arrive:  140ms;   /* a screen's own parts arriving as it loads           */
  --m-countup: 200ms;   /* numbers counting from zero (onescan.js mirrors it)  */
  --m-dwell:   3000ms;  /* how long the door success screen holds              */

  /* --- how it moves ------------------------------------------------------- */
  --e-standard: cubic-bezier(.4, 0, .2, 1);      /* general purpose            */
  --e-enter:    cubic-bezier(0, 0, .2, 1);       /* arriving: fast, then settles */
  --e-exit:     cubic-bezier(.4, 0, 1, 1);       /* leaving: don't linger      */
  --e-spring:   cubic-bezier(.34, 1.56, .64, 1); /* overshoot. Never at the door. */
  --e-firm:     cubic-bezier(.2, .8, .2, 1);     /* drag-and-drop landing      */

  /* --- how far ------------------------------------------------------------ */
  --m-lift:     -2px;   /* card on hover                                       */
  --m-travel:   24px;   /* desktop slide distance                              */
  --m-travel-s: 12px;   /* phone slide distance - long travel reads as lag     */
  --m-stagger:  15ms;   /* gap between each item in a cascade                  */
}

@media (max-width: 560px) {
  :root { --m-travel: var(--m-travel-s); }
}


/* ===========================================================================
   The non-negotiable one
   =========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;      /* no cascade waiting, invisible */
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  /* Movement becomes a plain fade. Everything still works. */
  .os-rise, .os-slide-r, .os-slide-l, .os-drop { transform: none !important; }
}


/* ===========================================================================
   Arrivals
   ---------------------------------------------------------------------------
   Everything a screen does as it loads is over inside a fifth of a second,
   cascade and all -- gear 2's own rule. These ran at 340ms with a 60ms
   stagger and a three-quarter-second count-up, so working screens sat half
   transparent for a second or more and read as still loading. A modal's
   pop, the wizard's slide and Live's 80% alert keep their own timings.
   =========================================================================== */

@keyframes os-rise   { from { opacity:0; transform: translateY(var(--m-travel)); } to { opacity:1; transform:none; } }
@keyframes os-drop   { from { opacity:0; transform: translateY(calc(var(--m-travel) * -1)); } to { opacity:1; transform:none; } }
@keyframes os-slideR { from { opacity:0; transform: translateX(var(--m-travel)); } to { opacity:1; transform:none; } }
@keyframes os-slideL { from { opacity:0; transform: translateX(calc(var(--m-travel) * -1)); } to { opacity:1; transform:none; } }
@keyframes os-fade   { from { opacity:0; } to { opacity:1; } }
@keyframes os-pop    { from { opacity:0; transform: scale(.92); } to { opacity:1; transform: scale(1); } }

.os-rise    { animation: os-rise   var(--m-arrive) var(--e-enter) both; }
.os-drop    { animation: os-drop   var(--m-arrive) var(--e-enter) both; }
.os-slide-r { animation: os-slideR var(--m-arrive) var(--e-enter) both; }
.os-slide-l { animation: os-slideL var(--m-arrive) var(--e-enter) both; }
.os-fade    { animation: os-fade   var(--m-arrive) var(--e-standard) both; }
.os-pop     { animation: os-pop    var(--m-base) var(--e-spring) both; }

/* Cascade - each child a beat behind the last, so the eye still follows
   the order, and the last of them lands 200ms after the first starts. */
.os-cascade > *       { animation: os-rise var(--m-arrive) var(--e-enter) both; }
.os-cascade > *:nth-child(1) { animation-delay: 0ms; }
.os-cascade > *:nth-child(2) { animation-delay: calc(var(--m-stagger) * 1); }
.os-cascade > *:nth-child(3) { animation-delay: calc(var(--m-stagger) * 2); }
.os-cascade > *:nth-child(n+4) { animation-delay: calc(var(--m-stagger) * 3); }
.os-cascade > *:nth-child(n+5) { animation-delay: calc(var(--m-stagger) * 4); }


/* ===========================================================================
   Interaction
   =========================================================================== */

.os-card     { transition: transform var(--m-quick) var(--e-standard),
                           box-shadow var(--m-quick) var(--e-standard); }
.os-card:hover { transform: translateY(var(--m-lift)); }

.os-press    { transition: transform var(--m-instant) var(--e-standard); }
.os-press:active { transform: scale(.97); }

.os-row      { transition: background-color var(--m-quick) var(--e-standard); }

/* A chip changing status */
@keyframes os-chip { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1); } }
.os-chip-change { animation: os-chip var(--m-base) var(--e-spring); }


/* ===========================================================================
   The door - gear 3. Fast, certain, no flourish.
   Staff see this 400 times a night. It must never cost a second.
   =========================================================================== */

@keyframes os-checked { from { opacity:0; transform: scale(.96); } to { opacity:1; transform: scale(1); } }
.os-checked-in { animation: os-checked var(--m-instant) var(--e-enter) both; }

/* The ring draining around the edge, showing the 3 seconds until the screen
   returns to scanning. Staff know it is coming back without having to wonder. */
@keyframes os-dwell-ring { from { stroke-dashoffset: 0; } to { stroke-dashoffset: var(--ring-length); } }
.os-dwell-ring { animation: os-dwell-ring var(--m-dwell) linear both; }

/* "Already checked in" - calm on purpose. Information, not a telling-off.
   No shake, no red, no bounce. */
.os-already { animation: os-fade var(--m-quick) var(--e-standard) both; }


/* ===========================================================================
   The 80% alert - the one moment where being dramatic is correct.
   Meant to be noticed from across a ballroom.
   =========================================================================== */

@keyframes os-alert-in { from { opacity:0; transform: translateY(-100%); } to { opacity:1; transform:none; } }
.os-alert { animation: os-alert-in var(--m-slow) var(--e-spring) both; }

@keyframes os-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.os-alert-count { animation: os-pulse var(--m-grand) var(--e-standard) 1; }

.os-bar-fill { transition: width var(--m-grand) var(--e-enter); }


/* ===========================================================================
   Floor plan - the one place physics is the point
   =========================================================================== */

.os-table      { transition: transform var(--m-quick) var(--e-standard),
                             box-shadow var(--m-quick) var(--e-standard); }
.os-table.is-dragging { transition: none; }          /* follows the finger exactly */
.os-table.is-landing  { transition: transform var(--m-base) var(--e-spring); }

/* A guest displaced by a table shrinking - you watch them travel to the
   unseated list. Nobody ever vanishes silently. */
@keyframes os-displace { from { opacity:1; transform:none; } to { opacity:0; transform: translateX(var(--m-travel)) scale(.9); } }
.os-displaced { animation: os-displace var(--m-slow) var(--e-exit) both; }


/* ===========================================================================
   Lists that change
   =========================================================================== */

/* An upload problem row folding itself out once fixed */
@keyframes os-resolve {
  from { opacity:1; max-height: 200px; transform:none; }
  to   { opacity:0; max-height: 0;     transform: translateX(var(--m-travel)); }
}
.os-resolved { animation: os-resolve var(--m-slow) var(--e-exit) both; overflow: hidden; }

.os-expand { transition: max-height var(--m-base) var(--e-standard); overflow: hidden; }


/* ===========================================================================
   Waiting - the page looks like itself before it has its data.
   Never a spinner in the middle of an empty screen.
   =========================================================================== */

@keyframes os-shimmer { from { background-position: -600px 0; } to { background-position: 600px 0; } }
.os-skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 600px 100%;
  animation: os-shimmer 1400ms linear infinite;
  border-radius: 8px;
}


/* ===========================================================================
   The wizard - you always know which way you are travelling
   =========================================================================== */

.os-step-forward  { animation: os-slideR var(--m-slow) var(--e-enter) both; }
.os-step-back     { animation: os-slideL var(--m-slow) var(--e-enter) both; }
.os-step-dot      { transition: background-color var(--m-base) var(--e-standard),
                                transform var(--m-base) var(--e-spring); }
