/* ============================================================
   ANIMATIONS — Berlin Live Transit
   ============================================================ */

/* ── Fade in up (used for departure rows, stop cards) ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Fade in (general) ── */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Slide down (dropdown, results) ── */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Pulse dot (real-time indicator) ── */
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.75); }
}

/* ── Shimmer (loading skeleton) ── */
@keyframes shimmer {
  from { background-position: -200% center; }
  to   { background-position:  200% center; }
}

/* ── Spin (loading spinner) ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Number flip (countdown update) ── */
@keyframes numFlip {
  from { transform: translateY(-40%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Bounce in (for favourite star) ── */
@keyframes bounceIn {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); }
}

/* ── Shake (error state) ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ── Entry animation for departure items ── */
.departure-item {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}
.departure-item:nth-child(1)  { animation-delay:  0ms; }
.departure-item:nth-child(2)  { animation-delay: 40ms; }
.departure-item:nth-child(3)  { animation-delay: 80ms; }
.departure-item:nth-child(4)  { animation-delay: 120ms; }
.departure-item:nth-child(5)  { animation-delay: 160ms; }
.departure-item:nth-child(6)  { animation-delay: 200ms; }
.departure-item:nth-child(7)  { animation-delay: 240ms; }
.departure-item:nth-child(8)  { animation-delay: 280ms; }
.departure-item:nth-child(9)  { animation-delay: 320ms; }
.departure-item:nth-child(10) { animation-delay: 360ms; }

/* ── Stop cards entry ── */
.stop-card {
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}
.stop-card:nth-child(1) { animation-delay:  0ms; }
.stop-card:nth-child(2) { animation-delay: 60ms; }
.stop-card:nth-child(3) { animation-delay: 120ms; }
.stop-card:nth-child(4) { animation-delay: 180ms; }
.stop-card:nth-child(5) { animation-delay: 240ms; }

/* ── Skeleton loading ── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    var(--bg-glass-hover) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

/* ── Spinner ── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader-icons {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-icons::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-top-color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 2s linear infinite;
  opacity: 0.6;
}

.loader-icons::after {
  content: '';
  position: absolute;
  inset: 15px;
  border: 2px solid var(--color-accent);
  border-radius: 50%;
  animation: pulseRing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulseRing {
  0% { transform: scale(0.85); opacity: 0; }
  50% { transform: scale(1); opacity: 0.4; }
  100% { transform: scale(1.15); opacity: 0; }
}

.loader-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: cycleIcons 4s infinite;
}

.loader-icon svg {
  width: 64px;
  height: 64px;
  color: var(--color-accent);
}

.loader-icon:nth-child(1) { animation-delay: 0s; }
.loader-icon:nth-child(2) { animation-delay: 1s; }
.loader-icon:nth-child(3) { animation-delay: 2s; }
.loader-icon:nth-child(4) { animation-delay: 3s; }

@keyframes cycleIcons {
  0%, 20% { opacity: 1; transform: scale(1); }
  25%, 95% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

/* ── Real-time dot ── */
.realtime-dot {
  animation: pulseDot 2s ease-in-out infinite;
}

/* ── @starting-style for smooth element entry (modern browsers) ── */
@supports (transition-behavior: allow-discrete) {
  .search-dropdown {
    transition:
      opacity var(--duration-base) var(--ease-out),
      transform var(--duration-base) var(--ease-out),
      display var(--duration-base) allow-discrete;
  }

  @starting-style {
    .search-dropdown.visible {
      opacity: 0;
      transform: translateY(-6px);
    }
  }

  .search-dropdown:not(.visible) {
    opacity: 0;
    transform: translateY(-6px);
    display: none;
  }
}
