/* ─────────────────────────────────────────────────────────────────
   css/use-a11y.css
   --------------------------------------------------------------------
   Visual layer for use-a11y-motor.js (single-switch scan + eye-gaze
   dwell on use.html). Stored in its own file so we never grow the
   inline <style> on use.html toward the 1K cap.

   LABEL: PRODUCTION-READY.
───────────────────────────────────────────────────────────────── */

/* Scan focus — the currently-selected tile in the scan loop. Bold
   ring + soft pulse so it's unmistakable from across a hospital
   room. Pulse is suppressed for users who request reduced motion
   so we don't trigger vertigo / migraines. */
.use-scan-focus {
  outline: 4px solid #E8A838 !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(232, 168, 56, 0.35),
              0 8px 24px rgba(0, 0, 0, 0.2) !important;
  position: relative;
  z-index: 5;
  animation: use-scan-pulse 1.4s ease-in-out infinite;
}
@keyframes use-scan-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(232, 168, 56, 0.35), 0 8px 24px rgba(0, 0, 0, 0.2); }
  50%      { box-shadow: 0 0 0 8px rgba(232, 168, 56, 0.55), 0 8px 24px rgba(0, 0, 0, 0.2); }
}
@media (prefers-reduced-motion: reduce) {
  .use-scan-focus { animation: none; }
}

/* Dwell arming — fills a ring around the tile over `--dwell-ms`.
   Animation is on a pseudo-element so the tile's own children
   aren't disturbed. */
.use-dwell-arming::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 4px solid transparent;
  border-top-color: #E8A838;
  border-right-color: #E8A838;
  pointer-events: none;
  animation: use-dwell-fill var(--dwell-ms, 1500ms) linear forwards;
  z-index: 4;
}
@keyframes use-dwell-fill {
  0%   { transform: rotate(0deg);   border-right-color: transparent; border-bottom-color: transparent; border-left-color: transparent; }
  25%  {                            border-right-color: #E8A838;     border-bottom-color: transparent; border-left-color: transparent; }
  50%  {                            border-right-color: #E8A838;     border-bottom-color: #E8A838;     border-left-color: transparent; }
  75%  {                            border-right-color: #E8A838;     border-bottom-color: #E8A838;     border-left-color: #E8A838; }
  100% { transform: rotate(0deg);   border-right-color: #E8A838;     border-bottom-color: #E8A838;     border-left-color: #E8A838; }
}
@media (prefers-reduced-motion: reduce) {
  .use-dwell-arming::after { animation: none; border-color: #E8A838; opacity: 0.7; }
}

/* The ♿ topbar pill. Inherits .topbar-mode look from the inline
   style block; we just add the active state and emoji sizing. */
.use-a11y-pill {
  font-size: 1.05rem !important;
  line-height: 1 !important;
  padding: 0.5rem 0.75rem !important;
}
.use-a11y-pill[aria-pressed="true"] {
  background: #E8A838 !important;
  color: #1A1A2E !important;
}

/* Settings popover */
.use-a11y-panel {
  position: fixed;
  top: 60px;
  right: 0.6rem;
  z-index: 9000;
  background: #ffffff;
  color: #1A1A2E;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  padding: 0.9rem 1rem;
  width: min(320px, calc(100vw - 1.2rem));
  font-family: inherit;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.use-a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.use-a11y-row.use-a11y-sub {
  padding-left: 0.4rem;
  font-size: 0.85rem;
  color: #444;
}
.use-a11y-label {
  font-weight: 700;
  flex: 1;
}
.use-a11y-sublabel {
  flex: 1;
}
.use-a11y-row input[type="range"] {
  flex: 1.2;
  accent-color: #E8A838;
  min-width: 120px;
}
.use-a11y-row input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: #E8A838;
  cursor: pointer;
}
.use-a11y-val {
  min-width: 3.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #1A1A2E;
}
.use-a11y-close {
  align-self: flex-end;
  margin-top: 0.2rem;
  background: #E8A838;
  color: #1A1A2E;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.use-a11y-close:active { transform: scale(0.97); }

/* While scan or dwell is active, ensure tiles can take focus visually
   without being clipped. Position:relative on .tile is already set in
   the inline style block, so we just guarantee a clean stacking. */
body.use-switch-scan .topbar-back.show.use-scan-focus,
body.use-switch-scan .sb-btn.use-scan-focus {
  outline-offset: 2px;
}
