/* ============================================================================ */
/* ========================== MOBILE TIMELINE ANIMATIONS =================== */
/* ============================================================================ */

/* Timeline Animation Classes */
.animate-timeline-item {
    animation: timelineItemFadeIn 0.8s ease-out forwards;
    opacity: 0;
    transform: translateY(30px);
}

.animate-timeline-node {
    animation: timelineNodePop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    transform: scale(0);
}

.animate-timeline-card {
    animation: timelineCardSlide 0.8s ease-out forwards;
    opacity: 0;
    transform: translateX(-30px);
}

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

@keyframes timelineNodePop {
    to {
        transform: scale(1);
    }
}

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

/* Enhanced Timeline Line Animation */
.about-timeline-line,
.timeline-line {
    position: relative;
    overflow: hidden;
}

.about-timeline-line::after,
.timeline-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--timeline-progress, 0%);
    background: linear-gradient(180deg,
        var(--ai-primary) 0%,
        var(--ai-secondary) 50%,
        var(--ai-accent) 100%);
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    transition: height 0.3s ease-out;
}

/* Touch Feedback */
.touch-active {
    transform: scale(0.95) !important;
    opacity: 0.8 !important;
    transition: all 0.1s ease !important;
}

/* Animation States */
.animate-in {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ============================================================================ */
/* ========================== MOBILE BUTTON FIXES =========================== */
/* ============================================================================ */

/* Fix hero section buttons on mobile */
@media (max-width: 768px) {
    /* Hero section button container */
    .hero-3d .flex.flex-col.sm\:flex-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
        width: 100% !important;
    }
    
    /* Hero section buttons */
    .hero-3d .ai-button,
    .hero-3d .border-2 {
        width: 100% !important;
        text-align: center !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 48px !important;
        padding: 0.75rem 1.5rem !important;
        font-size: 0.875rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Fix all flex containers with buttons */
    .flex.flex-col.sm\:flex-row,
    .flex.flex-row.sm\:flex-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }
    
    .flex.flex-col.sm\:flex-row > *,
    .flex.flex-row.sm\:flex-row > * {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }
    
    /* Improve tap targets */
    .social-link,
    .connect-btn {
        min-height: 48px;
        min-width: 48px;
        touch-action: manipulation;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    /* Fix stats dashboard on mobile */
    .grid.grid-cols-2.sm\:grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.75rem !important;
    }
    
    /* Fix project filters on mobile */
    .project-filter,
    .blog-filter {
        padding: 0.5rem 1rem !important;
        font-size: 0.75rem !important;
        margin-bottom: 0.5rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Fix contact form buttons */
    .contact-input,
    .contact-submit-btn {
        padding: 0.75rem !important;
        font-size: 0.875rem !important;
        min-height: 48px;
    }
    
    /* Fix navigation mobile optimization */
    .nav-container {
        padding: 0 0.75rem;
    }
    
    .logo-text {
        font-size: 1rem !important;
    }
    
    .logo-name {
        font-size: 0.875rem !important;
    }
}

/* ============================================================================ */
/* ========================== MOBILE TIMELINE FIXES ========================= */
/* ============================================================================ */

@media (max-width: 768px) {
    /* About section mobile timeline */
    .about-timeline-line {
        left: 1rem !important;
        width: 2px !important;
    }
    
    .about-timeline-item {
        padding-left: 2.5rem !important;
        margin-bottom: 2rem !important;
    }
    
    .about-timeline-item .flex {
        justify-content: flex-start !important;
        margin-left: -1rem;
    }
    
    .about-timeline-node {
        width: 30px !important;
        height: 30px !important;
        position: relative;
        z-index: 10;
    }
    
    .about-timeline-node-inner {
        width: 20px !important;
        height: 20px !important;
    }
    
    .about-card-left,
    .about-card-right {
        padding: 1.5rem !important;
        margin-bottom: 1.5rem;
        margin-left: 0 !important;
    }
    
    /* Education section mobile timeline */
    .timeline-line {
        left: 1rem !important;
        width: 2px !important;
    }
    
    .timeline-item {
        padding-left: 2.5rem !important;
        margin-bottom: 2rem !important;
    }
    
    .timeline-item .flex {
        justify-content: flex-start !important;
        margin-left: -1rem;
    }
    
    .timeline-node {
        width: 30px !important;
        height: 30px !important;
        position: relative;
        z-index: 10;
    }
    
    .timeline-node-inner {
        width: 20px !important;
        height: 20px !important;
    }
    
    .education-card-left,
    .education-card-right {
        padding: 1.5rem !important;
        margin-bottom: 1.5rem;
        margin-left: 0 !important;
    }
}

/* ============================================================================ */
/* ========================== MOBILE PERFORMANCE OPTIMIZATIONS ============= */
/* ============================================================================ */

@media (max-width: 768px) {
    /* Reduce complex animations */
    .animate-fade-in-up,
    .animate-fade-in-left,
    .animate-fade-in-right,
    .animate-slide-in-up,
    .animate-stagger {
        animation-duration: 0.3s !important;
    }
    
    /* Simplify gradients for better performance */
    .gradient-text {
        background: var(--ai-primary) !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
    }
    
    /* Reduce backdrop blur for performance */
    .backdrop-filter {
        backdrop-filter: blur(10px) !important;
    }
    
    /* Optimize shadows */
    .box-shadow,
    .shadow-lg,
    .shadow-xl {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Hide floating elements on mobile for performance */
    .absolute.top-1\/4,
    .absolute.top-1\/3,
    .absolute.top-2\/3,
    .absolute.bottom-32 {
        display: none !important;
    }
    
    /* Reduce animations on mobile for performance - but keep rainbow ring */
    .animate-spin:not(.rainbow-ring),
    .animate-pulse:not(.rainbow-ring),
    .animate-bounce:not(.rainbow-ring) {
        animation: none !important;
    }
    
    /* Ensure rainbow ring animation always works on mobile */
    .rainbow-ring {
        animation: rainbow-spin 3s linear infinite !important;
        opacity: 1 !important;
        display: block !important;
        position: absolute !important;
        border-radius: 50% !important;
        aspect-ratio: 1 / 1 !important;
        z-index: 0 !important;
        pointer-events: none !important;
    }
    
    /* Mobile profile image fixes */
    .profile-image-wrapper {
        position: relative !important;
        z-index: 2 !important;
        overflow: visible !important;
    }
    
    .profile-image {
        z-index: 3 !important;
        position: relative !important;
        border-radius: 50% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: cover !important;
    }
    
    /* Simplify background effects on mobile */
    body::before,
    body::after {
        opacity: 0.1 !important;
    }
    
    .hero-3d::before {
        opacity: 0.2 !important;
    }
}

/* ============================================================================ */
/* ========================== TOUCH IMPROVEMENTS ============================ */
/* ============================================================================ */

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .hover\:scale-105:hover {
        transform: none !important;
    }
    
    .hover\:bg-\[var\(--ai-primary\)\]:hover {
        background-color: inherit !important;
    }
    
    /* Make buttons more touch-friendly */
    .ai-button,
    .project-filter,
    .blog-filter,
    .nav-link-awesome {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Increase tap targets */
    .social-link,
    .connect-btn {
        min-height: 48px;
        min-width: 48px;
    }
}

/* ============================================================================ */
/* ========================== PROJECTS PAGE MOBILE FIXES =================== */
/* ============================================================================ */

/* Fix hamburger menu and back button overlap on projects page */
@media (max-width: 768px) {
    /* Ensure hamburger button doesn't overlap with back button */
    .sidebar-open-btn {
        position: fixed !important;
        top: 1rem !important;
        left: 1rem !important;
        z-index: 999 !important;
        width: 44px !important;
        height: 44px !important;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05)) !important;
        backdrop-filter: blur(40px) saturate(180%) brightness(1.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        color: rgba(255, 255, 255, 0.85) !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    }
    
    .sidebar-open-btn:hover {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08)) !important;
        border-color: rgba(255, 255, 255, 0.3) !important;
        color: rgba(255, 255, 255, 1) !important;
        transform: translateY(-3px) scale(1.02) !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
    }
    
    /* Position back to portfolio button to avoid overlap */
    .back-link {
        margin-top: 4rem !important;
        margin-left: 1rem !important;
        margin-right: 1rem !important;
        display: block !important;
        clear: both !important;
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* Adjust main content spacing */
    .main-content {
        padding-top: 0.5rem !important;
    }
}

@media (max-width: 480px) {
    /* Additional fixes for very small screens */
    .sidebar-open-btn {
        top: 0.75rem !important;
        left: 0.75rem !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05)) !important;
        backdrop-filter: blur(40px) saturate(180%) brightness(1.1) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        color: rgba(255, 255, 255, 0.85) !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    }
    
    .sidebar-open-btn:hover {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08)) !important;
        border-color: rgba(255, 255, 255, 0.3) !important;
        color: rgba(255, 255, 255, 1) !important;
        transform: translateY(-3px) scale(1.02) !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
    }
    
    .back-link {
        margin-top: 4.5rem !important;
        margin-left: 0.5rem !important;
        margin-right: 0.5rem !important;
        text-align: center !important;
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }
}

/* ============================================================================ */
/* ========================== MOBILE SPECIFIC FIXES ========================= */
/* ============================================================================ */

@media (max-width: 480px) {
    /* Typography adjustments */
    .text-6xl, .text-8xl {
        font-size: 2.5rem !important;
        line-height: 1.2;
    }
    
    .text-5xl {
        font-size: 2rem !important;
        line-height: 1.2;
    }
    
    .text-4xl {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }
    
    .text-3xl {
        font-size: 1.5rem !important;
        line-height: 1.2;
    }
    
    .text-2xl {
        font-size: 1.25rem !important;
        line-height: 1.2;
    }
    
    .text-xl {
        font-size: 1.125rem !important;
        line-height: 1.4;
    }
    
    /* Container and spacing adjustments */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-32 {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }
    
    .py-24 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    .py-20 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
    
    .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .py-12 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    .mb-16 {
        margin-bottom: 2rem !important;
    }
    
    .mb-12 {
        margin-bottom: 1.5rem !important;
    }
    
    .mb-8 {
        margin-bottom: 1rem !important;
    }
    
    /* Hero section mobile optimization */
    .hero-3d {
        min-height: 100vh;
        padding-top: 6rem !important;
    }
    
    .terminal-window {
        margin-bottom: 2rem !important;
        font-size: 0.75rem;
    }
    
    .terminal-body {
        padding: 0.75rem;
        min-height: 80px;
    }
    
    /* Grid optimizations */
    .grid {
        gap: 1rem !important;
    }
    
    .grid-cols-2 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    .grid-cols-3 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    
    /* Card optimizations */
    .ai-card {
        padding: 1rem !important;
    }
    
    .project-card {
        margin-bottom: 1rem;
    }
    
    /* Stats dashboard mobile */
    .ai-stat {
        padding: 1rem !important;
    }
    
    .ai-stat .text-4xl {
        font-size: 1.5rem !important;
    }
    
    /* Footer mobile */
    .footer-social {
        justify-content: center;
        gap: 1rem;
    }
}

/* Prevent zoom on input focus (mobile) */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px !important;
    }
    
    /* Smooth scrolling for mobile */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Optimize text rendering */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
}