/* 
 * Math Problem Generator
 * style.css - Main stylesheet
 * 
 * Google Material 3 inspired with dark theme
 * Electric blue/orange accent colors
 * Glassmorphic elements
 */

/* ---- VARIABLES ---- */
:root {
    /* Color Palette - Dark Theme */
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    
    /* Accent Colors */
    --accent-blue: #00b0ff;
    --accent-blue-light: #80d8ff;
    --accent-orange: #ff9100;
    --accent-orange-light: #ffd180;
    
    /* Text Colors */
    --text-primary: rgba(255, 255, 255, 0.87);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-disabled: rgba(255, 255, 255, 0.38);
    
    /* Functional Colors */
    --success: #00c853;
    --error: #ff5252;
    --warning: #ffab40;
    
    /* Sizing and Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.14);
    
    /* Animation Timing */
    --timing-fast: 0.2s;
    --timing-medium: 0.3s;
    --timing-slow: 0.5s;
}

/* ---- RESET & BASE STYLES ---- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: linear-gradient(135deg, #2a1c5a, #1c3a5a, #091428);
    color: var(--text-primary);
    overflow-x: hidden;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ---- TYPOGRAPHY ---- */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    text-align: center;
    color: var(--text-primary);
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
    letter-spacing: 1px;
}

p {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

/* ---- LAYOUT ---- */
.container {
    width: 100%;
    max-width: 1200px;
    padding: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.app-header {
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

/* ---- COMPONENTS ---- */

/* Card Styles */
.config-card, .results-card {
    background: rgba(30, 30, 60, 0.25);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    transition: transform var(--timing-medium) ease-in-out, opacity var(--timing-medium) ease-in-out;
}

/* Buttons */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 28px;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--timing-fast) ease;
    margin: var(--spacing-sm);
    letter-spacing: 0.5px;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 176, 255, 0.3);
}

.btn-primary:hover {
    background-color: var(--accent-blue-light);
    box-shadow: 0 6px 16px rgba(0, 176, 255, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: rgba(30, 30, 60, 0.3);
    color: var(--text-primary);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
    background-color: rgba(40, 40, 80, 0.4);
    transform: translateY(-2px);
}

.btn-accent {
    background-color: var(--accent-orange);
    color: white;
    font-size: 1.2rem;
    padding: var(--spacing-md) var(--spacing-xxl);
    margin-top: var(--spacing-lg);
    box-shadow: 0 4px 12px rgba(255, 145, 0, 0.3);
}

.btn-accent:hover {
    background-color: var(--accent-orange-light);
    box-shadow: 0 6px 16px rgba(255, 145, 0, 0.4);
    transform: translateY(-2px);
}

.btn-operation {
    width: 60px;
    height: 60px;
    font-size: 2rem;
    border-radius: 50%;
    background-color: rgba(30, 30, 60, 0.3);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--timing-fast) ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-operation:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-operation.selected {
    background-color: var(--accent-blue);
    color: white;
    box-shadow: 0 0 16px rgba(0, 176, 255, 0.5);
}

/* Operation Buttons Container */
.operation-buttons {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
}

/* Input Styles */
.input-container {
    position: relative;
    margin-bottom: var(--spacing-lg);
    width: 100%;
}

input {
    width: 100%;
    background-color: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    padding: var(--spacing-sm) 0;
    margin-bottom: var(--spacing-xs);
    text-align: center;
    /* Remove up/down arrows on number inputs */
    -moz-appearance: textfield;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input:focus {
    outline: none;
}

.input-line {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--accent-blue);
    position: relative;
}

.input-line::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 100%;
    height: 2px;
    background-color: var(--accent-blue-light);
    transition: transform var(--timing-medium) ease;
}

input:focus + .input-line::after {
    transform: translateX(-50%) scaleX(1);
}

.input-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: var(--spacing-xs);
}

.selection-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* Game Section Styles */
.game-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    height: 70vh;
    min-height: 500px;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    margin-top: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    order: 3;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background-color: rgba(30, 30, 60, 0.4);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: var(--spacing-xs);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-blue-light));
    width: 10%;
    transition: width var(--timing-medium) ease;
    border-radius: 3px;
    box-shadow: 0 0 8px rgba(0, 176, 255, 0.3);
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Problem Display */
.problem-display {
    background: rgba(30, 30, 60, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xxl);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: var(--spacing-xl);
}

.problem-text {
    font-size: 144px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    transition: all var(--timing-fast) ease;
}

.problem-text.error {
    color: var(--error);
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(4px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* Answer Container */
.answer-container {
    width: 100%;
    max-width: 400px;
    margin-bottom: var(--spacing-xl);
}

.answer-container .input-container {
    margin-bottom: 0;
}

.answer-container input {
    font-size: 2rem;
    text-align: center;
}

/* Timer */
.timer-container {
    margin-top: var(--spacing-lg);
}

.timer {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    letter-spacing: 2px;
}

/* Results Section */
.results-section {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.results-stats {
    background: rgba(30, 30, 60, 0.4);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.stat-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

.results-actions {
    margin-top: var(--spacing-xl);
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
}

/* Confetti Canvas */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ---- UTILITIES ---- */
.hidden {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    pointer-events: none;
    transition: none;
}

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.fade-in {
    animation: fadeIn var(--timing-medium) ease-in-out forwards;
}

.fade-out {
    animation: fadeOut var(--timing-medium) ease-in-out forwards;
}

/* ---- RESPONSIVE STYLES ---- */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .problem-text {
        font-size: 100px;
    }
    
    .btn-operation {
        width: 50px;
        height: 50px;
        font-size: 1.75rem;
    }
    
    .timer {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: var(--spacing-md);
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    .problem-text {
        font-size: 72px;
    }
    
    .operation-buttons {
        gap: var(--spacing-md);
    }
    
    .btn-operation {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
    
    .timer {
        font-size: 1.75rem;
    }
    
    .btn {
        padding: var(--spacing-sm) var(--spacing-md);
    }
}
