/*
 * Educational Empire Hub - Animations
 * Keyframes, scroll animations, and micro-interactions
 */

/* ===================================
   KEYFRAME ANIMATIONS
   =================================== */

/* Fade animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleInBounce {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Float animations */
@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

@keyframes floatRotate {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-10px) rotate(2deg);
    }

    50% {
        transform: translateY(-20px) rotate(0deg);
    }

    75% {
        transform: translateY(-10px) rotate(-2deg);
    }
}

@keyframes gentleFloat {

    0%,
    100% {
        transform: translateY(0) translateX(0);
    }

    25% {
        transform: translateY(-5px) translateX(3px);
    }

    50% {
        transform: translateY(-10px) translateX(0);
    }

    75% {
        transform: translateY(-5px) translateX(-3px);
    }
}

/* Pulse animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
    }

    50% {
        box-shadow: 0 0 40px rgba(212, 175, 55, 0.6);
    }
}

/* Shimmer effect */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Rotate animations */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes rotateReverse {
    from {
        transform: rotate(360deg);
    }

    to {
        transform: rotate(0deg);
    }
}

@keyframes rotateSlow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Draw SVG stroke */
@keyframes drawLine {
    0% {
        stroke-dashoffset: 1000;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

/* Typewriter effect for hero text */
@keyframes typewriter {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Letter cascade */
@keyframes letterReveal {
    0% {
        opacity: 0;
        transform: translateY(50px) rotateX(-90deg);
    }

    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0deg);
    }
}

/* Parallax layer movement */
@keyframes parallaxFloat {

    0%,
    100% {
        transform: translateY(0) translateX(0);
    }

    50% {
        transform: translateY(-30px) translateX(10px);
    }
}

/* Confetti */
@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Countdown flip */
@keyframes flipTop {
    0% {
        transform: rotateX(0deg);
    }

    100% {
        transform: rotateX(-90deg);
    }
}

@keyframes flipBottom {
    0% {
        transform: rotateX(90deg);
    }

    100% {
        transform: rotateX(0deg);
    }
}

/* Ink stroke for logo */
@keyframes inkStroke {
    0% {
        stroke-dashoffset: 500;
        fill: transparent;
    }

    70% {
        stroke-dashoffset: 0;
        fill: transparent;
    }

    100% {
        stroke-dashoffset: 0;
        fill: currentColor;
    }
}

/* Particle drift */
@keyframes particleDrift {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translate(var(--drift-x, 100px), var(--drift-y, -200px)) rotate(var(--drift-rotate, 180deg));
        opacity: 0;
    }
}

/* Glitch effect */
@keyframes glitch {

    0%,
    100% {
        transform: translateX(0);
        filter: none;
    }

    10% {
        transform: translateX(-2px);
        filter: hue-rotate(90deg);
    }

    20% {
        transform: translateX(2px);
        filter: hue-rotate(180deg);
    }

    30% {
        transform: translateX(-1px);
        filter: hue-rotate(270deg);
    }

    40% {
        transform: translateX(1px);
        filter: none;
    }
}

/* ===================================
   ANIMATION UTILITY CLASSES
   =================================== */

/* Base animation class */
.animate {
    animation-duration: var(--duration-slow);
    animation-timing-function: var(--ease-out);
    animation-fill-mode: both;
}

.animate--fast {
    animation-duration: var(--duration-fast);
}

.animate--slow {
    animation-duration: var(--duration-slower);
}

.animate--slowest {
    animation-duration: var(--duration-slowest);
}

/* Delay utilities */
.animate-delay-100 {
    animation-delay: 100ms;
}

.animate-delay-200 {
    animation-delay: 200ms;
}

.animate-delay-300 {
    animation-delay: 300ms;
}

.animate-delay-400 {
    animation-delay: 400ms;
}

.animate-delay-500 {
    animation-delay: 500ms;
}

.animate-delay-600 {
    animation-delay: 600ms;
}

.animate-delay-700 {
    animation-delay: 700ms;
}

.animate-delay-800 {
    animation-delay: 800ms;
}

.animate-delay-900 {
    animation-delay: 900ms;
}

.animate-delay-1000 {
    animation-delay: 1000ms;
}

/* Specific animations */
.animate-fadeIn {
    animation-name: fadeIn;
}

.animate-fadeInUp {
    animation-name: fadeInUp;
}

.animate-fadeInDown {
    animation-name: fadeInDown;
}

.animate-fadeInLeft {
    animation-name: fadeInLeft;
}

.animate-fadeInRight {
    animation-name: fadeInRight;
}

.animate-scaleIn {
    animation-name: scaleIn;
}

.animate-scaleInBounce {
    animation-name: scaleInBounce;
}

.animate-float {
    animation-name: float;
    animation-duration: 3s;
    animation-iteration-count: infinite;
}

.animate-floatRotate {
    animation-name: floatRotate;
    animation-duration: 4s;
    animation-iteration-count: infinite;
}

.animate-gentleFloat {
    animation-name: gentleFloat;
    animation-duration: 5s;
    animation-iteration-count: infinite;
}

.animate-pulse {
    animation-name: pulse;
    animation-duration: 2s;
    animation-iteration-count: infinite;
}

.animate-pulseGlow {
    animation-name: pulseGlow;
    animation-duration: 2s;
    animation-iteration-count: infinite;
}

.animate-rotate {
    animation-name: rotate;
    animation-duration: 20s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

.animate-rotateSlow {
    animation-name: rotateSlow;
    animation-duration: 60s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

/* Shimmer effect */
.shimmer {
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(255, 255, 255, 0.4) 50%,
            transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* ===================================
   SCROLL REVEAL ANIMATIONS
   =================================== */

/* Initial hidden state for scroll animations */
[data-scroll] {
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-out),
        transform var(--duration-slow) var(--ease-out);
}

[data-scroll="fade-up"] {
    transform: translateY(50px);
}

[data-scroll="fade-down"] {
    transform: translateY(-50px);
}

[data-scroll="fade-left"] {
    transform: translateX(-50px);
}

[data-scroll="fade-right"] {
    transform: translateX(50px);
}

[data-scroll="scale"] {
    transform: scale(0.8);
}

[data-scroll="rotate"] {
    transform: rotate(-10deg) scale(0.9);
}

/* Active state when scrolled into view */
[data-scroll].is-visible {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1) rotate(0deg);
}

/* Stagger children animations */
[data-scroll-stagger]>* {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--duration-normal) var(--ease-out),
        transform var(--duration-normal) var(--ease-out);
}

[data-scroll-stagger].is-visible>*:nth-child(1) {
    transition-delay: 0ms;
    opacity: 1;
    transform: translateY(0);
}

[data-scroll-stagger].is-visible>*:nth-child(2) {
    transition-delay: 100ms;
    opacity: 1;
    transform: translateY(0);
}

[data-scroll-stagger].is-visible>*:nth-child(3) {
    transition-delay: 200ms;
    opacity: 1;
    transform: translateY(0);
}

[data-scroll-stagger].is-visible>*:nth-child(4) {
    transition-delay: 300ms;
    opacity: 1;
    transform: translateY(0);
}

[data-scroll-stagger].is-visible>*:nth-child(5) {
    transition-delay: 400ms;
    opacity: 1;
    transform: translateY(0);
}

[data-scroll-stagger].is-visible>*:nth-child(6) {
    transition-delay: 500ms;
    opacity: 1;
    transform: translateY(0);
}

[data-scroll-stagger].is-visible>*:nth-child(7) {
    transition-delay: 600ms;
    opacity: 1;
    transform: translateY(0);
}

[data-scroll-stagger].is-visible>*:nth-child(8) {
    transition-delay: 700ms;
    opacity: 1;
    transform: translateY(0);
}

/* ===================================
   PAGE LOAD CHOREOGRAPHY
   =================================== */

/* Hero load sequence */
.hero-bg {
    animation: fadeIn 0.8s var(--ease-out) forwards;
}

.hero-title {
    opacity: 0;
    animation: fadeInUp 0.8s var(--ease-out) 0.3s forwards;
}

.hero-subtitle {
    opacity: 0;
    animation: fadeInUp 0.6s var(--ease-out) 0.6s forwards;
}

.hero-cta {
    opacity: 0;
    animation: scaleInBounce 0.8s var(--ease-bounce) 1s forwards;
}

.hero-decorative {
    opacity: 0;
    animation: fadeIn 1s var(--ease-out) 0.8s forwards;
}

/* Nav load */
.nav--animate {
    opacity: 0;
    animation: fadeInDown 0.5s var(--ease-out) 0.5s forwards;
}

/* Letter animation for hero title */
.letter-animate {
    display: inline-block;
    opacity: 0;
    transform: translateY(50px) rotateX(-90deg);
    transform-origin: center bottom;
}

.letter-animate.is-visible {
    animation: letterReveal 0.6s var(--ease-out) forwards;
}

/* ===================================
   HOVER MICRO-INTERACTIONS
   =================================== */

/* Lift effect */
.hover-lift {
    transition: transform var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-fast) var(--ease-out);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl);
}

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

.hover-glow:hover {
    box-shadow: 0 0 30px var(--color-accent);
}

/* Scale effect */
.hover-scale {
    transition: transform var(--duration-fast) var(--ease-out);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Tilt effect (requires JS for full effect) */
.hover-tilt {
    transition: transform var(--duration-fast) var(--ease-out);
    transform-style: preserve-3d;
}

/* Underline draw */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width var(--duration-normal) var(--ease-out),
        left var(--duration-normal) var(--ease-out);
}

.hover-underline:hover::after {
    width: 100%;
    left: 0;
}

/* Color shift */
.hover-color {
    transition: color var(--duration-fast),
        background-color var(--duration-fast);
}

/* Icon animation on hover */
.hover-icon-slide {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.hover-icon-slide .icon {
    transition: transform var(--duration-fast) var(--ease-out);
}

.hover-icon-slide:hover .icon {
    transform: translateX(5px);
}

.hover-icon-rotate .icon {
    transition: transform var(--duration-normal) var(--ease-out);
}

.hover-icon-rotate:hover .icon {
    transform: rotate(45deg);
}

/* ===================================
   SPECIAL EFFECTS
   =================================== */

/* Glitch text on hover */
.glitch-hover:hover {
    animation: glitch 0.5s ease-in-out;
}

/* Gradient border animation */
.gradient-border {
    position: relative;
    background: var(--color-surface);
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: var(--gradient-holographic);
    border-radius: inherit;
    z-index: -1;
    animation: holographicRotate 3s linear infinite;
}

/* Text glow */
.text-glow {
    text-shadow:
        0 0 10px currentColor,
        0 0 20px currentColor,
        0 0 40px currentColor;
}

/* Cursor trail particle (set via JS) */
.cursor-particle {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
    pointer-events: none;
    z-index: var(--z-max);
    animation: particleDrift 1s var(--ease-out) forwards;
}

/* Confetti piece */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -20px;
    z-index: var(--z-max);
    animation: confettiFall 3s linear forwards;
}

/* ===================================
   LOADING STATES
   =================================== */

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg,
            var(--color-border) 25%,
            var(--color-neutral-lighter) 50%,
            var(--color-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton--text {
    height: 1em;
    width: 100%;
    margin-bottom: 0.5em;
}

.skeleton--text:last-child {
    width: 70%;
}

.skeleton--circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.skeleton--image {
    width: 100%;
    aspect-ratio: 16 / 9;
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* ===================================
   COUNTER ANIMATION
   =================================== */

.counter {
    font-variant-numeric: tabular-nums;
}