/* ═══════════════════════════════════════════════════════════════
   MICRO-INTERACTIONS CSS - Delightful Details
   ═══════════════════════════════════════════════════════════════ */

/* ── Skeleton Loaders ────────────────────────────────────── */

.skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
}

.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.skeleton-image {
  width: 100%;
  height: 180px;
  background: linear-gradient(
    90deg,
    var(--surface2) 0%,
    var(--surface3) 50%,
    var(--surface2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-line {
  height: 12px;
  background: linear-gradient(
    90deg,
    var(--surface2) 0%,
    var(--surface3) 50%,
    var(--surface2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 6px;
}

.skeleton-title {
  width: 70%;
  height: 16px;
}

.skeleton-subtitle {
  width: 50%;
  height: 14px;
}

.skeleton-text {
  width: 90%;
}

/* ── Success Pulse ────────────────────────────────────── */

.success-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  color: var(--green);
  animation: success-pulse-anim 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 100;
}

@keyframes success-pulse-anim {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ── Particle Burst ────────────────────────────────────── */

.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: particle-burst 0.8s cubic-bezier(0.4, 0.0, 0.6, 1) forwards;
}

@keyframes particle-burst {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

/* ── Floating Feedback ────────────────────────────────────── */

.floating-feedback {
  position: fixed;
  font-size: 1.5rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 9999;
  animation: float-up 2s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

@keyframes float-up {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-100px) scale(0.5);
  }
}

/* ── Pull to Refresh ────────────────────────────────────── */

.pull-refresh-indicator {
  text-align: center;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
  transition: all 0.3s ease;
}

/* ── Smart Tooltips ────────────────────────────────────── */

.smart-tooltip {
  position: fixed;
  background: var(--surface3);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 10000;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.smart-tooltip.visible {
  opacity: 1;
}

.smart-tooltip.tooltip-top {
  transform: translateX(-50%) translateY(-10px);
}

.smart-tooltip.tooltip-bottom {
  transform: translateX(-50%) translateY(10px);
}

/* ── Scroll Reveal Animations ────────────────────────────────────── */

[data-reveal] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

[data-reveal-delay="1"] { transition-delay: 0.1s; }
[data-reveal-delay="2"] { transition-delay: 0.2s; }
[data-reveal-delay="3"] { transition-delay: 0.3s; }

/* ── Image Loading Blur-Up ────────────────────────────────────── */

.image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* ── Button Press Effects ────────────────────────────────────── */

.btn-primary,
.btn-secondary,
.btn-orange,
.btn-ghost,
.btn-sm,
.decision-chip,
.home-quick-btn,
.icon-btn {
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease,
              background 0.2s ease;
}

.btn-primary:active,
.btn-secondary:active,
.btn-orange:active {
  transform: scale(0.96);
}

/* ── Card Magnetic Hover ────────────────────────────────────── */

.restaurant-card,
.nearby-home-card,
.decision-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease;
}

/* ── Satisfying Number Counters ────────────────────────────────────── */

.counter-number {
  font-variant-numeric: tabular-nums;
  transition: color 0.3s ease;
}

.counter-number.counting {
  color: var(--primary);
  font-weight: 700;
}

/* ── Loading Dots Animation ────────────────────────────────────── */

.loading-dots::after {
  content: '';
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ── Swipe Gestures Visual ────────────────────────────────────── */

.swipeable {
  touch-action: pan-y;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.3s ease;
}

.swipeable.swiping {
  transition: none;
}

/* ── Pulsing Notification Dot ────────────────────────────────────── */

.notification-dot {
  width: 8px;
  height: 8px;
  background: var(--rose);
  border-radius: 50%;
  animation: notification-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes notification-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.5);
  }
}

/* ── Smooth Page Transitions ────────────────────────────────────── */

.page-transition-enter {
  opacity: 0;
  transform: translateX(20px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.page-transition-exit {
  opacity: 1;
  transform: translateX(0);
}

.page-transition-exit-active {
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ── Bounce In Animation (for new items) ────────────────────────────────────── */

@keyframes bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

.bounce-in {
  animation: bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ── Shake Animation (for errors) ────────────────────────────────────── */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97);
}

/* ── Glow Effect (for highlights) ────────────────────────────────────── */

.glow {
  animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% {
    box-shadow: 0 0 5px rgba(var(--primary-rgb), 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.8);
  }
}

/* ── Ripple Effect ────────────────────────────────────── */

.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
  width: 200%;
  height: 200%;
}

/* ── Feel: presses, arrivals and little rewards ─────────────────────── */

/* Press: everything tappable gives way a little under your thumb. */
.btn-primary, .btn-secondary, .btn-orange, .btn-ghost, .btn-sm, .decision-chip,
.home-quick-btn, .home-add-bar, .qa-sugg, .qa-status, .ja-place, .yo-btn, .hub-tile,
.hub-card, .open-now-card, .import-row, .share-nudge .btn-sm, .friend-row {
  transition: transform .14s cubic-bezier(.34, 1.56, .64, 1), filter .14s ease, box-shadow .2s ease;
}
.btn-primary:active, .btn-secondary:active, .btn-orange:active, .btn-ghost:active, .btn-sm:active,
.decision-chip:active, .home-quick-btn:active, .home-add-bar:active, .qa-sugg:active, .qa-status:active,
.ja-place:active, .yo-btn:active, .hub-tile:active, .hub-card:active, .open-now-card:active {
  transform: scale(.96);
  filter: brightness(.96);
}
.restaurant-card { transition: transform .18s ease, box-shadow .25s ease; }
.restaurant-card:active { transform: scale(.985); }

/* The main action on a screen gets a slow sheen now and then. */
.home-add-bar, .friends-invite-big, .qa-save { position: relative; overflow: hidden; }
.home-add-bar::after, .friends-invite-big::after, .qa-save:not(:disabled)::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .4) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sheen 5.5s ease-in-out 1.2s infinite;
}
@keyframes sheen { 0%, 70% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }

/* Switching List / Map / Stats rises in instead of snapping. */
.main-content.view-enter { animation: view-rise .32s cubic-bezier(.2, .8, .2, 1); }
@keyframes view-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Header counts pop when they change. */
.stat-pop { display: inline-block; animation: stat-pop .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes stat-pop { 40% { transform: scale(1.35); color: var(--gold, #f0b850); } }

/* Phones: dialogs slide up from the bottom like a native sheet. */
@media (max-width: 768px) {
  .modal-card { animation: sheet-up .38s cubic-bezier(.2, .9, .25, 1.05); }
  @keyframes sheet-up { from { opacity: .4; transform: translateY(60px); } to { opacity: 1; transform: none; } }
}

/* Saved stars and favorites spring. */
.card-favorite-btn.active { animation: fav-pop .45s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes fav-pop { 40% { transform: scale(1.25); } }

/* Clear keyboard focus without the browser's default box. */
:focus-visible { outline: 3px solid rgba(var(--primary-rgb), .55); outline-offset: 2px; }

/* The app's own "Reduce motion" setting switches all of the above off. */
body[data-ui-motion="reduced"] *, body[data-ui-motion="reduced"] *::before, body[data-ui-motion="reduced"] *::after {
  animation: none !important;
  transition: none !important;
}

/* ── Mobile-Specific Enhancements ────────────────────────────────────── */

@media (max-width: 768px) {
  /* Larger tap targets */
  .btn-primary,
  .btn-secondary,
  .btn-orange {
    min-height: 48px;
    padding: 14px 20px;
  }

  /* Smoother scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }
}

/* ── 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;
  }
}
