/* ============================================================================
   3-STATE CURSOR SYSTEM CSS - VELOCITY-BASED TRAILS + STATE MORPHING
   ============================================================================
   State 1: Default - White dot + velocity-based trailing stream
   State 2: Interactive - Crosshair morphing + trailing (when moving)
   State 3: Glossary - Crosshair + soft pulsing info ring
   GPU-accelerated with CSS transforms, no jank
   ============================================================================ */

/* ══════════════════════════════════════════════════════════════════════════
   GLOBAL CURSOR SUPPRESSION - Hide native cursor on ALL elements
   ══════════════════════════════════════════════════════════════════════════ */

* {
  cursor: none !important;
}

/* Re-enable native cursor on touch devices */
@media (pointer: coarse) {
  * {
    cursor: auto !important;
  }
  
  #cursor-dot,
  .cursor-trail-dot,
  #cursor-crosshair,
  #cursor-info-ring {
    display: none !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   CURSOR COLOR SYSTEM - CSS Custom Properties
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --cursor-color-default: #F5F5F7;
  --cursor-color-interactive: #F5F5F7;
  --cursor-glow-color: rgba(212, 186, 137, 0.3);
  --cursor-info-ring-color: rgba(139, 125, 107, 0.6);
}

/* ══════════════════════════════════════════════════════════════════════════
   ANIMATIONS - Soft pulsing ring for glossary state
   ══════════════════════════════════════════════════════════════════════════ */

@keyframes pulsing-info-ring {
  0%, 100% {
    transform: scale(1);
    opacity: 0.4;
    filter: drop-shadow(0 0 4px var(--cursor-info-ring-color));
  }
  50% {
    transform: scale(1.3);
    opacity: 0.2;
    filter: drop-shadow(0 0 8px var(--cursor-info-ring-color));
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   MAIN CURSOR CONTAINER - 16x16px fixed element
   ══════════════════════════════════════════════════════════════════════════ */

#cursor-dot {
  width: 16px;
  height: 16px;
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  left: 0;
  top: 0;
  
  /* GPU acceleration - critical for smooth animation */
  transform: translate(calc(-50% + 0px), calc(-50% + 0px));
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* ══════════════════════════════════════════════════════════════════════════
   STATE 1: DEFAULT - Minimal white dot
   ══════════════════════════════════════════════════════════════════════════ */

#cursor-dot::before {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--cursor-color-default);
  box-shadow: 0 0 2px rgba(245, 245, 247, 0.5);
}

/* ══════════════════════════════════════════════════════════════════════════
   STATE 2 & 3: INTERACTIVE & GLOSSARY - Crosshair morphing
   ══════════════════════════════════════════════════════════════════════════ */

.cursor-crosshair-group {
  display: none;
  position: absolute;
  width: 16px;
  height: 16px;
  left: 0;
  top: 0;
}

.cursor-crosshair-group.show {
  display: block;
}

/* Crosshair - horizontal line */
.cursor-crosshair-group::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 1px;
  background: var(--cursor-color-interactive);
  left: 2px;
  top: 8px;
  box-shadow: 0 0 3px rgba(245, 245, 247, 0.4);
}

/* Crosshair - vertical line */
.cursor-crosshair-group::after {
  content: '';
  position: absolute;
  width: 1px;
  height: 12px;
  background: var(--cursor-color-interactive);
  left: 8px;
  top: 2px;
  box-shadow: 0 0 3px rgba(245, 245, 247, 0.4);
}

/* ══════════════════════════════════════════════════════════════════════════
   STATE 3: GLOSSARY - Soft pulsing info ring
   ══════════════════════════════════════════════════════════════════════════ */

#cursor-info-ring {
  display: none;
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid var(--cursor-info-ring-color);
}

#cursor-info-ring.show {
  display: block;
  animation: pulsing-info-ring 2.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

/* ══════════════════════════════════════════════════════════════════════════
   TRAIL DOTS - Velocity-based visible dots following cursor
   ══════════════════════════════════════════════════════════════════════════ */

.cursor-trail-dot {
  width: 6px;
  height: 6px;
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  left: 0;
  top: 0;
  border-radius: 50%;
  
  /* GPU acceleration */
  transform: translate(calc(-50% + 0px), calc(-50% + 0px));
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  
  background: var(--cursor-color-default);
  box-shadow: 0 0 2px rgba(245, 245, 247, 0.3);
  opacity: 0.6;
}

/* Trail dots fade significantly when mouse stops (velocity = 0) */
.cursor-trail-dot[style*="opacity: 0"],
.cursor-trail-dot[style*="opacity: 0."] {
  opacity: 0 !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   WINDOW VISIBILITY - Fade in/out when entering/leaving
   ══════════════════════════════════════════════════════════════════════════ */

#cursor-dot {
  opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION SUPPORT
   ══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  #cursor-dot,
  .cursor-trail-dot,
  #cursor-crosshair,
  #cursor-info-ring {
    display: none !important;
  }
  
  * {
    cursor: auto !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   MOBILE / TOUCH DEVICE HANDLING
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  #cursor-dot,
  .cursor-trail-dot,
  #cursor-crosshair,
  #cursor-info-ring {
    display: none !important;
  }
  
  * {
    cursor: auto !important;
  }
}
