/* ═══ Animations ═══ */

@keyframes drift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(30px, 20px); }
}
@keyframes float-up {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0); }
  50% { opacity: 1; transform: scale(1); }
}
.fade-in {
  animation: fadeIn var(--duration) var(--ease) forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes editorReveal {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(196, 181, 253, 0); }
  50% { box-shadow: 0 0 24px rgba(196, 181, 253, 0.15), 0 0 48px rgba(147, 197, 253, 0.08); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══ Dream Orbit — Magical Loading Animation ═══ */

.dream-orbit {
  position: relative;
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  animation: orbit-rotate 6s linear infinite;
}
.dream-orbit-lg {
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
}

.dream-orbit-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  top: 0;
  left: 50%;
  margin-left: -3px;
  transform-origin: 3px 20px;
  animation: orbit-chase 2s var(--ease) infinite;
}
.dream-orbit-lg .dream-orbit-dot {
  width: 8px;
  height: 8px;
  margin-left: -4px;
  transform-origin: 4px 28px;
}

.dream-orbit-dot:nth-child(1) {
  background: var(--lavender);
  box-shadow: 0 0 10px rgba(196, 181, 253, 0.6), 0 0 20px rgba(196, 181, 253, 0.2);
  animation-delay: 0s;
}
.dream-orbit-dot:nth-child(2) {
  background: var(--moonlight);
  box-shadow: 0 0 10px rgba(147, 197, 253, 0.6), 0 0 20px rgba(147, 197, 253, 0.2);
  animation-delay: -0.66s;
}
.dream-orbit-dot:nth-child(3) {
  background: var(--rose);
  box-shadow: 0 0 10px rgba(253, 164, 175, 0.5), 0 0 20px rgba(253, 164, 175, 0.15);
  animation-delay: -1.33s;
}

.dream-orbit-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid rgba(196, 181, 253, 0.08);
  animation: orbit-ring-pulse 6s ease-in-out infinite;
}
.dream-orbit-lg .dream-orbit-ring {
  inset: 10px;
}

@keyframes orbit-chase {
  0% { transform: rotate(0deg) translateY(0); opacity: 0.3; }
  50% { opacity: 1; }
  100% { transform: rotate(360deg) translateY(0); opacity: 0.3; }
}
@keyframes orbit-rotate {
  to { transform: rotate(360deg); }
}
@keyframes orbit-ring-pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); border-color: rgba(196, 181, 253, 0.06); }
  50% { opacity: 1; transform: scale(1.1); border-color: rgba(196, 181, 253, 0.2); }
}

/* ═══ Dream Loading Text ═══ */

.dream-loading-text {
  font-size: 0.7rem;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  text-align: center;
  animation: text-breathe 3s ease-in-out infinite;
}

@keyframes text-breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ═══ Dream Progress Bar ═══ */

.dream-progress {
  position: relative;
  width: 100%;
  max-width: 200px;
  height: 4px;
  border-radius: 3px;
  background: rgba(196, 181, 253, 0.08);
  margin: 12px auto 0;
  overflow: visible;
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.dream-progress.active {
  opacity: 1;
}

/* Track inner clip for the fill */
.dream-progress-track {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  overflow: hidden;
}

.dream-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg,
    var(--lavender),
    var(--moonlight),
    rgba(253, 164, 175, 0.8),
    var(--lavender));
  background-size: 300% 100%;
  animation: progress-shimmer 3s linear infinite;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Glow underneath the filled portion */
.dream-progress-glow {
  position: absolute;
  top: -2px;
  left: 0;
  height: 8px;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(196, 181, 253, 0.3), rgba(147, 197, 253, 0.4));
  filter: blur(6px);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

/* Leading-edge sparkle — on the glow layer (outside the clipped track) */
.dream-progress-glow::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  box-shadow:
    0 0 6px rgba(255, 255, 255, 0.8),
    0 0 12px rgba(196, 181, 253, 0.6),
    0 0 20px rgba(147, 197, 253, 0.3);
  opacity: 0.9;
  animation: progress-sparkle 1.5s ease-in-out infinite;
}

/* Completion burst */
.dream-progress.complete .dream-progress-glow::after {
  animation: progress-burst 0.6s ease-out forwards;
}
.dream-progress.complete .dream-progress-glow {
  animation: glow-burst 0.6s ease-out forwards;
}

/* Error state */
.dream-progress.error .dream-progress-fill {
  background: linear-gradient(90deg, rgba(253, 164, 175, 0.6), rgba(253, 164, 175, 0.8));
  animation: none;
}
.dream-progress.error .dream-progress-glow {
  background: rgba(253, 164, 175, 0.3);
}
.dream-progress.error .dream-progress-glow::after {
  background: var(--rose);
  box-shadow: 0 0 8px rgba(253, 164, 175, 0.6);
  animation: none;
}

/* Inline variant for sidebar (narrower context) */
.dream-progress-inline {
  max-width: 100%;
  margin: 8px 0 4px;
}

@keyframes progress-shimmer {
  0% { background-position: 300% 0; }
  100% { background-position: -300% 0; }
}
@keyframes progress-sparkle {
  0%, 100% { opacity: 0.5; transform: translateY(-50%) scale(0.8); }
  50% { opacity: 1; transform: translateY(-50%) scale(1.1); }
}
@keyframes progress-burst {
  0% { opacity: 1; transform: translateY(-50%) scale(1); }
  50% { opacity: 1; transform: translateY(-50%) scale(2.5); }
  100% { opacity: 0; transform: translateY(-50%) scale(0); }
}
@keyframes glow-burst {
  0% { filter: blur(6px); opacity: 1; }
  50% { filter: blur(12px); opacity: 1; }
  100% { filter: blur(20px); opacity: 0; }
}

/* ═══ Full-Res Upgrade Bar ═══ */

.fullres-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease), height 0.3s var(--ease);
}
.fullres-bar.active {
  opacity: 1;
}

.fullres-bar-track {
  position: absolute;
  inset: 0;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}

.fullres-bar-fill {
  height: 100%;
  width: 28%;
  border-radius: 2px;
  background: linear-gradient(90deg,
    transparent,
    rgba(196, 181, 253, 0.5),
    rgba(147, 197, 253, 0.7),
    rgba(253, 164, 175, 0.5),
    transparent);
  animation: fullres-sweep 2s ease-in-out infinite;
}

.fullres-bar-glow {
  position: absolute;
  inset: -3px 0 -2px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg,
    transparent 10%,
    rgba(196, 181, 253, 0.25) 30%,
    rgba(147, 197, 253, 0.3) 50%,
    rgba(196, 181, 253, 0.25) 70%,
    transparent 90%);
  filter: blur(4px);
  animation: fullres-sweep 2s ease-in-out infinite;
  pointer-events: none;
}

.fullres-bar-label {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-family: 'Quicksand', sans-serif;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(196, 181, 253, 0.5);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.5s var(--ease) 0.3s, transform 0.5s var(--ease) 0.3s;
}
.fullres-bar.active .fullres-bar-label {
  opacity: 1;
  transform: translateY(0);
}

/* Completion flash */
.fullres-bar.complete .fullres-bar-fill {
  width: 100% !important;
  background: linear-gradient(90deg,
    rgba(52, 211, 153, 0.3),
    rgba(52, 211, 153, 0.6),
    rgba(52, 211, 153, 0.3));
  animation: none;
  transition: width 0.3s var(--ease);
}
.fullres-bar.complete .fullres-bar-glow {
  background: rgba(52, 211, 153, 0.25);
  filter: blur(8px);
  animation: fullres-complete-glow 0.8s ease-out forwards;
}
.fullres-bar.complete .fullres-bar-label {
  color: rgba(52, 211, 153, 0.7);
}

@keyframes fullres-sweep {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(460%); }
}

@keyframes fullres-complete-glow {
  0%   { opacity: 1; filter: blur(8px); }
  50%  { opacity: 1; filter: blur(14px); }
  100% { opacity: 0; filter: blur(20px); }
}

/* ═══ Action Button Shimmer ═══ */

.action-btn,
.fdock-btn-primary {
  position: relative;
  overflow: hidden;
}
.action-btn::before,
.fdock-btn-primary#fdock-generate::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  animation: btn-shimmer 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes btn-shimmer {
  0%, 70%, 100% { left: -100%; }
  40% { left: 140%; }
}
