/* ============================================
   AR Overlay Styles
   ============================================ */

/* AR Container - holds video + canvas + overlays */
#ar-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: #000;
  display: none;
}

#ar-container.active {
  display: block;
}

/* Camera Video Feed */
#camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(1); /* Don't mirror rear camera */
  z-index: 1;
}

#camera-video.front-camera {
  transform: scaleX(-1); /* Mirror front camera */
}

/* Detection Canvas (for bounding boxes and hand skeleton) */
#detection-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

/* Overlay Labels Container */
#overlay-labels {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

/* Individual Object Label */
.object-label {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  transition: all var(--transition-fast);
  will-change: transform, left, top;
}

.object-label.selected {
  z-index: 10;
}

/* Label Card (floating above bounding box) */
.label-card {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  white-space: nowrap;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease;
  min-width: 100px;
  margin-bottom: var(--space-sm);
}

.label-card::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--primary);
}

.object-label.selected .label-card {
  border-color: var(--gold);
  box-shadow: 0 4px 30px rgba(255, 215, 0, 0.3);
}

.object-label.selected .label-card::after {
  border-top-color: var(--gold);
}

/* Pinyin Display */
.label-pinyin {
  font-family: var(--font-pinyin);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Chinese Character Display */
.label-chinese {
  font-family: var(--font-chinese);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

/* English hint (small, below Chinese) */
.label-english {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Difficulty indicator */
.label-difficulty {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.label-difficulty.easy { background: var(--success); }
.label-difficulty.medium { background: var(--warning); }
.label-difficulty.hard { background: var(--error); }

/* Bounding Box Styles */
.bbox-outline {
  position: absolute;
  border: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  pointer-events: auto;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.bbox-outline.selected {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3), inset 0 0 20px rgba(255, 215, 0, 0.1);
}

/* Corner markers for bounding box */
.bbox-outline::before,
.bbox-outline::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: inherit;
}

.bbox-outline::before {
  top: -2px;
  left: -2px;
  border-top: 4px solid;
  border-left: 4px solid;
  border-radius: 4px 0 0 0;
}

.bbox-outline::after {
  bottom: -2px;
  right: -2px;
  border-bottom: 4px solid;
  border-right: 4px solid;
  border-radius: 0 0 4px 0;
}

/* Confidence badge */
.bbox-confidence {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--primary);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* ============================================
   Hand Tracking Visualization
   ============================================ */

/* Finger tip cursor */
.finger-cursor {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--success);
  border-radius: var(--radius-full);
  transform: translate(-50%, -50%);
  z-index: 5;
  pointer-events: none;
  transition: all 0.1s linear;
  box-shadow: 0 0 15px rgba(74, 222, 128, 0.5);
}

.finger-cursor.pointing {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.finger-cursor.pointing::after {
  content: '👆';
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
}

/* Pointing ray line */
.pointing-ray {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.8), transparent);
  transform-origin: left center;
  z-index: 4;
  pointer-events: none;
}

/* ============================================
   Object Selection Effects
   ============================================ */

/* Glow effect around selected object */
.selection-glow {
  position: absolute;
  border-radius: var(--radius-md);
  background: radial-gradient(ellipse, rgba(255, 215, 0, 0.15) 0%, transparent 70%);
  z-index: 2;
  pointer-events: none;
  animation: selectionPulse 2s ease-in-out infinite;
}

@keyframes selectionPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* New discovery sparkle */
.discovery-sparkle {
  position: absolute;
  font-size: 2rem;
  pointer-events: none;
  z-index: 10;
  animation: sparkleAnim 1s ease forwards;
}

@keyframes sparkleAnim {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

/* ============================================
   Tap to Select Overlay (fallback mode)
   ============================================ */

.tap-hint {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-overlay);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-lg);
  font-size: 0.8rem;
  color: var(--text-secondary);
  z-index: 10;
  animation: fadeIn 0.5s ease;
}

/* ============================================
   AR Status Messages
   ============================================ */
.ar-status {
  position: fixed;
  bottom: 150px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-overlay);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  color: var(--text-secondary);
  z-index: 15;
  text-align: center;
  pointer-events: none;
}

.ar-status.detecting {
  color: var(--warning);
}

.ar-status.ready {
  color: var(--success);
}

/* ============================================
   No Object Found State
   ============================================ */
.no-object-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  opacity: 0.7;
}

.no-object-message .scan-icon {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
  animation: pulse 2s ease-in-out infinite;
}

.no-object-message p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}
