/*
 * =====================================================
 * BIRDSONG DETECTIVE CHALLENGE V2.0
 * Professional Educational Experience Design
 * =====================================================
 * 
 * Design System: Professional, accessible, mobile-first
 * Framework: Progressive disclosure, microinteractions
 * Compliance: WCAG 2.1 AA, Responsive design
 */

/* =====================================================
   1. DESIGN TOKENS & VARIABLES
   ===================================================== */

:root {
    /* === Primary Color Palette === */
    --detective-primary: #2C5530;        /* Forest Green - Main actions */
    --detective-primary-light: #3d7545;
    --detective-primary-dark: #1f3d23;
    
    --detective-secondary: #8B4513;      /* Earth Brown - Secondary */
    --detective-secondary-light: #a15a28;
    --detective-secondary-dark: #6b340e;
    
    --detective-accent: #FFB347;         /* Warm Orange - Highlights */
    --detective-accent-light: #ffc166;
    --detective-accent-dark: #ff9e28;
    
    /* === Semantic Colors === */
    --color-success: #4CAF50;
    --color-success-bg: #E8F5E9;
    --color-warning: #FF9800;
    --color-warning-bg: #FFF3E0;
    --color-error: #F44336;
    --color-error-bg: #FFEBEE;
    --color-info: #2196F3;
    --color-info-bg: #E3F2FD;
    
    /* === Neutral Palette === */
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-tertiary: #9E9E9E;
    --text-inverse: #FFFFFF;
    
    --bg-primary: #FAFAFA;
    --bg-secondary: #F5F5F5;
    --surface: #FFFFFF;
    --surface-elevated: #FFFFFF;
    
    --border-light: #E0E0E0;
    --border-medium: #BDBDBD;
    --border-dark: #9E9E9E;
    
    /* === Status Colors === */
    --status-confident: #4CAF50;
    --status-uncertain: #FF9800;
    --status-incorrect: #F44336;
    --status-inprogress: #2196F3;
    
    /* === Typography Scale === */
    --font-primary: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro Display', sans-serif;
    --font-heading: 'Fredoka', 'Poppins', sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;
    
    --text-xs: 0.75rem;      /* 12px - Captions, labels */
    --text-sm: 0.875rem;     /* 14px - Body small */
    --text-base: 1rem;       /* 16px - Body text */
    --text-lg: 1.125rem;     /* 18px - Lead text */
    --text-xl: 1.25rem;      /* 20px - H4 */
    --text-2xl: 1.5rem;      /* 24px - H3 */
    --text-3xl: 1.875rem;    /* 30px - H2 */
    --text-4xl: 2.25rem;     /* 36px - H1 */
    
    /* === Spacing System (8px base) === */
    --space-0: 0;
    --space-1: 0.5rem;       /* 8px */
    --space-2: 1rem;         /* 16px */
    --space-3: 1.5rem;       /* 24px */
    --space-4: 2rem;         /* 32px */
    --space-5: 2.5rem;       /* 40px */
    --space-6: 3rem;         /* 48px */
    --space-8: 4rem;         /* 64px */
    --space-10: 5rem;        /* 80px */
    
    /* === Border Radius === */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    /* === Shadows === */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* === Transitions === */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* === Z-Index Scale === */
    --z-base: 0;
    --z-dropdown: 1000;
    --z-sticky: 1100;
    --z-modal-backdrop: 1200;
    --z-modal: 1300;
    --z-tooltip: 1400;
    --z-notification: 1500;
}

/* =====================================================
   2. BASE RESET & TYPOGRAPHY
   ===================================================== */

.birdsong-detective-v2 {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Allow selection in input areas */
.birdsong-detective-v2 input,
.birdsong-detective-v2 textarea {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.birdsong-detective-v2 * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.birdsong-detective-v2 h1,
.birdsong-detective-v2 h2,
.birdsong-detective-v2 h3,
.birdsong-detective-v2 h4,
.birdsong-detective-v2 h5,
.birdsong-detective-v2 h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.birdsong-detective-v2 h1 { font-size: var(--text-4xl); }
.birdsong-detective-v2 h2 { font-size: var(--text-3xl); }
.birdsong-detective-v2 h3 { font-size: var(--text-2xl); }
.birdsong-detective-v2 h4 { font-size: var(--text-xl); }
.birdsong-detective-v2 h5 { font-size: var(--text-lg); }
.birdsong-detective-v2 h6 { font-size: var(--text-base); font-weight: 600; }

/* =====================================================
   3. LAYOUT SYSTEM
   ===================================================== */

.detective-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-4);
}

.detective-grid {
    display: grid;
    gap: var(--space-4);
}

.detective-flex {
    display: flex;
    gap: var(--space-2);
}

.detective-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.detective-flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* =====================================================
   4. CARD SYSTEM
   ===================================================== */

.detective-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.detective-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.detective-card-elevated {
    box-shadow: var(--shadow-lg);
}

.detective-card-header {
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--border-light);
    position: relative;
}

.detective-card-header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--detective-accent), var(--detective-primary));
    border-radius: 2px;
    animation: expandBar 0.6s ease-out 0.3s both;
}

@keyframes expandBar {
    from { width: 0; opacity: 0; }
    to { width: 60px; opacity: 1; }
}

.detective-card-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--detective-primary);
    margin-bottom: var(--space-1);
    text-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.detective-card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

/* =====================================================
   5. BUTTON SYSTEM
   ===================================================== */

.detective-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-base);
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius-lg);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

.detective-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Button Variants */
.detective-btn-primary {
    background: var(--detective-primary);
    color: var(--text-inverse);
}

.detective-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--detective-primary-light), var(--detective-primary));
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(44, 85, 48, 0.3);
}

.detective-btn-primary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
}

.detective-btn-secondary {
    background: var(--detective-secondary);
    color: var(--text-inverse);
}

.detective-btn-secondary:hover:not(:disabled) {
    background: var(--detective-secondary-light);
}

.detective-btn-outline {
    background: transparent;
    border: 2px solid var(--detective-primary);
    color: var(--detective-primary);
}

.detective-btn-outline:hover:not(:disabled) {
    background: var(--detective-primary);
    color: var(--text-inverse);
}

.detective-btn-ghost {
    background: transparent;
    color: var(--detective-primary);
}

.detective-btn-ghost:hover:not(:disabled) {
    background: rgba(44, 85, 48, 0.1);
}

/* Button Sizes */
.detective-btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-sm);
}

.detective-btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-lg);
}

.detective-btn-icon {
    padding: var(--space-2);
    aspect-ratio: 1;
}

/* =====================================================
   6. FORM SYSTEM
   ===================================================== */

.detective-form-group {
    margin-bottom: var(--space-4);
}

.detective-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.detective-label-required::after {
    content: " *";
    color: var(--color-error);
}

.detective-input,
.detective-textarea,
.detective-select {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-base);
    font-family: inherit;
    color: var(--text-primary);
    background: var(--surface);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.detective-input:focus,
.detective-textarea:focus,
.detective-select:focus {
    outline: none;
    border-color: var(--detective-primary);
    box-shadow: 0 0 0 3px rgba(44, 85, 48, 0.1);
}

.detective-textarea {
    min-height: 120px;
    resize: vertical;
}

.detective-input-hint {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.detective-input-error {
    border-color: var(--color-error);
}

.detective-input-error-message {
    display: block;
    font-size: var(--text-sm);
    color: var(--color-error);
    margin-top: var(--space-1);
}

/* =====================================================
   7. PROGRESS & INDICATORS
   ===================================================== */

.detective-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.detective-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--detective-primary), var(--detective-accent));
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

.detective-step-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: var(--space-4) 0;
}

.detective-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    position: relative;
}

.detective-step::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border-light);
    z-index: -1;
}

.detective-step:last-child::after {
    display: none;
}

.detective-step-circle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all var(--transition-base);
}

.detective-step.active .detective-step-circle {
    background: var(--detective-primary);
    color: var(--text-inverse);
    border-color: var(--detective-primary);
}

.detective-step.completed .detective-step-circle {
    background: var(--color-success);
    color: var(--text-inverse);
    border-color: var(--color-success);
}

.detective-step-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-align: center;
}

.detective-step.active .detective-step-label {
    color: var(--detective-primary);
    font-weight: 600;
}

/* =====================================================
   8. AUDIO PLAYER SYSTEM
   ===================================================== */

.detective-audio-player {
    background: var(--surface);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
}

.detective-audio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.detective-audio-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.detective-audio-waveform {
    height: 80px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-2);
}

.detective-waveform-bar {
    flex: 1;
    max-width: 4px;
    background: var(--detective-primary);
    border-radius: var(--radius-sm);
    opacity: 0.5;
    transition: all var(--transition-fast);
}

.detective-audio-controls {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.detective-audio-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--detective-primary);
    color: var(--text-inverse);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.detective-audio-btn:hover {
    background: var(--detective-primary-light);
    transform: scale(1.05);
}

.detective-audio-timeline {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.detective-audio-progress {
    flex: 1;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.detective-audio-progress-fill {
    height: 100%;
    background: var(--detective-primary);
    border-radius: var(--radius-full);
    transition: width 100ms linear;
}

.detective-audio-time {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    min-width: 45px;
}

/* =====================================================
   9. BADGE & NOTIFICATION SYSTEM
   ===================================================== */

.detective-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
}

.detective-badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.detective-badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.detective-badge-error {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.detective-badge-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.detective-alert {
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    border-left: 4px solid;
    margin-bottom: var(--space-3);
}

.detective-alert-success {
    background: var(--color-success-bg);
    border-color: var(--color-success);
    color: var(--color-success);
}

.detective-alert-warning {
    background: var(--color-warning-bg);
    border-color: var(--color-warning);
    color: var(--color-warning);
}

.detective-alert-error {
    background: var(--color-error-bg);
    border-color: var(--color-error);
    color: var(--color-error);
}

.detective-alert-info {
    background: var(--color-info-bg);
    border-color: var(--color-info);
    color: var(--color-info);
}

/* =====================================================
   10. TOOLTIP SYSTEM
   ===================================================== */

.detective-tooltip {
    position: relative;
    display: inline-flex;
}

.detective-tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--text-primary);
    color: var(--text-inverse);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: var(--z-tooltip);
}

.detective-tooltip:hover .detective-tooltip-content {
    opacity: 1;
}

/* =====================================================
   11. RESPONSIVE UTILITIES
   ===================================================== */

@media (max-width: 767px) {
    .detective-container {
        padding: var(--space-2);
    }
    
    .detective-btn-lg {
        padding: var(--space-2) var(--space-4);
        font-size: var(--text-base);
    }
    
    .detective-step-indicator {
        flex-wrap: wrap;
    }
}

/* =====================================================
   12. ANIMATION UTILITIES
   ===================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.detective-animate-in {
    animation: fadeInScale 0.5s ease-out both;
}

.detective-slide-in {
    animation: slideIn var(--transition-slow) ease-out;
}

.detective-pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* =====================================================
   13. ACCESSIBILITY HELPERS
   ===================================================== */

.detective-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.detective-focus-visible:focus-visible {
    outline: 3px solid var(--detective-accent);
    outline-offset: 2px;
}

/* =====================================================
   14. UTILITY CLASSES
   ===================================================== */

.detective-text-center { text-align: center; }
.detective-text-right { text-align: right; }
.detective-text-left { text-align: left; }

.detective-mb-1 { margin-bottom: var(--space-1); }
.detective-mb-2 { margin-bottom: var(--space-2); }
.detective-mb-3 { margin-bottom: var(--space-3); }
.detective-mb-4 { margin-bottom: var(--space-4); }

.detective-mt-1 { margin-top: var(--space-1); }
.detective-mt-2 { margin-top: var(--space-2); }
.detective-mt-3 { margin-top: var(--space-3); }
.detective-mt-4 { margin-top: var(--space-4); }

.detective-hidden { display: none; }
.detective-visible { display: block; }

