/* Mobile Enhancements and Touch Interactions */

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .btn-primary, .btn-secondary, .filter-btn, .social-links a, button {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.25rem;
    }
    
    .terminal-nav a {
        padding: 0.75rem 1rem;
    }
    
    /* Remove hover effects on touch devices */
    .project-card:hover, .cert-card:hover {
        transform: none;
    }
    
    /* Add active states for better feedback */
    .btn-primary:active, .btn-secondary:active, .filter-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
}

/* Mobile-first responsive design improvements */
@media (max-width: 768px) {
    /* Improved spacing and readability */
    body {
        padding: 1.25rem 1rem 2rem;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Better header layout on mobile */
    .profile-card {
        padding: 1.5rem 1.25rem;
        gap: 1.5rem;
    }
    
    h1 {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .tagline {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    /* Stack buttons vertically on small screens */
    .cta-group {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    
    .btn-primary, .btn-secondary {
        width: 100%;
        justify-content: center;
    }
    
    /* Improved section spacing */
    .section {
        padding: 1.5rem 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    /* Better timeline layout */
    .timeline-item {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .timeline-date {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        display: block;
        position: static;
        text-align: left;
        color: var(--accent);
    }
    
    .timeline-content::before {
        display: none;
    }
    
    /* Horizontal scroll for terminal nav */
    .terminal-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.75rem;
        white-space: nowrap;
        /* Hide scrollbar but keep functionality */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .terminal-nav::-webkit-scrollbar {
        display: none;
    }
    
    /* Add scroll hint */
    .terminal-nav::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, var(--surface));
        pointer-events: none;
    }
    
    /* Project filters as horizontal scroll */
    .project-filters {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
        scrollbar-width: thin;
    }
    
    /* Better project cards on mobile */
    .project-card {
        padding: 1.25rem;
    }
    
    .project-links {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .project-links .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Improved tag layout */
    .tags {
        gap: 0.3rem;
    }
    
    .tag {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Better skills grid */
    .skills-grid {
        gap: 1.5rem;
    }
    
    /* Social links optimization */
    .social-links {
        justify-content: space-around;
        width: 100%;
    }
    
    /* Footer adjustments */
    footer {
        padding: 1.25rem 1rem;
        font-size: 0.8rem;
    }
}

/* Landscape mode optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .profile-card {
        grid-template-columns: 120px 1fr;
        text-align: left;
    }
    
    .profile-image {
        width: 100px;
        height: 100px;
        min-width: 100px;
        min-height: 100px;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    .hero-meta {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Small phone optimizations */
@media (max-width: 375px) {
    body {
        padding: 1rem 0.75rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    .section {
        padding: 1.25rem 1rem;
    }
    
    .hero-meta-item {
        padding: 0.5rem 0.75rem;
    }
    
    .timeline-item {
        padding: 0.75rem;
    }
}

/* Touch gesture support */
.swipeable {
    touch-action: pan-y;
}

.horizontal-scroll {
    touch-action: pan-x;
}

/* Improved form inputs for mobile */
input, textarea, select {
    font-size: 16px; /* Prevents zoom on iOS */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Safe area insets for modern devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
    
    .scroll-indicator {
        bottom: max(2rem, calc(env(safe-area-inset-bottom) + 1rem));
    }
    
    .theme-toggle {
        top: max(1rem, env(safe-area-inset-top));
        right: max(1rem, env(safe-area-inset-right));
    }
}

/* Pull-to-refresh hint */
@media (max-width: 768px) {
    body::before {
        content: '';
        position: fixed;
        top: -80px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 40px;
        background: var(--accent);
        border-radius: 50%;
        opacity: 0;
        transition: all 0.3s ease;
        z-index: 9999;
    }
    
    body.pulling::before {
        top: 20px;
        opacity: 0.5;
    }
    
    body.refreshing::before {
        top: 20px;
        opacity: 1;
        animation: spin 1s linear infinite;
    }
}

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

/* Mobile-specific animations */
@media (max-width: 768px) {
    /* Simpler animations for better performance */
    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Disable parallax on mobile */
    header {
        transform: none !important;
    }
    
    /* Optimize scroll performance */
    * {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary, .btn-secondary {
        border: 2px solid currentColor;
    }
    
    .tag {
        border: 1px solid currentColor;
    }
    
    .project-card, .cert-card, .timeline-content {
        border: 2px solid var(--border-strong);
    }
}