/**
 * i9DB Landing Page - Custom Styles
 * 
 * Custom animations and styling to complement Tailwind CSS.
 * Requirements: 8.3 - Visual feedback within 100ms for interactions
 */

/* ==========================================================================
   Base Styles
   ========================================================================== */

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
*:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   Animations - Entrance Effects
   ========================================================================== */

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Fade in up animation for scroll reveal */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Staggered animation delays for grid items */
.animate-stagger-1 { animation-delay: 0.1s; }
.animate-stagger-2 { animation-delay: 0.2s; }
.animate-stagger-3 { animation-delay: 0.3s; }
.animate-stagger-4 { animation-delay: 0.4s; }
.animate-stagger-5 { animation-delay: 0.5s; }
.animate-stagger-6 { animation-delay: 0.6s; }

/* Scale in animation */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn 0.3s ease-out;
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

/* ==========================================================================
   Animations - Continuous Effects
   ========================================================================== */

/* Slow bounce for floating elements */
@keyframes bounceSlow {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-bounce-slow {
    animation: bounceSlow 3s ease-in-out infinite;
}

/* Pulse glow effect */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
}

.animate-pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

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

.animate-shimmer {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ==========================================================================
   Modal Transitions
   ========================================================================== */

/* Modal backdrop */
.modal-backdrop {
    transition: opacity 0.2s ease-out;
}

.modal-backdrop-enter {
    opacity: 0;
}

.modal-backdrop-enter-active {
    opacity: 1;
}

.modal-backdrop-exit {
    opacity: 1;
}

.modal-backdrop-exit-active {
    opacity: 0;
}

/* Modal content */
.modal-content {
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

.modal-content-enter {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
}

.modal-content-enter-active {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.modal-content-exit {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.modal-content-exit-active {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
}

/* ==========================================================================
   Interactive Elements
   ========================================================================== */

/* Payment method button states */
.payment-method-btn {
    transition: all 0.15s ease-out;
}

.payment-method-btn:hover {
    transform: translateY(-2px);
}

.payment-method-btn.active {
    border-color: #3b82f6;
    background-color: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.payment-method-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* CTA button hover effect */
.cta-button {
    transition: all 0.15s ease-out;
    position: relative;
    overflow: hidden;
}

.cta-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease-out, height 0.4s ease-out;
}

.cta-button:hover::after {
    width: 300px;
    height: 300px;
}

.cta-button:active {
    transform: scale(0.98);
}

/* Feature card hover effect */
.feature-card {
    transition: all 0.2s ease-out;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.15);
}

/* Feature category card hover effect (detailed features section) */
.feature-category-card {
    transition: all 0.3s ease-out;
}

.feature-category-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.15);
}

.feature-category-card:hover .aspect-video img {
    transform: scale(1.05);
}

/* Testimonial card hover */
.testimonial-card {
    transition: all 0.2s ease-out;
}

.testimonial-card:hover {
    transform: translateY(-2px);
}

/* FAQ accordion animation */
.faq-content {
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    overflow: hidden;
}

.faq-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.faq-content.expanded {
    max-height: 500px;
    opacity: 1;
}

.faq-icon {
    transition: transform 0.3s ease-out;
}

.faq-icon.rotated {
    transform: rotate(180deg);
}

/* ==========================================================================
   Loading States
   ========================================================================== */

/* Spinner */
.spinner {
    border: 3px solid #f3f4f6;
    border-top-color: #3b82f6;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

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

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 9999;
    animation: toastSlideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-success {
    background-color: #10b981;
}

.toast-error {
    background-color: #ef4444;
}

.toast-info {
    background-color: #3b82f6;
}

.toast-warning {
    background-color: #f59e0b;
}

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

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

.toast-exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}

/* ==========================================================================
   Scroll Reveal (for JavaScript integration)
   ========================================================================== */

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    will-change: opacity, transform;
}

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

/* Ensure elements are visible if JS fails or is disabled */
@media (scripting: none) {
    .reveal {
        opacity: 1;
        transform: none;
    }
}

/* ==========================================================================
   Lazy Loading Image Styles - Enhanced
   ========================================================================== */

/* Progressive image loading with WebP support */
.lazy-image {
    opacity: 0;
    transition: opacity 0.4s ease-out, filter 0.4s ease-out, transform 0.3s ease-out;
    will-change: opacity, filter;
}

.lazy-image.loaded {
    opacity: 1;
}

.lazy-image.error {
    opacity: 0;
    pointer-events: none;
}

/* WebP support detection */
.webp .webp-source {
    display: block;
}

.no-webp .webp-source {
    display: none;
}

/* Enhanced image container with loading states */
.image-container {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.image-container.loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: shimmerSweep 2s infinite;
    z-index: 1;
}

.image-container.loaded::before {
    display: none;
}

.image-container.error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

/* Loading placeholder with better animation */
.loading-placeholder {
    opacity: 1;
    transition: opacity 0.3s ease-out;
    z-index: 2;
}

.loading-placeholder.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Enhanced fallback styling */
.image-fallback {
    opacity: 0;
    transition: opacity 0.3s ease-out;
    z-index: 3;
}

.image-fallback.visible {
    opacity: 1;
}

/* Blur-up effect for progressive loading */
.lazy-blur {
    filter: blur(8px) brightness(1.1);
    transition: filter 0.4s ease-out, opacity 0.4s ease-out;
}

.lazy-blur.loaded {
    filter: blur(0) brightness(1);
}

/* Optimized shimmer animation */
@keyframes shimmerSweep {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Image optimization indicators */
.image-optimization-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    z-index: 4;
}

/* Responsive image optimizations */
@media (max-width: 640px) {
    .lazy-image {
        transition-duration: 0.2s; /* Faster transitions on mobile */
    }
    
    .image-container::before {
        animation-duration: 1.5s; /* Faster shimmer on mobile */
    }
}

/* Print optimizations */
@media print {
    .loading-placeholder,
    .image-fallback,
    .image-optimization-badge {
        display: none !important;
    }
    
    .lazy-image {
        opacity: 1 !important;
        filter: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .image-fallback {
        border: 2px solid currentColor;
    }
    
    .loading-placeholder {
        background: #000;
        color: #fff;
    }
}

/* Reduced motion support for images */
@media (prefers-reduced-motion: reduce) {
    .lazy-image,
    .loading-placeholder,
    .image-fallback {
        transition: none !important;
    }
    
    .image-container::before {
        animation: none !important;
    }
}

/* ==========================================================================
   Form Styles
   ========================================================================== */

/* Input focus animation */
.form-input {
    transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.form-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Input error state */
.form-input.error {
    border-color: #ef4444;
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Input success state */
.form-input.success {
    border-color: #10b981;
}

/* Error message animation */
.error-message {
    animation: fadeIn 0.2s ease-out;
}

/* ==========================================================================
   Copy Button Feedback
   ========================================================================== */

.copy-btn {
    transition: all 0.15s ease-out;
}

.copy-btn.copied {
    background-color: #10b981;
    color: white;
}

.copy-btn.copied::before {
    content: '✓ ';
}

/* ==========================================================================
   Pricing Card Effects
   ========================================================================== */

.pricing-card {
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

.pricing-card:hover {
    transform: scale(1.02);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Gradient border effect */
.gradient-border {
    position: relative;
    background: linear-gradient(white, white) padding-box,
                linear-gradient(135deg, #3b82f6, #10b981) border-box;
    border: 2px solid transparent;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 640px) {
    .payment-method-btn {
        padding: 12px 8px;
    }
    
    .payment-method-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .toast {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }
    
    /* Reduce animation intensity on mobile */
    .feature-card:hover,
    .testimonial-card:hover {
        transform: none;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .cta-button,
    .payment-method-btn,
    #payment-modal,
    #success-modal {
        display: none !important;
    }
    
    * {
        animation: none !important;
        transition: none !important;
    }
}
