/* MEMap - Custom CSS & Mobile Ergonomics */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* Material Symbols sizing */
.material-symbols-outlined {
  display: inline-block;
  width: 1em;
  height: 1em;
  line-height: 1 !important;
  box-sizing: content-box;
  overflow: hidden;
  white-space: nowrap;
  direction: ltr;
  vertical-align: middle;
}

/* Specular button highlights from Stitch */
.btn-specular {
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), 0 0 14px rgba(255, 255, 255, 0.16),
              inset 0 -1px 0.4px rgba(0, 0, 0, 0.2), inset 0 1px 0.4px #FFFFFF;
}

.card-bevel {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Two-Layer Glassmorphism: Dark smoked glass with crisp soft reflections */
.glass-panel {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.13) 0%, rgba(255, 255, 255, 0.04) 28%, rgba(255, 255, 255, 0) 58%),
    rgba(6, 7, 9, 0.52);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 1px 0 0 rgba(255, 255, 255, 0.10),
    0 20px 44px rgba(0, 0, 0, 0.65);
}

.glass-card {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 32%, rgba(255, 255, 255, 0) 60%),
    rgba(3, 4, 6, 0.68);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 1px 0 0 rgba(255, 255, 255, 0.05),
    0 8px 24px rgba(0, 0, 0, 0.45);
}

.glass-item {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.01) 45%, rgba(255, 255, 255, 0) 70%),
    rgba(3, 4, 6, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.65),
    0 2px 6px rgba(0, 0, 0, 0.38);
}

.glass-item.glass-item-primary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.02) 48%, rgba(255, 255, 255, 0) 72%),
    rgba(4, 5, 7, 0.80);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.7),
    0 4px 12px rgba(0, 0, 0, 0.45);
}

@media (hover: hover) and (pointer: fine) {
  .glass-item:hover {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.02) 48%, rgba(255, 255, 255, 0) 72%),
      rgba(6, 7, 10, 0.84);
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.22),
      inset 0 -1px 0 rgba(0, 0, 0, 0.65),
      0 6px 14px rgba(0, 0, 0, 0.48);
  }
}

.glass-item:active {
  background: rgba(2, 2, 3, 0.96);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

/* Splash Progress Bar */
@keyframes splash-progress {
  0% { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}

.animate-splash-bar {
  transform-origin: left center;
  animation: splash-progress 2.3s cubic-bezier(0.2, 0, 0, 1) forwards;
}

/* Pulsing Location Marker */
@keyframes marker-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  70% { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

.animate-marker-pulse {
  animation: marker-pulse 2s ease-out infinite;
}

/* Earth Drift animation for the subtle background */
@keyframes earth-drift {
  0% { transform: scale(1.15) translate(0%, 0%); }
  50% { transform: scale(1.19) translate(-3%, -2%); }
  100% { transform: scale(1.15) translate(0%, 0%); }
}

.animate-earth-drift {
  animation: earth-drift 32s ease-in-out infinite;
}

/* Mobile Safe Areas & Dynamic Viewport Height */
.min-h-dvh-safe {
  min-height: 100vh;
  min-height: 100dvh;
}

.safe-padding-top {
  padding-top: max(16px, env(safe-area-inset-top));
}

.safe-padding-bottom {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Leaflet Dark Theme Overrides */
.leaflet-container {
  background-color: #07080A !important;
  font-family: inherit;
}

.leaflet-top {
  top: calc(max(16px, env(safe-area-inset-top)) + 48px) !important;
}

.leaflet-bar {
  border: 1px solid #242728 !important;
  border-radius: 8px !important;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-bar a {
  background-color: #101111 !important;
  color: #F4F4F6 !important;
  border-bottom: 1px solid #242728 !important;
}

.leaflet-bar a:hover {
  background-color: #1B1C1E !important;
  color: #57C1FF !important;
}

.leaflet-control-attribution {
  background-color: rgba(7, 8, 10, 0.75) !important;
  color: #78787C !important;
  font-size: 10px !important;
  backdrop-filter: blur(8px);
  border-radius: 4px;
  margin: 4px !important;
}

.leaflet-control-attribution a {
  color: #9C9C9D !important;
}

/* Leaflet Tile Dark inversion/filter if OSM standard tiles are used */
.leaflet-tile-dark {
  filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

/* Pulse Marker custom HTML in Leaflet */
.user-location-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.user-location-pulse {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background-color: rgba(87, 193, 255, 0.35);
  animation: marker-pulse 2s ease-out infinite;
}

.user-location-dot {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  background-color: #57C1FF;
  border: 2.5px solid #FFFFFF;
  box-shadow: 0 0 10px rgba(87, 193, 255, 0.8);
}

/* Touch friendly scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #242728;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #434345;
}

/* Prevent unwanted pull-to-refresh on mobile */
body {
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
input, textarea {
  user-select: text;
}

/* =========================================================
   UI Motion & View Stagger Transitions
   ========================================================= */

/* Interactive menu buttons (4 main items + header action) */
.ui-menu-item {
  transition: transform 180ms var(--ease-out),
              background-color 180ms ease,
              border-color 180ms ease,
              box-shadow 180ms ease;
}

.ui-menu-item .ui-chevron {
  transition: transform 200ms var(--ease-out);
}

.ui-menu-item:active {
  transform: scale(0.98);
  transition-duration: 110ms;
}

@media (hover: hover) and (pointer: fine) {
  .ui-menu-item:hover {
    transform: translateY(-1px);
  }
  .ui-menu-item:hover .ui-chevron {
    transform: translateX(3px);
  }
  .ui-menu-item:active {
    transform: scale(0.98);
  }
}

/* Progressive positioning entrance for views (2s - 2.4s choreography) */
@keyframes ui-stagger-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ui-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.view-entering [data-stagger] {
  opacity: 0;
  animation: ui-stagger-in 650ms var(--ease-out) both;
  animation-delay: calc(var(--stagger-index, 0) * 180ms);
  will-change: transform, opacity;
}

/* Accessibility: Reduced motion drops transform movement, keeps gentle fade */
@media (prefers-reduced-motion: reduce) {
  .ui-menu-item,
  .ui-menu-item .ui-chevron {
    transition: background-color 150ms ease, border-color 150ms ease;
  }
  .ui-menu-item:active,
  .ui-menu-item:hover,
  .ui-menu-item:hover .ui-chevron {
    transform: none;
  }
  .view-entering [data-stagger] {
    animation-name: ui-fade-in;
    animation-duration: 300ms;
    animation-delay: calc(var(--stagger-index, 0) * 60ms);
  }
}
