/* ============================================================
   Choply — Premium Loading Animation System
   ============================================================ */

/* ── Full-Screen Loader Overlay ── */
.fc-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #FAFAF8);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  pointer-events: auto;
}
.fc-loader-overlay.fc-loader-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.fc-loader-overlay.fc-loader-hidden {
  display: none;
}

[data-theme="dark"] .fc-loader-overlay {
  background: var(--bg, #0D0D1A);
}

/* ── Loader Content ── */
.fc-loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  animation: fcLoaderEnter 0.4s var(--ease-out, ease) both;
}
@keyframes fcLoaderEnter {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.fc-loader-overlay.fc-loader-hide .fc-loader-content {
  animation: fcLoaderExit 0.35s ease both;
}
@keyframes fcLoaderExit {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.88); }
}

/* ── Brand Name ── */
.fc-loader-brand {
  font-family: var(--font-display, 'Syne', sans-serif);
  font-weight: 800;
  font-size: 22px;
  color: var(--text-primary, #1A1A2E);
  letter-spacing: -0.02em;
  margin-bottom: -12px;
}
.fc-loader-brand span {
  color: var(--primary, #FF6B35);
}

/* ── Food Scene ── */
.fc-loader-scene {
  position: relative;
  width: 140px;
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* ── Tray ── */
.fc-loader-tray {
  position: relative;
  width: 110px;
  height: 18px;
  background: var(--primary, #FF6B35);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 20px rgba(255, 107, 53, 0.25);
  animation: trayBounce 2.2s var(--ease-spring, cubic-bezier(0.34,1.56,0.64,1)) infinite;
}
@keyframes trayBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ── Burger ── */
.fc-loader-burger {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  animation: burgerBounce 2.2s var(--ease-spring, cubic-bezier(0.34,1.56,0.64,1)) infinite;
  animation-delay: 0.05s;
}
@keyframes burgerBounce {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg); }
  25%      { transform: translateX(-50%) translateY(-10px) rotate(-2deg); }
  50%      { transform: translateX(-50%) translateY(-14px) rotate(0deg); }
  75%      { transform: translateX(-50%) translateY(-8px) rotate(2deg); }
}

/* Burger layers */
.fc-burger-top {
  width: 72px;
  height: 24px;
  background: linear-gradient(135deg, #E8A44A, #D4922E);
  border-radius: 36px 36px 4px 4px;
  position: relative;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.08);
}
.fc-burger-top::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 12px;
  width: 4px;
  height: 4px;
  background: #F5D89A;
  border-radius: 50%;
  box-shadow: 16px 2px 0 #F5D89A, 32px -1px 0 #F5D89A, 8px 8px 0 #F5D89A, 24px 7px 0 #F5D89A;
}
.fc-burger-lettuce {
  width: 78px;
  height: 8px;
  background: var(--accent, #06D6A0);
  border-radius: 2px;
  margin: 0 -3px;
  position: relative;
  clip-path: polygon(0% 50%, 5% 0%, 12% 60%, 20% 10%, 30% 55%, 40% 5%, 50% 60%, 60% 0%, 70% 55%, 80% 10%, 90% 50%, 95% 5%, 100% 45%, 100% 100%, 0% 100%);
}
.fc-burger-patty {
  width: 70px;
  height: 12px;
  background: linear-gradient(135deg, #6B3A2A, #4A2518);
  border-radius: 6px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.fc-burger-cheese {
  width: 76px;
  height: 7px;
  background: var(--warning, #FFB800);
  border-radius: 2px;
  margin: -1px -3px;
  clip-path: polygon(0% 0%, 100% 0%, 98% 100%, 85% 70%, 70% 100%, 55% 65%, 40% 100%, 25% 70%, 10% 100%, 2% 75%);
}
.fc-burger-bottom {
  width: 72px;
  height: 16px;
  background: linear-gradient(135deg, #D4922E, #C07E1E);
  border-radius: 4px 4px 18px 18px;
  box-shadow: inset 0 3px 0 rgba(255,255,255,0.1);
}

/* ── Steam Particles ── */
.fc-loader-steam {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 50px;
  pointer-events: none;
}
.fc-steam-particle {
  position: absolute;
  bottom: 0;
  width: 6px;
  height: 6px;
  background: var(--primary, #FF6B35);
  border-radius: 50%;
  opacity: 0;
}
.fc-steam-particle:nth-child(1) {
  left: 15%;
  animation: steamRise 2s ease-out infinite;
}
.fc-steam-particle:nth-child(2) {
  left: 45%;
  animation: steamRise 2s ease-out infinite 0.5s;
  width: 5px;
  height: 5px;
}
.fc-steam-particle:nth-child(3) {
  left: 75%;
  animation: steamRise 2s ease-out infinite 1s;
  width: 4px;
  height: 4px;
}
@keyframes steamRise {
  0%   { opacity: 0; transform: translateY(0) scale(1); }
  20%  { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-40px) scale(2.5) translateX(6px); }
}

/* ── Floating Food Dots ── */
.fc-loader-dots {
  position: absolute;
  inset: -20px;
  pointer-events: none;
}
.fc-loader-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0.35;
}
.fc-loader-dot:nth-child(1) {
  top: 8%; left: 10%;
  background: var(--primary);
  animation: dotFloat 3s ease-in-out infinite;
}
.fc-loader-dot:nth-child(2) {
  top: 20%; right: 8%;
  background: var(--accent);
  animation: dotFloat 3s ease-in-out infinite 0.7s;
  width: 5px; height: 5px;
}
.fc-loader-dot:nth-child(3) {
  bottom: 30%; left: 5%;
  background: var(--warning);
  animation: dotFloat 3s ease-in-out infinite 1.4s;
  width: 4px; height: 4px;
}
.fc-loader-dot:nth-child(4) {
  bottom: 15%; right: 12%;
  background: var(--primary-light, #FF8C42);
  animation: dotFloat 3s ease-in-out infinite 2.1s;
  width: 5px; height: 5px;
}
@keyframes dotFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.35; }
  50%      { transform: translateY(-10px) scale(1.3); opacity: 0.6; }
}

/* ── Loading Text ── */
.fc-loader-text {
  font-family: var(--font-sans, 'Inter', sans-serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-secondary, #6B7280);
  min-height: 24px;
  text-align: center;
  transition: opacity 0.3s ease;
}

/* ── Progress Bar ── */
.fc-loader-progress {
  width: 200px;
  height: 4px;
  background: var(--bg-elevated, #F3F3F0);
  border-radius: var(--radius-full, 9999px);
  overflow: hidden;
  position: relative;
}
[data-theme="dark"] .fc-loader-progress {
  background: rgba(255,255,255,0.08);
}
.fc-loader-progress-bar {
  height: 100%;
  width: 100%;
  border-radius: var(--radius-full, 9999px);
  background: linear-gradient(90deg, var(--primary, #FF6B35), var(--primary-light, #FF8C42));
  transform-origin: left;
  animation: progressPulse 2s ease-in-out infinite;
}
@keyframes progressPulse {
  0%   { transform: scaleX(0.15) translateX(0); }
  50%  { transform: scaleX(0.7) translateX(15%); }
  100% { transform: scaleX(0.15) translateX(600%); }
}

/* ══════════════════════════════════════════════
   BUTTON LOADING STATES
   ══════════════════════════════════════════════ */

/* Generic button loading — apply .fc-btn-loading to any button */
.fc-btn-loading {
  position: relative;
  pointer-events: none !important;
  cursor: not-allowed !important;
  opacity: 0.75;
}
.fc-btn-loading .fc-btn-text {
  visibility: hidden;
}
.fc-btn-loading .fc-btn-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fc-btn-spinner {
  display: none;
}
.fc-btn-loading .fc-btn-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.fc-btn-spinner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: btnDotPulse 1.2s ease-in-out infinite;
}
.fc-btn-spinner-dot:nth-child(2) { animation-delay: 0.15s; }
.fc-btn-spinner-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes btnDotPulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* ══════════════════════════════════════════════
   REDUCED MOTION
   ══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .fc-loader-content,
  .fc-loader-overlay.fc-loader-hide .fc-loader-content,
  .fc-loader-tray,
  .fc-loader-burger,
  .fc-steam-particle,
  .fc-loader-dot,
  .fc-loader-progress-bar,
  .fc-btn-spinner-dot {
    animation: none !important;
  }
  .fc-loader-tray,
  .fc-loader-burger {
    transform: none !important;
  }
  .fc-loader-overlay {
    transition: none !important;
  }
}

/* ══════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .fc-loader-scene {
    width: 120px;
    height: 100px;
  }
  .fc-loader-tray {
    width: 90px;
  }
  .fc-burger-top,
  .fc-burger-bottom {
    width: 60px;
  }
  .fc-burger-lettuce,
  .fc-burger-cheese {
    width: 66px;
  }
  .fc-burger-patty {
    width: 58px;
  }
  .fc-loader-brand {
    font-size: 19px;
  }
  .fc-loader-text {
    font-size: 14px;
    padding: 0 24px;
  }
  .fc-loader-progress {
    width: 160px;
  }
}
