/* =====================================================================
   LAKÁSŐR - Micro-Interactions & Animations
   60fps Smooth Native App Feel
   ===================================================================== */

/* =====================================================================
   1. PAGE LOAD ANIMATIONS
   ===================================================================== */

/* Staggered fade-in for page content (exclude fixed/absolute positioned elements) */
.page-content > *:not([style*="position: fixed"]):not(.save-feedback):not(.load-modal):not(.modal):not(.toast) {
  animation: fadeInUp 0.4s ease backwards;
}

.page-content > *:nth-child(1) { animation-delay: 0ms; }
.page-content > *:nth-child(2) { animation-delay: 50ms; }
.page-content > *:nth-child(3) { animation-delay: 100ms; }
.page-content > *:nth-child(4) { animation-delay: 150ms; }
.page-content > *:nth-child(5) { animation-delay: 200ms; }
.page-content > *:nth-child(6) { animation-delay: 250ms; }
.page-content > *:nth-child(7) { animation-delay: 300ms; }
.page-content > *:nth-child(8) { animation-delay: 350ms; }

/* Ensure fixed positioned overlays are never animated on page load */
.save-feedback,
.load-modal,
.modal,
.toast,
.bottom-sheet-overlay,
.native-modal-overlay,
.native-toast-container {
  animation: none !important;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Hero animation */
.hero-content {
  animation: heroFadeIn 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes heroFadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================================
   2. BUTTON MICRO-INTERACTIONS
   ===================================================================== */

.btn,
.btn-primary,
.btn-secondary,
.native-button {
  position: relative;
  overflow: hidden;
  transform: translateZ(0); /* GPU layer */
  transition: 
    transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

/* Press down effect */
.btn:active,
.btn-primary:active,
.btn-secondary:active,
.native-button:active {
  transform: scale(0.96) translateZ(0);
}

/* Ripple effect container */
.btn::before,
.btn-primary::before,
.btn-secondary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
  border-radius: 100%;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: none;
  z-index: 0;
}

/* Ensure button text stays above ripple */
.btn,
.btn-primary,
.btn-secondary {
  isolation: isolate;
}

.btn.ripple-active::before,
.btn-primary.ripple-active::before,
.btn-secondary.ripple-active::before {
  animation: rippleEffect 0.6s ease-out;
}

@keyframes rippleEffect {
  0% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(40);
  }
}

/* =====================================================================
   3. CARD INTERACTIONS
   ===================================================================== */

.glass-card,
.card,
.feature-card,
.result-card,
.native-card {
  transition: 
    transform 0.2s cubic-bezier(0.23, 1, 0.32, 1),
    box-shadow 0.2s ease;
}

/* Hover lift effect */
@media (hover: hover) {
  .glass-card:hover,
  .card:hover,
  .feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 
      0 12px 24px -8px rgba(0, 0, 0, 0.15),
      0 4px 8px -4px rgba(0, 0, 0, 0.1);
  }
  
  [data-theme="dark"] .glass-card:hover,
  [data-theme="dark"] .card:hover,
  [data-theme="dark"] .feature-card:hover {
    box-shadow: 
      0 12px 24px -8px rgba(0, 0, 0, 0.4),
      0 4px 8px -4px rgba(0, 0, 0, 0.3);
  }
}

/* Press effect on mobile */
.glass-card:active,
.card:active,
.feature-card:active,
.result-card:active {
  transform: scale(0.98);
}

/* =====================================================================
   4. INPUT FOCUS ANIMATIONS
   ===================================================================== */

input,
select,
textarea {
  transition: 
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  /* Note: removed transform:scale to prevent layout shifts */
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Floating label animation */
.floating-label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  transition: all 0.2s ease;
  background: var(--color-surface);
  padding: 0 4px;
}

.input-wrapper.focused .floating-label,
.input-wrapper.filled .floating-label {
  top: 0;
  font-size: 12px;
  color: var(--color-primary);
}

/* =====================================================================
   5. LIST ITEM ANIMATIONS
   ===================================================================== */

.native-list-item,
.list-item,
.accordion-header {
  transition: 
    background-color 0.15s ease,
    transform 0.15s ease;
}

.native-list-item:active,
.list-item:active,
.accordion-header:active {
  transform: scale(0.99);
  background: var(--color-surface-hover);
}

/* Staggered list animation */
.native-list .native-list-item {
  animation: listSlideIn 0.3s ease backwards;
}

.native-list .native-list-item:nth-child(1) { animation-delay: 0ms; }
.native-list .native-list-item:nth-child(2) { animation-delay: 40ms; }
.native-list .native-list-item:nth-child(3) { animation-delay: 80ms; }
.native-list .native-list-item:nth-child(4) { animation-delay: 120ms; }
.native-list .native-list-item:nth-child(5) { animation-delay: 160ms; }

@keyframes listSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =====================================================================
   6. CHECKBOX & TOGGLE ANIMATIONS
   Only apply to elements with .native-checkbox class to avoid breaking
   existing page-specific checkbox styles
   ===================================================================== */

input[type="checkbox"].native-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

input[type="checkbox"].native-checkbox:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
  animation: checkPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

input[type="checkbox"].native-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

@keyframes checkPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* =====================================================================
   7. SUCCESS/ERROR STATE ANIMATIONS
   ===================================================================== */

.success-animation {
  animation: successPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes successPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.error-shake {
  animation: errorShake 0.4s ease;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* =====================================================================
   8. PROGRESS ANIMATIONS
   ===================================================================== */

.progress-bar {
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.2) 50%,
    transparent 100%
  );
  animation: progressShine 2s ease-in-out infinite;
}

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

/* Circular progress */
.progress-circle {
  transform: rotate(-90deg);
}

.progress-circle-track {
  stroke: var(--color-border);
}

.progress-circle-fill {
  stroke: var(--color-primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

/* =====================================================================
   9. NOTIFICATION/BADGE ANIMATIONS
   ===================================================================== */

.badge-pulse {
  animation: badgePulse 2s ease infinite;
}

@keyframes badgePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

/* Count change animation */
.count-change {
  animation: countBump 0.3s ease;
}

@keyframes countBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* =====================================================================
   10. ICON ANIMATIONS
   ===================================================================== */

.icon-spin {
  animation: iconSpin 1s linear infinite;
}

@keyframes iconSpin {
  to { transform: rotate(360deg); }
}

.icon-bounce {
  animation: iconBounce 0.5s ease;
}

@keyframes iconBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.icon-wiggle {
  animation: iconWiggle 0.5s ease;
}

@keyframes iconWiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

/* =====================================================================
   11. ACCORDION ANIMATIONS
   ===================================================================== */

.accordion-content {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: 
    max-height 0.3s ease,
    opacity 0.3s ease,
    padding 0.3s ease;
}

.accordion-item.open .accordion-content {
  max-height: 1000px;
  opacity: 1;
}

.accordion-icon {
  transition: transform 0.3s ease;
}

.accordion-item.open .accordion-icon {
  transform: rotate(180deg);
}

/* =====================================================================
   12. SCROLL-TRIGGERED ANIMATIONS
   ===================================================================== */

.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: 
    opacity 0.6s ease,
    transform 0.6s ease;
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Different animation styles */
.animate-on-scroll.fade-left {
  transform: translateX(-30px);
}

.animate-on-scroll.fade-left.visible {
  transform: translateX(0);
}

.animate-on-scroll.fade-right {
  transform: translateX(30px);
}

.animate-on-scroll.fade-right.visible {
  transform: translateX(0);
}

.animate-on-scroll.scale-in {
  transform: scale(0.9);
}

.animate-on-scroll.scale-in.visible {
  transform: scale(1);
}

/* =====================================================================
   13. TAB BAR MICRO-INTERACTIONS
   ===================================================================== */

.tab-bar-item {
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tab-bar-item:active {
  transform: scale(0.9);
}

.tab-bar-icon {
  transition: 
    color 0.2s ease,
    transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.tab-bar-item.active .tab-bar-icon {
  animation: tabIconBounce 0.4s ease;
}

@keyframes tabIconBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.2); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1.05); }
}

/* =====================================================================
   14. MODAL ANIMATIONS
   ===================================================================== */

.modal-enter {
  animation: modalFadeIn 0.3s ease forwards;
}

.modal-exit {
  animation: modalFadeOut 0.2s ease forwards;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalFadeOut {
  to {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
}

/* =====================================================================
   15. 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;
  }
  
  .page-content > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
