/* ══════════════════════════════════════════════════════════
   LEERSPEL DO - DESIGN SYSTEM
   Bron: docs/design-system.md + design-preview-v2.html
   ══════════════════════════════════════════════════════════ */

/* ──── CSS VARIABELEN ──── */

:root {
    /* Basis */
    --bg: #F0ECFF;
    --surface: #F8F6FF;
    --accent: #54478C;
    --accent-hover: #6B5BA7;
    --text-dark: #2A2727;
    --text-light: #6B6768;
    --border: #D8D3E8;
    --caption: #908A9E;
    --success: #1E6830;
    --error: #9E3830;

    /* Niveaukleuren - fill (achtergronden, balkjes) */
    --level-0: #B2ACC0;
    --level-1: #EA7F79;
    --level-2: #FFA376;
    --level-3: #F7D05D;
    --level-4: #7EE092;
    --level-5: #9F79D3;

    /* Niveaukleuren - tekst (WCAG compliant op lichte achtergrond) */
    --level-0-text: #6E6880;
    --level-1-text: #9E3830;
    --level-2-text: #8E4E20;
    --level-3-text: #7A6010;
    --level-4-text: #1E6830;
    --level-5-text: #54378C;

    /* Module regenboog (10 kleuren) - fill */
    --mod-1: #EA7F79;
    --mod-2: #FFA376;
    --mod-3: #F7D05D;
    --mod-4: #C5E04E;
    --mod-5: #7EE092;
    --mod-6: #80E1EA;
    --mod-7: #759CF0;
    --mod-8: #9F79D3;
    --mod-9: #C772E4;
    --mod-10: #F075EC;

    /* Module regenboog - licht (hover/subtiele achtergrond) */
    --mod-1-light: #F2B2AF;
    --mod-2-light: #FFC8AD;
    --mod-3-light: #FAE39E;
    --mod-4-light: #DDEF9E;
    --mod-5-light: #B2ECBE;
    --mod-6-light: #B3EDF2;
    --mod-7-light: #ACC4F6;
    --mod-8-light: #C5AFE5;
    --mod-9-light: #DDAAEF;
    --mod-10-light: #F6ACF4;

    /* Module regenboog - tekst (WCAG compliant) */
    --mod-1-text: #9E3830;
    --mod-2-text: #8E4E20;
    --mod-3-text: #7A6010;
    --mod-4-text: #4E6010;
    --mod-5-text: #1E6830;
    --mod-6-text: #1A6068;
    --mod-7-text: #2E4A8E;
    --mod-8-text: #54378C;
    --mod-9-text: #72308E;
    --mod-10-text: #8E2E88;

    /* Medailles */
    --brons: #CB9456;
    --zilver: #9AA5B0;
    --goud: #F0C24A;
    --diamant: #B9F2FF;

    /* UI tokens */
    --radius-card: 12px;
    --radius-btn: 8px;
    --radius-tag: 20px;
    --shadow: 0 2px 12px rgba(84, 71, 140, 0.08);
    --shadow-hover: 0 4px 20px rgba(84, 71, 140, 0.14);
}


/* ──── RESET & BASIS ──── */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    font-size: 1.05rem;
    line-height: 1.75;
    letter-spacing: 0.050em;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.01em;
    line-height: 1.3;
}

h1 { font-size: 2.2rem; margin-bottom: 8px; }
h2 { font-size: 1.6rem; margin-bottom: 12px; }
h3 { font-size: 1.2rem; margin-bottom: 8px; }

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
}


/* ──── LAYOUT ──── */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px;
}

.page-content {
    padding-top: 60px; /* ruimte voor fixed header */
}


/* ──── HEADER & HAMBURGER MENU ──── */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(84, 71, 140, 0.06);
}

.header-logo {
    width: 30px;
    height: 30px;
    margin-left: 12px;
}

.header-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--accent);
    margin-left: 8px;
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 51;
}

.hamburger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(42, 39, 39, 0.4);
    z-index: 48;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.menu-panel {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 20px 16px;
    z-index: 49;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 4px 20px rgba(84, 71, 140, 0.1);
    max-height: calc(100vh - 56px);
    overflow-y: auto;
}

.menu-panel.active {
    transform: translateY(0);
    opacity: 1;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
}

.menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    border-radius: var(--radius-card);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}

.menu-item:hover {
    background: rgba(84, 71, 140, 0.06);
}

.menu-item-icon {
    font-size: 1.5rem;
}

.menu-item-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--accent);
    text-align: center;
}

.menu-item-disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: default;
}

.menu-item-disabled .menu-item-label {
    color: var(--text-light);
}


/* ──── CARDS ──── */

.card {
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-clickable:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    cursor: pointer;
}


/* ──── BUTTONS ──── */

.btn {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-btn);
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    color: var(--surface);
}

.btn-secondary {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}

.btn-secondary:hover {
    background: var(--accent);
    color: var(--surface);
}

.btn-ghost {
    background: transparent;
    color: var(--text-light);
}

.btn-ghost:hover {
    color: var(--accent);
    background: rgba(84, 71, 140, 0.06);
}

.btn-success {
    background: var(--level-4);
    color: var(--text-dark);
}

.btn-danger {
    background: var(--level-1);
    color: var(--surface);
}

.btn-full {
    width: 100%;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}


/* ──── TAGS/PILLS ──── */

.tag {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: var(--radius-tag);
    display: inline-block;
    margin: 2px;
}

/* Module tags: stroke-only */
.tag-module {
    background: transparent;
    border: 2px solid;
}

/* Niveau pills: filled */
.tag-level {
    color: var(--surface);
}

.tag-level-0 { background: var(--level-0); }
.tag-level-1 { background: var(--level-1); }
.tag-level-2 { background: var(--level-2); color: var(--text-dark); }
.tag-level-3 { background: var(--level-3); color: var(--text-dark); }
.tag-level-4 { background: var(--level-4); color: var(--text-dark); }
.tag-level-5 { background: var(--level-5); }


/* ──── INPUTS ──── */

.input {
    font-family: 'Atkinson Hyperlegible', sans-serif;
    font-size: 1.05rem;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-btn);
    background: var(--surface);
    color: var(--text-dark);
    width: 100%;
    outline: none;
    transition: border-color 0.2s ease;
    letter-spacing: 0.050em;
}

.input:focus {
    border-color: var(--accent);
}

.input::placeholder {
    color: var(--border);
}


/* ──── PROGRESS BARS ──── */

.progress-bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
    margin: 6px 0;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
}


/* ──── MODULE CARDS ──── */

.module-card {
    padding: 16px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
}

.module-card-wide {
    border-left-width: 4px;
}

.module-emoji {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.module-info {
    flex: 1;
    min-width: 0;
}

.module-name {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
}

.module-stats {
    font-size: 0.88rem;
    color: var(--text-light);
}

/* Medaille driehoek op module card */
.module-medal {
    position: absolute;
    top: 0;
    right: 0;
    width: 70px;
    height: 70px;
    clip-path: polygon(100% 0, 0 0, 100% 100%);
    opacity: 0.25;
}

.module-medal-emoji {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 1.3rem;
    z-index: 1;
}


/* ──── WELCOME MESSAGE ──── */

.welcome {
    background: linear-gradient(135deg, rgba(159, 121, 211, 0.12), rgba(117, 156, 240, 0.10));
    border-radius: var(--radius-card);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.welcome-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent);
}

.welcome-sub {
    font-size: 1rem;
    color: var(--text-light);
    margin-top: 4px;
}


/* ──── NAV BUTTONS (home page) ──── */

.nav-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--surface);
    border: none;
    border-radius: var(--radius-card);
    padding: 16px 12px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    text-decoration: none;
}

.nav-btn:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.nav-btn-icon {
    font-size: 1.5rem;
}

.nav-btn-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent);
}


/* ──── STREAK DISPLAY ──── */

.streak-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--accent);
}

.streak-flame {
    font-size: 1.6rem;
}

.streak-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
}


/* ──── MINI CHART ──── */

.mini-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 50px;
}

.mini-bar {
    flex: 1;
    border-radius: 3px 3px 0 0;
    min-width: 8px;
    transition: height 0.4s ease;
}


/* ──── STACKED BAR ──── */

.stacked-bar {
    display: flex;
    height: 28px;
    border-radius: 14px;
    overflow: visible;
    margin: 8px 0;
}

.stacked-bar > :first-child { border-radius: 14px 0 0 14px; }
.stacked-bar > :last-child { border-radius: 0 14px 14px 0; }

.stacked-segment {
    transition: width 0.6s ease, filter 0.15s ease;
    position: relative;
    cursor: pointer;
}

.stacked-segment:hover {
    filter: brightness(1.08);
}

.stacked-segment::after {
    content: attr(data-label);
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: var(--surface);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    white-space: nowrap;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.stacked-segment:hover::after {
    opacity: 1;
}


/* ──── BADGES / ACHIEVEMENTS ──── */

.badge {
    text-align: center;
    padding: 16px 12px;
}

.badge-icon {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

.badge-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent);
}

.badge-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 2px;
}

.badge-date {
    font-size: 0.78rem;
    color: var(--caption);
    margin-top: 4px;
}

.badge-locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.badge-secret {
    opacity: 0.3;
}


/* ──── QUIZ / SPEELSCHERM ──── */

.quiz-card {
    padding: 24px;
}

.quiz-question {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 16px;
    line-height: 1.5;
}

.quiz-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    align-items: center;
}

.quiz-option {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-btn);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 1rem;
}

.quiz-option:hover {
    border-color: var(--accent);
    background: rgba(84, 71, 140, 0.04);
}

.quiz-option.correct {
    border-color: var(--level-4);
    background: rgba(126, 224, 146, 0.15);
}

.quiz-option.wrong {
    border-color: var(--level-1);
    background: rgba(234, 127, 121, 0.12);
}

.quiz-timer {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 16px;
    overflow: hidden;
}

.quiz-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--level-4), var(--level-3));
    border-radius: 2px;
    transition: width 1s linear;
}


/* ──── SELF-SCORE BUTTONS ──── */

.score-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border);
    border-radius: var(--radius-btn);
    background: var(--surface);
    cursor: pointer;
    text-align: center;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.15s ease;
}

.score-btn:hover {
    transform: translateY(-1px);
}

.score-btn-fout {
    border-color: var(--level-1);
    color: var(--level-1-text);
}

.score-btn-fout:hover {
    background: rgba(234, 127, 121, 0.1);
}

.score-btn-bijna {
    border-color: var(--level-2);
    color: var(--level-2-text);
}

.score-btn-bijna:hover {
    background: rgba(255, 163, 118, 0.1);
}

.score-btn-goed {
    border-color: var(--level-4);
    color: var(--level-4-text);
}

.score-btn-goed:hover {
    background: rgba(126, 224, 146, 0.1);
}


/* ──── UITLEG BOX ──── */

.uitleg-box {
    background: rgba(84, 71, 140, 0.05);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-btn) var(--radius-btn) 0;
    padding: 14px 18px;
    margin-top: 12px;
    font-size: 0.98rem;
    line-height: 1.7;
}


/* ──── TOOLTIPS ──── */

.tooltip-word {
    border-bottom: 1px dotted var(--text-light);
    cursor: help;
    position: relative;
}

.tooltip-word:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: var(--surface);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.88rem;
    white-space: nowrap;
    z-index: 10;
    margin-bottom: 6px;
}


/* ──── ACHIEVEMENT POPUP ──── */

.achievement-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--surface);
    border-radius: var(--radius-card);
    padding: 16px 20px;
    box-shadow: 0 8px 32px rgba(84, 71, 140, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: popup-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    max-width: 320px;
    border-left: 4px solid var(--level-3);
}

@keyframes popup-slide-in {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.popup-emoji {
    font-size: 2rem;
}

.popup-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--accent);
}

.popup-desc {
    font-size: 0.9rem;
    color: var(--text-light);
}


/* ──── FLASH MESSAGES ──── */

.flash-messages {
    margin-bottom: 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-btn);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.flash-error {
    background: rgba(234, 127, 121, 0.15);
    border: 1px solid var(--level-1);
    color: var(--error);
}

.flash-success {
    background: rgba(126, 224, 146, 0.15);
    border: 1px solid var(--level-4);
    color: var(--success);
}

.flash-info {
    background: rgba(84, 71, 140, 0.08);
    border: 1px solid var(--border);
    color: var(--text-dark);
}


/* ──── SECTION LABEL ──── */

.section-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.caption {
    font-size: 0.75rem;
    color: var(--caption);
}


/* ──── GRIDS ──── */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 12px;
}


/* ──── UTILITY ──── */

.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.text-center { text-align: center; }
.text-light { color: var(--text-light); }
.text-caption { color: var(--caption); font-size: 0.75rem; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

.hidden { display: none; }


/* ──── RESPONSIVE ──── */

/* Mobile (360px+) - default */

/* Tablet (768px+) */
@media (min-width: 768px) {
    .container {
        padding: 24px;
    }

    .menu-grid {
        max-width: 600px;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .container {
        padding: 32px;
    }
}

/* Small mobile adjustments */
@media (max-width: 767px) {
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.3rem; }

    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }

    .nav-grid { grid-template-columns: repeat(2, 1fr); }

    .container {
        padding: 16px 12px;
    }
}
