/* Overlay chrome for the AR view. Dark, high-contrast, thumb-reachable. */

:root {
  --ar-fg: #ffffff;
  --ar-bg: rgba(14, 15, 20, 0.82);
  --ar-accent: #3f8ef7;
  --ar-radius: 14px;
  --ar-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ar-safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ar-fg);
  -webkit-font-smoothing: antialiased;
}

/* The camera feed canvas fills the window; XR8 draws into it. */
#camerafeed {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.ar-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;   /* taps fall through to the canvas by default */
  z-index: 10;
}

.ar-ui button { pointer-events: auto; }

/* --- start screen --- */

.ar-start {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #14161d 0%, #05060a 100%);
  pointer-events: auto;
}

/* Required: the display:flex above would otherwise beat the UA's
   [hidden] { display: none }, leaving the start screen on top of the camera. */
.ar-start[hidden] { display: none; }

.ar-start-inner { text-align: center; max-width: 340px; }

.ar-title {
  margin: 0 0 10px;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.ar-sub {
  margin: 0 0 30px;
  font-size: 16px;
  line-height: 1.45;
  opacity: 0.72;
}

.ar-start-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 17px 44px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--ar-accent);
  cursor: pointer;
}

.ar-start-btn:active { transform: scale(0.97); }

.ar-hint {
  margin: 22px 0 0;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.5;
}

/* --- loading --- */

.ar-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(5, 6, 10, 0.9);
  font-size: 15px;
  pointer-events: auto;
}

.ar-loading[hidden] { display: none; }

.ar-spinner-ring {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--ar-accent);
  border-radius: 50%;
  animation: ar-spin 0.9s linear infinite;
}

@keyframes ar-spin { to { transform: rotate(360deg); } }

/* --- prompt / status / toast --- */

.ar-prompt {
  position: absolute;
  left: 50%;
  bottom: calc(120px + var(--ar-safe-bottom));
  transform: translateX(-50%);
  padding: 13px 22px;
  border-radius: 999px;
  background: var(--ar-bg);
  backdrop-filter: blur(10px);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  animation: ar-pulse 2.2s ease-in-out infinite;
}

.ar-prompt[hidden] { display: none; }

@keyframes ar-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

.ar-status {
  position: absolute;
  top: calc(14px + var(--ar-safe-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 15px;
  border-radius: 999px;
  background: var(--ar-bg);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.9;
}

.ar-status[hidden] { display: none; }

.ar-toast {
  position: absolute;
  left: 50%;
  top: calc(58px + var(--ar-safe-top));
  transform: translateX(-50%);
  max-width: 82vw;
  padding: 11px 18px;
  border-radius: var(--ar-radius);
  background: var(--ar-bg);
  backdrop-filter: blur(10px);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

.ar-toast[hidden] { display: none; }

/* --- controls --- */

.ar-controls {
  position: absolute;
  right: 16px;
  bottom: calc(22px + var(--ar-safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.ar-controls[hidden] { display: none; }

.ar-btn {
  appearance: none;
  border: 0;
  color: var(--ar-fg);
  background: var(--ar-bg);
  backdrop-filter: blur(10px);
  font-weight: 600;
  cursor: pointer;
}

.ar-btn:active { transform: scale(0.94); }

.ar-btn-round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
}

.ar-btn-wide {
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-size: 14px;
}

/* --- error --- */

.ar-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: #05060a;
  pointer-events: auto;
}

.ar-error[hidden] { display: none; }

.ar-error-inner { max-width: 340px; text-align: center; }

.ar-error h2 {
  margin: 0 0 12px;
  font-size: 21px;
  font-weight: 650;
}

.ar-error p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  opacity: 0.75;
}

/* --- debug readout (?debug) --- */

.ar-debug {
  position: fixed;
  top: calc(8px + var(--ar-safe-top));
  left: 8px;
  right: 8px;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  pointer-events: none;
}

.ar-debug .k { opacity: 0.55; white-space: nowrap; }
.ar-debug .v { color: #7ee787; word-break: break-all; }
