/* ==========================================================================
   Levin's Leerwereld — Stylesheet
   Educatieve webapp voor kinderen (4 jaar)
   Touch-first, iPad 10", Raspberry Pi performance
   ========================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f0f4ff;
    color: #333;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* --- Schermmanagement --- */
.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Hoofdmenu --- */
#menu-screen.active {
    justify-content: center;
}

.app-title {
    font-size: clamp(2rem, 6vw, 3.5rem);
    color: #4a3cb5;
    text-align: center;
    margin-bottom: 0.5rem;
    padding: 0 1rem;
}

/* --- Sessie Score (hoofdmenu) --- */
.session-score {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.session-score:empty {
    display: none;
}

.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.8rem;
    border-radius: 2rem;
    font-size: 1rem;
    font-weight: 700;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.session-badge .badge-icon {
    font-size: 1.2rem;
}

/* --- Module Grid --- */
.module-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 1rem 2rem;
    max-width: 700px;
    width: 100%;
}

.module-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 130px;
    padding: 1.25rem;
    border: none;
    border-radius: 1.5rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    -webkit-appearance: none;
    position: relative;
}

.module-card:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.module-card .card-icon {
    font-size: 2.8rem;
    line-height: 1;
}

/* Progress indicator op module card */
.module-progress {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.75rem;
    opacity: 0.85;
}

/* Kleuren per module */
.module-card[data-color="blue"]   { background: linear-gradient(135deg, #667eea, #764ba2); }
.module-card[data-color="green"]  { background: linear-gradient(135deg, #43e97b, #38f9d7); color: #1a5c3a; }
.module-card[data-color="orange"] { background: linear-gradient(135deg, #f7971e, #ffd200); color: #7a4a00; }
.module-card[data-color="pink"]   { background: linear-gradient(135deg, #f093fb, #f5576c); }
.module-card[data-color="teal"]   { background: linear-gradient(135deg, #4facfe, #00f2fe); color: #0a3d5c; }
.module-card[data-color="red"]    { background: linear-gradient(135deg, #ff5858, #f09819); }

/* --- Level Selectie Scherm --- */
.level-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.5rem;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.spacer {
    width: 56px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    margin: auto;
    align-content: center;
}

.level-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border: 4px solid #d0d5e8;
    border-radius: 1.25rem;
    background: #fff;
    font-size: 1.5rem;
    font-weight: 800;
    color: #4a3cb5;
    cursor: pointer;
    transition: transform 0.12s ease;
    -webkit-appearance: none;
    min-height: 70px;
}

.level-btn:active {
    transform: scale(0.95);
}

.level-btn .level-stars {
    font-size: 0.7rem;
    line-height: 1;
    min-height: 0.8rem;
}

/* Level met sterren (eerder behaald) */
.level-btn.completed {
    border-color: #43e97b;
    background: #e8fef0;
}

.level-btn.locked {
    opacity: 0.4;
    pointer-events: none;
}

/* --- Oefenscherm --- */
.exercise-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.5rem;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.btn-icon {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border: none;
    border-radius: 50%;
    background: #eef1ff;
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
}

.btn-icon:active {
    background: #d8ddff;
}

.exercise-title {
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    color: #4a3cb5;
    text-align: center;
    flex: 1;
    padding: 0 0.5rem;
}

.score-display {
    font-size: 1.3rem;
    font-weight: 700;
    color: #4a3cb5;
    white-space: nowrap;
}

/* --- Vraaggebied --- */
.exercise-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1.5rem;
    gap: 1.5rem;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.question-area {
    text-align: center;
}

.question-text {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 700;
    color: #333;
    line-height: 1.3;
}

.question-image {
    margin-top: 0.75rem;
    font-size: clamp(2.5rem, 8vw, 5rem);
    line-height: 1.2;
}

/* --- Audio knop (voor letters module) --- */
.btn-audio {
    width: 110px;
    height: 110px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.5rem auto;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.15s ease;
    -webkit-appearance: none;
}

.btn-audio:active {
    transform: scale(0.93);
}

.btn-audio.playing {
    animation: pulse 0.6s ease infinite;
}

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

/* --- Antwoordopties --- */
.options-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    max-width: 700px;
}

.option-btn {
    min-width: 90px;
    min-height: 90px;
    padding: 1rem 1.5rem;
    border: 4px solid #d0d5e8;
    border-radius: 1.25rem;
    background: #fff;
    font-size: clamp(1.3rem, 4vw, 2rem);
    font-weight: 700;
    color: #333;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
    -webkit-appearance: none;
    flex: 1 1 auto;
    max-width: 200px;
}

.option-btn:active {
    transform: scale(0.96);
}

.option-btn.correct {
    border-color: #2ecc71;
    background: #d4f8e0;
    animation: pop 0.35s ease;
}

.option-btn.wrong {
    border-color: #e74c3c;
    background: #fde0dc;
    animation: shake 0.4s ease;
}

.option-btn.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* --- Feedback --- */
.feedback-area {
    text-align: center;
    min-height: 2.5rem;
}

.feedback-text {
    font-size: 1.5rem;
    font-weight: 700;
}

.feedback-text.correct {
    color: #2ecc71;
}

.feedback-text.wrong {
    color: #e74c3c;
}

/* --- Footer knoppen --- */
.exercise-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    width: 100%;
    flex-shrink: 0;
}

.btn-primary, .btn-secondary {
    min-height: 64px;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-appearance: none;
}

.btn-primary {
    background: #4a3cb5;
    color: #fff;
}

.btn-primary:active {
    background: #3a2e95;
}

.btn-secondary {
    background: #eef1ff;
    color: #4a3cb5;
}

.btn-secondary:active {
    background: #d8ddff;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

/* --- Animaties --- */
@keyframes pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

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

/* --- Voltooid scherm --- */
.complete-message {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 700;
    color: #4a3cb5;
    text-align: center;
    line-height: 1.4;
}

.complete-stars {
    font-size: clamp(3rem, 10vw, 6rem);
    margin: 1rem 0;
}

/* --- Responsive: Landscape --- */
@media (orientation: landscape) and (max-height: 500px) {
    .module-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }

    .module-card {
        min-height: 100px;
        padding: 1rem;
    }

    .app-title {
        margin-bottom: 0.5rem;
        font-size: 1.8rem;
    }

    .level-grid {
        grid-template-columns: repeat(10, 1fr);
        gap: 0.5rem;
        padding: 1rem;
    }

    .exercise-body {
        flex-direction: row;
        padding: 0.75rem;
        gap: 1rem;
    }

    .question-text {
        font-size: 1.5rem;
    }

    .options-area {
        max-width: 50%;
    }

    .btn-audio {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }
}

/* --- Responsive: Kleine schermen --- */
@media (max-width: 400px) {
    .module-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .level-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.6rem;
        padding: 1rem;
    }

    .option-btn {
        min-height: 80px;
        font-size: 1.2rem;
    }
}
