/**
 * Animations - All animation classes and keyframes
 */

/* ============================
   PAGE ENTRY ANIMATION
   Applied to <main class="main page-enter"> on every page
============================= */
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}
.page-enter {
    animation: pageEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 0.05s;
}

/* ==================== ANIMATION UTILITIES ==================== */
.animate {
    animation-duration: var(--duration-normal);
    animation-fill-mode: both;
    animation-timing-function: var(--ease-out);
}

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

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

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

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

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

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

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

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

/* ==================== SCROLL REVEAL ==================== */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--duration-slow) var(--ease-out),
        transform var(--duration-slow) var(--ease-out);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Reveal variants */
.reveal-left {
    opacity: 0;
    transform: translateX(-30px);
}

.reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(30px);
}

.reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
}

.reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* Stagger children */
.stagger-children>* {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--duration-normal) var(--ease-out),
        transform var(--duration-normal) var(--ease-out);
}

.stagger-children.visible>*:nth-child(1) {
    transition-delay: 0ms;
}

.stagger-children.visible>*:nth-child(2) {
    transition-delay: 50ms;
}

.stagger-children.visible>*:nth-child(3) {
    transition-delay: 100ms;
}

.stagger-children.visible>*:nth-child(4) {
    transition-delay: 150ms;
}

.stagger-children.visible>*:nth-child(5) {
    transition-delay: 200ms;
}

.stagger-children.visible>*:nth-child(6) {
    transition-delay: 250ms;
}

.stagger-children.visible>*:nth-child(7) {
    transition-delay: 300ms;
}

.stagger-children.visible>*:nth-child(8) {
    transition-delay: 350ms;
}

.stagger-children.visible>* {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== FADE ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

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

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

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

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

.fade-in {
    animation-name: fadeIn;
}

.fade-out {
    animation-name: fadeOut;
}

.fade-in-up {
    animation-name: fadeInUp;
}

.fade-in-down {
    animation-name: fadeInDown;
}

/* ==================== SLIDE ANIMATIONS ==================== */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

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

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

.slide-in-left {
    animation-name: slideInLeft;
}

.slide-in-right {
    animation-name: slideInRight;
}

.slide-out-left {
    animation-name: slideOutLeft;
}

/* ==================== SCALE ANIMATIONS ==================== */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

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

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }

    50% {
        transform: translateY(-10px);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

.scale-in {
    animation-name: scaleIn;
}

.scale-out {
    animation-name: scaleOut;
}

.pulse {
    animation: pulse 2s infinite;
}

.bounce {
    animation: bounce 1s infinite;
}

/* ==================== ROTATING ANIMATIONS ==================== */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

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

.spin {
    animation: spin 1s linear infinite;
}

/* ==================== LOADING SPINNER ==================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

/* ==================== COUNTER ANIMATION ==================== */
.counter {
    display: inline-block;
}

/* ==================== GRADIENT ANIMATIONS ==================== */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

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

.gradient-animate {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

/* ==================== TEXT REVEAL ==================== */
@keyframes typewriter {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 2s steps(40) forwards;
}

/* ==================== FLOAT ANIMATION ==================== */
@keyframes float {

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

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

.float {
    animation: float 3s ease-in-out infinite;
}

/* ==================== HERO SPECIFIC ==================== */
@keyframes heroGlow {

    0%,
    100% {
        box-shadow: 0 0 30px rgba(var(--color-primary-rgb), 0.3);
    }

    50% {
        box-shadow: 0 0 60px rgba(var(--color-primary-rgb), 0.5);
    }
}

.hero-glow {
    animation: heroGlow 3s ease-in-out infinite;
}

/* ==================== AURORA / BLOB BACKGROUND ==================== */
@keyframes auroraBlob1 {
    0% {
        transform: translate(0px, 0px) scale(1) rotate(0deg);
    }

    33% {
        transform: translate(60px, -40px) scale(1.15) rotate(60deg);
    }

    66% {
        transform: translate(-40px, 30px) scale(0.92) rotate(120deg);
    }

    100% {
        transform: translate(0px, 0px) scale(1) rotate(0deg);
    }
}

@keyframes auroraBlob2 {
    0% {
        transform: translate(0px, 0px) scale(1) rotate(0deg);
    }

    33% {
        transform: translate(-70px, 50px) scale(1.1) rotate(-80deg);
    }

    66% {
        transform: translate(50px, -30px) scale(0.95) rotate(-160deg);
    }

    100% {
        transform: translate(0px, 0px) scale(1) rotate(0deg);
    }
}

@keyframes auroraBlob3 {
    0% {
        transform: translate(0px, 0px) scale(1);
        opacity: 0.4;
    }

    50% {
        transform: translate(30px, -60px) scale(1.2);
        opacity: 0.6;
    }

    100% {
        transform: translate(0px, 0px) scale(1);
        opacity: 0.4;
    }
}

@keyframes auroraBlob4 {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0.3;
    }

    40% {
        transform: translate(-50px, 40px) scale(1.18);
        opacity: 0.55;
    }

    80% {
        transform: translate(20px, -20px) scale(0.88);
        opacity: 0.35;
    }

    100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.3;
    }
}

/* Aurora container - fixed to viewport for global consistency */
.aurora-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}

.aurora-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    will-change: transform;
}

.aurora-blob--1 {
    width: 700px;
    height: 700px;
    top: -20%;
    left: -10%;
    background: radial-gradient(ellipse, rgba(99, 102, 241, 0.35) 0%, rgba(139, 92, 246, 0.15) 60%, transparent 80%);
    animation: auroraBlob1 18s ease-in-out infinite;
}

.aurora-blob--2 {
    width: 600px;
    height: 600px;
    bottom: -15%;
    right: -10%;
    background: radial-gradient(ellipse, rgba(6, 182, 212, 0.3) 0%, rgba(59, 130, 246, 0.12) 60%, transparent 80%);
    animation: auroraBlob2 22s ease-in-out infinite;
    animation-delay: -8s;
}

.aurora-blob--3 {
    width: 400px;
    height: 400px;
    top: 30%;
    right: 20%;
    background: radial-gradient(ellipse, rgba(168, 85, 247, 0.25) 0%, rgba(236, 72, 153, 0.1) 60%, transparent 80%);
    animation: auroraBlob3 14s ease-in-out infinite;
    animation-delay: -5s;
}

.aurora-blob--4 {
    width: 500px;
    height: 500px;
    bottom: 10%;
    left: 15%;
    background: radial-gradient(ellipse, rgba(34, 211, 238, 0.2) 0%, rgba(99, 102, 241, 0.08) 60%, transparent 80%);
    animation: auroraBlob4 20s ease-in-out infinite;
    animation-delay: -12s;
}

/* Light mode aurora — softer */
[data-theme="light"] .aurora-blob--1 {
    background: radial-gradient(ellipse, rgba(99, 102, 241, 0.18) 0%, rgba(139, 92, 246, 0.07) 60%, transparent 80%);
}

[data-theme="light"] .aurora-blob--2 {
    background: radial-gradient(ellipse, rgba(6, 182, 212, 0.15) 0%, rgba(59, 130, 246, 0.06) 60%, transparent 80%);
}

[data-theme="light"] .aurora-blob--3 {
    background: radial-gradient(ellipse, rgba(168, 85, 247, 0.12) 0%, transparent 70%);
}

[data-theme="light"] .aurora-blob--4 {
    background: radial-gradient(ellipse, rgba(34, 211, 238, 0.1) 0%, transparent 70%);
}

/* ==================== FLOATING PARTICLES ==================== */
@keyframes particleFloat {
    0% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(-120px) scale(0.6);
        opacity: 0;
    }
}

.particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat linear infinite;
}

/* ==================== TEXT SHIMMER ==================== */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }

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

.text-shimmer {
    background: linear-gradient(90deg,
            var(--color-primary) 0%,
            #a855f7 25%,
            #06b6d4 50%,
            var(--color-primary) 75%,
            #a855f7 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s linear infinite;
}

/* ==================== MAGNETIC HOVER ==================== */
.magnetic {
    transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ==================== CARD TILT ==================== */
@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: perspective(600px) rotateY(-8deg) translateY(20px);
    }

    to {
        opacity: 1;
        transform: perspective(600px) rotateY(0deg) translateY(0);
    }
}

.card-entrance {
    animation: cardEntrance 0.6s var(--ease-out) forwards;
}

/* ==================== GLOW PULSE ==================== */
@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.2), 0 0 40px rgba(var(--color-primary-rgb), 0.1);
    }

    50% {
        box-shadow: 0 0 40px rgba(var(--color-primary-rgb), 0.4), 0 0 80px rgba(var(--color-primary-rgb), 0.2);
    }
}

.glow-pulse {
    animation: glowPulse 3s ease-in-out infinite;
}

/* ==================== TYPING CURSOR ==================== */
@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.typing-cursor::after {
    content: '|';
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    color: var(--color-primary);
}

/* ==================== SECTION REVEAL WITH CLIP ==================== */
@keyframes clipReveal {
    from {
        clip-path: inset(0 100% 0 0);
    }

    to {
        clip-path: inset(0 0% 0 0);
    }
}

.clip-reveal.visible {
    animation: clipReveal 0.8s var(--ease-out) forwards;
}

/* ==================== STAR / SPARKLE ==================== */
@keyframes sparkle {

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

    50% {
        transform: scale(1) rotate(180deg);
        opacity: 1;
    }
}

.sparkle-icon {
    display: inline-block;
    animation: sparkle 2s ease-in-out infinite;
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal,
    .reveal-left,
    .reveal-right,
    .reveal-scale {
        opacity: 1;
        transform: none;
    }

    .stagger-children>* {
        opacity: 1;
        transform: none;
    }

    .aurora-blob,
    .text-shimmer,
    .particle {
        animation: none !important;
    }
}