/* === Orchestrated page entrance - clip-path reveal === */
@keyframes revealUp {
  from {
    clip-path: inset(100% 0 0 0);
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes revealLeft {
  from {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes revealScale {
  from {
    clip-path: inset(50% 50% 50% 50%);
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
    transform: scale(1);
  }
}

/* === Simple fades === */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* === Ambient background drift === */
@keyframes ambientDrift {
  0% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-2%, 1%) rotate(1deg); }
  100% { transform: translate(1%, -1%) rotate(-0.5deg); }
}

/* === Scanning line across hero === */
@keyframes scanLine {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% {
    transform: translateX(100vw);
    opacity: 0;
  }
}

/* === Animated gradient border === */
@keyframes borderRotate {
  0% { --border-angle: 0deg; }
  100% { --border-angle: 360deg; }
}

/* === Gradient shimmer for buttons/accents === */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* === Text reveal - letters unblur === */
@keyframes textUnblur {
  from {
    filter: blur(8px);
    opacity: 0;
    letter-spacing: 0.3em;
  }
  to {
    filter: blur(0);
    opacity: 1;
    letter-spacing: -0.02em;
  }
}

/* === Tooltip === */
@keyframes tooltipIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* === Pulse === */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 10px var(--accent-primary-dim); }
  50% { box-shadow: 0 0 25px var(--accent-primary-dim); }
}

/* === Shake (quiz wrong answer) === */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* === Scale pop === */
@keyframes scalePop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* === Counter tick for stats === */
@keyframes counterTick {
  0% { transform: translateY(100%); opacity: 0; }
  60% { transform: translateY(-5%); }
  100% { transform: translateY(0); opacity: 1; }
}

/* === Card accent stripe slide === */
@keyframes stripeSlide {
  from {
    transform: translateY(100%) skewY(-45deg);
    opacity: 0;
  }
  to {
    transform: translateY(0) skewY(-45deg);
    opacity: 1;
  }
}

/* === SVG draw === */
@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

/* === Node activate (for diagrams) === */
@keyframes nodeActivate {
  0% {
    fill: var(--bg-elevated);
    r: 8;
  }
  50% {
    fill: var(--accent-primary);
    r: 11;
  }
  100% {
    fill: var(--accent-primary);
    r: 9;
  }
}

/* === Data flow (for diagrams) === */
@keyframes dataFlow {
  0% { offset-distance: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* === Gradient shift === */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* === Spin === */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* === Diagram-specific === */
@keyframes flowPulse {
  0%, 100% {
    stroke-width: 2;
    stroke-opacity: 0.3;
  }
  50% {
    stroke-width: 3;
    stroke-opacity: 0.8;
  }
}

@keyframes nodeBreathe {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.08);
    filter: brightness(1.3);
  }
}

/* ============================================
   ORCHESTRATED ENTRANCE SYSTEM
   ============================================
   Usage: add .orchestrate to a parent container.
   Direct children get staggered clip-path reveals.
   ============================================ */

.orchestrate > * {
  opacity: 0;
  animation: revealUp 0.7s var(--ease-out) forwards;
}

.orchestrate > *:nth-child(1)  { animation-delay: 0ms; }
.orchestrate > *:nth-child(2)  { animation-delay: 80ms; }
.orchestrate > *:nth-child(3)  { animation-delay: 160ms; }
.orchestrate > *:nth-child(4)  { animation-delay: 240ms; }
.orchestrate > *:nth-child(5)  { animation-delay: 320ms; }
.orchestrate > *:nth-child(6)  { animation-delay: 400ms; }
.orchestrate > *:nth-child(7)  { animation-delay: 480ms; }
.orchestrate > *:nth-child(8)  { animation-delay: 560ms; }
.orchestrate > *:nth-child(9)  { animation-delay: 640ms; }
.orchestrate > *:nth-child(10) { animation-delay: 720ms; }
.orchestrate > *:nth-child(11) { animation-delay: 800ms; }
.orchestrate > *:nth-child(12) { animation-delay: 880ms; }
.orchestrate > *:nth-child(13) { animation-delay: 960ms; }
.orchestrate > *:nth-child(14) { animation-delay: 1040ms; }

/* === Cascade variant - wave motion from left === */
.orchestrate--wave > * {
  opacity: 0;
  animation: revealLeft 0.6s var(--ease-out) forwards;
}

.orchestrate--wave > *:nth-child(1)  { animation-delay: 0ms; }
.orchestrate--wave > *:nth-child(2)  { animation-delay: 60ms; }
.orchestrate--wave > *:nth-child(3)  { animation-delay: 120ms; }
.orchestrate--wave > *:nth-child(4)  { animation-delay: 180ms; }
.orchestrate--wave > *:nth-child(5)  { animation-delay: 240ms; }
.orchestrate--wave > *:nth-child(6)  { animation-delay: 300ms; }
.orchestrate--wave > *:nth-child(7)  { animation-delay: 360ms; }
.orchestrate--wave > *:nth-child(8)  { animation-delay: 420ms; }

/* === Scale entrance variant === */
.orchestrate--scale > * {
  opacity: 0;
  animation: revealScale 0.5s var(--ease-spring) forwards;
}

.orchestrate--scale > *:nth-child(1)  { animation-delay: 0ms; }
.orchestrate--scale > *:nth-child(2)  { animation-delay: 70ms; }
.orchestrate--scale > *:nth-child(3)  { animation-delay: 140ms; }
.orchestrate--scale > *:nth-child(4)  { animation-delay: 210ms; }
.orchestrate--scale > *:nth-child(5)  { animation-delay: 280ms; }
.orchestrate--scale > *:nth-child(6)  { animation-delay: 350ms; }

/* === Stagger utility classes (legacy) === */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }
.stagger-7 { animation-delay: 350ms; }
.stagger-8 { animation-delay: 400ms; }

/* === Animate in (simple) === */
.animate-in {
  opacity: 0;
  animation: fadeSlideUp var(--duration-slow) var(--ease-out) forwards;
}

/* === Correct / Incorrect quiz animations === */
.quiz-correct {
  animation: scalePop var(--duration-normal) var(--ease-spring);
  border-color: var(--accent-green) !important;
  background: var(--accent-green-dim) !important;
}

.quiz-incorrect {
  animation: shake var(--duration-normal) var(--ease-out);
  border-color: var(--accent-red) !important;
  background: var(--accent-red-dim) !important;
}

/* === Loading spinner === */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-medium);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin var(--duration-slower) linear infinite;
}

/* === Progress ring fill animation === */
@keyframes progressFill {
  from {
    stroke-dashoffset: var(--circumference);
  }
}

/* === Hover micro-interactions === */

/* Tilt on hover (apply to card parents) */
.hover-tilt {
  transition: transform var(--duration-normal) var(--ease-out);
}

.hover-tilt:hover {
  transform: perspective(800px) rotateY(-2deg) rotateX(1deg) translateY(-4px);
}

/* Glow pulse on hover */
.hover-glow {
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

.hover-glow:hover {
  box-shadow: 0 0 30px rgba(240, 180, 41, 0.12), 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Reveal child on hover */
.hover-reveal .hover-reveal__target {
  opacity: 0;
  transform: translateY(6px);
  transition: all var(--duration-normal) var(--ease-out);
}

.hover-reveal:hover .hover-reveal__target {
  opacity: 1;
  transform: translateY(0);
}
