/* ── MOTION DESIGN SYSTEM ─────────────────────────────────────────────────── */
/* Entrance animations, micro-interactions, and transition effects.           */
/* Uses CSS-only techniques for performance and simplicity.                   */

/* ── Entrance animations ─────────────────────────────────────────────────── */

/* Panel slide-in (replaces old panelIn) */
@keyframes panelIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fade up — general purpose entrance */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fade in — simple opacity */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Scale in — for badges, pills, icons */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* Slide in from right — for cards entering */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Slide in from left */
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Section panel transitions ───────────────────────────────────────────── */
.section-panel.active {
  animation: panelIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Staggered content entrance ──────────────────────────────────────────── */
/* Apply .animate-in to a parent and children get staggered entrance */
.animate-in > * {
  opacity: 0;
  animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.animate-in > *:nth-child(1)  { animation-delay: 0.05s; }
.animate-in > *:nth-child(2)  { animation-delay: 0.10s; }
.animate-in > *:nth-child(3)  { animation-delay: 0.15s; }
.animate-in > *:nth-child(4)  { animation-delay: 0.20s; }
.animate-in > *:nth-child(5)  { animation-delay: 0.25s; }
.animate-in > *:nth-child(6)  { animation-delay: 0.30s; }
.animate-in > *:nth-child(7)  { animation-delay: 0.35s; }
.animate-in > *:nth-child(8)  { animation-delay: 0.40s; }
.animate-in > *:nth-child(9)  { animation-delay: 0.45s; }
.animate-in > *:nth-child(10) { animation-delay: 0.50s; }

/* ── Dialogue stagger — messages appear like a conversation ──────────────── */
.dialogue {
  opacity: 0;
  animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.section-panel.active .dialogue:nth-of-type(1) { animation-delay: 0.1s; }
.section-panel.active .dialogue:nth-of-type(2) { animation-delay: 0.25s; }
.section-panel.active .dialogue:nth-of-type(3) { animation-delay: 0.4s; }
.section-panel.active .dialogue:nth-of-type(4) { animation-delay: 0.55s; }
.section-panel.active .dialogue:nth-of-type(5) { animation-delay: 0.7s; }

/* ── Task card entrance ──────────────────────────────────────────────────── */
.task-card {
  animation: fadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Progress dot completion pulse ───────────────────────────────────────── */
@keyframes dotPulse {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50%  { transform: scale(1.4); box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { transform: scale(1); box-shadow: 0 0 6px rgba(52, 211, 153, 0.5); }
}
.prog-dot.done {
  animation: dotPulse 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Task completion header transition ───────────────────────────────────── */
.task-header {
  transition: background 0.6s ease;
}
.task-card.completed .task-header {
  background: linear-gradient(135deg, #14532D 0%, #16A34A 100%);
}

/* ── Answer block feedback entrance ──────────────────────────────────────── */
.feedback-msg.show {
  animation: fadeUp 0.3s ease forwards;
}

/* ── Interaction feedback entrance ───────────────────────────────────────── */
.interaction-feedback.show {
  animation: fadeUp 0.3s ease forwards;
}

/* ── Subtle glow for active elements ────────────────────────────────────── */
@keyframes subtleGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.1); }
  50%      { box-shadow: 0 0 30px rgba(59, 130, 246, 0.2); }
}

/* ── Content card hover lift ─────────────────────────────────────────────── */
.content-card {
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}
.content-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .content-card:hover {
  box-shadow: var(--shadow-md), 0 0 30px rgba(59, 130, 246, 0.06);
}

/* ── Button press effect ─────────────────────────────────────────────────── */
.check-btn:active:not(:disabled),
.btn-next:active,
.reveal-trigger:active {
  transform: translateY(0) scale(0.97);
}

/* ── Smooth scroll indicator ─────────────────────────────────────────────── */
@keyframes scrollHint {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%      { transform: translateY(6px); opacity: 1; }
}

/* ── Video block entrance ────────────────────────────────────────────────── */
.video-block {
  animation: fadeUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Scene break entrance ────────────────────────────────────────────────── */
.scene-break {
  animation: fadeIn 0.5s ease forwards;
}

/* ── Email block entrance ────────────────────────────────────────────────── */
.email-block {
  animation: slideInRight 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Narrator text entrance ──────────────────────────────────────────────── */
.narrator {
  animation: slideInLeft 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Choice option hover micro-interaction ───────────────────────────────── */
.choice-option {
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.choice-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .choice-option:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), 0 0 20px rgba(59, 130, 246, 0.08);
}

/* ── Reveal content smooth expand ────────────────────────────────────────── */
.reveal-content.revealed {
  animation: fadeUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Completion screen entrance ──────────────────────────────────────────── */
#completion-screen.show {
  animation: fadeUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Confetti animation (CSS-only) ───────────────────────────────────────── */
@keyframes confettiFall {
  0%   { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes confettiSway {
  0%, 100% { margin-left: 0; }
  25%      { margin-left: 30px; }
  75%      { margin-left: -30px; }
}

.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall 3s ease-in forwards, confettiSway 1.5s ease-in-out infinite;
}
.confetti-piece:nth-child(odd)  { border-radius: 50%; }
.confetti-piece:nth-child(even) { border-radius: 2px; }

.confetti-piece:nth-child(1)  { left: 5%;  background: #3B82F6; animation-delay: 0.0s; animation-duration: 2.8s; width: 8px; height: 8px; }
.confetti-piece:nth-child(2)  { left: 12%; background: #34D399; animation-delay: 0.2s; animation-duration: 3.2s; }
.confetti-piece:nth-child(3)  { left: 20%; background: #F59E0B; animation-delay: 0.1s; animation-duration: 2.6s; width: 12px; height: 12px; }
.confetti-piece:nth-child(4)  { left: 28%; background: #EF4444; animation-delay: 0.4s; animation-duration: 3.0s; }
.confetti-piece:nth-child(5)  { left: 35%; background: #8B5CF6; animation-delay: 0.15s; animation-duration: 2.9s; width: 7px; height: 7px; }
.confetti-piece:nth-child(6)  { left: 42%; background: #EC4899; animation-delay: 0.3s; animation-duration: 3.4s; }
.confetti-piece:nth-child(7)  { left: 50%; background: #3B82F6; animation-delay: 0.05s; animation-duration: 2.7s; width: 11px; height: 11px; }
.confetti-piece:nth-child(8)  { left: 58%; background: #34D399; animation-delay: 0.35s; animation-duration: 3.1s; }
.confetti-piece:nth-child(9)  { left: 65%; background: #F59E0B; animation-delay: 0.25s; animation-duration: 2.5s; width: 9px; height: 9px; }
.confetti-piece:nth-child(10) { left: 72%; background: #EF4444; animation-delay: 0.1s; animation-duration: 3.3s; }
.confetti-piece:nth-child(11) { left: 80%; background: #8B5CF6; animation-delay: 0.45s; animation-duration: 2.8s; width: 13px; height: 13px; }
.confetti-piece:nth-child(12) { left: 88%; background: #EC4899; animation-delay: 0.2s; animation-duration: 3.0s; }
.confetti-piece:nth-child(13) { left: 95%; background: #3B82F6; animation-delay: 0.3s; animation-duration: 2.6s; }
.confetti-piece:nth-child(14) { left: 8%;  background: #34D399; animation-delay: 0.5s; animation-duration: 3.5s; width: 6px; height: 6px; }
.confetti-piece:nth-child(15) { left: 45%; background: #F59E0B; animation-delay: 0.15s; animation-duration: 2.9s; }
.confetti-piece:nth-child(16) { left: 55%; background: #EF4444; animation-delay: 0.4s; animation-duration: 3.2s; width: 10px; height: 10px; }
.confetti-piece:nth-child(17) { left: 32%; background: #8B5CF6; animation-delay: 0.25s; animation-duration: 2.7s; }
.confetti-piece:nth-child(18) { left: 75%; background: #EC4899; animation-delay: 0.35s; animation-duration: 3.1s; width: 8px; height: 8px; }

/* ── Sidebar nav item transition ─────────────────────────────────────────── */
.nav-item {
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.nav-item:hover .nav-label {
  transform: translateX(2px);
}
.nav-label {
  transition: color 0.15s ease, transform 0.2s ease;
}

/* ── Focus ring for keyboard navigation ──────────────────────────────────── */
:focus-visible {
  outline: 2px solid #3B82F6;
  outline-offset: 2px;
  border-radius: 4px;
}
[data-theme="dark"] .check-btn:focus-visible,
[data-theme="dark"] .btn-next:focus-visible {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), 0 0 20px rgba(59, 130, 246, 0.15);
}

/* Remove focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* ── Smooth scrolling ────────────────────────────────────────────────────── */
.main-content {
  scroll-behavior: smooth;
}

/* ── Reduced motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .main-content {
    scroll-behavior: auto;
  }
}
