/**
 * VRCC Bidirectional Hover Synchronization - CSS Styles
 *
 * Visual feedback for hover states between listing cards and map markers
 *
 * @package VRCC\OwnerRezSync\PublicFacing
 * @since 3.15.8
 * @version 1.0.0
 */

/* ==========================================================================
   1. Card Hover States (triggered by map marker hover)
   ========================================================================== */

/**
 * Card highlighted when map marker is hovered
 * Subtle elevation and border to draw attention
 */
.vrcc-card-map-hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15),
              0 2px 8px rgba(0, 0, 0, 0.1);
  border: 2px solid #6e9997;
  transform: translateY(-2px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  position: relative;
}

/**
 * Card highlighted on click (temporary highlight)
 * More prominent than hover state
 */
.vrcc-card-highlighted {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2),
              0 4px 12px rgba(0, 0, 0, 0.15);
  border: 3px solid #4a7876;
  transform: translateY(-4px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
  position: relative;
  background-color: rgba(110, 153, 151, 0.02);
}

/**
 * Pulse animation for active/clicked card
 */
@keyframes card-pulse {
  0% {
    box-shadow: 0 8px 24px rgba(110, 153, 151, 0.3);
  }
  50% {
    box-shadow: 0 8px 24px rgba(110, 153, 151, 0.5);
  }
  100% {
    box-shadow: 0 8px 24px rgba(110, 153, 151, 0.3);
  }
}

.vrcc-card-highlighted {
  animation: card-pulse 1.5s ease-in-out;
}

/* ==========================================================================
   2. Map Marker Hover States
   ========================================================================== */

/**
 * Marker highlighted when card is hovered
 * Scale up and add glow effect
 */
.vrcc-marker-highlighted {
  transform: scale(1.15) !important;
  z-index: 1000 !important;
  filter: brightness(1.1) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/**
 * Price marker specific styling when highlighted
 */
.vrcc-marker-highlighted .vrcc-marker-price {
  background-color: #4a7876 !important;
  color: #ffffff !important;
  font-weight: 600;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 12px rgba(74, 120, 118, 0.4);
}

/**
 * Marker icon glow effect when highlighted
 */
.vrcc-marker-highlighted::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  background: radial-gradient(circle, rgba(110, 153, 151, 0.3) 0%, transparent 70%);
  border-radius: 50%;
  z-index: -1;
  opacity: 0;
  animation: marker-glow 1.5s ease-in-out infinite;
}

@keyframes marker-glow {
  0%, 100% {
    opacity: 0;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* ==========================================================================
   3. Active/Clicked Marker States
   ========================================================================== */

/**
 * Pulsing animation for active marker (clicked)
 */
.vrcc-marker-active {
  animation: marker-pulse 1.5s ease-in-out infinite;
  z-index: 1001 !important;
}

@keyframes marker-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

/**
 * Active marker with ripple effect
 */
.vrcc-marker-active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border: 2px solid #6e9997;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: marker-ripple 1.5s ease-out infinite;
}

@keyframes marker-ripple {
  0% {
    width: 100%;
    height: 100%;
    opacity: 1;
  }
  100% {
    width: 200%;
    height: 200%;
    opacity: 0;
  }
}

/* ==========================================================================
   4. Map Popup Hover States
   ========================================================================== */

/**
 * Enhanced popup styling when marker is hovered
 */
.leaflet-popup.vrcc-popup-highlighted .leaflet-popup-content-wrapper {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  border: 2px solid #6e9997;
  transition: all 0.2s ease;
}

.leaflet-popup.vrcc-popup-highlighted .leaflet-popup-tip {
  border-top-color: #6e9997;
}

/* ==========================================================================
   5. Smooth Scroll Indicator
   ========================================================================== */

/**
 * Visual indicator during auto-scroll
 */
.vrcc-scroll-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(110, 153, 151, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.vrcc-scroll-indicator.active {
  opacity: 1;
}

/* ==========================================================================
   6. Mobile/Touch States
   ========================================================================== */

/**
 * Mobile: Different interaction styles
 * No hover states, only click/tap
 */
@media (max-width: 768px) {
  .vrcc-card-map-hover {
    /* Disable hover effects on mobile */
    transform: none;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .vrcc-marker-highlighted {
    /* Simpler highlight on mobile */
    transform: scale(1.1) !important;
    filter: brightness(1.05);
  }

  /* Active states are more prominent on mobile */
  .vrcc-card-highlighted {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  }
}

/* ==========================================================================
   7. Accessibility Enhancements
   ========================================================================== */

/**
 * Focus states for keyboard navigation
 */
.vrcc-property-card:focus-within {
  outline: 3px solid #6e9997;
  outline-offset: 4px;
  box-shadow: 0 4px 16px rgba(110, 153, 151, 0.3);
}

/**
 * Reduce motion for users who prefer it
 */
@media (prefers-reduced-motion: reduce) {
  .vrcc-card-map-hover,
  .vrcc-card-highlighted,
  .vrcc-marker-highlighted,
  .vrcc-marker-active {
    transition: none;
    animation: none;
  }

  .vrcc-marker-highlighted::before,
  .vrcc-marker-active::after {
    display: none;
  }
}

/* ==========================================================================
   8. High Contrast Mode Support
   ========================================================================== */

/**
 * Enhanced borders for high contrast mode
 */
@media (prefers-contrast: high) {
  .vrcc-card-map-hover,
  .vrcc-card-highlighted {
    border-width: 3px;
    border-color: #000000;
  }

  .vrcc-marker-highlighted .vrcc-marker-price {
    border-width: 3px;
    border-color: #000000;
  }
}

/* ==========================================================================
   9. Dark Mode Support (if theme supports it)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .vrcc-card-map-hover,
  .vrcc-card-highlighted {
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1),
                0 2px 8px rgba(255, 255, 255, 0.05);
    border-color: #8eb3b1;
    background-color: rgba(110, 153, 151, 0.05);
  }

  .vrcc-marker-highlighted .vrcc-marker-price {
    background-color: #5a8c89 !important;
    box-shadow: 0 4px 12px rgba(110, 153, 151, 0.3);
  }

  .vrcc-scroll-indicator {
    background: rgba(142, 179, 177, 0.95);
  }
}

/* ==========================================================================
   10. Loading/Transition States
   ========================================================================== */

/**
 * Skeleton loading for lazy-loaded cards
 */
.vrcc-property-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

.vrcc-property-card.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 100%
  );
  animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ==========================================================================
   11. Z-Index Management
   ========================================================================== */

/**
 * Ensure proper layering of hover states
 */
.vrcc-property-card {
  position: relative;
  z-index: 1;
}

.vrcc-card-map-hover {
  z-index: 10;
}

.vrcc-card-highlighted {
  z-index: 20;
}

/* Map markers */
.leaflet-marker-pane {
  z-index: 600;
}

.vrcc-marker-highlighted {
  z-index: 1000 !important;
}

.vrcc-marker-active {
  z-index: 1001 !important;
}

/* ==========================================================================
   12. Performance Optimizations
   ========================================================================== */

/**
 * GPU acceleration for smooth animations
 */
.vrcc-card-map-hover,
.vrcc-card-highlighted,
.vrcc-marker-highlighted,
.vrcc-marker-active {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000px;
  -webkit-perspective: 1000px;
}

/**
 * Contain paint for better performance
 */
.vrcc-property-card {
  contain: layout style paint;
}
