/* Mobile-specific styles for enhanced user experience */

/* Touch-friendly improvements */
@media (max-width: 768px) {
    /* Enhanced touch targets */
    .btn, .center-spin-btn, .nav-link, .winner-close {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Better touch feedback */
    .btn:active, .center-spin-btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* Prevent text selection on interactive elements */
    .wheel-container, .btn, .center-spin-btn {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Enhanced mobile input experience */
    .input-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        line-height: 1.5;
        padding: 12px;
        border-radius: 8px;
        border: 2px solid var(--gray-200);
        transition: all 0.3s ease;
    }
    
    .input-textarea:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
        outline: none;
    }
    
    /* Mobile-optimized wheel */
    #wheel {
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Better mobile spacing */
    .container {
        padding: 0 16px;
    }
    
    .wheel-section {
        gap: 24px;
        margin-bottom: 32px;
    }
    
    /* Enhanced mobile typography */
    .hero-title {
        font-size: 2.5rem;
        line-height: 1.2;
        margin-bottom: 16px;
    }
    
    .hero-subtitle {
        font-size: 1.125rem;
        line-height: 1.5;
        color: var(--text-color-light);
    }
    
    /* Mobile-optimized buttons */
    .btn-spin {
        width: 100%;
        max-width: 280px;
        height: 56px;
        font-size: 1.125rem;
        font-weight: 700;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    }
    
    /* Enhanced mobile winner display */
    .winner-card {
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    .winner-name {
        font-size: 2rem;
        font-weight: 700;
        text-align: center;
        word-break: break-word;
        hyphens: auto;
    }
    
    /* Mobile navigation improvements */
    .nav-menu {
        gap: 16px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-link {
        padding: 12px 16px;
        border-radius: 8px;
        font-weight: 600;
        transition: all 0.3s ease;
    }
    
    .nav-link:hover {
        background-color: var(--primary-super-light);
        color: var(--primary-color);
    }
    
    /* Mobile header height fixes - INCREASED HEIGHT */
    .header {
        min-height: 120px; /* Increased from 100px to prevent overlap */
        padding: 12px 0;
    }
    
    .nav {
        height: auto;
        min-height: 96px; /* Increased to accommodate larger touch targets */
        padding: 12px 0;
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .nav-menu {
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        width: 100%;
        margin-top: 12px;
    }
    
    .nav-link {
        min-height: 48px; /* Increased for better touch */
        padding: 14px 18px;
        font-size: 15px;
        white-space: nowrap;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .logo {
        font-size: 1.5rem; /* Slightly smaller on mobile */
        margin-bottom: 12px;
    }
    
    /* Force visibility for wheel elements */
    .center-spin-btn.force-visible,
    .wheel-pointer.force-visible {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10 !important;
    }
    
    /* Ensure wheel elements stay visible during spin */
    .center-spin-btn {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10 !important;
    }
    
    .wheel-pointer {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 10 !important;
    }
    
    /* Footer wrapping fixes - COMPREHENSIVE */
    .footer {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .footer-content {
        flex-wrap: wrap;
        gap: 16px;
        justify-content: center;
        text-align: center;
        padding: 0 16px;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .footer-links {
        flex-wrap: wrap;
        gap: 16px;
        justify-content: center;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .footer-link {
        white-space: nowrap;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .footer-copyright,
    .footer-made-by {
        width: 100%;
        text-align: center;
        margin-top: 16px;
        font-size: 14px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Prevent horizontal scroll on body */
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Ensure container doesn't overflow */
    .container {
        max-width: 100%;
        overflow-x: hidden;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    #wheel {
        width: 280px;
        height: 280px;
    }
    
    .center-spin-btn {
        width: 80px;
        height: 80px;
        font-size: 1rem;
    }
    
    .btn-spin {
        height: 52px;
        font-size: 1rem;
    }
    
    .winner-name {
        font-size: 1.75rem;
    }
    
    .input-textarea {
        min-height: 120px;
        font-size: 16px;
    }
    
    /* Enhanced footer wrapping for small screens */
    .footer-content {
        padding: 0 8px;
    }
    
    .footer-links {
        gap: 12px;
    }
    
    .footer-link {
        font-size: 14px;
        padding: 6px 10px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .wheel-section {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .hero {
        margin-bottom: 20px;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    #wheel {
        width: 240px;
        height: 240px;
    }
    
    .center-spin-btn {
        width: 70px;
        height: 70px;
        font-size: 0.875rem;
    }
}

/* High-DPI mobile devices */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .wheel-pointer {
        filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
    }
    
    .center-spin-btn {
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    
    .btn-spin {
        box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    }
}

/* Mobile performance optimizations */
@media (max-width: 768px) {
    /* Reduce animation complexity */
    .wheel-wrapper:hover .wheel-pointer {
        transform: translateX(-50%) scale(1.05);
        transition: transform 0.15s ease;
    }
    
    .btn:hover {
        transform: translateY(-1px);
        transition: transform 0.15s ease;
    }
    
    .center-spin-btn:hover {
        transform: translate(-50%, -50%) scale(1.02);
        transition: transform 0.15s ease;
    }
    
    /* Optimize for mobile scrolling */
    html {
        scroll-behavior: smooth;
    }
    
    /* Better mobile focus states */
    .btn:focus-visible,
    .center-spin-btn:focus-visible,
    .input-textarea:focus-visible {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }
}

/* Mobile accessibility improvements */
@media (max-width: 768px) {
    /* Ensure sufficient contrast */
    .winner-name {
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
    
    /* Better mobile keyboard navigation */
    .btn:focus,
    .center-spin-btn:focus,
    .input-textarea:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Enhanced mobile screen reader support */
    .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 animations */
@media (max-width: 768px) {
    @keyframes mobileSlideIn {
        from {
            transform: translateY(-20px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    .winner-section-mobile.visible {
        animation: mobileSlideIn 0.5s ease-out;
    }
    
    @keyframes mobilePulse {
        0%, 100% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.05);
        }
    }
    
    .btn-spin:active {
        animation: mobilePulse 0.2s ease-in-out;
    }
}

/* Mobile gesture support */
@media (max-width: 768px) {
    .wheel-container {
        touch-action: manipulation;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Swipe gesture visual feedback */
    .wheel-container.swiping {
        opacity: 0.8;
        transition: opacity 0.2s ease;
    }
}

/* Mobile-specific loading states */
@media (max-width: 768px) {
    .btn-spin:disabled {
        opacity: 0.6;
        transform: scale(0.98);
    }
    
    .btn-spin.loading {
        position: relative;
        color: transparent;
    }
    
    .btn-spin.loading::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 20px;
        margin: -10px 0 0 -10px;
        border: 2px solid transparent;
        border-top: 2px solid white;
        border-radius: 50%;
        animation: mobileSpin 1s linear infinite;
    }
    
    @keyframes mobileSpin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
}
