/**
 * GMI Marketing - Antigravity Effects
 * Advanced animations and visual effects
 */

/* ========================================
   PWA 모드에서 애니메이션 비활성화
   네이티브 앱처럼 깔끔하게
   ======================================== */
@media (display-mode: standalone) {
    .ag-float,
    .ag-float-slow,
    .ag-float-fast,
    .gmi-float,
    .gmi-float-delay-1,
    .gmi-float-delay-2,
    .ag-orbit,
    .ag-pulse,
    .ag-glow,
    .gmi-glow,
    .gmi-pulse {
        animation: none !important;
        transform: none !important;
    }

    /* 호버 효과만 유지 */
    .ag-magnetic:hover {
        transform: scale(1.02) !important;
    }
}

/* 모바일에서도 애니메이션 축소 */
@media (max-width: 768px) {
    .ag-float,
    .ag-float-slow,
    .ag-float-fast,
    .gmi-float,
    .gmi-float-delay-1,
    .gmi-float-delay-2 {
        animation: none !important;
        transform: none !important;
    }

    .ag-pulse,
    .gmi-pulse {
        animation-duration: 3s !important;
    }
}

/* ========================================
   Antigravity Float Effects
   ======================================== */
.ag-float {
    animation: agFloat 6s ease-in-out infinite;
}

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

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

@keyframes agFloat {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(1deg);
    }
    50% {
        transform: translateY(-25px) rotate(0deg);
    }
    75% {
        transform: translateY(-10px) rotate(-1deg);
    }
}

/* Delayed float animations */
.ag-float-d1 { animation-delay: 0.5s; }
.ag-float-d2 { animation-delay: 1s; }
.ag-float-d3 { animation-delay: 1.5s; }
.ag-float-d4 { animation-delay: 2s; }

/* ========================================
   Magnetic Hover Effects
   ======================================== */
.ag-magnetic {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ag-magnetic:hover {
    transform: scale(1.05) translateY(-5px);
}

/* ========================================
   Orbiting Elements
   ======================================== */
.ag-orbit-container {
    position: relative;
}

.ag-orbit {
    position: absolute;
    animation: agOrbit 20s linear infinite;
}

.ag-orbit-reverse {
    animation-direction: reverse;
}

@keyframes agOrbit {
    from {
        transform: rotate(0deg) translateX(100px) rotate(0deg);
    }
    to {
        transform: rotate(360deg) translateX(100px) rotate(-360deg);
    }
}

/* ========================================
   Pulse & Glow Effects
   ======================================== */
.ag-pulse {
    animation: agPulse 2s ease-in-out infinite;
}

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

.ag-glow {
    animation: agGlow 2s ease-in-out infinite alternate;
}

@keyframes agGlow {
    from {
        box-shadow: 0 0 20px rgba(37, 99, 235, 0.3),
                    0 0 40px rgba(37, 99, 235, 0.1);
    }
    to {
        box-shadow: 0 0 30px rgba(37, 99, 235, 0.5),
                    0 0 60px rgba(37, 99, 235, 0.2);
    }
}

.ag-glow-purple {
    animation: agGlowPurple 2s ease-in-out infinite alternate;
}

@keyframes agGlowPurple {
    from {
        box-shadow: 0 0 20px rgba(124, 58, 237, 0.3),
                    0 0 40px rgba(124, 58, 237, 0.1);
    }
    to {
        box-shadow: 0 0 30px rgba(124, 58, 237, 0.5),
                    0 0 60px rgba(124, 58, 237, 0.2);
    }
}

/* ========================================
   Particle System
   ======================================== */
.ag-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}

.ag-particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    animation: agParticleFloat 15s infinite;
}

.ag-particle-sm {
    width: 4px;
    height: 4px;
}

.ag-particle-md {
    width: 8px;
    height: 8px;
}

.ag-particle-lg {
    width: 12px;
    height: 12px;
}

@keyframes agParticleFloat {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ========================================
   Morphing Shapes
   ======================================== */
.ag-morph {
    animation: agMorph 8s ease-in-out infinite;
}

@keyframes agMorph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    25% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
    50% {
        border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%;
    }
    75% {
        border-radius: 60% 40% 60% 30% / 70% 30% 50% 60%;
    }
}

/* ========================================
   3D Transforms
   ======================================== */
.ag-perspective {
    perspective: 1000px;
}

.ag-3d-rotate {
    transform-style: preserve-3d;
    animation: ag3dRotate 20s linear infinite;
}

@keyframes ag3dRotate {
    from {
        transform: rotateY(0deg);
    }
    to {
        transform: rotateY(360deg);
    }
}

.ag-tilt {
    transition: transform 0.5s ease;
}

.ag-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(5deg);
}

/* ========================================
   Wave Effect
   ======================================== */
.ag-wave {
    position: relative;
    overflow: hidden;
}

.ag-wave::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: agWave 3s linear infinite;
}

@keyframes agWave {
    from {
        transform: translateX(-50%) translateY(-50%) rotate(0deg);
    }
    to {
        transform: translateX(50%) translateY(50%) rotate(360deg);
    }
}

/* ========================================
   Text Effects
   ======================================== */
.ag-text-gradient {
    background: linear-gradient(135deg, #2563eb, #7c3aed, #06b6d4);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: agTextGradient 5s ease infinite;
}

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

.ag-text-shimmer {
    position: relative;
    display: inline-block;
}

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

@keyframes agTextShimmer {
    to {
        left: 100%;
    }
}

/* ========================================
   Loading Animations
   ======================================== */
.ag-loader {
    width: 48px;
    height: 48px;
    position: relative;
}

.ag-loader-orbit {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: agLoaderSpin 1s linear infinite;
}

.ag-loader-orbit:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border-top-color: var(--secondary-color);
    animation-duration: 0.8s;
    animation-direction: reverse;
}

.ag-loader-orbit:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-top-color: var(--accent-color);
    animation-duration: 0.6s;
}

@keyframes agLoaderSpin {
    to {
        transform: rotate(360deg);
    }
}

/* DNA Helix Loader */
.ag-dna-loader {
    display: flex;
    gap: 8px;
}

.ag-dna-strand {
    width: 8px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 4px;
    animation: agDnaWave 1s ease-in-out infinite;
}

.ag-dna-strand:nth-child(2) { animation-delay: 0.1s; }
.ag-dna-strand:nth-child(3) { animation-delay: 0.2s; }
.ag-dna-strand:nth-child(4) { animation-delay: 0.3s; }
.ag-dna-strand:nth-child(5) { animation-delay: 0.4s; }

@keyframes agDnaWave {
    0%, 100% {
        transform: scaleY(1);
    }
    50% {
        transform: scaleY(0.5);
    }
}

/* ========================================
   Card Effects
   ======================================== */
.ag-card-3d {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.ag-card-3d:hover {
    transform: rotateY(10deg) rotateX(5deg);
}

.ag-card-3d::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: translateZ(1px);
    pointer-events: none;
}

/* Glass Card */
.ag-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ag-glass-dark {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* iOS/모바일에서 무거운 효과 비활성화 */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari에서 backdrop-filter 비활성화 (성능 이슈) */
    .ag-glass,
    .ag-glass-dark {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: rgba(30, 41, 59, 0.95);
    }

    /* iOS에서 파티클 애니메이션 단순화 */
    .ag-particle,
    .gmi-particle {
        animation-duration: 30s !important;
    }
}

/* 모바일 기기에서 무거운 효과 줄이기 */
@media (max-width: 768px), (hover: none) {
    .ag-float,
    .gmi-float {
        animation: none;
    }

    .ag-particle,
    .gmi-particle {
        animation-duration: 25s !important;
    }

    .ag-morph {
        animation: none;
        border-radius: 50%;
    }

    .ag-3d-rotate {
        animation: none;
    }

    .ag-tilt:hover {
        transform: none;
    }
}

/* ========================================
   Entrance Animations
   ======================================== */
.ag-fade-in {
    animation: agFadeIn 0.6s ease forwards;
}

@keyframes agFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ag-slide-up {
    animation: agSlideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes agSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ag-scale-in {
    animation: agScaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes agScaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Staggered entrance */
.ag-stagger > * {
    opacity: 0;
    animation: agFadeIn 0.5s ease forwards;
}

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

/* ========================================
   Interactive Hover States
   ======================================== */
.ag-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ag-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.ag-expand {
    transition: transform 0.3s ease;
}

.ag-expand:hover {
    transform: scale(1.02);
}

/* ========================================
   Reduce Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
