/* === Math App Theme === */

/* Override CSS variables with math theme */
:root {
    --primary: var(--math-primary);
    --secondary: var(--math-secondary);
    --tertiary: var(--math-tertiary);
}

/* App-specific Math theme */
body {
    background: linear-gradient(135deg, #FFF9F0 0%, #FFE5F1 100%);
}

body::before {
    background: var(--math-tertiary);
}

body::after {
    background: var(--math-secondary);
}

h1 {
    color: var(--math-primary);
    text-shadow: 3px 3px 0px var(--math-secondary);
}

.card {
    border-color: var(--math-primary);
    box-shadow: 0 8px 32px rgba(255, 107, 157, 0.15);
}

.card::before {
    content: '✨';
}

select, input {
    border-color: var(--math-tertiary);
}

select:focus, input:focus {
    border-color: var(--math-primary);
    box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.1);
}

.btn-back {
    color: var(--math-primary);
    border-color: var(--math-primary);
}

.btn-back:hover {
    background: var(--math-primary);
}

button {
    background: linear-gradient(135deg, var(--math-primary), #FF8CB4);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

.btn-pdf {
    background: linear-gradient(135deg, var(--math-tertiary), #7FC8F8);
    box-shadow: 0 4px 15px rgba(93, 173, 226, 0.4);
}

.preview-header {
    border-bottom-color: var(--math-secondary);
}

.preview-title {
    color: var(--math-primary);
}

/* === Tasks Grid === */
.tasks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* === Task Items === */
.task-item {
    background: linear-gradient(135deg, #FFF9F0 0%, #FFFEF9 100%);
    padding: 1rem 1.5rem;
    border-radius: 16px;
    border: 2px solid var(--math-secondary);
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-dark);
    transition: all 0.3s ease;
    animation: popIn 0.4s ease-out both;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.task-item.correct {
    background: linear-gradient(135deg, #D5F4E6 0%, #ABEBC6 100%);
    border-color: #27AE60;
}

.task-item.incorrect {
    background: linear-gradient(135deg, #FADBD8 0%, #F5B7B1 100%);
    border-color: #E74C3C;
}

.task-item .equation {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-item input {
    width: 70px;
    padding: 0.5rem;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    border: 3px solid var(--math-tertiary);
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.task-item input:focus {
    outline: none;
    border-color: var(--math-primary);
    box-shadow: 0 0 0 4px rgba(255, 107, 157, 0.2);
    transform: scale(1.05);
}

.task-item.correct input {
    border-color: #27AE60;
    background: white;
}

.task-item.incorrect input {
    border-color: #E74C3C;
    background: white;
}

.task-item:hover {
    transform: translateY(-5px) rotate(2deg);
    box-shadow: 0 8px 20px rgba(254, 194, 96, 0.3);
}

.task-item:nth-child(even):hover {
    transform: translateY(-5px) rotate(-2deg);
}

.task-item.correct:hover,
.task-item.incorrect:hover {
    transform: translateY(-5px);
}

.milestone-celebration {
    background: linear-gradient(135deg, var(--math-primary), var(--math-secondary));
}

footer {
    border-top-color: rgba(255, 107, 157, 0.2);
}

footer a {
    color: var(--math-primary);
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .tasks-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .task-item {
        font-size: 1.4rem;
        padding: 1rem;
    }

    .task-item input {
        width: 60px;
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .task-item {
        font-size: 1.3rem;
        padding: 0.8rem;
        gap: 0.5rem;
    }

    .task-item input {
        width: 55px;
        font-size: 1.3rem;
        padding: 0.4rem;
    }
}

/* === Progress Bar for Unlock System === */
.progress-bar-container {
    background: linear-gradient(135deg, #FFF9F0 0%, #FFFEF9 100%);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    border: 2px solid var(--math-secondary);
    margin-top: 2rem;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.15);
}

.progress-bar-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--math-primary);
    margin-bottom: 0.75rem;
    text-align: center;
}

.progress-bar-track {
    width: 100%;
    height: 30px;
    background: #E8E8E8;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--math-primary), var(--math-secondary));
    border-radius: 15px;
    transition: width 0.5s ease-out;
    box-shadow: 0 2px 8px rgba(255, 107, 157, 0.4);
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-bar-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-top: 0.75rem;
    text-align: center;
}

/* === Unlock Message === */
.unlock-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--math-primary), var(--math-secondary));
    color: white;
    padding: 2rem 3rem;
    border-radius: 24px;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 10px 40px rgba(255, 107, 157, 0.5);
    z-index: 1000;
    border: 4px solid white;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* === Completion Screen === */
.completion-screen {
    text-align: center;
    padding: 4rem 2rem;
    animation: fadeIn 1s ease-out;
    margin-top: 2rem;
}

.completion-emoji {
    font-size: 8rem;
    margin-bottom: 2rem;
    animation: bounce 1s ease-in-out infinite;
}

.completion-heading {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1rem;
    font-family: 'Fredoka', sans-serif;
}

.completion-message {
    font-size: 1.3rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.completion-crown-display {
    display: inline-block;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    padding: 1rem 2rem;
    border-radius: 20px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    animation: bounceIn 0.8s ease-out 0.5s both;
}

.completion-crown-display .crown-icon {
    font-size: 2rem;
    margin-right: 0.5rem;
    animation: none;
}

.completion-crown-display .crown-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.completion-restart-btn {
    background: linear-gradient(135deg, var(--primary), #FF8DC7);
    color: white;
    padding: 1rem 2rem;
    border: none;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
    transition: all 0.3s ease;
    width: auto;
    margin-top: 0;
}

.completion-restart-btn:hover {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .progress-bar-container {
        padding: 1rem 1.5rem;
    }

    .progress-bar-label {
        font-size: 1rem;
    }

    .progress-bar-track {
        height: 25px;
    }

    .progress-bar-text {
        font-size: 0.9rem;
    }

    .unlock-message {
        padding: 1.5rem 2rem;
        font-size: 1.5rem;
        max-width: 90%;
    }
}
