/* WAC Track iOS V1: focused WebKit, safe-area, field-use, and state overrides. */

html {
  min-height: 100%;
  min-height: -webkit-fill-available;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(114, 197, 255, 0.18);
}

body {
  min-height: 100%;
  min-height: -webkit-fill-available;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

body.camera-focus,
body.camera-focus #cameraBox,
body.camera-focus #video {
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
}

:where(button, [role="button"], input[type="range"], input[type="checkbox"], select) {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

:where(button, [role="button"]):active {
  transform: scale(0.97);
  filter: brightness(1.12);
  transition: transform 45ms linear, filter 45ms linear;
}

#cameraBackBtn,
#scanCameraNowBtn,
#zoomOutBtn,
#zoomInBtn,
#torchBtn,
#cameraUndoLastBtn {
  min-width: 52px !important;
  min-height: 52px !important;
}

.camera-focus .camera-topline {
  left: 12px !important;
  left: max(12px, env(safe-area-inset-left)) !important;
  right: 12px !important;
  right: max(12px, env(safe-area-inset-right)) !important;
  bottom: 12px !important;
  bottom: max(12px, env(safe-area-inset-bottom)) !important;
  padding-left: 12px !important;
  padding-left: max(12px, env(safe-area-inset-left)) !important;
  padding-right: 12px !important;
  padding-right: max(12px, env(safe-area-inset-right)) !important;
}

.camera-focus .camera-state-chip,
.camera-focus .camera-status {
  padding-bottom: 12px !important;
  padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
}

.bottom-nav {
  padding-bottom: 8px !important;
  padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
  padding-left: 8px !important;
  padding-left: max(8px, env(safe-area-inset-left)) !important;
  padding-right: 8px !important;
  padding-right: max(8px, env(safe-area-inset-right)) !important;
}

.camera-state-chip,
.sync-state-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 2px solid #7d95a9;
  border-radius: 12px;
  background: #102338;
  color: #f8fbff;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.005em;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  transition: opacity 90ms linear, transform 90ms ease-out, border-color 90ms linear;
}

.sync-state-banner {
  margin: 10px 0 12px;
  padding: 10px 12px;
}

.camera-focus .camera-state-chip {
  position: absolute;
  z-index: 14;
  left: 12px;
  left: max(12px, env(safe-area-inset-left));
  right: 12px;
  right: max(12px, env(safe-area-inset-right));
  bottom: 76px;
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + 64px);
  justify-content: center;
  padding: 8px 12px;
  text-align: center;
  pointer-events: none;
}

.camera-state-chip [data-state-symbol],
.sync-state-banner [data-state-symbol] {
  display: inline-grid;
  place-items: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.88rem;
  line-height: 1;
}

.camera-state-chip [data-state-label],
.sync-state-banner [data-state-label] {
  min-width: 0;
  overflow-wrap: anywhere;
}

.state-opening { border-color: #f6b94d; background: #3b2b0f; color: #fff3d6; }
.state-ready { border-color: #62c7ff; background: #0b3047; color: #eefaff; }
.state-detecting { border-color: #f6b94d; background: #3b2b0f; color: #fff3d6; }
.state-queued { border-color: #56d394; background: #0d3828; color: #effff7; }
.state-duplicate { border-color: #f6b94d; background: #3b2b0f; color: #fff3d6; }
.state-invalid { border-color: #ffbf66; background: #42270d; color: #fff4df; }
.state-error { border-color: #ff7b82; background: #43171c; color: #fff1f2; }
.state-closed { border-color: #8097aa; background: #172735; color: #f4f8fb; }
.state-offline { border-color: #ffbf66; background: #42270d; color: #fff4df; }
.state-idle { border-color: #8097aa; background: #172735; color: #f4f8fb; }
.state-syncing { border-color: #62c7ff; background: #0b3047; color: #eefaff; }
.state-synced { border-color: #56d394; background: #0d3828; color: #effff7; }
.state-retry { border-color: #f6b94d; background: #3b2b0f; color: #fff3d6; }
.state-failed { border-color: #ff7b82; background: #43171c; color: #fff1f2; }
.state-conflict { border-color: #ff9b61; background: #452012; color: #fff2e9; }

.ios-audio-state[data-state="ready"] { color: #9ce8bf; }
.ios-audio-state[data-state="blocked"],
.ios-audio-state[data-state="unsupported"] { color: #ffd28a; }

@media (orientation: landscape) {
  .camera-focus .camera-state-chip {
    left: 59vw;
    right: 12px;
    right: max(12px, env(safe-area-inset-right));
    bottom: 76px;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 64px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .camera-state-chip,
  .sync-state-banner,
  :where(button, [role="button"]),
  .camera-success-flash,
  .tap-target-ring,
  .scan-frame::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

.reduced-effects .launch-experience,
.reduced-effects .scan-frame::after,
.reduced-effects .tap-target-ring,
.reduced-effects .metric-bump {
  animation: none !important;
  transition: none !important;
  filter: none !important;
}

[data-ios-tier="legacy"] .camera-focus .scan-frame::after,
[data-ios-tier="legacy"] .camera-focus .tap-target-ring,
[data-ios-tier="legacy"] .camera-focus .camera-status,
[data-ios-tier="legacy"] .camera-focus .camera-state-chip,
[data-ios-tier="legacy"] .camera-focus .camera-top-widget .camera-status-badge {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  animation: none !important;
  box-shadow: none !important;
}

[data-ios-tier="legacy"] .launch-experience,
[data-ios-tier="legacy"] .metric-bump {
  animation: none !important;
  transition: none !important;
}
