/* Import child-friendly Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Bubblegum+Sans&display=swap');

/* CSS Variables for Design System */
:root {
    --primary-font: 'Fredoka One', cursive;
    --secondary-font: 'Bubblegum Sans', cursive;

    --color-bg-light: #f0f4ff;
    --color-bg-dark: #1a1a2e;
    --color-text-light: #2d3748;
    --color-text-dark: #f7fafc;

    --color-primary: #6366f1;
    --color-secondary: #ec4899;
    --color-success: #10b981;
    --color-error: #ef4444;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);

    /* Theme Variables (Default Light) */
    --bg-modal: #ffffff;
    --text-modal: var(--color-text-light);
}

/* Dark Mode Theme */
body.dark-mode {
    --bg-modal: #1e1e2e;
    --text-modal: #e2e8f0;

    /* Darker background gradient for evening use */
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
}

/* Global Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--secondary-font);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--color-text-dark);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-normal);
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Loading Screen */
.loading-content {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
}

.loading-content h1 {
    font-family: var(--primary-font);
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-success), var(--color-primary));
    transition: width var(--transition-normal);
}

#loadingStatus {
    font-size: 1.2rem;
    margin-top: 1rem;
}

/* Welcome Screen */
.welcome-content {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
}

.welcome-content h1 {
    font-family: var(--primary-font);
    font-size: 4rem;
    margin-bottom: 1rem;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    animation: bounce 2s infinite;
}

.subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

/* Buttons */
button {
    font-family: var(--secondary-font);
    font-size: 1.1rem;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

button:active {
    transform: translateY(0);
}

.btn-large {
    font-size: 1.5rem;
    padding: 1.5rem 3rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(10px);
}

/* Icon Button (Toggle) */
.btn-icon {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-fast);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
}

/* Help Text */
.help-text {
    margin-top: 3rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

.help-text a {
    color: white;
    text-decoration: underline;
    cursor: pointer;
}

/* Learning Screen */
.letter-display {
    text-align: center;
    padding: 2rem;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.letter-box {
    margin-bottom: 3rem;
}

.letter-main {
    font-family: var(--primary-font);
    font-size: 20vw;
    line-height: 1;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
    animation: letterAppear var(--transition-normal);
}

@keyframes letterAppear {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.letter-bounce {
    animation: letterBounce 0.6s ease;
}

@keyframes letterBounce {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.2);
    }

    50% {
        transform: scale(0.95);
    }

    75% {
        transform: scale(1.05);
    }
}

/* Examples Container */
.examples-container {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.example-item {
    font-size: 2rem;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    animation: exampleAppear var(--transition-slow) ease;
}

@keyframes exampleAppear {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.example-emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    justify-content: center;
    margin-bottom: 0.5rem;
    max-width: 250px;
}

.example-emoji-mini {
    font-size: 2rem;
}

.digit-example {
    min-width: 200px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity var(--transition-normal);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-modal);
    color: var(--text-modal);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: modalSlideIn var(--transition-normal);
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Subtle border for dark mode */
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    font-family: var(--primary-font);
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--color-primary);
}

.modal-content p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.modal-content input {
    font-family: var(--secondary-font);
    font-size: 2rem;
    padding: 1rem;
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    width: 100%;
    max-width: 200px;
    text-align: center;
    margin-bottom: 1rem;
    letter-spacing: 0.5rem;
}

.modal-content input:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal-buttons button {
    flex: 1;
    max-width: 150px;
}

.error-message {
    color: var(--color-error);
    font-weight: bold;
    margin-top: 1rem;
}

.error-message.hidden {
    display: none;
}

/* Shake animation for errors */
.shake {
    animation: shake 0.5s;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    50% {
        transform: translateX(10px);
    }

    75% {
        transform: translateX(-10px);
    }
}

/* Help Modal specific styles */
.modal-content ol {
    text-align: left;
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.modal-content code {
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    color: var(--color-primary);
}

/* Animations */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .letter-main {
        font-size: 25vw;
    }

    .welcome-content h1 {
        font-size: 2.5rem;
    }

    .example-item {
        font-size: 1.5rem;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    body {
        background: #000;
        color: #fff;
    }

    .modal-content {
        border: 3px solid var(--color-primary);
    }
}

/* Focus States for Accessibility */
button:focus,
input:focus,
a:focus {
    outline: 3px solid var(--color-secondary);
    outline-offset: 2px;
}

/* Timer Display in Modal */
.timer-display {
    font-family: 'Fredoka One', cursive;
    font-size: 3rem;
    color: var(--primary-color);
    margin: 10px 0;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}