/* RG_MOTION 20261013-rgm1 - additive motion layer. Every rule is inert until rg-motion.js adds html.rgm-on and a feature class (html.rgm-f-*).
   Only transform-class properties (translate, scale) and opacity are animated. All durations are under 300 ms. */

@media screen and (prefers-reduced-motion: no-preference) {

  @keyframes rgm-fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes rgm-pop { from { opacity: 0; translate: 0 8px; scale: .98; } to { opacity: 1; translate: 0 0; scale: 1; } }
  @keyframes rgm-rise { from { opacity: 0; translate: 0 4px; } to { opacity: 1; translate: 0 0; } }
  @keyframes rgm-toast { from { opacity: 0; translate: 16px 0; } to { opacity: 1; translate: 0 0; } }
  @keyframes rgm-press { from { scale: 1; } to { scale: .98; } }
  @keyframes rgm-hover { from { opacity: .9; } to { opacity: 1; } }
  @keyframes rgm-lift { from { translate: 0 0; } to { translate: 0 -1px; } }
  @keyframes rgm-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

  /* Buttons and primary controls: 90 ms press, short hover settle */
  html.rgm-f-press :is(button, [role="button"], input[type="button"], input[type="submit"], .tbtn, .btn, .ac-btn, .pr-btn-primary, .pr-btn-outline, .sa-btn-primary, .sa-btn-approve, .sa-btn-reject, .iw-btn, .hrw-btn):not(:disabled):not([aria-disabled="true"]):active {
    animation: rgm-press 90ms ease-out both;
  }
  @media (hover: hover) {
    html.rgm-f-press :is(button, [role="button"], input[type="button"], input[type="submit"], .tbtn, .btn, .ac-btn, .pr-btn-primary, .pr-btn-outline, .sa-btn-primary, .sa-btn-approve, .sa-btn-reject, .iw-btn, .hrw-btn):not(:disabled):not([aria-disabled="true"]):hover:not(:active) {
      animation: rgm-hover 120ms ease-out both;
    }
  }

  /* Gold keyboard focus ring (text fields keep their own focus style) */
  html.rgm-f-focus :is(button, a[href], [role="button"], select, summary, input[type="checkbox"], input[type="radio"], input[type="button"], input[type="submit"], [tabindex]:not([tabindex="-1"]):not(input):not(textarea)):focus-visible {
    outline: 2px solid #C9A227;
    outline-offset: 2px;
  }

  /* Summary tiles: 1 px lift, shadow fades in through a pseudo-element (opacity only). Tiles with their own hover effect are left alone. */
  @media (hover: hover) {
    html.rgm-f-cards :is(.kpi, .sa-kpi, .pr-kpi, .pr-stat, .ac-stat, .hrw-kpi, .metric, .card[onclick], .ac-card[onclick], .pr-card[onclick], .sa-card[onclick], .iw-card[onclick], a.card):hover {
      animation: rgm-lift 120ms ease-out both;
    }
    html.rgm-f-cards :is(.kpi, .sa-kpi, .pr-kpi, .pr-stat, .ac-stat, .hrw-kpi, .metric, .card[onclick], .ac-card[onclick], .pr-card[onclick], .sa-card[onclick], .iw-card[onclick], a.card):hover::after {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      border-radius: inherit;
      box-shadow: 0 6px 16px -6px rgba(10, 22, 40, .28);
      animation: rgm-fade 120ms ease-out both;
    }
    html.rgm-f-rows tbody tr:hover {
      background-image: linear-gradient(rgba(201, 162, 39, .08), rgba(201, 162, 39, .08));
    }
  }

  /* Modals and drawers: 180 ms fade plus 8 px settle. Closing is never delayed. */
  html.rgm-f-modal .rgm-in.rgm-ov { animation: rgm-fade 180ms ease-out both; }
  html.rgm-f-modal .rgm-in.rgm-ov > * { animation: rgm-pop 180ms ease-out both; }
  html.rgm-f-modal .rgm-in.rgm-pn { animation: rgm-pop 180ms ease-out both; }

  /* Screen swap: 150 ms fade of the newly shown section */
  html.rgm-f-screen .rgm-scr { animation: rgm-fade 150ms ease-out both; }

  /* First-render stagger: 20 ms steps, at most 12 items; table rows fade only */
  html.rgm-f-stagger .rgm-st { animation: rgm-rise 120ms ease-out backwards; }
  html.rgm-f-stagger tr.rgm-st { animation-name: rgm-fade; }
  html.rgm-f-stagger .rgm-d0 { animation-delay: 0ms; }
  html.rgm-f-stagger .rgm-d1 { animation-delay: 20ms; }
  html.rgm-f-stagger .rgm-d2 { animation-delay: 40ms; }
  html.rgm-f-stagger .rgm-d3 { animation-delay: 60ms; }
  html.rgm-f-stagger .rgm-d4 { animation-delay: 80ms; }
  html.rgm-f-stagger .rgm-d5 { animation-delay: 100ms; }
  html.rgm-f-stagger .rgm-d6 { animation-delay: 120ms; }
  html.rgm-f-stagger .rgm-d7 { animation-delay: 140ms; }
  html.rgm-f-stagger .rgm-d8 { animation-delay: 160ms; }
  html.rgm-f-stagger .rgm-d9 { animation-delay: 180ms; }
  html.rgm-f-stagger .rgm-d10 { animation-delay: 200ms; }
  html.rgm-f-stagger .rgm-d11 { animation-delay: 220ms; }

  /* Toasts that the portal itself does not animate */
  html.rgm-f-toast .rgm-toast { animation: rgm-toast 180ms ease-out both; }

  /* Skeleton: opacity pulse only (no moving gradient) */
  html.rgm-f-skeleton .rgm-skel { animation: rgm-pulse 1.2s ease-in-out infinite; }
}

/* Skeleton shape (static, readable even when the layer is off) */
.rgm-skel { display: block; height: 12px; margin: 8px 0; border-radius: 6px; background: rgba(201, 162, 39, .18); }
.rgm-skel:nth-child(3n + 2) { width: 82%; }
.rgm-skel:nth-child(3n) { width: 64%; }

@media print {
  [class*="rgm-"] { animation: none !important; translate: none !important; scale: none !important; }
  .rgm-skel { display: none !important; }
}
