/* Global app styles - complementing Tailwind with dark mode support */
@import 'tailwind.css';

/* Root CSS variables for theming */
:root {
    --bg-primary: #faf9f7;
    --bg-secondary: #f1f0ed;
    --bg-tertiary: #e8e6e3;
    --text-primary: #2d2a26;
    --text-secondary: #6b6662;
    --text-muted: #9a968f;
    --border-color: #d6d3ce;
    --border-hover: #c4c0b8;
    --shadow-color: rgba(45, 42, 38, 0.08);
    --shadow-color-hover: rgba(45, 42, 38, 0.12);
    --music-primary: #8b5cf6;
    --music-secondary: #a78bfa;
    --music-accent: #f9a8d4;
    --music-success: #34d399;
    --music-error: #f87171;
    --music-warning: #fcd34d;
}

/* Dark mode variables - Much darker theme */
.dark {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #222222;
    --border-hover: #333333;
    --shadow-color: rgba(0, 0, 0, 0.6);
    --shadow-color-hover: rgba(0, 0, 0, 0.8);
    --music-primary: #a78bfa;
    --music-secondary: #c4b5fd;
    --music-accent: #fbb6ce;
    --music-success: #6ee7b7;
    --music-error: #fca5a5;
    --music-warning: #fde68a;
}

/* Apply theme variables to body */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar styles with theme support */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.dark ::-webkit-scrollbar-thumb {
    background: #333333;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #444444;
}

/* Ensure proper rendering for SVG elements */
svg {
    display: block;
    max-width: 100%;
}

/* Smooth transitions for interactive elements */
* {
    transition-property: background-color, border-color, color, fill, stroke, box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* Override default focus styles with theme-aware ones */
*:focus {
    outline: none;
}

/* Ensure proper text rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Theme-aware music primary color */
.music-primary {
    color: var(--music-primary);
}

/* Screen reader only content */
.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;
}

/* Ensure main content takes full available space */
main {
    min-height: calc(100vh - 4rem);
}

/* Navigation link styles with dark mode support */
.nav-link-top {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease-in-out;
}

.nav-link-top:hover {
    color: var(--music-primary);
    border-bottom-color: var(--music-primary);
}

.nav-link-mobile {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
}

.nav-link-mobile:hover {
    color: var(--music-primary);
    background-color: var(--bg-tertiary);
}

/* Card components with theme support */
.card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px var(--shadow-color);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 10px 15px -3px var(--shadow-color-hover);
    border-color: var(--border-hover);
}

/* Button components with enhanced theming */
.btn-primary-theme {
    background-color: var(--music-primary);
    color: white;
    border: 1px solid var(--music-primary);
}

.btn-primary-theme:hover {
    background-color: var(--music-secondary);
    border-color: var(--music-secondary);
}

.btn-secondary-theme {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary-theme:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-hover);
}

/* Input components with theme support */
.input-theme {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.input-theme:focus {
    border-color: var(--music-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.input-theme::placeholder {
    color: var(--text-muted);
}

/* Enhanced mobile menu animations */
@media (max-width: 768px) {
    .mobile-menu-enter {
        transform: translateY(-100%);
        opacity: 0;
    }
    
    .mobile-menu-enter-active {
        transform: translateY(0);
        opacity: 1;
        transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    }
    
    .mobile-menu-exit {
        transform: translateY(0);
        opacity: 1;
    }
    
    .mobile-menu-exit-active {
        transform: translateY(-100%);
        opacity: 0;
        transition: transform 0.3s ease-in, opacity 0.3s ease-in;
    }
}

/* Theme transition animations */
.theme-transition {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Enhanced focus styles for accessibility */
.focus-enhanced:focus {
    outline: 2px solid var(--music-primary);
    outline-offset: 2px;
}

/* Glassmorphism effect for modern UI */
.glass-effect {
    background: rgba(250, 249, 247, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(214, 211, 206, 0.3);
}

.dark .glass-effect {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Glass navigation with darker theme */
.glass-nav {
    background: rgba(250, 249, 247, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.dark .glass-nav {
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Gradient backgrounds with theme awareness */
.gradient-bg-light {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-bg-dark {
    background: linear-gradient(135deg, #2d1b69 0%, #11998e 100%);
}

/* Animation improvements */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced fade in with better performance */
.animate-fade-in-up {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInSmooth 0.6s ease-out forwards;
    will-change: transform, opacity;
}

/* Optimize emoji rendering to prevent flashing */
span:has-emoji, 
.emoji {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    font-display: swap;
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent emoji from causing layout shifts */
.text-4xl, .text-5xl {
    line-height: 1;
    display: inline-block;
    vertical-align: baseline;
}

@keyframes fadeInSmooth {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Prevent initial animation flash */
.opacity-hidden {
    opacity: 0 !important;
    visibility: hidden;
}

.opacity-ready {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease-in;
}

/* Ensure icons render smoothly */
.animate-music-note {
    animation: float 3s ease-in-out infinite;
    will-change: transform;
    backface-visibility: hidden;
}

/* Prevent animation flash on page load */
.animate-stagger > * {
    opacity: 0;
    animation: fadeIn 0.6s ease-out forwards;
}

/* Stagger animation for multiple elements */
.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }

/* Music note floating animation */
.float-animation {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Enhanced hover effects */
.hover-lift {
    transition: transform 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
}

/* Progress indicators with theme support */
.progress-bar {
    background-color: var(--bg-tertiary);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    background-color: var(--music-primary);
    height: 100%;
    transition: width 0.3s ease;
}

/* Status indicators */
.status-success {
    color: var(--music-success);
}

.status-error {
    color: var(--music-error);
}

.status-warning {
    color: var(--music-warning);
}

/* Loading animations */
.loading-spinner {
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--music-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive text scaling */
@media (max-width: 640px) {
    .responsive-text-lg {
        font-size: 1.125rem;
        line-height: 1.75rem;
    }
}

@media (min-width: 641px) {
    .responsive-text-lg {
        font-size: 1.5rem;
        line-height: 2rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
    
    .dark {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    /* Improve touch targets for mobile */
    button, .btn, a, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
    
    /* Remove hover effects on touch devices */
    .hover-lift:hover {
        transform: none;
    }
    
    /* Larger text for better readability */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    /* Better spacing for touch */
    .quiz-option {
        padding: 16px 20px;
        margin-bottom: 12px;
    }
    
    /* Larger volume controls */
    input[type="range"] {
        min-height: 44px;
        padding: 8px;
    }
    
    /* Ensure mobile navigation links are properly sized */
    .nav-link-mobile {
        min-height: 56px;
        display: flex;
        align-items: center;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(139, 92, 246, 0.2);
    }
    
    /* Improve mobile menu button */
    nav button {
        min-height: 48px;
        min-width: 48px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(139, 92, 246, 0.2);
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Prevent zoom on input focus */
    input, select, textarea {
        font-size: 16px !important;
        transform: translateZ(0);
    }
    
    /* Fix viewport issues */
    body {
        -webkit-text-size-adjust: 100%;
    }
    
    /* Smooth scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
}

/* Touch-specific button styles */
.btn-touch {
    min-height: 48px;
    min-width: 48px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(139, 92, 246, 0.2);
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Improve mobile navigation menu */
@media (max-width: 768px) {
    .mobile-menu-container {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background: rgba(250, 249, 247, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--border-color);
        z-index: 40;
    }
    
    .dark .mobile-menu-container {
        background: rgba(10, 10, 10, 0.98);
    }
    
    /* Animate mobile menu */
    .animate-slide-in {
        animation: slideInFromTop 0.3s ease-out;
    }
    
    @keyframes slideInFromTop {
        from {
            transform: translateY(-100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* Enhanced mobile navigation */
@media (max-width: 768px) {
    .nav-link-mobile {
        padding: 16px 20px;
        font-size: 18px;
        min-height: 56px;
    }
    
    .theme-toggle-mobile {
        padding: 12px;
        min-height: 48px;
        min-width: 48px;
    }
}

/* Mobile-friendly animations */
@media (hover: none) {
    .interactive-button:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .interactive-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

