/* Mobile Optimizations CSS - Enhanced Version */

/* CSS Custom Properties for Mobile */
:root {
    --mobile-header-height: 70px;
    --mobile-padding: 20px;
    --mobile-gap: 16px;
    --touch-target-size: 48px; /* Increased for better accessibility */
    --vh: 1vh; /* Will be updated by JavaScript */

    /* Enhanced mobile breakpoints */
    --mobile-xs: 320px;
    --mobile-sm: 375px;
    --mobile-md: 414px;
    --mobile-lg: 480px;
    --tablet-sm: 768px;
    --tablet-lg: 1024px;

    /* Mobile-specific colors */
    --mobile-primary: #00ff88;
    --mobile-secondary: #00d4aa;
    --mobile-accent: #0099cc;
    --mobile-bg-primary: rgba(10, 10, 15, 0.95);
    --mobile-bg-secondary: rgba(26, 26, 46, 0.9);
    --mobile-border: rgba(0, 255, 136, 0.2);
    --mobile-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

    /* Animation and transition settings */
    --mobile-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --mobile-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Mobile Device Detection Classes */
.mobile-device {
    /* Applied when mobile device is detected */
    touch-action: manipulation;
}

.mobile-device .desktop-only {
    display: none !important;
}

.desktop-device .mobile-only {
    display: none !important;
}

/* Viewport Height Fix for Mobile Browsers */
.mobile-device .full-height {
    height: calc(var(--vh, 1vh) * 100);
    min-height: calc(var(--vh, 1vh) * 100);
}

/* Touch-Friendly Interactive Elements */
.mobile-device button,
.mobile-device .btn,
.mobile-device .nav-link,
.mobile-device input[type="submit"],
.mobile-device input[type="button"] {
    min-height: var(--touch-target-size);
    min-width: var(--touch-target-size);
    padding: 12px 16px;
    font-size: 16px; /* Prevent zoom on iOS */
    border-radius: 8px;
    transition: transform 0.1s ease;
}

/* Touch Feedback */
.mobile-device button:active,
.mobile-device .btn:active,
.mobile-device .nav-link:active,
.touch-active {
    transform: scale(0.95);
    background-color: rgba(0, 255, 136, 0.2) !important;
}

/* Reduced animations for performance */
.reduced-animations * {
    animation-duration: 0.2s !important;
    transition-duration: 0.2s !important;
}

.reduced-animations .hero-bg-particles,
.reduced-animations .floating-elements {
    display: none !important;
}

/* Mobile Form Optimizations */
.mobile-device input,
.mobile-device textarea,
.mobile-device select {
    font-size: 16px !important; /* Prevent zoom on iOS */
    padding: 12px 16px;
    border-radius: 8px;
    min-height: var(--touch-target-size);
    -webkit-appearance: none;
    appearance: none;
}

.mobile-device input[type="number"] {
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
}

.mobile-device input[type="number"]::-webkit-outer-spin-button,
.mobile-device input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Mobile Navigation Enhancements */
@media (max-width: 768px) {
    .navbar {
        height: var(--mobile-header-height);
        padding: 0 var(--mobile-padding);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
    
    .nav-container {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: var(--touch-target-size);
        height: var(--touch-target-size);
        background: none;
        border: none;
        color: #fff;
        font-size: 1.5rem;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.3s ease;
    }
    
    .mobile-menu-toggle:hover {
        background: rgba(0, 255, 136, 0.1);
        color: #00ff88;
    }
    
    .nav-menu {
        position: fixed;
        top: var(--mobile-header-height);
        left: 0;
        right: 0;
        background: rgba(10, 10, 15, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        max-height: calc(100vh - var(--mobile-header-height));
        overflow-y: auto;
        padding: var(--mobile-padding);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-menu li {
        width: 100%;
        margin: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu .nav-link {
        display: block;
        padding: 16px 0;
        color: #fff;
        text-decoration: none;
        font-size: 1rem;
        transition: all 0.3s ease;
        border-radius: 0;
    }
    
    .nav-menu .nav-link:hover {
        color: #00ff88;
        background: rgba(0, 255, 136, 0.1);
        padding-left: 8px;
    }
}

/* Mobile Hero Section */
@media (max-width: 768px) {
    .hero-section {
        padding-top: calc(var(--mobile-header-height) + 20px);
        min-height: calc(var(--vh, 1vh) * 100);
        padding-left: var(--mobile-padding);
        padding-right: var(--mobile-padding);
    }
    
    .hero-title {
        font-size: 2rem !important;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
        margin-bottom: 1.5rem;
    }
    
    .hero-description {
        font-size: 0.9rem !important;
        margin-bottom: 2rem;
    }
    
    .hero-actions {
        flex-direction: column;
        gap: var(--mobile-gap);
        width: 100%;
    }
    
    .hero-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Mobile Card Layouts */
@media (max-width: 768px) {
    .grid,
    .miners-grid,
    .feature-grid,
    .tokenomics-grid {
        grid-template-columns: 1fr !important;
        gap: var(--mobile-gap) !important;
        padding: 0 var(--mobile-padding);
    }
    
    .card,
    .miner-card,
    .feature-card {
        padding: var(--mobile-padding);
        margin-bottom: var(--mobile-gap);
    }
    
    .miner-card {
        min-height: auto;
        max-width: none;
    }
}

/* Mobile Modal Optimizations */
@media (max-width: 768px) {
    .modal {
        padding: var(--mobile-padding);
        align-items: flex-end;
    }
    
    .modal-content {
        width: 100%;
        max-width: none;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        margin: 0;
        animation: slideUpModal 0.3s ease-out;
    }
    
    @keyframes slideUpModal {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    
    .modal-header {
        padding: var(--mobile-padding);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        position: sticky;
        top: 0;
        background: inherit;
        z-index: 1;
    }
    
    .modal-body {
        padding: var(--mobile-padding);
        max-height: 60vh;
        overflow-y: auto;
    }
}

/* Mobile Purchase Flow */
@media (max-width: 768px) {
    .purchase-form {
        padding: var(--mobile-padding);
    }
    
    .purchase-steps {
        flex-direction: column;
        gap: var(--mobile-gap);
    }
    
    .purchase-step {
        width: 100%;
        text-align: center;
    }
    
    .purchase-summary {
        position: sticky;
        bottom: 0;
        background: rgba(10, 10, 15, 0.98);
        backdrop-filter: blur(20px);
        padding: var(--mobile-padding);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .purchase-button {
        width: 100%;
        padding: 16px;
        font-size: 1.1rem;
        font-weight: 600;
    }
}

/* Mobile Wallet Connection */
@media (max-width: 768px) {
    .wallet-options {
        grid-template-columns: 1fr !important;
        gap: var(--mobile-gap);
    }
    
    .wallet-option {
        padding: var(--mobile-padding);
        text-align: center;
    }
    
    .wallet-icon {
        font-size: 2rem;
        margin-bottom: 8px;
    }
}

/* Mobile Stats and Metrics */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--mobile-gap);
    }
    
    .stat-card {
        padding: 12px;
        text-align: center;
    }
    
    .stat-value {
        font-size: 1.2rem;
        font-weight: 700;
    }
    
    .stat-label {
        font-size: 0.8rem;
        opacity: 0.8;
    }
}

/* Mobile Footer */
@media (max-width: 768px) {
    .footer {
        padding: var(--mobile-padding);
    }
    
    .footer-container {
        flex-direction: column;
        gap: 2rem;
    }
    
    .footer-links {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem;
    }
    
    .footer-column {
        text-align: center;
    }
    
    .footer-social {
        justify-content: center;
        gap: 1rem;
    }
}

/* Landscape Orientation Optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-section {
        min-height: calc(var(--vh, 1vh) * 100);
        padding-top: calc(var(--mobile-header-height) + 10px);
    }
    
    .hero-title {
        font-size: 1.8rem !important;
    }
    
    .hero-subtitle {
        font-size: 0.9rem !important;
    }
    
    .modal-content {
        max-height: 85vh;
    }
    
    .navbar {
        height: 50px;
    }
}

/* Accessibility Improvements for Mobile */
@media (max-width: 768px) {
    /* Focus indicators */
    button:focus,
    .btn:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid #00ff88;
        outline-offset: 2px;
    }
    
    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .card,
        .modal-content {
            border: 2px solid #fff;
        }
        
        button,
        .btn {
            border: 2px solid currentColor;
        }
    }
    
    /* 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;
        }
    }
}

/* Enhanced Mobile Menu Button */
.mobile-menu-toggle {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: #fff;
    transition: all 0.3s ease;
    border-radius: 1px;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 255, 136, 0.1);
}

.mobile-menu-toggle:hover .hamburger-line {
    background: #00ff88;
}

/* Animated hamburger menu */
.nav-menu.active ~ .mobile-menu-toggle .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-menu.active ~ .mobile-menu-toggle .hamburger-line:nth-child(2) {
    opacity: 0;
}

.nav-menu.active ~ .mobile-menu-toggle .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Navigation Dropdown Enhancements */
@media (max-width: 768px) {
    .nav-dropdown .dropdown-menu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        background: rgba(0, 0, 0, 0.5) !important;
        border-radius: 8px !important;
        margin: 8px 0 !important;
        padding: 8px !important;
        box-shadow: inset 0 0 10px rgba(0, 255, 136, 0.1) !important;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .nav-dropdown.active .dropdown-menu {
        max-height: 300px;
    }

    .nav-dropdown .dropdown-menu li {
        border-bottom: none !important;
        margin: 0 !important;
    }

    .nav-dropdown .dropdown-menu .nav-link {
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
        color: rgba(255, 255, 255, 0.8) !important;
        border-radius: 6px !important;
    }

    .nav-dropdown .dropdown-menu .nav-link:hover {
        background: rgba(0, 255, 136, 0.1) !important;
        color: #00ff88 !important;
        padding-left: 20px !important;
    }

    .dropdown-arrow {
        transition: transform 0.3s ease;
    }

    .nav-dropdown.active .dropdown-arrow {
        transform: rotate(180deg);
    }
}

/* Mobile Performance Optimizations */
@media (max-width: 768px) {
    /* Reduce animations for better performance */
    .mobile-device * {
        will-change: auto;
    }

    /* Optimize scrolling */
    .mobile-device {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Reduce backdrop filters on low-end devices */
    @media (max-resolution: 150dpi) {
        .nav-menu,
        .modal-content {
            backdrop-filter: none !important;
            -webkit-backdrop-filter: none !important;
        }
    }
}

/* Dark mode optimizations for mobile */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .mobile-device {
        background-color: #000;
    }

    .card,
    .modal-content {
        background: rgba(20, 20, 30, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}
