/* touch-feedback.css — universal tap-acknowledgement + busy/loading UX
 * for the MachinistZen kiosk surface. Drop into every kiosk-facing page so every
 * interactive element gives operators instant feedback that their tap
 * registered. Without this, taps that trigger an async fetch look dead
 * for 200-2000ms and operators rage-tap, firing the action 3-4 times.
 *
 * Rules of the file:
 *   1. ANY interactive element gets a press-scale + brightness-dip via :active
 *   2. .is-loading / [aria-busy=true] elements get a spinner overlay +
 *      pointer-events:none so further taps are swallowed
 *   3. Respects prefers-reduced-motion (no scale, no animation)
 *
 * Tested touch-target classes inherited from existing kiosk pages:
 *   .tab-btn  .list-tab-btn  .qr-btn  .slideshow-btn
 *   .qa-btn   .wh-btn         .pm-btn  button[role=tab]  .card
 */

/* ─── press feedback ─── universal :active + tap-highlight */
button,
a,
[role="button"],
[role="tab"],
.tab-btn,
.list-tab-btn,
.qr-btn,
.slideshow-btn,
.qa-btn,
.wh-btn,
.pm-btn,
.tap-target,
.card,
.machine-card,
.machine,
.m-card,
.tile {
  -webkit-tap-highlight-color: rgba(184, 117, 74, 0.25);   /* MachinistZen copper tint */
  touch-action: manipulation;                              /* kill 300ms tap delay */
  user-select: none;
  -webkit-user-select: none;
  transition: transform 90ms ease-out, filter 120ms ease-out, opacity 120ms ease-out;
}

button:active,
a:active,
[role="button"]:active,
[role="tab"]:active,
.tab-btn:active,
.list-tab-btn:active,
.qr-btn:active,
.slideshow-btn:active,
.qa-btn:active,
.wh-btn:active,
.pm-btn:active,
.tap-target:active,
.card:active,
.machine-card:active,
.tile:active {
  transform: scale(0.96);
  filter: brightness(0.88);
}

/* Operators can't see :hover state on touch panels anyway — make :hover
 * a soft tint but rely on :active for the punchy press feedback. */
button:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
.tap-target:focus-visible {
  outline: 2px solid #B8754A;
  outline-offset: 2px;
}

/* ─── busy / loading state ─── apply to any element that's mid-fetch
 *
 * USAGE (frontend):
 *   - imperative:  el.setAttribute('aria-busy','true');
 *   - or classy:   el.classList.add('is-loading');
 *   - clear:       el.removeAttribute('aria-busy');  el.classList.remove('is-loading');
 *
 * Effect: 60% opacity, no further taps accepted, spinner overlay centered. */
[aria-busy="true"],
.is-loading {
  opacity: 0.6 !important;
  pointer-events: none !important;
  cursor: wait !important;
  position: relative;
}

[aria-busy="true"]::after,
.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: mz-tapspin 800ms linear infinite;
  pointer-events: none;
}

@keyframes mz-tapspin {
  to { transform: rotate(360deg); }
}

/* ─── tap-flash overlay (set by touch-feedback.js on touchstart) ───
 * A short, additional confirmation flicker so even taps that don't
 * trigger fetch/loading still "feel" registered. */
.mz-tap-flash {
  animation: mz-tap-flash 180ms ease-out;
}

@keyframes mz-tap-flash {
  0%   { background-color: rgba(184, 117, 74, 0.32); }
  100% { background-color: transparent; }
}

/* ─── accessibility / reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  button:active,
  a:active,
  [role="button"]:active,
  [role="tab"]:active,
  .tap-target:active {
    transform: none;
    filter: brightness(0.85);
  }
}
