/* Mandera Crypto Center - Complete Cryptocurrency Course - MOBILE OPTIMIZED */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --secondary: #9b59b6;
    --secondary-dark: #8e44ad;
    --accent: #e74c3c;
    --accent-dark: #c0392b;
    --success: #2ecc71;
    --success-dark: #27ae60;
    --warning: #f1c40f;
    --warning-dark: #f39c12;
    --light: #ffffff;
    --light-bg: #f8f9fa;
    --light-text: #333333;
    --light-border: #e0e0e0;
    --dark: #1a1a2e;
    --dark-bg: #16213e;
    --dark-text: #e6e6e6;
    --dark-border: #2d3748;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-dark: 0 4px 12px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
    --radius: 12px;
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
}

/* Light Theme (Default) */
.light-theme {
    --bg-color: var(--light-bg);
    --text-color: var(--light-text);
    --card-bg: var(--light);
    --border-color: var(--light-border);
    --header-bg: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --footer-bg: var(--primary-dark);
    --shadow-color: var(--shadow);
    --module-gradient: linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(155, 89, 182, 0.1));
}

/* Dark Theme */
.dark-theme {
    --bg-color: var(--dark);
    --text-color: var(--dark-text);
    --card-bg: var(--dark-bg);
    --border-color: var(--dark-border);
    --header-bg: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
    --footer-bg: var(--dark);
    --shadow-color: var(--shadow-dark);
    --module-gradient: linear-gradient(135deg, rgba(52, 152, 219, 0.2), rgba(155, 89, 182, 0.2));
}

/* Base Mobile Optimizations */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Enable smooth scrolling on mobile */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    min-height: 100vh;
    padding: 0;
    /* Safe area padding for notched phones */
    padding-top: var(--safe-area-inset-top);
    padding-bottom: var(--safe-area-inset-bottom);
    padding-left: var(--safe-area-inset-left);
    padding-right: var(--safe-area-inset-right);
    overflow-x: hidden;
}

/* Improve touch targets and prevent text selection */
a, button, .nav-btn, .quiz-btn, .complete-btn, .module-btn, .toggle-btn {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    cursor: pointer;
}

/* Container with mobile-first approach */
.container {
    max-width: 100%;
    margin: 0 auto;
    background-color: var(--card-bg);
    box-shadow: var(--shadow-color);
    overflow: hidden;
    border: 1px solid var(--border-color);
    min-height: 100vh;
}

/* Mobile-first responsive typography */
html {
    font-size: 16px;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 13px;
    }
}

/* Header Styles - Mobile Optimized */
header {
    background: var(--header-bg);
    color: white;
    padding: 1.5rem 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

@media (min-width: 768px) {
    header {
        padding: 2.5rem;
    }
}

header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('https://images.unsplash.com/photo-1639762681485-074b7f938ba0?w=1600&q=20');
    background-size: cover;
    opacity: 0.1;
    z-index: 0;
}

header > * {
    position: relative;
    z-index: 1;
}

.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-direction: column;
}

.logo-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.3);
    margin-bottom: 1rem;
    transition: transform 0.8s ease, box-shadow 0.8s ease;
}

@media (min-width: 768px) {
    .logo-img {
        width: 140px;
        height: 140px;
        border-width: 5px;
    }
}

/* Disable hover effects on touch devices */
@media (hover: hover) and (pointer: fine) {
    .logo-img:hover {
        transform: rotateY(180deg) scale(1.05);
        box-shadow: 0 0 40px rgba(155, 89, 182, 0.5);
    }
}

.header-text h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #ffffff, #f1c40f, #ffffff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

@media (min-width: 768px) {
    .header-text h1 {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }
}

@media (min-width: 1024px) {
    .header-text h1 {
        font-size: 3.2rem;
    }
}

@keyframes shine {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.tagline {
    font-size: 1rem;
    opacity: 0.95;
    font-style: italic;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

@media (min-width: 768px) {
    .tagline {
        font-size: 1.25rem;
    }
}

/* Theme Toggle - Mobile Optimized */
.theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 100;
}

@media (min-width: 768px) {
    .theme-toggle {
        top: 1.5rem;
        right: 1.5rem;
    }
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    transition: var(--transition);
    font-size: 0.9rem;
    min-height: 44px; /* Minimum touch target size */
}

@media (min-width: 768px) {
    .toggle-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
}

/* Progress Bars - Mobile Optimized */
.progress-container {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    margin: 1.5rem 0;
    height: 12px;
    overflow: hidden;
    position: relative;
}

@media (min-width: 768px) {
    .progress-container {
        height: 16px;
        margin: 2rem 0;
    }
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--accent));
    border-radius: 8px;
    width: 0%;
    position: relative;
    overflow: hidden;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Main Content - Mobile First */
main {
    padding: 1.5rem;
}

@media (min-width: 768px) {
    main {
        padding: 2.5rem;
    }
}

.module-header {
    background: var(--module-gradient);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border-left: 6px solid var(--primary);
    position: relative;
    overflow: hidden;
}

@media (min-width: 768px) {
    .module-header {
        padding: 2rem;
        margin-bottom: 2.5rem;
    }
}

.module-header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.module-header h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary);
    position: relative;
    display: inline-block;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .module-header h2 {
        font-size: 2rem;
        margin-bottom: 1.25rem;
    }
}

.module-header h2::after {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
}

.module-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.module-meta span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    backdrop-filter: blur(5px);
    font-size: 0.9rem;
}

/* Topics Container - Mobile First Grid */
.topics-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

@media (min-width: 640px) {
    .topics-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 2rem;
    }
}

@media (min-width: 1024px) {
    .topics-container {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
        gap: 2.5rem;
    }
}

.topic-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 2px solid var(--border-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
}

@media (min-width: 768px) {
    .topic-card {
        padding: 2rem;
    }
}

.topic-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary), var(--secondary));
}

.topic-number {
    position: absolute;
    top: -15px;
    right: -15px;
    background: linear-gradient(135deg, var(--accent), var(--warning));
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

@media (min-width: 768px) {
    .topic-number {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
        top: -20px;
        right: -20px;
    }
}

.topic-card h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary);
    padding-right: 60px;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .topic-card h3 {
        font-size: 1.5rem;
        margin-bottom: 1.25rem;
        padding-right: 70px;
    }
}

/* Content Boxes - Mobile Optimized */
.story-box,
.key-concept,
.analogy-box,
.quiz-box {
    padding: 1.25rem;
    border-radius: 10px;
    margin: 1rem 0;
}

@media (min-width: 768px) {
    .story-box,
    .key-concept,
    .analogy-box,
    .quiz-box {
        padding: 1.5rem;
        margin: 1.25rem 0;
    }
}

.story-box {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(155, 89, 182, 0.1));
    border-left: 5px solid var(--secondary);
}

.key-concept {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.1), rgba(39, 174, 96, 0.1));
    border: 2px solid var(--success);
}

.analogy-box {
    background: linear-gradient(135deg, rgba(241, 196, 15, 0.1), rgba(243, 156, 18, 0.1));
    border: 2px solid var(--warning);
}

.quiz-box {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.1), rgba(192, 57, 43, 0.1));
    border: 2px solid var(--accent);
}

.quiz-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px; /* Minimum touch target size */
    font-size: 1rem;
}

/* Navigation - Mobile Optimized */
.navigation {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.06));
    border-top: 2px solid var(--border-color);
    position: relative;
    margin-top: 2rem;
}

@media (min-width: 640px) {
    .navigation {
        flex-direction: row;
        justify-content: space-between;
        padding: 2rem;
    }
}

.navigation::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
}

.nav-btn {
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    position: relative;
    overflow: hidden;
    min-height: 44px; /* Minimum touch target size */
}

@media (min-width: 640px) {
    .nav-btn {
        padding: 1rem 2rem;
    }
}

/* Module Navigation - Mobile Friendly */
.module-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--module-gradient);
    border-radius: var(--radius);
    border: 2px solid var(--border-color);
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.module-btn {
    padding: 0.75rem 1.25rem;
    background: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--primary);
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
    justify-content: center;
    font-size: 0.9rem;
    white-space: nowrap;
    min-height: 44px; /* Minimum touch target size */
}

/* Search Bar - Mobile Optimized */
.search-container {
    max-width: 100%;
    margin: 1.5rem auto;
    position: relative;
    padding: 0 1rem;
}

@media (min-width: 768px) {
    .search-container {
        max-width: 600px;
        margin: 2rem auto;
    }
}

#moduleSearch {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--primary);
    border-radius: 50px;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-color);
    transition: var(--transition);
    -webkit-appearance: none;
    min-height: 48px;
}

/* Footer - Mobile Optimized */
footer {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--footer-bg);
    color: white;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.social-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 1.1rem;
    min-height: 44px;
}

/* Back to Top Button - Mobile Friendly */
#backToTop {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--primary);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: none;
    transition: var(--transition);
    z-index: 1000;
    min-height: 50px;
}

/* Mobile Menu Button */
#mobileMenuBtn {
    display: flex;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    margin: 1rem auto;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    min-height: 44px;
    font-size: 1rem;
}

@media (min-width: 769px) {
    #mobileMenuBtn {
        display: none;
    }
}

/* Enhanced Responsive Breakpoints */
@media (max-width: 320px) {
    .module-btn {
        min-width: 100px;
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    .social-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* Landscape Orientation Optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 1rem;
    }
    
    .logo-img {
        width: 80px;
        height: 80px;
        margin-bottom: 0.5rem;
    }
    
    .header-text h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    .tagline {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
}

/* High DPI (Retina) Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-img {
        border-width: 2px;
    }
    
    @media (min-width: 768px) {
        .logo-img {
            border-width: 3px;
        }
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
    body:not(.light-theme) {
        color-scheme: dark;
    }
}

/* Print Styles - Mobile Friendly */
@media print {
    .theme-toggle,
    .navigation,
    .module-nav,
    .social-links,
    #backToTop,
    #mobileMenuBtn,
    .quiz-btn,
    .toggle-btn {
        display: none !important;
    }
    
    .container {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
    }
    
    body {
        padding: 0;
        background: white;
        color: black;
        font-size: 12pt;
    }
    
    .topic-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* iOS-specific optimizations */
@supports (-webkit-touch-callout: none) {
    .topic-card,
    .nav-btn,
    .module-btn {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
    
    .logo-img:hover {
        transform: none; /* Disable 3D transforms on iOS */
    }
}

/* Android Chrome optimizations */
@supports (-webkit-appearance: none) and (not (-ms-ime-align: auto)) {
    .progress-bar::after {
        animation-duration: 3s;
    }
}

/* Edge optimizations */
@supports (-ms-ime-align: auto) {
    .module-header::before {
        background: var(--primary); /* Fallback for Edge */
    }
}

/* Firefox optimizations */
@-moz-document url-prefix() {
    .logo-img {
        image-rendering: -moz-crisp-edges;
    }
    }
