/**
 * Math Practice Pages - Shared Styles
 * Color variables (--primary, --primary-dark, etc.) should be defined
 * inline in each page's <style> block before importing this file.
 */

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: var(--background);
    min-height: 100vh;
    color: var(--text);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 20px;
    margin-bottom: 30px;
    color: white;
    box-shadow: 0 10px 30px var(--header-shadow, rgba(0, 0, 0, 0.2));
    animation: slideDown 0.5s ease-out;
}

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

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.header-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.streak-badge, .timer-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s;
}

.streak-badge:hover, .timer-badge:hover {
    transform: scale(1.05);
}

.streak-badge .flame {
    font-size: 1.2rem;
    animation: flicker 1s ease-in-out infinite;
}

@keyframes flicker {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.progress-bar {
    background: rgba(255, 255, 255, 0.2);
    height: 8px;
    border-radius: 4px;
    margin-top: 20px;
    overflow: hidden;
}

.progress-fill {
    background: white;
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-display {
    margin-top: 10px;
    font-size: 1.1rem;
}

/* Tab Navigation */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: white;
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.tab-btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 1rem;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    background: transparent;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    background: var(--primary-light);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--tab-shadow, rgba(0, 0, 0, 0.2));
}

.tab-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-btn .lock-icon {
    font-size: 0.9rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* Problem Cards */
.problem-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    animation: cardAppear 0.4s ease-out;
    animation-fill-mode: both;
}

.problem-card:nth-child(1) { animation-delay: 0.05s; }
.problem-card:nth-child(2) { animation-delay: 0.1s; }
.problem-card:nth-child(3) { animation-delay: 0.15s; }
.problem-card:nth-child(4) { animation-delay: 0.2s; }
.problem-card:nth-child(5) { animation-delay: 0.25s; }
.problem-card:nth-child(6) { animation-delay: 0.3s; }
.problem-card:nth-child(7) { animation-delay: 0.35s; }
.problem-card:nth-child(8) { animation-delay: 0.4s; }
.problem-card:nth-child(9) { animation-delay: 0.45s; }
.problem-card:nth-child(10) { animation-delay: 0.5s; }

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

.problem-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.problem-card.correct {
    border: 3px solid var(--correct);
    background: linear-gradient(135deg, #ECFDF5 0%, white 100%);
    animation: correctPulse 0.5s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.problem-card.incorrect {
    border: 3px solid var(--incorrect);
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-8px); }
    80% { transform: translateX(8px); }
}

.problem-card.answered {
    opacity: 0.9;
}

.problem-number {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.problem-type {
    display: inline-block;
    background: #F1F5F9;
    color: var(--text-light);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-left: 10px;
}

.problem-question {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 18px;
    line-height: 1.5;
    white-space: pre-line;
}

.answer-section {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.answer-input {
    flex: 1;
    min-width: 120px;
    padding: 14px 18px;
    font-size: 1.2rem;
    font-family: 'Fredoka', sans-serif;
    border: 3px solid #E2E8F0;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
}

.answer-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--input-focus-shadow, rgba(0, 0, 0, 0.05));
}

.answer-input:disabled {
    background: #F8FAFC;
    color: var(--text-light);
}

.check-btn {
    padding: 14px 28px;
    font-size: 1rem;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.check-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.check-btn:active {
    transform: scale(0.98);
}

.check-btn:disabled {
    background: #CBD5E1;
    cursor: not-allowed;
    transform: none;
}

.feedback {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 1rem;
    display: none;
    animation: feedbackAppear 0.3s ease;
}

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

.feedback.correct {
    display: block;
    background: #ECFDF5;
    color: #059669;
}

.feedback.incorrect {
    display: block;
    background: #FEF2F2;
    color: #DC2626;
}

.hint {
    margin-top: 8px;
    color: var(--text-light);
    font-size: 0.9rem;
    font-style: italic;
}

/* Games Section Theming */
.games-header {
    text-align: center;
    padding: 25px;
    border-radius: 16px;
    margin-bottom: 20px;
    color: white;
    animation: slideDown 0.5s ease-out;
}

.games-header.lego {
    background: linear-gradient(135deg, #FF6B35 0%, #E85A24 100%);
}

.games-header.jets {
    background: linear-gradient(135deg, #4A90D9 0%, #357ABD 100%);
}

.games-header.vehicles {
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
}

.games-header h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.games-header .theme-emoji {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: bounce 2s ease-in-out infinite;
}

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

/* Game Cards */
.game-card {
    background: white;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    animation: cardAppear 0.4s ease-out;
    animation-fill-mode: both;
    border-left: 5px solid var(--primary);
}

.game-card.lego { border-left-color: #FF6B35; }
.game-card.jets { border-left-color: #4A90D9; }
.game-card.vehicles { border-left-color: #7C3AED; }

.game-emoji {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}

.game-timer {
    display: inline-block;
    float: right;
    font-size: 0.9rem;
    font-weight: 700;
    color: #10B981;
    background: #ECFDF5;
    border: 2px solid #10B981;
    border-radius: 20px;
    padding: 3px 12px;
    margin-bottom: 8px;
    transition: color 0.3s, background 0.3s, border-color 0.3s;
}

.game-timer.warning {
    color: #D97706;
    background: #FFFBEB;
    border-color: #D97706;
}

.game-timer.danger {
    color: #DC2626;
    background: #FEF2F2;
    border-color: #DC2626;
    animation: timerPulse 0.6s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Completion Cards */
.completion-card {
    display: none;
    background: linear-gradient(135deg, var(--correct) 0%, #059669 100%);
    color: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    margin-top: 30px;
    animation: celebrationPulse 2s ease-in-out infinite;
}

.completion-card.show {
    display: block;
    animation: celebrationAppear 0.5s ease, celebrationPulse 2s ease-in-out infinite;
}

@keyframes celebrationAppear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes celebrationPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.completion-card h2 {
    font-size: 2rem;
    margin-bottom: 15px;
}

.completion-card .celebration-emoji {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: bounce 1s ease-in-out infinite;
}

.completion-card .stats {
    font-size: 1.2rem;
    margin-top: 20px;
}

.unlock-message {
    background: linear-gradient(135deg, #FCD34D 0%, #F59E0B 100%);
    color: #78350F;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    margin-top: 20px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(252, 211, 77, 0.5); }
    50% { box-shadow: 0 0 0 15px rgba(252, 211, 77, 0); }
}

.already-completed {
    background: linear-gradient(135deg, #FCD34D 0%, #F59E0B 100%);
    color: #78350F;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    margin-bottom: 20px;
}

.already-completed h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.nav-link {
    display: inline-block;
    margin-top: 20px;
    color: white;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.welcome-banner {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--welcome-gradient-end, #FDE68A) 100%);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
    text-align: center;
    border: 2px solid var(--primary-light);
    animation: fadeIn 0.5s ease;
}

.welcome-banner h2 {
    font-size: 1.6rem;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.welcome-banner p {
    color: var(--text);
    font-size: 1.1rem;
}

.welcome-banner .date {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 10px;
}

.profile-photo {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary);
    box-shadow: 0 4px 15px var(--profile-shadow, rgba(0, 0, 0, 0.2));
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.profile-photo:hover {
    transform: scale(1.05);
}

/* Locked Games Message */
.locked-games {
    text-align: center;
    padding: 60px 30px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.locked-games .lock-emoji {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: wiggle 2s ease-in-out infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

.locked-games h3 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 10px;
}

.locked-games p {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Sound Toggle */
.sound-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.2s ease;
    z-index: 100;
}

.sound-toggle:hover {
    transform: scale(1.1);
}

/* Confetti container */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100%) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Email notification status */
.email-status {
    margin-top: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
}

.email-status.sending {
    display: block;
    background: #FEF3C7;
    color: #92400E;
}

.email-status.sent {
    display: block;
    background: #D1FAE5;
    color: #065F46;
}

.email-status.error {
    display: block;
    background: #FEE2E2;
    color: #991B1B;
}

/* Medal System */
.medals-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.medal-pill {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 20px;
    padding: 5px 13px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.medal-pill:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

.medal-pill.popping {
    animation: medal-pop 0.75s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
    z-index: 50;
}

@keyframes medal-pop {
    0%   { transform: scale(1) rotate(0deg); }
    20%  { transform: scale(2.4) rotate(-12deg); }
    40%  { transform: scale(3.5) rotate(10deg); }
    60%  { transform: scale(3.2) rotate(-8deg); }
    80%  { transform: scale(2.6) rotate(6deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Medal earned banner on completion card */
.medal-earned-banner {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.35) 0%, rgba(255, 165, 0, 0.2) 100%);
    border: 2px solid rgba(255, 215, 0, 0.65);
    border-radius: 16px;
    padding: 20px;
    margin-top: 20px;
    text-align: center;
    animation: medal-shine 1.8s ease-in-out infinite;
}

.medal-earned-banner .medal-new-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
    animation: bounce 0.8s ease-in-out infinite;
}

.medal-earned-banner h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #78350F;
    margin-bottom: 4px;
}

.medal-earned-banner p {
    font-size: 1rem;
    color: #92400E;
}

@keyframes medal-shine {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.45); }
    50% { box-shadow: 0 0 22px 8px rgba(255, 215, 0, 0.2); }
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .problem-question {
        font-size: 1.2rem;
    }

    .answer-section {
        flex-direction: column;
    }

    .answer-input, .check-btn {
        width: 100%;
    }

    .tabs {
        flex-direction: column;
    }
}

/* Visual / pictorial problem rendering */
.problem-visual {
    margin: 10px 0 14px;
    overflow-x: auto;
}

.problem-visual svg {
    max-width: 100%;
    height: auto;
}
