/*
 * QMB Math Facts - Enhanced CSS
 * File: /qmbportal/quizzes/assets/css/math_facts.css
 *
 * Enhanced visual design with modern UI patterns and improved user experience
 */

 @import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;900&display=swap');
 @import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap');
 
 /* Import design system and components */
 @import url('components/utilities.css');
 @import url('components/header.css');
 @import url('components/modal.css');
 
 /* =============================================================================
    CSS CUSTOM PROPERTIES
    ============================================================================= */
 
 :root {
     /* Color Palette */
     --primary-blue: #667eea;
     --primary-purple: #764ba2;
     --accent-pink: #f5576c;
     --accent-green: #50f179;
     --accent-orange: #ff9a56;
     --accent-teal: #11998e;
     --accent-lime: #38ef7d;
     
     /* Neutral Colors */
     --bg-primary: #ffffff;
     --bg-secondary: #f8fafc;
     --bg-tertiary: #f1f5f9;
     --text-primary: #2d3748;
     --text-secondary: #4a5568;
     --text-muted: #64748b;
     --border-light: #e2e8f0;
     --border-medium: #cbd5e0;
     
     /* Shadows */
     --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
     --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
     --shadow-large: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
     --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
     
     /* Spacing */
     --space-xs: 0.25rem;
     --space-sm: 0.5rem;
     --space-md: 1rem;
     --space-lg: 1.5rem;
     --space-xl: 2rem;
     --space-2xl: 2.5rem;
     --space-3xl: 3rem;
     
     /* Border Radius */
     --radius-sm: 8px;
     --radius-md: 12px;
     --radius-lg: 16px;
     --radius-xl: 20px;
     --radius-2xl: 24px;
     --radius-full: 9999px;
     
     /* Transitions */
     --transition-fast: 0.15s ease;
     --transition-normal: 0.2s ease;
     --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
     --transition-bounce: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
 }
 
 /* =============================================================================
    BASE STYLES
    ============================================================================= */
 
 * { 
     margin: 0;
     padding: 0;
     box-sizing: border-box;
 }
 
 body {
     font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
     background: linear-gradient(135deg, #112167 0%, #2c3e50 100%);
     min-height: 100vh;
     padding: var(--space-xl);
     line-height: 1.6;
     color: var(--text-primary);
     -webkit-font-smoothing: antialiased;
     -moz-osx-font-smoothing: grayscale;
 }
 
 .container {
     max-width: 1200px;
     margin: 0 auto;
     background: var(--bg-primary);
     border-radius: var(--radius-2xl);
     box-shadow: var(--shadow-xl);
     overflow: hidden;
     position: relative;
 }
 
 .container::before {
     content: '';
     position: absolute;
     top: 0;
     left: 0;
     right: 0;
     height: 6px;
     background: linear-gradient(90deg, var(--primary-blue), var(--accent-pink), var(--accent-green), var(--accent-orange));
     border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
 }
 
 /* =============================================================================
    ENHANCED GAME SETUP SECTION
    ============================================================================= */
 
 .game-setup {
    margin: auto;
    background: white;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--shadow-large);
    max-width: 1200px;
    width: 100%;
    position: relative;
    overflow: hidden;
 }
.setup-section {
    margin-bottom: 1.5rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.section-icon {
    font-size: 1.5rem;
    padding: 0.5rem;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--bg-light), #e2e8f0);
}

.section-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* Button Grid Layouts */
.operand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    max-width: 1000px;
    margin: 0 auto;
}

.timer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    max-width: 1000px;
    margin: 0 auto;
}

.btn-operand .emoji,
.btn-operand .label,
.btn-timer .time-value,
.btn-timer .time-unit,
.btn-level .level-name,
.btn-level .level-range,
.btn-level .level-badge {
    pointer-events: none;
}

/* Enhanced Button Styles */
.btn-operand, .btn-timer, .btn-level {
    background: white;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1rem 0.8rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
    text-align: center;
    box-shadow: var(--shadow-soft);
}

.btn-operand::before,
.btn-timer::before,
.btn-level::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s;
}

.btn-operand:hover::before,
.btn-timer:hover::before,
.btn-level:hover::before {
    left: 100%;
}

.btn-operand:hover,
.btn-timer:hover,
.btn-level:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    border-color: var(--primary-blue);
}

/* Operation Button Styles */
.btn-operand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-height: 100px;
}

.btn-operand .emoji {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.btn-operand .label {
    font-size: 0.85rem;
    opacity: 0.7;
}

.btn-operand.active {
    background: linear-gradient(135deg, green, #38ef7d);
    color: white;
    border-color: var(--accent-green);
    box-shadow: 0 8px 25px rgba(80, 241, 121, 0.3);
}

/* Timer Button Styles */
.btn-timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.btn-timer .time-value {
    font-size: 1.5rem;
    font-weight: 900;
}

.btn-timer .time-unit {
    font-size: 0.85rem;
    opacity: 0.7;
}

.btn-timer.active {
    background: linear-gradient(135deg, var(--golden-dark), var(--golden));
    color: black;
    border-color: var(--golden-light);
    box-shadow: 0 8px 25px rgba(245, 87, 108, 0.3);
}

/* Level Button Styles */
.btn-level {
    text-align: left;
    padding: 1.5rem;
}

.btn-level .level-name {
    font-size: 1.1rem;
    font-weight: 700;
    display: block;
    margin-bottom: 0.25rem;
}

.btn-level .level-range {
    font-size: 0.9rem;
    opacity: 0.7;
    display: block;
}

.btn-level .level-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.btn-level.active {
    background: linear-gradient(135deg, var(--orange-dark), var(--orange));
    color: white;
    border-color: var(--orange-light);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-level.active .level-badge {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Start Button */
.btn-start {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 3rem auto 0;
    background: linear-gradient(135deg, var(--accent-orange), #ff6b35);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 1.25rem 3rem;
    font-size: 1.3rem;
    font-weight: 900;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: 0 10px 25px rgba(255, 154, 86, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-start::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transition: all 0.6s ease;
    transform: translate(-50%, -50%);
}

.btn-start:hover::before {
    width: 300px;
    height: 300px;
}

.btn-start:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 35px rgba(255, 154, 86, 0.5);
}

.btn-start:active {
    transform: translateY(-2px);
}

.rocket-icon {
    font-size: 1.5rem;
    animation: rocketBounce 2s ease-in-out infinite;
}

@keyframes rocketBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
    60% { transform: translateY(-4px); }
}
 
 /* =============================================================================
    GAME AREA
    ============================================================================= */
 
 .game-area {
     padding: var(--space-xl);
     min-height: 400px;
 }
 
 .problem-container {
     background: var(--bg-primary);
     border-radius: var(--radius-xl);
     padding: var(--space-xl);
     box-shadow: var(--shadow-medium);
     max-width: 600px;
     margin: 0 auto;
     border: 1px solid var(--border-light);
 }
 
 .problem-display {
     display: flex;
     align-items: center;
     justify-content: center;
     gap: var(--space-lg);
     font-size: 2.5rem;
     font-weight: bold;
     color: var(--text-primary);
     margin-bottom: var(--space-xl);
     padding: var(--space-lg);
     background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
     border-radius: var(--radius-lg);
     border: 2px solid var(--border-light);
 }
 
 #operand1, #operand2 {
     color: var(--primary-blue);
     min-width: 80px;
     text-align: center;
     font-family: 'Quicksand', sans-serif;
     font-weight: 700;
 }
 
 #operator {
     color: var(--accent-pink);
     font-size: 2.5rem;
     font-weight: 900;
 }
 
 #equals {
     color: var(--text-secondary);
     font-weight: 600;
 }
 
 #answer-display {
     min-width: 100px;
     text-align: center;
     padding: var(--space-sm) var(--space-md);
     background: var(--bg-primary);
     border-radius: var(--radius-md);
     border: 2px solid var(--border-medium);
     transition: var(--transition-normal);
     font-family: 'Quicksand', sans-serif;
 }
 
 /* =============================================================================
    ANSWER INPUT SECTION
    ============================================================================= */
 
 .answer-section {
     display: flex;
     gap: var(--space-md);
     margin-bottom: var(--space-xl);
     align-items: center;
     justify-content: center;
     flex-wrap: wrap;
 }
 
 .answer-input {
     width: 200px;
     padding: var(--space-lg);
     font-size: 2rem;
     text-align: center;
     border: 3px solid var(--border-light);
     border-radius: var(--radius-lg);
     transition: var(--transition-normal);
     font-weight: bold;
     font-family: 'Quicksand', sans-serif;
     background: var(--bg-primary);
 }
 
 .answer-input:focus {
     outline: none;
     border-color: var(--primary-blue);
     box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
     background: #fefefe;
 }
 
 .answer-input::placeholder {
     color: var(--text-muted);
     font-weight: 500;
 }
 
 .btn-submit {
     background: linear-gradient(135deg, var(--accent-teal), var(--accent-lime));
     color: white;
     border: none;
     border-radius: var(--radius-lg);
     padding: var(--space-lg) var(--space-xl);
     font-size: 1.2rem;
     font-weight: bold;
     cursor: pointer;
     transition: var(--transition-slow);
     font-family: inherit;
     box-shadow: var(--shadow-soft);
 }
 
 .btn-submit:hover {
     transform: translateY(-2px);
     box-shadow: 0 8px 25px rgba(17, 153, 142, 0.3);
 }
 
 .btn-restart {
     margin-left: var(--space-sm);
     background: linear-gradient(135deg, var(--accent-orange), #d97706);
     color: white;
     border: none;
     border-radius: var(--radius-lg);
     padding: var(--space-lg) var(--space-xl);
     font-size: 1.2rem;
     font-weight: bold;
     cursor: pointer;
     transition: var(--transition-slow);
     font-family: inherit;
     box-shadow: var(--shadow-soft);
 }
 
 .btn-restart:hover {
     transform: translateY(-2px);
     box-shadow: 0 8px 25px rgba(255, 154, 86, 0.3);
 }
 
 .btn-parameter {
     margin-right: var(--space-sm);
     background: linear-gradient(135deg, #fbbf24, #d97706);
     color: var(--text-primary);
     border: none;
     border-radius: var(--radius-lg);
     padding: var(--space-lg) var(--space-xl);
     font-size: 1.2rem;
     font-weight: bold;
     cursor: pointer;
     transition: var(--transition-slow);
     font-family: inherit;
     box-shadow: var(--shadow-soft);
 }
 
 .btn-parameter:hover {
     transform: translateY(-2px);
     box-shadow: 0 8px 25px rgba(251, 191, 36, 0.3);
 }
 
 /* =============================================================================
    ENHANCED ON-SCREEN KEYPAD
    ============================================================================= */
 
 .keypad {
     max-width: 320px;
     margin: 0 auto;
     padding: var(--space-md);
     background: var(--bg-secondary);
     border-radius: var(--radius-lg);
     box-shadow: var(--shadow-soft);
 }
 
 .keypad-row {
     display: flex;
     gap: var(--space-sm);
     margin-bottom: var(--space-sm);
     justify-content: center;
 }
 
 .key-num,
 .key-clear {
     background: var(--bg-primary);
     border: 2px solid var(--border-light);
     border-radius: var(--radius-md);
     width: 80px;
     height: 60px;
     font-size: 1.5rem;
     font-weight: bold;
     color: var(--text-primary);
     cursor: pointer;
     transition: var(--transition-normal);
     font-family: inherit;
     box-shadow: var(--shadow-soft);
 }
 
 .key-num:hover,
 .key-clear:hover {
     background: var(--bg-tertiary);
     transform: scale(1.05);
     box-shadow: var(--shadow-medium);
 }
 
 .key-num:active,
 .key-clear:active {
     transform: scale(0.95);
     transition: var(--transition-fast);
 }
 
 .key-clear {
     background: linear-gradient(135deg, #fee2e2, #fecaca);
     color: #dc2626;
     border-color: #fecaca;
 }
 
 .key-clear:hover {
     background: linear-gradient(135deg, #fecaca, #fca5a5);
 }
 
 /* =============================================================================
    FEEDBACK SECTION
    ============================================================================= */
 
 .feedback {
     text-align: center;
     font-size: 1.3rem;
     font-weight: bold;
     margin-top: var(--space-lg);
     min-height: 40px;
     padding: var(--space-md);
     border-radius: var(--radius-md);
     transition: var(--transition-normal);
 }
 
 .feedback.success {
     background: linear-gradient(135deg, #dcfce7, #bbf7d0);
     color: #166534;
     border: 2px solid #bbf7d0;
 }
 
 .feedback.error {
     background: linear-gradient(135deg, #fee2e2, #fecaca);
     color: #dc2626;
     border: 2px solid #fecaca;
 }
 
 .feedback.info {
     background: linear-gradient(135deg, #dbeafe, #bfdbfe);
     color: #1e40af;
     border: 2px solid #bfdbfe;
 }
 
 /* =============================================================================
    GAME PROGRESS
    ============================================================================= */
 
 .game-progress {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-top: var(--space-xl);
     padding: var(--space-lg);
     background: var(--bg-secondary);
     border-radius: var(--radius-lg);
     border: 1px solid var(--border-light);
 }
 
 .progress-text {
     font-size: 1.1rem;
     color: var(--text-secondary);
     font-weight: 600;
 }
 
 .progress-text span {
     font-weight: bold;
     color: var(--primary-blue);
 }
 
 .countdown-timer {
     font-size: 2rem;
     font-weight: bold;
     color: var(--text-primary);
     padding: var(--space-sm) var(--space-lg);
     background: var(--bg-primary);
     border-radius: var(--radius-md);
     box-shadow: var(--shadow-soft);
     border: 2px solid var(--border-light);
 }
 
 #time-remaining {
     font-family: 'Courier New', monospace;
     color: var(--accent-pink);
 }
 
 /* =============================================================================
    RESPONSIVE DESIGN
    ============================================================================= */
 
 @media (max-width: 768px) {
     body {
         padding: var(--space-md);
     }
 
     .game-setup {
         padding: var(--space-xl) var(--space-lg);
         margin: var(--space-md);
     }
 
     .setup-header h2 {
         font-size: 2rem;
     }
 
     .operand-buttons,
     .timer-buttons {
         grid-template-columns: 1fr 1fr;
         gap: var(--space-sm);
     }
 
     .level-buttons {
         grid-template-columns: 1fr;
         gap: var(--space-sm);
     }
 
     .problem-display {
         font-size: 1.8rem;
         gap: var(--space-md);
         padding: var(--space-md);
         flex-wrap: wrap;
     }
     
     #operand1, #operand2 {
         min-width: 60px;
     }
     
     .answer-input {
         width: 150px;
         font-size: 1.5rem;
     }
 
     .answer-section {
         flex-direction: column;
         gap: var(--space-md);
     }
 
     .btn-submit,
     .btn-restart,
     .btn-parameter {
         width: 100%;
         margin: 0;
         margin-bottom: var(--space-sm);
     }
     
     .game-progress {
         flex-direction: column;
         gap: var(--space-md);
         text-align: center;
     }
 }
 
 @media (max-width: 480px) {
     .container {
         border-radius: var(--radius-lg);
     }
     
     .game-setup,
     .game-area {
         padding: var(--space-md);
         margin: var(--space-sm);
     }
 
     .operand-buttons,
     .timer-buttons {
         grid-template-columns: 1fr;
     }
 
     .btn-operand,
     .btn-timer,
     .btn-level {
         padding: var(--space-md);
         font-size: 0.9rem;
     }
 
     .btn-operand .emoji {
         font-size: 1.5rem;
     }
     
     .problem-display {
         font-size: 1.4rem;
         gap: var(--space-sm);
         padding: var(--space-md);
     }
     
     .answer-input {
         width: 100%;
         font-size: 1.3rem;
     }
     
     .keypad {
         max-width: 100%;
     }
     
     .key-num,
     .key-clear {
         width: 70px;
         height: 50px;
         font-size: 1.2rem;
     }
 
     .btn-start {
         padding: var(--space-md) var(--space-xl);
         font-size: 1.1rem;
         margin-top: var(--space-xl);
     }
 }
 
 /* =============================================================================
    ACCESSIBILITY
    ============================================================================= */
 
 @media (prefers-reduced-motion: reduce) {
     .rocket-icon {
         animation: none;
     }
     
     .btn-operand::before,
     .btn-timer::before,
     .btn-level::before,
     .btn-start::before {
         transition: none;
     }
 
     * {
         animation-duration: 0.01ms !important;
         animation-iteration-count: 1 !important;
         transition-duration: 0.01ms !important;
     }
 }
 
 @media (prefers-contrast: high) {
     .btn-level.active,
     .btn-timer.active,
     .btn-operand.active,
     .btn-start,
     .btn-submit {
         border: 3px solid currentColor;
     }
     
     .answer-input:focus {
         border-width: 4px;
     }
 }
 
 /* Focus styles for keyboard navigation */
 .btn-operand:focus,
 .btn-timer:focus,
 .btn-level:focus,
 .btn-start:focus,
 .btn-submit:focus,
 .btn-restart:focus,
 .btn-parameter:focus,
 .key-num:focus,
 .key-clear:focus {
     outline: 3px solid var(--primary-blue);
     outline-offset: 2px;
 }
 
 .answer-input:focus {
     outline: none; /* Custom focus styles already applied */
 }
 
 /* =============================================================================
    PRINT STYLES
    ============================================================================= */
 
 @media print {
     body {
         background: white;
         color: black;
     }
     
     .game-setup,
     .keypad,
     .btn-submit,
     .btn-restart,
     .btn-parameter {
         display: none !important;
     }
     
     .container {
         box-shadow: none;
         border: 1px solid #000;
     }
 
     .container::before {
         display: none;
     }
 }