/* ==========================================================================
   Urukais Klick - Mobile Optimization CSS
   Optimizaciones específicas para dispositivos móviles y tablets
   ========================================================================== */

/* --- Mobile First Base --- */
@media (max-width: 1024px) {
    /* Tablet Optimizations */
    .container {
        padding-inline: 1.5rem;
    }
    
    .navbar {
        padding-block: 0.75rem;
    }
    
    .nav-menu {
        padding: 1.5rem;
        max-width: 80%;
    }
    
    .hero {
        min-block-size: 90vh;
        padding-block: 6rem 4rem;
    }
    
    .hero-title {
        font-size: clamp(2rem, 5vw, 3rem);
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 2.5vw, 1.25rem);
    }
    
    .section {
        padding-block: 6rem;
    }
    
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 1.5rem;
    }
    
    .contact-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }
    
    .contact-info {
        order: 2;
    }
    
    .contact-form {
        order: 1;
    }
}

/* --- Mobile Optimizations --- */
@media (max-width: 768px) {
    /* Touch Targets - Minimum 44px */
    .nav-toggle {
        width: 48px;
        height: 48px;
        touch-action: manipulation;
    }
    
    .nav-link {
        padding: 1rem 1.5rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        touch-action: manipulation;
    }
    
    .filter-btn {
        min-height: 44px;
        padding: 0.75rem 1.25rem;
        touch-action: manipulation;
    }
    
    .project-action-btn {
        width: 44px;
        height: 44px;
        touch-action: manipulation;
    }
    
    .social-link {
        width: 48px;
        height: 48px;
        touch-action: manipulation;
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        touch-action: manipulation;
    }
    
    /* Improved Touch Spacing */
    .services-grid {
        gap: 1rem;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .project-tech {
        gap: 0.375rem;
    }
    
    .tech-tag {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }
    
    /* Navigation Improvements */
    .navbar {
        padding-block: 0.625rem;
    }
    
    .nav-menu {
        padding: 1.25rem;
        max-width: 85%;
        inset-block-start: 60px;
    }
    
    .nav-menu.active {
        height: calc(100vh - 60px);
    }
    
    /* Hero Section Mobile */
    .hero {
        min-block-size: 100vh;
        padding-block: 5rem 3rem;
        text-align: center;
    }
    
    .hero-title {
        font-size: clamp(1.75rem, 8vw, 2.5rem);
        line-height: 1.1;
        margin-block-end: 1rem;
    }
    
    .hero-subtitle {
        font-size: clamp(0.9375rem, 4vw, 1.125rem);
        line-height: 1.5;
        margin-block-end: 2rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .hero-buttons .btn {
        width: 100%;
        max-width: 280px;
    }
    
    /* Section Headers */
    .section-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }
    
    .section-subtitle {
        font-size: clamp(0.875rem, 3.5vw, 1rem);
    }
    
    /* Services Mobile */
    .service-card {
        padding: 1.5rem;
    }
    
    .service-icon {
        width: 56px;
        height: 56px;
    }
    
    .service-title {
        font-size: 1rem;
    }
    
    .service-description {
        font-size: 0.875rem;
    }
    
    /* Projects Mobile */
    .projects-filter {
        gap: 0.5rem;
        margin-block-end: 2rem;
    }
    
    .project-image {
        height: 200px;
    }
    
    .project-content {
        padding: 1.25rem;
    }
    
    .project-title {
        font-size: 1rem;
    }
    
    .project-description {
        font-size: 0.875rem;
    }
    
    .project-links {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .project-link {
        justify-content: center;
        min-height: 44px;
    }
    
    /* Contact Mobile */
    .contact-form {
        padding: 1.5rem;
    }
    
    .contact-card {
        padding: 1.25rem;
        gap: 0.75rem;
    }
    
    .contact-icon {
        width: 44px;
        height: 44px;
    }
    
    .social-links {
        justify-content: center;
        gap: 0.75rem;
    }
    
    /* Footer Mobile */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .footer-newsletter {
        max-width: 400px;
        margin: 0 auto;
    }
    
    .newsletter-form {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .newsletter-form input {
        width: 100%;
    }
    
    .newsletter-form button {
        width: 100%;
    }
}

/* --- Small Mobile --- */
@media (max-width: 480px) {
    /* Compact Layout */
    .container {
        padding-inline: 1rem;
    }
    
    .navbar {
        padding-block: 0.5rem;
    }
    
    .nav-menu {
        padding: 1rem;
        max-width: 90%;
        inset-block-start: 55px;
    }
    
    .nav-menu.active {
        height: calc(100vh - 55px);
    }
    
    .hero {
        padding-block: 4rem 2rem;
    }
    
    .hero-title {
        font-size: clamp(1.5rem, 10vw, 2rem);
    }
    
    .hero-subtitle {
        font-size: clamp(0.875rem, 5vw, 1rem);
    }
    
    .section {
        padding-block: 4rem;
    }
    
    /* Touch Optimizations */
    .btn {
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }
    
    .filter-btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .service-card {
        padding: 1.25rem;
    }
    
    .service-icon {
        width: 48px;
        height: 48px;
    }
    
    .service-title {
        font-size: 0.9375rem;
    }
    
    .service-description {
        font-size: 0.8125rem;
    }
    
    .project-image {
        height: 180px;
    }
    
    .project-content {
        padding: 1rem;
    }
    
    .project-title {
        font-size: 0.9375rem;
    }
    
    .project-description {
        font-size: 0.8125rem;
    }
    
    .tech-tag {
        padding: 0.25rem 0.5rem;
        font-size: 0.6875rem;
    }
    
    .contact-form {
        padding: 1.25rem;
    }
    
    .form-input,
    .form-textarea,
    .form-select {
        padding: 0.625rem 0.875rem;
        font-size: 0.9375rem;
    }
    
    .contact-card {
        padding: 1rem;
    }
    
    .contact-icon {
        width: 40px;
        height: 40px;
    }
    
    .social-link {
        width: 44px;
        height: 44px;
    }
}

/* --- Landscape Mode Optimizations --- */
@media (max-height: 500px) and (orientation: landscape) {
    /* Compact Hero for Landscape */
    .hero {
        min-block-size: 100vh;
        padding-block: 2rem;
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: center;
        gap: 2rem;
    }
    
    .hero-content {
        text-align: start;
    }
    
    .hero-title {
        font-size: clamp(1.5rem, 4vw, 2rem);
        margin-block-end: 0.75rem;
    }
    
    .hero-subtitle {
        font-size: clamp(0.875rem, 2.5vw, 1rem);
        margin-block-end: 1.5rem;
    }
    
    .hero-buttons {
        flex-direction: row;
        gap: 1rem;
    }
    
    .hero-buttons .btn {
        width: auto;
        min-width: 140px;
    }
    
    /* Compact Sections */
    .section {
        padding-block: 3rem;
    }
    
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .service-card {
        padding: 1rem;
    }
    
    .service-icon {
        width: 40px;
        height: 40px;
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .project-image {
        height: 120px;
    }
    
    .project-content {
        padding: 0.75rem;
    }
    
    .project-title {
        font-size: 0.875rem;
    }
    
    .project-description {
        font-size: 0.75rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .tech-tag {
        padding: 0.1875rem 0.375rem;
        font-size: 0.625rem;
    }
    
    .project-links {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .project-link {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
        min-height: 36px;
    }
}

/* --- Touch Gestures Support --- */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .nav-link:hover,
    .btn:hover,
    .filter-btn:hover,
    .project-card:hover,
    .service-card:hover,
    .social-link:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Active states for touch */
    .nav-link:active,
    .btn:active,
    .filter-btn:active,
    .project-card:active,
    .service-card:active,
    .social-link:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* Improved touch feedback */
    .btn,
    .filter-btn,
    .project-link,
    .nav-link {
        -webkit-tap-highlight-color: rgba(255, 107, 0, 0.2);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Smooth scrolling for touch */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent text selection on interactive elements */
    .btn,
    .filter-btn,
    .project-action-btn,
    .social-link {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* --- High DPI Displays --- */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Crisper text on high DPI */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    
    /* Sharper icons */
    .fas,
    .fab {
        -webkit-font-smoothing: antialiased;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    /* Respect user's motion preferences */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    /* Keep essential transitions */
    .nav-menu.active,
    .btn,
    .filter-btn {
        transition: transform 0.3s ease, opacity 0.3s ease;
    }
}

/* --- Dark Mode Mobile --- */
@media (max-width: 768px) {
    [data-theme="light"] {
        --bg-primary: #ffffff;
        --bg-secondary: #f8fafc;
        --text-primary: #1e293b;
        --text-secondary: #64748b;
        --accent: #ff6b00;
    }
    
    [data-theme="light"] .navbar {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
    }
    
    [data-theme="light"] .nav-menu {
        background: #ffffff;
        color: #1e293b;
    }
    
    [data-theme="light"] .hero {
        background: linear-gradient(135deg, #ffffff, #f8fafc);
        color: #1e293b;
    }
    
    [data-theme="light"] .section {
        background: #ffffff;
    }
    
    [data-theme="light"] .service-card,
    [data-theme="light"] .project-card,
    [data-theme="light"] .contact-form {
        background: #f8fafc;
        border-color: rgba(0, 0, 0, 0.1);
    }
}

/* --- iOS Safari Fixes --- */
@supports (-webkit-touch-callout: none) {
    /* Prevent zoom on input focus */
    .form-input,
    .form-textarea,
    .form-select {
        font-size: 16px;
    }
    
    /* Safe area insets */
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
    
    .hero {
        padding-top: calc(env(safe-area-inset-top) + 4rem);
    }
    
    /* Fix viewport height */
    .hero {
        min-height: -webkit-fill-available;
    }
    
    /* Smooth scrolling */
    html {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent bounce scroll */
    body {
        overscroll-behavior-y: contain;
    }
}

/* --- Android Chrome Fixes --- */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Fix viewport height on Android */
    .hero {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    /* Improve touch performance */
    .btn,
    .filter-btn,
    .nav-link {
        touch-action: manipulation;
    }
    
    /* Prevent text selection */
    .btn,
    .filter-btn,
    .project-link {
        -webkit-user-select: none;
        user-select: none;
    }
}
