/* ===========================
   HUSHIKO App Magic Effects
   Dashboard & App Pages Animations
   2025-11-27
   =========================== */

/* ===========================
   1. STAT CARDS - Enhanced
   =========================== */

.stat-card {
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  cursor: pointer;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-hero);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.stat-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 40px rgba(155, 135, 217, 0.2);
}

.stat-card:hover::before {
  transform: scaleX(1);
}

/* Stat icon pulse on hover */
.stat-card:hover .stat-icon {
  animation: statIconPulse 0.6s ease;
}

@keyframes statIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Animated counter styling */
.stat-content h3 {
  transition: color 0.3s ease;
}

.stat-content h3.counting {
  color: var(--color-purple);
}

/* ===========================
   2. SCROLL REVEAL FOR APP
   =========================== */

.app-fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-fade-in.revealed {
  opacity: 1;
  transform: translateY(0);
}

.app-fade-in-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-fade-in-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

.app-fade-in-right {
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-fade-in-right.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* Stagger animation for grids */
.app-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-stagger.revealed > *:nth-child(1) { transition-delay: 0s; opacity: 1; transform: translateY(0); }
.app-stagger.revealed > *:nth-child(2) { transition-delay: 0.1s; opacity: 1; transform: translateY(0); }
.app-stagger.revealed > *:nth-child(3) { transition-delay: 0.2s; opacity: 1; transform: translateY(0); }
.app-stagger.revealed > *:nth-child(4) { transition-delay: 0.3s; opacity: 1; transform: translateY(0); }
.app-stagger.revealed > *:nth-child(5) { transition-delay: 0.4s; opacity: 1; transform: translateY(0); }
.app-stagger.revealed > *:nth-child(6) { transition-delay: 0.5s; opacity: 1; transform: translateY(0); }
.app-stagger.revealed > *:nth-child(7) { transition-delay: 0.6s; opacity: 1; transform: translateY(0); }
.app-stagger.revealed > *:nth-child(8) { transition-delay: 0.7s; opacity: 1; transform: translateY(0); }

/* ===========================
   3. QUICK ACTIONS - Enhanced
   =========================== */

.quick-actions-grid {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.quick-actions-grid .btn-primary,
.quick-actions-grid .btn-secondary {
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.quick-actions-grid .btn-primary::after,
.quick-actions-grid .btn-secondary::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.quick-actions-grid .btn-primary:hover::after,
.quick-actions-grid .btn-secondary:hover::after {
  width: 300px;
  height: 300px;
}

.quick-actions-grid .btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(155, 135, 217, 0.35);
}

.quick-actions-grid .btn-secondary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

/* ===========================
   4. EMPTY STATES - Enhanced
   =========================== */

.empty-state {
  position: relative;
  overflow: hidden;
}

.empty-state::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle at center,
    rgba(155, 135, 217, 0.03) 0%,
    transparent 50%
  );
  animation: emptyStateGlow 8s ease-in-out infinite;
}

@keyframes emptyStateGlow {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10%, 10%); }
}

.empty-state-icon {
  animation: emptyIconFloat 3s ease-in-out infinite;
}

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

/* ===========================
   5. STORY CARDS - Enhanced
   =========================== */

.story-card {
  position: relative;
  overflow: hidden; /* Clip image corners */
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-radius: var(--radius-md);
  background: var(--color-white);
}

.story-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 16px 40px rgba(155, 135, 217, 0.25);
}

/* Magical gradient border on hover - using box-shadow instead of pseudo */
.story-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  padding: 2px;
  background: linear-gradient(135deg, var(--color-purple), var(--color-orange), var(--color-purple));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: 10;
}

.story-card:hover::before {
  opacity: 1;
}

/* Story card image must respect border-radius */
.story-card-image {
  overflow: hidden;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* Ensure PDF tooltip can overflow */
.story-card-actions {
  overflow: visible;
  position: relative;
  z-index: 5;
}

/* Processing/Generating pulse effect */
.story-card[data-status="processing"],
.story-card[data-status="pending"],
.story-card[data-status="generating_text"],
.story-card[data-status="generating_audio"],
.story-card[data-status="generating_images"] {
  animation: processingPulse 2s ease-in-out infinite;
}

@keyframes processingPulse {
  0%, 100% {
    box-shadow: var(--shadow-md);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(155, 135, 217, 0.3), var(--shadow-md);
  }
}

/* Processing indicator overlay */
.story-card[data-status="processing"]::after,
.story-card[data-status="pending"]::after,
.story-card[data-status="generating_text"]::after,
.story-card[data-status="generating_audio"]::after,
.story-card[data-status="generating_images"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-hero);
  animation: processingBar 1.5s ease-in-out infinite;
}

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

/* Story card image hover zoom */
.story-card-image img {
  transition: transform 0.5s ease;
}

.story-card:hover .story-card-image img {
  transform: scale(1.08);
}

/* ===========================
   6. CHILD CARDS - Enhanced
   =========================== */

.child-card {
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.child-card:hover {
  transform: translateY(-5px) scale(1.02);
}

/* ===========================
   7. GENERATOR PROGRESS - Enhanced
   =========================== */

.progress-stage {
  transition: all 0.4s ease;
}

.progress-stage.active {
  transform: scale(1.1);
}

.progress-stage.active .stage-icon {
  animation: stageIconBounce 0.6s ease infinite;
}

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

.progress-stage.completed .stage-icon {
  animation: stageComplete 0.5s ease forwards;
}

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

/* Progress fill animation */
.progress-fill {
  transition: width 0.5s ease;
  background: var(--gradient-hero);
  position: relative;
  overflow: hidden;
}

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

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

/* ===========================
   8. GENERATING SCREEN - Enhanced
   =========================== */

.generating-card {
  animation: generateCardEntry 0.6s ease forwards;
}

@keyframes generateCardEntry {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Enhanced fairy animation */
.fairy {
  animation: fairyFloat 3s ease-in-out infinite;
}

@keyframes fairyFloat {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-15px) rotate(5deg); }
}

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

@keyframes fairyGlowPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.8;
  }
}

/* Sparkles enhanced */
.sparkle {
  animation: sparkleFloat 2s ease-in-out infinite;
}

.sparkle:nth-child(1) { animation-delay: 0s; }
.sparkle:nth-child(2) { animation-delay: 0.3s; }
.sparkle:nth-child(3) { animation-delay: 0.6s; }
.sparkle:nth-child(4) { animation-delay: 0.9s; }
.sparkle:nth-child(5) { animation-delay: 1.2s; }
.sparkle:nth-child(6) { animation-delay: 1.5s; }

@keyframes sparkleFloat {
  0%, 100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-20px) scale(0.8);
    opacity: 0.5;
  }
}

/* ===========================
   9. DASHBOARD SECTIONS
   =========================== */

.dashboard-section {
  transition: all 0.3s ease;
}

.dashboard-section:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

/* Section header line animation */
.section-header h2 {
  position: relative;
  display: inline-block;
}

.section-header h2::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-hero);
  transition: width 0.4s ease;
}

.dashboard-section:hover .section-header h2::after {
  width: 100%;
}

/* ===========================
   10. FORM INPUTS - Enhanced
   =========================== */

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px rgba(155, 135, 217, 0.2);
  transition: box-shadow 0.3s ease;
}

/* ===========================
   11. BUTTONS - Ripple Effect
   =========================== */

.btn-primary,
.btn-secondary {
  position: relative;
  overflow: hidden;
}

.btn-ripple {
  position: absolute;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: rippleEffect 0.6s ease-out forwards;
  pointer-events: none;
}

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

/* Story card action buttons */
.story-card-actions button,
.story-card-actions a {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.story-card-actions button:hover,
.story-card-actions a:hover {
  transform: scale(1.1);
}

.story-card-actions button:active,
.story-card-actions a:active {
  transform: scale(0.95);
}

/* ===========================
   12. LOADING STATES
   =========================== */

.loading-skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

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

/* ===========================
   13. PAGE LOAD ANIMATION
   =========================== */

.app-container {
  animation: pageLoad 0.5s ease forwards;
}

@keyframes pageLoad {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===========================
   14. NAVIGATION ENHANCEMENTS
   =========================== */

.app-nav__link {
  position: relative;
}

.app-nav__link::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--gradient-hero);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.app-nav__link:hover::before {
  width: 80%;
}

.app-nav__link--active::before {
  width: 80%;
}

/* Credits badge pulse on low credits */
.app-nav__credits.low-credits {
  animation: lowCreditsPulse 2s ease-in-out infinite;
}

@keyframes lowCreditsPulse {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(155, 126, 189, 0.3);
  }
  50% {
    box-shadow: 0 2px 15px rgba(255, 107, 107, 0.5);
  }
}

/* ===========================
   15. TOAST NOTIFICATIONS
   =========================== */

.toast {
  animation: toastSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes toastSlideIn {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.removing {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideOut {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ===========================
   16. MODAL ENHANCEMENTS
   =========================== */

.modal-content {
  animation: modalEntry 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes modalEntry {
  0% {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-backdrop {
  animation: backdropFade 0.3s ease forwards;
}

@keyframes backdropFade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* ===========================
   17. THEME/LANGUAGE TILES
   =========================== */

.theme-tile,
.language-tile {
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.theme-tile:hover,
.language-tile:hover {
  transform: translateY(-4px) scale(1.02);
}

.theme-tile.selected,
.language-tile.selected {
  animation: tileSelected 0.3s ease forwards;
}

@keyframes tileSelected {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ===========================
   18. REDUCED MOTION
   =========================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .app-fade-in,
  .app-fade-in-left,
  .app-fade-in-right,
  .app-stagger > * {
    opacity: 1;
    transform: none;
  }
}
