/* FlexTrize - Mobile Enhancements */
/* Additional mobile-specific improvements and utilities */

/* iOS Safari fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    input[type="search"],
    input[type="text"],
    input[type="email"],
    textarea {
        -webkit-appearance: none;
        border-radius: 0;
    }
    
    /* Fix iOS Safari viewport issues */
    body {
        -webkit-text-size-adjust: 100%;
        -webkit-overflow-scrolling: touch;
    }
}

/* Android Chrome fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    select,
    textarea,
    input {
        font-size: 16px !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    .glass-card {
        border-width: 0.5px;
    }
    
    .nav-logo,
    .footer-logo {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
    :root {
        --glass-bg: rgba(255, 255, 255, 0.03);
        --glass-border: rgba(255, 255, 255, 0.08);
    }
}

/* Reduced motion support */
@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;
    }
    
    .gradient-orb {
        animation: none !important;
    }
}

/* Mobile-specific utilities */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
    
    /* Mobile text alignment */
    .mobile-center {
        text-align: center !important;
    }
    
    .mobile-left {
        text-align: left !important;
    }
    
    /* Mobile spacing */
    .mobile-mt-0 { margin-top: 0 !important; }
    .mobile-mb-0 { margin-bottom: 0 !important; }
    .mobile-mx-auto { margin-left: auto !important; margin-right: auto !important; }
    
    /* Mobile width utilities */
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-max-width-sm {
        max-width: 300px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Touch device specific styles */
    .btn:hover {
        transform: none;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    .glass-card:hover {
        transform: none;
    }
    
    .hover-lift:hover {
        transform: none;
    }
    
    /* Larger touch targets */
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Landscape orientation fixes */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .hero-section {
        min-height: auto;
        padding: var(--spacing-md) 0;
    }
    
    .navigation {
        padding: 0.5rem 0;
    }
    
    .nav-container {
        min-height: 50px;
    }
    
    .main-content {
        padding-top: 60px;
    }
    
    .mobile-menu-content {
        padding: var(--spacing-md);
        max-height: 80vh;
        overflow-y: auto;
    }
    
    .mobile-nav-link {
        padding: 0.75rem 0;
        font-size: 1.125rem;
    }
}

/* Foldable device support */
@media (max-width: 280px) {
    /* Ultra-narrow screens (folded phones) */
    .container {
        padding: 0 0.5rem;
    }
    
    .nav-logo {
        font-size: 1rem;
    }
    
    .btn {
        font-size: 0.75rem;
        padding: 0.625rem 0.875rem;
    }
    
    .glass-card {
        padding: 0.75rem;
    }
    
    h1 {
        font-size: 1.25rem;
    }
    
    h2 {
        font-size: 1.125rem;
    }
    
    h3 {
        font-size: 1rem;
    }
}

/* Wide mobile screens */
@media (min-width: 481px) and (max-width: 768px) {
    .hero-cta {
        flex-direction: row;
        max-width: 400px;
    }
    
    .hero-cta .btn {
        width: auto;
        flex: 1;
    }
    
    .newsletter-form {
        flex-direction: row;
        max-width: 450px;
    }
    
    .newsletter-input {
        flex: 1;
    }
    
    .newsletter-btn {
        width: auto;
        white-space: nowrap;
    }
    
    .crypto-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .indicators-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Print styles for mobile */
@media print {
    .navigation,
    .mobile-menu,
    .mobile-menu-btn,
    .animated-bg,
    .gradient-orb {
        display: none !important;
    }
    
    .main-content {
        padding-top: 0 !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .glass-card {
        background: white !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
    }
}

/* Focus improvements for mobile */
@media (max-width: 768px) {
    *:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }
    
    .btn:focus {
        outline-color: rgba(255, 255, 255, 0.8);
    }
    
    input:focus,
    textarea:focus,
    select:focus {
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    }
}

/* Loading states for mobile */
.mobile-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.mobile-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Mobile-specific animations */
@media (max-width: 768px) {
    .animate-fade-in-up {
        animation-duration: 0.5s;
    }
    
    .animate-fade-in-down {
        animation-duration: 0.5s;
    }
    
    .reveal {
        transition-duration: 0.5s;
    }
    
    .hover-lift {
        transition: none;
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    /* Skip link for mobile */
    .skip-link {
        position: absolute;
        top: -40px;
        left: 6px;
        background: var(--color-primary);
        color: white;
        padding: 8px;
        text-decoration: none;
        border-radius: 4px;
        z-index: 10000;
        transition: top 0.3s;
    }
    
    .skip-link:focus {
        top: 6px;
    }
    
    /* Better focus indicators */
    .mobile-nav-link:focus {
        background: rgba(99, 102, 241, 0.2);
        outline: 2px solid var(--color-primary);
        outline-offset: -2px;
    }
    
    /* Screen reader only content */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* Mobile-specific error states */
@media (max-width: 768px) {
    .form-error {
        border-color: var(--color-danger) !important;
        background: rgba(239, 68, 68, 0.05) !important;
    }
    
    .error-message {
        color: var(--color-danger);
        font-size: 0.875rem;
        margin-top: 0.25rem;
        display: block;
    }
    
    .form-success {
        border-color: var(--color-success) !important;
        background: rgba(16, 185, 129, 0.05) !important;
    }
}

/* Mobile keyboard support */
@media (max-width: 768px) {
    /* Prevent zoom on input focus for iOS */
    input[type="text"],
    input[type="email"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
    }
    
    /* Better mobile form styling */
    .form-group {
        margin-bottom: var(--spacing-md);
    }
    
    .form-label {
        display: block;
        margin-bottom: var(--spacing-xs);
        font-weight: 600;
        color: var(--text-primary);
    }
    
    .form-control {
        width: 100%;
        padding: var(--spacing-sm) var(--spacing-md);
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-md);
        color: var(--text-primary);
        font-size: 16px;
        transition: all var(--transition-base);
    }
    
    .form-control:focus {
        border-color: var(--color-primary);
        background: rgba(99, 102, 241, 0.05);
        outline: none;
    }
}

/* Fix overflow issues for small screens */
@media (max-width: 390px) {
    * {
        box-sizing: border-box;
    }
    
    body {
        overflow-x: hidden;
        width: 100%;
    }
    
    .container {
        max-width: 100%;
        overflow-x: hidden;
        padding: 0 var(--spacing-sm);
    }
    
    .hero-section {
        padding: var(--spacing-lg) 0;
        min-height: auto;
        overflow: hidden;
    }
    
    .hero-container {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
        padding: 0;
        max-width: 100%;
    }
    
    .hero-visual {
        max-width: 100%;
        margin: 0 auto;
        padding: var(--spacing-sm);
        overflow: hidden;
    }
    
    .hero-chart {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 200px;
        overflow: hidden;
    }
    
    .hero-stats {
        padding: var(--spacing-sm);
        margin: 0;
        max-width: 100%;
    }
    
    .stats-row {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
        width: 100%;
    }
    
    .stat-card {
        padding: var(--spacing-sm);
        min-height: auto;
        width: 100%;
    }
    
    .stat-number {
        font-size: clamp(1.25rem, 4vw, 1.5rem);
    }
    
    .stat-suffix {
        font-size: clamp(0.875rem, 3vw, 1rem);
    }
    
    .hero-title {
        font-size: clamp(1.25rem, 5vw, 1.75rem);
        line-height: 1.2;
        margin-bottom: var(--spacing-sm);
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-subtitle {
        font-size: clamp(0.875rem, 3.5vw, 0.9375rem);
        line-height: 1.4;
        margin-bottom: var(--spacing-md);
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .hero-badge {
        font-size: clamp(0.6875rem, 2.5vw, 0.75rem);
        padding: 0.375rem 0.625rem;
        margin-bottom: var(--spacing-sm);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    .hero-cta {
        flex-direction: column;
        gap: var(--spacing-sm);
        width: 100%;
    }
    
    .hero-cta .btn {
        width: 100%;
        min-height: 44px;
        font-size: clamp(0.875rem, 3vw, 0.9375rem);
    }
    
    /* Fix for hero visual elements */
    .hero-visual .glass-card {
        max-width: 100%;
        margin: 0 auto;
        overflow: hidden;
    }
    
    /* Ensure all content fits in viewport */
    .section {
        padding: var(--spacing-lg) var(--spacing-sm);
        overflow-x: hidden;
    }
    
    /* Newsletter form fixes */
    .newsletter-form {
        flex-direction: column;
        gap: var(--spacing-sm);
        width: 100%;
    }
    
    .newsletter-input,
    .newsletter-btn {
        width: 100%;
        min-height: 44px;
    }
}
