/* Advanced Animations for CardAdda Website */

/* Keyframe Animations */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

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

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

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

@keyframes cardFloat {
    0%, 100% {
        transform: perspective(1000px) rotateY(-15deg) translateY(0px);
    }
    50% {
        transform: perspective(1000px) rotateY(-15deg) translateY(-10px);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) translateX(-50%);
    }
    40% {
        transform: translateY(-10px) translateX(-50%);
    }
    60% {
        transform: translateY(-5px) translateX(-50%);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(201, 170, 113, 0.4);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(201, 170, 113, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(201, 170, 113, 0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Enhanced light mode animations */
@keyframes lightModeGlow {
    0% {
        box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(212, 175, 55, 0.4), 0 0 40px rgba(212, 175, 55, 0.2);
    }
    100% {
        box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
    }
}

@keyframes lightModeFloat {
    0%, 100% {
        transform: translateY(0px) translateX(0px);
    }
    25% {
        transform: translateY(-8px) translateX(4px);
    }
    50% {
        transform: translateY(-12px) translateX(0px);
    }
    75% {
        transform: translateY(-8px) translateX(-4px);
    }
}

@keyframes professionalPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(212, 175, 55, 0.1);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
    }
}

@keyframes elegantSlide {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes glow {
    from {
        box-shadow: 0 0 20px rgba(201, 170, 113, 0.4);
    }
    to {
        box-shadow: 0 0 30px rgba(201, 170, 113, 0.8), 0 0 40px rgba(201, 170, 113, 0.6);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-200deg);
    }
    to {
        opacity: 1;
        transform: rotate(0deg);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--accent-color);
    }
}

@keyframes flipIn {
    from {
        transform: perspective(400px) rotateY(90deg);
        opacity: 0;
    }
    40% {
        transform: perspective(400px) rotateY(-20deg);
    }
    60% {
        transform: perspective(400px) rotateY(10deg);
        opacity: 1;
    }
    80% {
        transform: perspective(400px) rotateY(-5deg);
    }
    to {
        transform: perspective(400px) rotateY(0deg);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes cardHover {
    0% {
        transform: perspective(1000px) rotateX(0deg) rotateY(0deg);
    }
    100% {
        transform: perspective(1000px) rotateX(-10deg) rotateY(10deg);
    }
}

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

@keyframes particleFloat {
    0%, 100% {
        transform: translateY(0px) translateX(0px) rotate(0deg);
        opacity: 1;
    }
    33% {
        transform: translateY(-30px) translateX(30px) rotate(120deg);
        opacity: 0.8;
    }
    66% {
        transform: translateY(-10px) translateX(-20px) rotate(240deg);
        opacity: 0.6;
    }
}

/* Enhanced Hover Effects */
.credit-card {
    position: relative;
    overflow: hidden;
}

.credit-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.credit-card:hover::before {
    animation: shimmer 1.5s ease-in-out;
    opacity: 1;
}

.credit-card:hover {
    animation: glow 1s ease-in-out alternate infinite;
}

/* Enhanced light mode specific animations */
[data-theme="light"] .credit-card:hover {
    animation: lightModeGlow 2s ease-in-out infinite;
}

[data-theme="light"] .floating-card {
    animation: lightModeFloat 8s ease-in-out infinite;
}

[data-theme="light"] .btn-primary:hover {
    animation: professionalPulse 1.5s ease-in-out;
}

[data-theme="light"] .card-item {
    animation: elegantSlide 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Button Hover Effects */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::after {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    animation: pulse 1s infinite;
}

/* Navigation Animation */
.navbar {
    transform: translateY(-100%);
    animation: slideInDown 0.8s ease-out forwards;
}

.nav-link {
    position: relative;
    overflow: hidden;
}

.nav-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(201, 170, 113, 0.2), transparent);
    transition: left 0.5s;
}

.nav-link:hover::before {
    left: 100%;
}

/* Card Grid Animations */
.card-item {
    animation: slideInUp 0.6s ease-out forwards;
}

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

.card-wrapper:hover .credit-card {
    animation: cardHover 0.6s ease-out forwards;
}

/* Stats Counter Animation */
.stat-number {
    animation: numberCount 1s ease-out;
}

/* Form Animations */
.form-group {
    position: relative;
}

.form-group input,
.form-group select {
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(201, 170, 113, 0.2);
}

/* Category Button Animations */
.category-btn {
    position: relative;
    overflow: hidden;
}

.category-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(201, 170, 113, 0.3), transparent);
    transition: left 0.5s;
}

.category-btn:hover::before {
    left: 100%;
}

.category-btn.active {
    animation: pulse 0.5s ease-out;
}

/* Benefit Cards Animation */
.benefit-card {
    animation: flipIn 0.8s ease-out;
}

.benefit-card:nth-child(1) { animation-delay: 0.1s; }
.benefit-card:nth-child(2) { animation-delay: 0.2s; }
.benefit-card:nth-child(3) { animation-delay: 0.3s; }
.benefit-card:nth-child(4) { animation-delay: 0.4s; }

.benefit-icon {
    transition: all 0.3s ease;
}

.benefit-card:hover .benefit-icon {
    animation: rotateIn 0.6s ease-out;
    transform: scale(1.1);
}

/* Table Animation */
.table-row {
    animation: slideInLeft 0.5s ease-out;
}

.table-row:nth-child(1) { animation-delay: 0.1s; }
.table-row:nth-child(2) { animation-delay: 0.2s; }
.table-row:nth-child(3) { animation-delay: 0.3s; }
.table-row:nth-child(4) { animation-delay: 0.4s; }
.table-row:nth-child(5) { animation-delay: 0.5s; }

/* Footer Animation */
.footer-section {
    animation: slideInUp 0.6s ease-out;
}

.footer-section:nth-child(1) { animation-delay: 0.1s; }
.footer-section:nth-child(2) { animation-delay: 0.2s; }
.footer-section:nth-child(3) { animation-delay: 0.3s; }
.footer-section:nth-child(4) { animation-delay: 0.4s; }

/* Social Links Animation */
.social-links a {
    transition: all 0.3s ease;
}

.social-links a:hover {
    animation: bounce 0.6s ease-out;
}

/* Scroll Indicator Animation */
.scroll-indicator {
    animation: bounce 2s infinite;
}

/* Particle Effects */
.hero-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(201, 170, 113, 0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(201, 170, 113, 0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(201, 170, 113, 0.4), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(201, 170, 113, 0.3), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(201, 170, 113, 0.2), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: particleFloat 10s linear infinite;
    opacity: 0.5;
}

/* Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(201, 170, 113, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Text Reveal Animation */
.hero-title .title-line {
    opacity: 0;
    transform: translateY(30px);
    animation: slideInUp 0.8s ease-out forwards;
}

.hero-title .title-line:first-child {
    animation-delay: 0.2s;
}

.hero-title .title-line:last-child {
    animation-delay: 0.4s;
}

/* Advanced Card Flip Effect */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.card-flip:hover .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
}

.card-flip-back {
    transform: rotateY(180deg);
}

/* Smooth Scroll Reveal */
@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(50px);
        transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

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

    .reveal-delay-1 { transition-delay: 0.1s; }
    .reveal-delay-2 { transition-delay: 0.2s; }
    .reveal-delay-3 { transition-delay: 0.3s; }
    .reveal-delay-4 { transition-delay: 0.4s; }
}

/* Stagger Animation */
.stagger-animation > * {
    opacity: 0;
    transform: translateY(20px);
    animation: slideInUp 0.6s ease-out forwards;
}

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

/* Magnetic Effect */
.magnetic {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.magnetic:hover {
    transform: translate3d(0, -3px, 0);
}

/* Morphing Shapes */
.morphing-shape {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    animation: morphing 8s ease-in-out infinite;
}

@keyframes morphing {
    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% / 60% 40% 60% 30%;
    }
    75% {
        border-radius: 60% 30% 60% 40% / 30% 70% 40% 60%;
    }
}

/* Glitch Effect */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-dark);
    overflow: hidden;
    clip: rect(0, 900px, 0, 0);
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 red;
    animation: glitch-anim-1 2s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 blue;
    animation: glitch-anim-2 1s infinite linear alternate-reverse;
}

@keyframes glitch-anim-1 {
    0% { clip: rect(42px, 9999px, 44px, 0); }
    5% { clip: rect(12px, 9999px, 59px, 0); }
    10% { clip: rect(48px, 9999px, 29px, 0); }
    15% { clip: rect(42px, 9999px, 73px, 0); }
    20% { clip: rect(63px, 9999px, 27px, 0); }
    25% { clip: rect(34px, 9999px, 55px, 0); }
    30% { clip: rect(86px, 9999px, 73px, 0); }
    35% { clip: rect(20px, 9999px, 20px, 0); }
    40% { clip: rect(26px, 9999px, 60px, 0); }
    45% { clip: rect(25px, 9999px, 66px, 0); }
    50% { clip: rect(57px, 9999px, 98px, 0); }
    55% { clip: rect(5px, 9999px, 46px, 0); }
    60% { clip: rect(82px, 9999px, 31px, 0); }
    65% { clip: rect(54px, 9999px, 27px, 0); }
    70% { clip: rect(28px, 9999px, 99px, 0); }
    75% { clip: rect(45px, 9999px, 69px, 0); }
    80% { clip: rect(23px, 9999px, 85px, 0); }
    85% { clip: rect(54px, 9999px, 84px, 0); }
    90% { clip: rect(45px, 9999px, 47px, 0); }
    95% { clip: rect(37px, 9999px, 20px, 0); }
    100% { clip: rect(4px, 9999px, 91px, 0); }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(65px, 9999px, 100px, 0); }
    5% { clip: rect(52px, 9999px, 74px, 0); }
    10% { clip: rect(79px, 9999px, 85px, 0); }
    15% { clip: rect(75px, 9999px, 5px, 0); }
    20% { clip: rect(67px, 9999px, 61px, 0); }
    25% { clip: rect(14px, 9999px, 79px, 0); }
    30% { clip: rect(1px, 9999px, 66px, 0); }
    35% { clip: rect(86px, 9999px, 30px, 0); }
    40% { clip: rect(23px, 9999px, 98px, 0); }
    45% { clip: rect(85px, 9999px, 72px, 0); }
    50% { clip: rect(71px, 9999px, 75px, 0); }
    55% { clip: rect(2px, 9999px, 48px, 0); }
    60% { clip: rect(30px, 9999px, 16px, 0); }
    65% { clip: rect(59px, 9999px, 50px, 0); }
    70% { clip: rect(41px, 9999px, 33px, 0); }
    75% { clip: rect(34px, 9999px, 52px, 0); }
    80% { clip: rect(48px, 9999px, 56px, 0); }
    85% { clip: rect(2px, 9999px, 58px, 0); }
    90% { clip: rect(87px, 9999px, 17px, 0); }
    95% { clip: rect(35px, 9999px, 95px, 0); }
    100% { clip: rect(90px, 9999px, 39px, 0); }
}

/* Performance Optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* GPU Acceleration */
.credit-card,
.btn,
.card-wrapper,
.benefit-card {
    transform: translateZ(0);
    will-change: transform;
}

/* Theme Toggle Animations */
@keyframes themeToggleSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

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

@keyframes themeIconSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }
}

.theme-toggle:active {
    animation: themeToggleSpin 0.3s ease-in-out;
}

.theme-toggle:hover {
    box-shadow: 0 4px 15px rgba(201, 170, 113, 0.3);
}

/* Smooth theme transitions */
.theme-transition {
    transition: all 0.3s ease !important;
}

.theme-transition * {
    transition: 
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease !important;
}

/* Light theme animation adjustments */
[data-theme="light"] .floating-card {
    animation-duration: 8s;
}

[data-theme="light"] .particle {
    opacity: 0.6;
}

/* Theme-specific glow effects */
[data-theme="dark"] .theme-toggle:hover {
    box-shadow: 
        0 0 20px rgba(201, 170, 113, 0.3),
        0 4px 15px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .theme-toggle:hover {
    box-shadow: 
        0 0 20px rgba(184, 134, 11, 0.2),
        0 4px 15px rgba(0, 0, 0, 0.1);
}