/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Map container - ensure interactions work */
#map {
  position: relative;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  touch-action: manipulation;
  z-index: 1;
}

/* Ensure map canvas gets proper layering */
#map canvas {
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

/* Make sure no overlays block map interactions */
.maplibregl-map {
  position: relative !important;
  z-index: 1 !important;
}

/* Ensure MapTiler controls are positioned correctly (map starts below header) */
.maplibregl-ctrl-top-right {
  top: var(--map-controls-top, 120px) !important;
  right: 10px !important;
  z-index: 25 !important;
}

.maplibregl-ctrl-bottom-right {
  bottom: 120px !important;
  right: 10px !important;
  z-index: 45 !important;
}

/* MapTiler popup dark mode support */
.maplibregl-popup-content {
  border-radius: 8px;
  padding: 0;
  min-width: 280px;
}

.maplibregl-popup-close-button {
  font-size: 18px;
  font-weight: normal;
  right: 8px;
  top: 8px;
  transition: color 0.2s ease;
}

/* Hide scrollbars but keep functionality */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Filter button active state */
.filter-btn.active {
  box-shadow: 0 0 0 2px rgb(59 130 246 / 0.5);
  transform: translateY(-1px);
}

/* Bounce animation for map markers */
@keyframes bounce {
  0%,
  20%,
  53%,
  80%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  40%,
  43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

/* Better focus states for accessibility */
button:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .maplibregl-ctrl-group {
    margin-right: 8px;
    margin-top: 8px;
  }

  .maplibregl-ctrl-top-right {
    top: var(--map-controls-top, 160px) !important;
  }

  .maplibregl-ctrl-bottom-right {
    bottom: 140px !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .maplibregl-popup-content {
    border-width: 2px;
  }
}

/* Native-style drawer interactions */
.dragging {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dragging * {
  pointer-events: none;
}

/* Smooth drawer handle interactions */
[data-controller*="drawer"] button[data-action*="toggle"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

/* Enhanced drawer styling for native feel */
[data-controller*="drawer"] {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

[data-controller*="drawer"] [data-drawer-target="content"] {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Native iOS-style handle bar */
[data-controller*="drawer"] .w-12.h-1 {
  transition: background-color 0.2s ease;
}

[data-controller*="drawer"]:hover .w-12.h-1,
[data-controller*="drawer"].dragging .w-12.h-1 {
  background-color: rgb(156 163 175); /* gray-400 */
}

/* Smooth arrow transitions */
[data-drawer-target="arrow"] {
  transition: transform 0.2s ease;
}

/* Ensure filter buttons have proper spacing on small screens */
@media (max-width: 640px) {
  .grid.grid-cols-2 {
    gap: 0.5rem;
  }
}

/* Difficulty handle colors - safeguard against Tailwind purging */
.bg-green-500 {
  background-color: rgb(34 197 94) !important;
}

.bg-yellow-500 {
  background-color: rgb(245 158 11) !important;
}

.bg-red-500 {
  background-color: rgb(239 68 68) !important;
}

.bg-purple-500 {
  background-color: rgb(139 92 246) !important;
}

/* Enhanced drawer handle styling with hover effects */
.drawer-handle:hover {
  transform: scaleY(1.2);
  opacity: 0.8;
}

/* Drawer handle pulse effect on active/dragging state */
[data-controller*="drawer"].dragging .drawer-handle,
[data-controller*="drawer"]:active .drawer-handle {
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

/* Native app height fixes */
.native-app html,
.native-app body {
  height: 100vh !important;
  min-height: 100vh !important;
}

.native-app main {
  height: 100vh !important;
  min-height: 100vh !important;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Keep drawer interactions smooth even with reduced motion */
  [data-controller*="drawer"] [data-drawer-target="content"] {
    transition-duration: 0.2s !important;
  }
}
