/* Hadithi za Rafiki - Android Optimized CSS */

/* CSS Variables for consistent theming */
:root {
    --primary-color: #195F3C;
    --secondary-color: #C85A46;
    --success-color: #22c55e;
    --accent-color: #8B5CF6;
    --background: #F5F7FA;
    --foreground: #1a1a1a;
    --card-bg: #ffffff;
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    
    /* Child-friendly font sizes */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
}

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Neue', cursive;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    /* Prevent zoom on mobile */
    touch-action: manipulation;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-mascot {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* App Container */
.app-container {
    min-height: 100vh;
    background-color: var(--background);
}

/* Hero Section */
.hero-section {
    height: 200px;
    background: linear-gradient(135deg, rgba(25, 95, 60, 0.9), rgba(200, 90, 70, 0.7));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-content {
    z-index: 2;
}

.hero-title {
    font-family: 'Fredoka One', cursive;
    font-size: var(--font-size-4xl);
    margin-bottom: 8px;
    animation: float 3s ease-in-out infinite;
}

.hero-subtitle {
    font-size: var(--font-size-lg);
    opacity: 0.9;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* Progress Section */
.progress-section {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.level-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 2px solid var(--primary-color);
}

.level-card h3 {
    font-family: 'Fredoka One', cursive;
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: var(--font-size-xl);
}

.xp-bar {
    width: 100%;
    height: 12px;
    background-color: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    transition: width 0.5s ease;
    border-radius: 6px;
}

.xp-text {
    font-size: var(--font-size-sm);
    color: #6b7280;
    font-weight: 600;
}

.stats-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 2px solid var(--accent-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.stat-icon {
    font-size: var(--font-size-lg);
}

.stat-text {
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), #10b981);
    transition: width 0.5s ease;
    border-radius: 4px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border: none;
    border-radius: var(--border-radius);
    font-family: 'Comic Neue', cursive;
    font-weight: 600;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    min-height: 80px;
    /* Improve touch targets for mobile */
    min-width: 44px;
    min-height: 44px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary-color), #16a34a);
    color: white;
}

.action-btn.secondary {
    background: linear-gradient(135deg, var(--accent-color), #a855f7);
    color: white;
}

.action-btn.success {
    background: linear-gradient(135deg, var(--success-color), #16a34a);
    color: white;
}

.action-btn.info {
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    color: white;
}

.btn-icon {
    font-size: var(--font-size-xl);
}

/* Stories Section */
.stories-section h2 {
    font-family: 'Fredoka One', cursive;
    font-size: var(--font-size-2xl);
    color: var(--foreground);
    margin-bottom: 20px;
}

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.story-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
}

.story-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-color);
}

.story-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.story-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.story-content {
    padding: 16px;
}

.story-title {
    font-family: 'Fredoka One', cursive;
    font-size: var(--font-size-lg);
    color: var(--foreground);
    margin-bottom: 8px;
}

.story-description {
    font-size: var(--font-size-sm);
    color: #6b7280;
    margin-bottom: 12px;
    line-height: 1.5;
}

.story-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.difficulty {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.difficulty.rahisi {
    background-color: #dcfce7;
    color: #166534;
}

.difficulty.wastani {
    background-color: #fef3c7;
    color: #92400e;
}

.difficulty.ngumu {
    background-color: #fee2e2;
    color: #991b1b;
}

.stars {
    color: #fbbf24;
    font-size: var(--font-size-sm);
}

.story-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-color), #16a34a);
    color: white;
    font-family: 'Comic Neue', cursive;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.story-btn:hover {
    background: linear-gradient(135deg, #16a34a, var(--primary-color));
}

.story-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
}

/* Daily Tip */
.daily-tip {
    background: linear-gradient(135deg, var(--accent-color), #a855f7);
    color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.tip-icon {
    font-size: var(--font-size-3xl);
    animation: twinkle 2s ease-in-out infinite;
}

.tip-content h3 {
    font-family: 'Fredoka One', cursive;
    font-size: var(--font-size-lg);
    margin-bottom: 8px;
}

.tip-content p {
    font-size: var(--font-size-sm);
    opacity: 0.9;
    line-height: 1.5;
}

/* Mascot Modal */
.mascot-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.mascot-content {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.mascot-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 16px;
    animation: bounce 2s infinite;
}

.mascot-message p {
    font-size: var(--font-size-base);
    margin-bottom: 20px;
    line-height: 1.6;
}

.mascot-close-btn {
    background: linear-gradient(135deg, var(--primary-color), #16a34a);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: 'Comic Neue', cursive;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.mascot-close-btn:hover {
    background: linear-gradient(135deg, #16a34a, var(--primary-color));
}

/* Story Modal */
.story-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.story-content {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.close-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    cursor: pointer;
    color: #6b7280;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--foreground);
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { transform: translateY(0px); }
    40%, 43% { transform: translateY(-15px); }
    70% { transform: translateY(-8px); }
    90% { transform: translateY(-3px); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes twinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 16px 12px;
    }
    
    .progress-section {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stories-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .hero-title {
        font-size: var(--font-size-3xl);
    }
    
    .hero-subtitle {
        font-size: var(--font-size-base);
    }
    
    .daily-tip {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .mascot-content,
    .story-content {
        margin: 10px;
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 480px) {
    .action-btn {
        font-size: var(--font-size-xs);
        padding: 16px 12px;
    }
    
    .btn-icon {
        font-size: var(--font-size-lg);
    }
    
    .hero-section {
        height: 160px;
    }
    
    .stories-section h2 {
        font-size: var(--font-size-xl);
    }
}

/* Android specific optimizations */
@media screen and (max-width: 480px) {
    /* Prevent zoom on form inputs */
    input, select, textarea {
        font-size: 16px;
    }
    
    /* Optimize touch targets */
    button, .story-card, .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Smooth scrolling */
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* PWA specific styles */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .hero-section {
        padding-top: env(safe-area-inset-top);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    
    .story-card,
    .action-btn,
    .level-card,
    .stats-card {
        border-width: 3px;
    }
}
