/**
 * Quran Quest - Mobile Styles
 * Responsive design and mobile-specific optimizations
 */

/* Mobile Navigation */
@media (max-width: 768px) {
    /* Typography Scale Down */
    h1 { 
        font-size: 2rem; 
    }
    
    h2 { 
        font-size: 1.75rem; 
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    .logo { 
        font-size: 4rem; 
    }
    
    .arabic {
        font-size: 1.75rem;
        line-height: 1.8;
    }
    
    .arabic-large {
        font-size: 2rem;
        line-height: 2;
    }
    
    .arabic-medium {
        font-size: 1.5rem;
        line-height: 1.6;
    }
    
    /* Layout Adjustments */
    .screen {
        padding: 1rem;
        min-height: 100vh;
    }
    
    .container {
        padding: 0;
    }

    /* Button Adjustments */
    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
        min-height: 48px; /* Touch-friendly */
        gap: 0.5rem;
    }
    
    .btn-large {
        padding: 1rem 2rem;
        min-height: 56px;
        font-size: 1rem;
    }
    
    .btn-small {
        padding: 0.5rem 1rem;
        min-height: 40px;
        font-size: 0.8rem;
    }
    
    /* Play Button */
    .play-button {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
    
    /* Card Adjustments */
    .card {
        padding: 1.25rem;
    }
    
    .card-compact {
        padding: 1rem;
    }
    
    .card-large {
        padding: 1.5rem;
    }
    
    /* Grid Adjustments */
    .grid-3,
    .grid-4,
    .grid-auto {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .options-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Stats Grid Mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .stat-value {
        font-size: 2.5rem;
    }
    
    /* Navigation Buttons */
    .back-btn,
    .settings-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        top: 1rem;
        border-radius: 0.75rem;
    }
    
    .back-btn {
        left: 1rem;
    }
    
    .settings-btn {
        right: 1rem;
    }
    
    /* Volume Button */
    .volume-btn {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
        bottom: 1rem;
        right: 1rem;
    }

    /* Ayah Badge */
    .ayah-badge {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
        bottom: 1rem;
        left: 1rem;
    }
    
    /* Daily Ayah Mobile Position */
    .daily-ayah {
        position: fixed;
        top: auto;
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        max-width: none;
        z-index: 1000;
    }
    
    .daily-ayah .card {
        padding: 1.25rem;
    }
    
    .daily-close {
        width: 28px;
        height: 28px;
        font-size: 1rem;
        top: 0.75rem;
        right: 0.75rem;
    }
    
    /* Progress Bar */
    .progress-bar {
        height: 48px;
        margin: 1.5rem 0;
    }
    
    .progress-label {
        font-size: 1rem;
    }
    
    /* Modal Adjustments */
    .modal-content {
        padding: 1.5rem;
        width: 95%;
        margin: 1rem;
        max-height: 85vh;
    }
    
    /* Setting Items */
    .setting-item {
        padding: 0.875rem 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .setting-item .toggle {
        align-self: flex-end;
    }
    
    /* Menu Buttons */
    .menu-buttons {
        gap: 1rem;
        max-width: 100%;
    }
    
    /* Option Cards */
    .option-card {
        padding: 1.25rem;
        min-height: 80px;
        font-size: 0.95rem;
        border-radius: 0.875rem;
    }
    
    /* Story Content */
    .story-content {
        font-size: 1rem;
        line-height: 1.7;
    }
    
    /* Audio Player */
    .audio-player {
        margin: 1.5rem 0;
    }
    
    /* Loading Spinner */
    .loading {
        padding: 3rem 1rem;
    }
    
    .spinner {
        width: 48px;
        height: 48px;
    }
    
    /* Icon Sizes */
    .icon-large {
        font-size: 3.5rem;
        margin-bottom: 1rem;
    }
    
    .icon-medium {
        font-size: 2.5rem;
    }
    
    /* Spacing Adjustments */
    .m-xl { margin: 1.5rem; }
    .mt-xl { margin-top: 1.5rem; }
    .mb-xl { margin-bottom: 1.5rem; }
    .ml-xl { margin-left: 1.5rem; }
    .mr-xl { margin-right: 1.5rem; }
    
    .p-xl { padding: 1.5rem; }
    .pt-xl { padding-top: 1.5rem; }
    .pb-xl { padding-bottom: 1.5rem; }
    .pl-xl { padding-left: 1.5rem; }
    .pr-xl { padding-right: 1.5rem; }
    
    /* Text Size Adjustments */
    .text-large {
        font-size: 1.125rem;
    }

    /* Ayah Quote (Ocean Reader, Prophet Stories) - less crowding once
       nested inside a card that's already lost horizontal room */
    .ayah-quote {
        padding: 1rem;
        padding-right: 3rem;
    }

    .ayah-play-btn {
        width: 32px;
        height: 32px;
        top: 0.75rem;
        right: 0.75rem;
        font-size: 0.85rem;
    }

    /* Word Bank (Hifz memorization) - smaller tiles so more fit per row
       on a narrow screen without forcing a single word per line */
    .word-tile {
        padding: 0.6rem 0.9rem;
        font-size: 1.25rem;
    }

    /* Land preview strip on the main menu */
    .land-preview span {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }
}

/* Small Mobile (phones in portrait) */
@media (max-width: 480px) {
    /* Even Smaller Typography */
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .logo {
        font-size: 3rem;
    }
    
    /* Tighter Spacing */
    .screen {
        padding: 0.75rem;
    }
    
    .card {
        padding: 1rem;
        border-radius: 1rem;
    }
    
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
        gap: 0.5rem;
    }
    
    /* Smaller Play Button */
    .play-button {
        width: 64px;
        height: 64px;
        font-size: 1.5rem;
    }
    
    /* Single Column Stats */
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    /* Compact Navigation */
    .back-btn,
    .settings-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        top: 0.75rem;
    }
    
    .back-btn {
        left: 0.75rem;
    }
    
    .settings-btn {
        right: 0.75rem;
    }
    
    .volume-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        bottom: 0.75rem;
        right: 0.75rem;
    }

    .ayah-badge {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        bottom: 0.75rem;
        left: 0.75rem;
    }
    
    /* Modal Full Screen */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        padding: 1rem;
    }
    
    /* Daily Ayah Compact */
    .daily-ayah {
        bottom: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
    }
    
    .daily-ayah .card {
        padding: 1rem;
    }
    
    /* Option Cards Smaller */
    .option-card {
        padding: 1rem;
        min-height: 64px;
        font-size: 0.9rem;
    }

    .ayah-quote {
        padding: 0.85rem;
        padding-right: 2.75rem;
    }

    .ayah-quote .arabic {
        font-size: 1.25rem;
    }

    .word-tile {
        padding: 0.5rem 0.75rem;
        font-size: 1.1rem;
    }

    .land-preview span {
        width: 42px;
        height: 42px;
        font-size: 1.25rem;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .screen {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    h2 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }
    
    .logo {
        font-size: 3rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .progress-bar {
        height: 40px;
        margin: 1rem 0;
    }
    
    .menu-buttons {
        gap: 0.75rem;
    }
    
    /* Two column grid in landscape */
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
    
    /* Daily ayah smaller in landscape */
    .daily-ayah {
        max-width: 300px;
        top: 1rem;
        bottom: auto;
        right: 1rem;
        left: auto;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering on retina displays */
    .btn,
    .card,
    .play-button {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover,
    .card:hover {
        transform: none;
        box-shadow: inherit;
    }
    
    /* Larger touch targets */
    .btn {
        min-height: 44px; /* iOS recommended minimum */
    }
    
    .btn-icon {
        width: 44px;
        height: 44px;
    }
    
    .volume-btn,
    .ayah-badge {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Increase option card touch areas */
    .option-card {
        min-height: 60px;
        padding: 1rem;
    }
    
    /* Better finger-friendly toggle */
    .toggle {
        width: 56px;
        height: 32px;
    }
    
    .toggle::after {
        width: 28px;
        height: 28px;
        top: 2px;
        left: 2px;
    }
    
    .toggle.active::after {
        left: 26px;
    }
}

/* Reduce Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .float,
    .spinner {
        animation: none;
    }
    
    .screen.active {
        animation: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --gold: #FFD700;
        --text: #FFFFFF;
        --text-muted: #CCCCCC;
        --navy: #000000;
        --navy-light: #1A1A1A;
    }
    
    .card {
        border: 2px solid var(--gold);
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Dark Mode Adjustments (if system preference) */
@media (prefers-color-scheme: dark) {
    /* Already dark by default, but ensure consistency */
    body {
        background: linear-gradient(135deg, var(--navy) 0%, #000000 100%);
    }
    
    .card {
        background: rgba(15, 23, 42, 0.9);
        border-color: rgba(255, 255, 255, 0.2);
    }
}
@media (max-width: 480px) {
    .player-level { width: 46px; height: 46px; }
    .player-level-num { font-size: 1.25rem; }
    .player-title { font-size: 1rem; }
    .toast { top: 4.5rem; padding: 0.6rem 1rem; font-size: 0.9rem; border-radius: 1rem; }
}

@media (max-width: 480px) {
    .wbw-word { min-width: 64px; padding: 0.5rem; }
    .wbw-ar { font-size: 1.5rem; }
    .tool-btn { flex: 1 1 auto; text-align: center; }
    .recite-btn { flex: 1 1 45%; }
    .land-card .icon-large { font-size: 3.5rem; }
}

@media (max-width: 600px) {
    .screen { padding-top: 4.75rem; }
    .daily-ayah .card { max-height: 55vh; overflow-y: auto; }
    .daily-ayah .arabic { font-size: 1.35rem !important; }
    h2 { font-size: 1.5rem; }
}
