/* ========================================
   San Thit Hein Portfolio - Animations
   ======================================== */

/* ========================================
   Scroll Reveal Animations
   ======================================== */
.reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Stagger delays */
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }
.delay-5 { transition-delay: 0.5s; }

/* ========================================
   Hero Animations
   ======================================== */
.animate-up {
    opacity: 0;
    transform: translateY(30px);
    animation: animateUp 1s ease forwards;
}

.animate-up.delay-1 { animation-delay: 0.2s; }
.animate-up.delay-2 { animation-delay: 0.4s; }
.animate-up.delay-3 { animation-delay: 0.6s; }

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

/* ========================================
   Text Animations
   ======================================== */
.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    animation: textReveal 0.8s ease forwards;
}

@keyframes textReveal {
    to {
        transform: translateY(0);
    }
}

/* Character by character animation */
.char-animate {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: charAnimate 0.5s ease forwards;
}

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

/* ========================================
   Image Reveal Animations
   ======================================== */
.image-reveal {
    position: relative;
    overflow: hidden;
}

.image-reveal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-accent);
    z-index: 1;
    transform: scaleX(1);
    transform-origin: right;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-reveal.revealed::before {
    transform: scaleX(0);
}

.image-reveal img {
    transform: scale(1.3);
    transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.image-reveal.revealed img {
    transform: scale(1);
}

/* ========================================
   Floating Animations
   ======================================== */
.float {
    animation: float 6s ease-in-out infinite;
}

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

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

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

/* ========================================
   Pulse Animation
   ======================================== */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse-scale {
    animation: pulseScale 2s ease-in-out infinite;
}

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

/* ========================================
   Glow Animation
   ======================================== */
.glow {
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--color-accent),
                    0 0 10px var(--color-accent),
                    0 0 15px var(--color-accent);
    }
    50% {
        box-shadow: 0 0 10px var(--color-accent),
                    0 0 20px var(--color-accent),
                    0 0 30px var(--color-accent);
    }
}

/* ========================================
   Line Drawing Animation
   ======================================== */
.line-draw {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: lineDraw 2s ease forwards;
}

@keyframes lineDraw {
    to {
        stroke-dashoffset: 0;
    }
}

/* ========================================
   Parallax Effect Classes
   ======================================== */
.parallax {
    will-change: transform;
}

.parallax-slow {
    --parallax-speed: 0.3;
}

.parallax-medium {
    --parallax-speed: 0.5;
}

.parallax-fast {
    --parallax-speed: 0.7;
}

/* ========================================
   Magnetic Effect
   ======================================== */
.magnetic {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Tilt Effect
   ======================================== */
.tilt {
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

.tilt-inner {
    transform: translateZ(30px);
}

/* ========================================
   Ripple Effect
   ======================================== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ========================================
   Shimmer Effect
   ======================================== */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    100% {
        left: 100%;
    }
}

/* ========================================
   Counter Animation
   ======================================== */
.count-up {
    display: inline-block;
}

/* ========================================
   Stagger Grid Animation
   ======================================== */
.stagger-grid > * {
    opacity: 0;
    transform: translateY(30px);
}

.stagger-grid.animate > * {
    animation: staggerFadeUp 0.6s ease forwards;
}

.stagger-grid.animate > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-grid.animate > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-grid.animate > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-grid.animate > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-grid.animate > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-grid.animate > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-grid.animate > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-grid.animate > *:nth-child(8) { animation-delay: 0.8s; }

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

/* ========================================
   Page Transition
   ======================================== */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-accent);
    z-index: 99999;
    transform: scaleY(0);
    transform-origin: bottom;
}

.page-transition.active {
    animation: pageTransition 1s ease;
}

@keyframes pageTransition {
    0% {
        transform: scaleY(0);
        transform-origin: bottom;
    }
    50% {
        transform: scaleY(1);
        transform-origin: bottom;
    }
    50.1% {
        transform-origin: top;
    }
    100% {
        transform: scaleY(0);
        transform-origin: top;
    }
}

/* ========================================
   Loading Skeleton
   ======================================== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-secondary) 25%,
        var(--color-bg-tertiary) 50%,
        var(--color-bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s infinite;
}

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

/* ========================================
   Material Design Ripple Effect
   ======================================== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: var(--color-ripple);
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    top: 50%;
    left: 50%;
    opacity: 0;
    transform: scale(0);
}

.ripple:active::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ========================================
   Theme Transition
   ======================================== */
.theme-transition {
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

/* ========================================
   Floating Animation (for cards on hover)
   ======================================== */
.float-hover {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.float-hover:hover {
    transform: translateY(-8px);
    box-shadow: var(--elevation-4);
}

/* ========================================
   Gradient Animation
   ======================================== */
.gradient-animate {
    background: linear-gradient(
        45deg,
        var(--color-accent),
        var(--color-accent-light),
        var(--color-accent),
        var(--color-accent-dark)
    );
    background-size: 400% 400%;
    animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* ========================================
   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;
    }
}
