/* ========================================
   KIDS BIBLE GAME - COMPLETE CSS REDESIGN
   Mobile-first, responsive, optimized UX
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

/* ========================================
   CSS VARIABLES
   ======================================== */
:root {
    --bg-dark: #1a202c;
    --bg-card: #2d3748;
    --bg-card-hover: #4a5568;
    --text-light: #e2e8f0;
    --text-muted: #cbd5e1;
    --primary-blue: #63b3ed;
    --primary-teal: #4fd1c5;
    --success-green: #48bb78;
    --success-dark: #2f855a;
    --error-red: #fc8181;
    --error-dark: #9b2c2c;
    --warning-yellow: #f6e05e;
    --border-color: #4a5568;

    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 15px;

    --font-sm: 0.9em;
    --font-base: 1em;
    --font-lg: 1.1em;
    --font-xl: 1.3em;
    --font-2xl: 1.8em;
    --font-3xl: 2.4em;
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   LAYOUT - MOBILE FIRST
   ======================================== */
body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-md);
    padding-bottom: 140px; /* Space for fixed feedback */
}

body > h1 {
    color: var(--primary-blue);
    font-size: var(--font-xl);
    font-weight: 700;
    margin: var(--spacing-sm) 0;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

/* ========================================
   HEADER & PROGRESS
   ======================================== */
header {
    width: 100%;
    margin-bottom: var(--spacing-md);
}

#progress-bar-container {
    width: 100%;
    height: 18px;
    background-color: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success-green), var(--primary-teal));
    border-radius: 10px;
    transition: width 0.5s ease-in-out;
    width: 0%;
}

#hint-tokens-display {
    text-align: center;
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--warning-yellow);
    margin-bottom: var(--spacing-md);
}

/* ========================================
   GAME LAYOUT
   ======================================== */
.game-layout {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
}

/* ========================================
   CHARACTER & SPEECH BUBBLE
   ======================================== */
#character-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
}

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

#character-image {
    width: 100px;
    height: auto;
    display: block;
    animation: bob 4s ease-in-out infinite;
}

#speech-bubble {
    width: 100%;
    max-width: 100%;
    background: var(--bg-card);
    color: var(--text-light);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-base);
    font-weight: 600;
    line-height: 1.6;
    margin: var(--spacing-md) 0;
    min-height: 60px;
    max-height: 250px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* JS controls opacity and transform */
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#speech-bubble::-webkit-scrollbar {
    width: 8px;
}

#speech-bubble::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 4px;
}

#speech-bubble::-webkit-scrollbar-thumb {
    background: var(--primary-blue);
    border-radius: 4px;
}

/* ========================================
   QUIZ AREA & ANSWERS
   ======================================== */
#quiz-area {
    width: 100%;
}

#answers-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    width: 100%;
}

.answer-option {
    background-color: var(--bg-card);
    border: 2px solid var(--border-color);
    border-bottom-width: 4px;
    border-radius: var(--radius-sm);
    padding: var(--spacing-lg);
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.5;
}

.answer-option:hover:not(.disabled) {
    background-color: var(--bg-card-hover);
    transform: translateY(-2px);
    border-color: var(--primary-blue);
}

.answer-option:active:not(.disabled) {
    transform: translateY(0);
}

.answer-option.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.answer-option.correct {
    background-color: var(--success-dark);
    border-color: var(--success-green);
}

.answer-option.incorrect {
    background-color: var(--error-dark);
    border-color: var(--error-red);
}

/* ========================================
   STORY SLIDES
   ======================================== */
.story-slide {
    background-color: var(--bg-card);
    padding: var(--spacing-xl);
    border-radius: var(--radius-md);
    font-size: var(--font-lg);
    line-height: 1.8;
    color: var(--text-light);
    max-height: 350px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ========================================
   FEEDBACK CONTAINER
   ======================================== */
#feedback-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-lg);
    background-color: var(--bg-card);
    border-top: 3px solid var(--border-color);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

#feedback-container.correct {
    background-color: var(--success-dark);
    border-top-color: var(--success-green);
}

#feedback-container.incorrect {
    background-color: var(--error-dark);
    border-top-color: var(--error-red);
}

#feedback-text {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--text-light);
    text-align: center;
    line-height: 1.5;
}

/* ========================================
   BUTTONS
   ======================================== */
#next-button,
.completion-button {
    width: 100%;
    max-width: 300px;
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    border-bottom: 4px solid #0056b3;
    font-size: var(--font-base);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

#next-button:hover,
.completion-button:hover {
    background: linear-gradient(135deg, #0056b3, #004085);
    transform: translateY(-2px);
}

#next-button:active,
.completion-button:active {
    transform: translateY(0);
}

.completion-button {
    display: inline-block;
    margin: var(--spacing-sm);
}

/* ========================================
   TABLET STYLES (768px and up)
   ======================================== */
@media (min-width: 768px) {
    body {
        padding: var(--spacing-xl);
        padding-bottom: 160px;
    }

    body > h1 {
        font-size: var(--font-2xl);
        margin: var(--spacing-lg) 0;
    }

    #progress-bar-container {
        height: 20px;
        margin-bottom: var(--spacing-lg);
    }

    #hint-tokens-display {
        font-size: var(--font-lg);
        margin-bottom: var(--spacing-lg);
    }

    .game-layout {
        gap: var(--spacing-xl);
    }

    #character-container {
        width: 100%;
    }

    #character-image {
        width: 140px;
    }

    #speech-bubble {
        font-size: var(--font-lg);
        padding: var(--spacing-xl);
        max-height: 280px;
    }

    #answers-container {
        grid-template-columns: 1fr 1fr;
        gap: var(--spacing-lg);
    }

    .answer-option {
        padding: var(--spacing-xl);
        font-size: var(--font-lg);
    }

    .story-slide {
        font-size: var(--font-xl);
        padding: 2rem;
        max-height: 400px;
    }

    #feedback-container {
        padding: var(--spacing-xl);
    }

    #feedback-text {
        font-size: var(--font-xl);
    }
}

/* ========================================
   DESKTOP STYLES (1024px and up)
   ======================================== */
@media (min-width: 1024px) {
    body > h1 {
        font-size: var(--font-3xl);
        margin: var(--spacing-xl) 0;
    }

    .game-layout {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2rem;
    }

    #character-container {
        width: 100%;
        flex-shrink: 0;
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: flex-start;
        gap: var(--spacing-xl);
    }

    #character-image {
        width: 200px;
        height: auto;
        flex-shrink: 0;
    }

    #speech-bubble {
        position: relative;
        left: auto;
        top: auto;
        margin-left: 0;
        width: 100%;
        max-width: 600px;
        flex: 1;
    }

    /* Add tail to speech bubble on desktop */
    #speech-bubble::after {
        content: '';
        position: absolute;
        top: 30px;
        right: 100%;
        width: 0;
        height: 0;
        border: 15px solid transparent;
        border-right-color: var(--bg-card);
        border-left: 0;
    }

    #quiz-area {
        width: 100%;
        max-width: 900px;
    }

    #answers-container {
        gap: var(--spacing-xl);
    }

    .story-slide {
        font-size: 1.4em;
    }
}

/* ========================================
   UTILITY & ACCESSIBILITY
   ======================================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Focus styles for accessibility */
button:focus-visible,
.answer-option:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Print styles */
@media print {
    #feedback-container {
        position: static;
    }

    body {
        background: white;
        color: black;
    }
}

/* ========================================
   SUMMARY SCREEN STYLES
   ======================================== */
.summary-active #character-container {
    justify-content: center !important; /* Override desktop style */
}

.summary-active #character-image {
    width: 250px; /* Larger character */
    max-width: 60%;
    animation: none; /* Stop bobbing animation */
}

.summary-active #speech-bubble {
    display: none; /* Hide speech bubble */
}

.summary-active #answers-container {
    grid-template-columns: 1fr; /* Ensure single-column layout for summary text */
}
