/* ====================================
   GLOBAL OVERFLOW PROTECTION
   Prevent horizontal scroll on mobile
   ==================================== */

html, body {
  overflow-x: clip;
  max-width: 100vw;
  position: relative;
}

* {
  /* Prevent any element from causing horizontal overflow */
  max-width: 100%;
}

/* ====================================
   SMOOTH PARALLAX EFFECT
   Hardware-accelerated, mobile-optimized
   ==================================== */

.parallax-bg {
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Disable parallax on mobile for smooth 60fps performance */
@media (max-width: 768px) {
  .parallax-bg {
    position: fixed !important;
    will-change: auto;
  }
}

/* Enable CSS-only parallax on desktop (buttery smooth) */
@media (min-width: 769px) and (hover: hover) {
  .parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transform: translateY(calc(var(--scroll-offset, 0) * -0.15px));
  }
}

/* ====================================
   MICRO-INTERACTIONS
   Mobile-optimized animations
   ==================================== */

/* Wave Animation - Infinite Horizontal Movement */
@keyframes wave {
  0% { 
    transform: translateX(0);
  }
  25% { 
    transform: translateX(-30vw);
  }
  50% { 
    transform: translateX(-60vw);
  }
  65% { 
    transform: translateX(-45vw);
  }
  85% { 
    transform: translateX(-80vw);
  }
  100% { 
    transform: translateX(-100vw);
  }
}

.wave-animation {
  animation: wave 20s ease-in-out infinite;
}

/* Sailboat Animation - Sailing across the wave horizon */
@keyframes sailboat-journey {
  0% {
    transform: translateX(-5vw) translateY(0) rotate(-7deg);
  }
  12.5% {
    transform: translateX(7.5vw) translateY(-18px) rotate(5deg);
  }
  25% {
    transform: translateX(25vw) translateY(12px) rotate(-6deg);
  }
  37.5% {
    transform: translateX(37.5vw) translateY(-20px) rotate(6deg);
  }
  50% {
    transform: translateX(52.5vw) translateY(8px) rotate(-4deg);
  }
  62.5% {
    transform: translateX(67.5vw) translateY(-16px) rotate(7deg);
  }
  75% {
    transform: translateX(77.5vw) translateY(14px) rotate(-5deg);
  }
  87.5% {
    transform: translateX(90vw) translateY(-12px) rotate(5deg);
  }
  100% {
    transform: translateX(105vw) translateY(0) rotate(-7deg);
  }
}

.sailboat-journey {
  animation: sailboat-journey 45s ease-in-out infinite;
  will-change: transform;
}

/* Floating animation for decorative elements */
@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(5deg);
  }
}

/* Wiggle animation for playful elements */
@keyframes wiggle {
  0%, 100% {
    transform: rotate(-5deg);
  }
  50% {
    transform: rotate(5deg);
  }
}

/* Wind trail animation - intermittent bursts */
@keyframes wind-burst {
  0% {
    opacity: 0;
    transform: translateX(15px) scaleX(0.3);
  }
  5% {
    opacity: 0.7;
    transform: translateX(10px) scaleX(0.8);
  }
  15% {
    opacity: 0.5;
    transform: translateX(-10px) scaleX(1.4);
  }
  25% {
    opacity: 0;
    transform: translateX(-30px) scaleX(2);
  }
  100% {
    opacity: 0;
    transform: translateX(-30px) scaleX(2);
  }
}

.wind-trails path:nth-child(1) {
  animation: wind-burst 4s ease-out infinite;
}

.wind-trails path:nth-child(2) {
  animation: wind-burst 4.5s ease-out infinite 0.4s;
}

.wind-trails path:nth-child(3) {
  animation: wind-burst 5s ease-out infinite 0.8s;
}

.wind-trails path:nth-child(4) {
  animation: wind-burst 4.2s ease-out infinite 1.2s;
}

/* Search Bar - Gentle Expand on Focus (desktop only) */
.search-container {
  transition: box-shadow 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .search-container:focus-within {
    transform: scale(1.02);
  }
}

/* Search Input - Placeholder Fade */
.search-input::placeholder {
  transition: opacity 0.3s ease;
}

.search-input:focus::placeholder {
  opacity: 0.4;
}

/* When typing, fade placeholder completely */
.search-input:not(:placeholder-shown)::placeholder {
  opacity: 0;
}

/* Button Hover Lift + Shadow (desktop only) */
.btn-lift {
  transition: transform 0.2s ease,
              box-shadow 0.2s ease,
              background-color 0.2s ease;
  will-change: transform;
}

@media (hover: hover) and (pointer: fine) {
  .btn-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(5, 150, 105, 0.4),
                0 4px 6px -2px rgba(5, 150, 105, 0.2);
  }
}

.btn-lift:active {
  transform: scale(0.97);
}

/* Popular Pills - Stagger Animation */
@keyframes pillFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Popular Pill Animation & Hover */
.popular-pill {
  opacity: 0;
  animation: pillFadeIn 0.4s ease forwards;
  will-change: opacity, transform;
  transition: transform 0.2s ease,
              background-color 0.2s ease;
}

.popular-pill:nth-child(1) { animation-delay: 0.5s; }
.popular-pill:nth-child(2) { animation-delay: 0.6s; }
.popular-pill:nth-child(3) { animation-delay: 0.7s; }
.popular-pill:nth-child(4) { animation-delay: 0.8s; }

@media (hover: hover) and (pointer: fine) {
  .popular-pill:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.3);
  }
}

.popular-pill:active {
  transform: scale(0.95);
}



/* Search Icon Animation (desktop only) */
.search-icon {
  transition: transform 0.2s ease, color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .search-container:focus-within .search-icon {
    transform: scale(1.1);
    color: #059669;
  }
}

/* City Cards - Enhanced Hover & Animation */
@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.city-card {
  opacity: 0;
  animation: cardSlideIn 0.4s ease forwards;
  transition: transform 0.3s ease,
              box-shadow 0.3s ease;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

@media (hover: hover) and (pointer: fine) {
  .city-card:hover {
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25),
                0 0 0 1px rgba(255, 255, 255, 0.1);
  }
}

/* Limit animation delays on mobile for faster perceived load */
@media (max-width: 640px) {
  .city-card:nth-child(1) { animation-delay: 0.05s; }
  .city-card:nth-child(2) { animation-delay: 0.1s; }
  .city-card:nth-child(3) { animation-delay: 0.15s; }
  .city-card:nth-child(n+4) { animation-delay: 0.2s; }
}

@media (min-width: 641px) {
  .city-card:nth-child(1) { animation-delay: 0.1s; }
  .city-card:nth-child(2) { animation-delay: 0.15s; }
  .city-card:nth-child(3) { animation-delay: 0.2s; }
  .city-card:nth-child(4) { animation-delay: 0.25s; }
  .city-card:nth-child(5) { animation-delay: 0.3s; }
  .city-card:nth-child(6) { animation-delay: 0.35s; }
  .city-card:nth-child(n+7) { animation-delay: 0.4s; }
}

/* Popular Label Fade In */
@keyframes labelFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.popular-label {
  opacity: 0;
  animation: labelFade 0.3s ease forwards;
  animation-delay: 0.4s;
}

/* Smooth Focus Ring */
.focus-ring {
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.focus-ring:focus-within {
  box-shadow: 0 0 0 8px rgba(52, 211, 153, 0.15);
}

/* Clear Button Micro-interaction */
.clear-btn {
  transition: transform 0.2s ease, opacity 0.2s ease;
}

@media (hover: hover) {
  .clear-btn:hover {
    transform: rotate(90deg);
  }
}
