/* Custom CSS voor Echt Koreaans E-Learning Platform - Optimized Cards, Typography & Mobile Architecture */

/* ================================================== */
/* 0. Globale Schaal & Typografie Boost              */
/* ================================================== */
html {
    font-size: 16px; /* Standaard basis voor responsieve schaling */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    height: 100vh;
    height: 100dvh; /* Voorkomt scrollen buiten scherm op iOS Safari & Android Chrome */
    margin: 0;
    padding: 0;
    font-size: 1rem;
    line-height: 1.6;
    color: #1e293b;
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: manipulation;
}

/* Titels opschalen */
h1, .text-3xl { font-size: 2.1rem !important; font-weight: 800 !important; }
h2, .text-2xl { font-size: 1.6rem !important; font-weight: 700 !important; }
h3, .text-xl  { font-size: 1.35rem !important; font-weight: 700 !important; }

/* Overriding van Tailwind extreem kleine tekst-utilities (text-[10px], text-xs, etc.) */
.text-\[10px\], .text-\[11px\], .text-xs {
    font-size: 0.875rem !important;
}

/* ================================================== */
/* 1. Grote Leesbare Hoofdstukteksten                */
/* ================================================== */
#reader-content {
    font-size: 1.15rem; /* ~21px comfortabel lezen */
    line-height: 1.8;
    overflow-wrap: anywhere;
    word-break: keep-all;
    max-width: 100%;
}

#reader-content p {
    font-size: 1.15rem !important;
    line-height: 1.8 !important;
    margin-bottom: 1.1rem !important;
}

#reader-content ul, 
#reader-content ol {
    font-size: 1.15rem !important;
    margin-top: 0.75rem !important;
    margin-bottom: 1.1rem !important;
}

#reader-content li {
    font-size: 1.15rem !important;
    line-height: 1.75 !important;
    margin-bottom: 0.5rem !important;
}

#reader-content h1 { font-size: 2.3rem !important; font-weight: 800 !important; color: #0f172a !important; margin-bottom: 1rem !important; }
#reader-content h2 { font-size: 1.8rem !important; font-weight: 800 !important; color: #0f172a !important; margin-top: 1.5rem !important; margin-bottom: 0.85rem !important; }
#reader-content h3 { font-size: 1.45rem !important; font-weight: 700 !important; color: #0f172a !important; margin-top: 1.25rem !important; margin-bottom: 0.75rem !important; }

/* ================================================== */
/* 2. SPRAAKBLOKKEN FIX (Niet meer te hoog in de zin) */
/* ================================================== */
.korean-word {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    vertical-align: middle;
    gap: 4px;
    background-color: rgba(2, 132, 199, 0.08);
    color: #0369a1;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
    font-size: 1em !important;            /* Past zich precies aan op zinsgrootte */
    padding: 0.12rem 0.5rem !important;   /* Slank & plat zodat het niet te hoog is */
    line-height: 1.3;
    border-radius: 0.375rem;
    border-bottom: 2px solid #0284c7;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    user-select: none;
    white-space: normal;                  /* Voorkomt dat lange zinnen uitsteken */
    word-break: keep-all;                 /* Breekt Koreaans af op woordspaties i.p.v. midden in tekens */
    overflow-wrap: anywhere;              /* Breekt de regel af als de zin breder is dan het scherm */
    max-width: 100%;                      /* Garandeert dat het blok nooit breder wordt dan het scherm */
    touch-action: manipulation;
}

.korean-word:hover,
.korean-word:active {
    background-color: #0284c7;
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.2);
}

/* Audio Actieve Status (Rode Puls-Animatie) */
@keyframes pulseAudio {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4);
        transform: scale(1.04);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(225, 29, 72, 0);
        transform: scale(1);
    }
}

.korean-word.speaking, 
.btn-audio.speaking {
    background-color: #e11d48 !important;
    color: #ffffff !important;
    border-color: #be123c !important;
    pointer-events: none !important;
    animation: pulseAudio 1.2s infinite ease-in-out !important;
}

/* ================================================== */
/* 3. Progressieve Evaluatie Blokken & Kaarten        */
/* ================================================== */
.block-container {
    transition: all 0.2s ease-in-out;
    padding: 1.6rem 1.8rem !important;
    border-radius: 1.25rem !important;
    margin: 1.5rem 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03) !important;
}

.block-container.status-easy {
    border-left: 6px solid #10b981 !important;
    background-color: rgba(240, 253, 244, 0.7) !important;
}

.block-container.status-medium {
    border-left: 6px solid #f59e0b !important;
    background-color: rgba(254, 252, 232, 0.7) !important;
}

.block-container.status-eli5 {
    border-left: 6px solid #6366f1 !important;
    background-color: rgba(238, 242, 255, 0.7) !important;
}

.block-feedback-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem !important;
    padding-top: 1.1rem !important;
    border-top: 1px dashed #cbd5e1;
}

/* ================================================== */
/* 4. Grammatica & Cultuur Callout Boxes              */
/* ================================================== */
.note-advanced,
.note-culture {
    padding: 1.5rem 1.75rem;
    border-radius: 0 1rem 1rem 0;
    margin: 1.5rem 0;
    font-size: 1.05rem;
}

.note-advanced {
    border-left: 6px solid #8b5cf6;
    background-color: #f5f3ff;
}

.note-advanced-title {
    color: #6d28d9;
    font-weight: 800;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.note-culture {
    border-left: 6px solid #d97706;
    background-color: #fef3c7;
}

.note-culture-title {
    color: #b45309;
    font-weight: 800;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ================================================== */
/* 5. Custom Extra Drawers                            */
/* ================================================== */
.extra-drawer {
    transition: all 0.25s ease-in-out;
    padding: 1.35rem;
    border-radius: 1rem;
    font-size: 1.05rem;
}

.drawer-medium {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.drawer-eli5 {
    background-color: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
}

/* ================================================== */
/* 6. Header, Sidebar & Topbar Controls               */
/* ================================================== */
header {
    padding-top: max(0.5rem, env(safe-area-inset-top)) !important;
    padding-bottom: 0.85rem !important;
}

header select, header input, header label, header span {
    font-size: 0.95rem !important;
}

#logo-btn {
    font-size: 1.05rem !important;
    padding: 0.6rem 1.2rem !important;
    border-radius: 0.9rem !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.35rem;
    border-radius: 0.85rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #475569;
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.nav-btn:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    transform: translateX(3px);
}

.nav-btn.active {
    background-color: #0284c7;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.nav-icon {
    font-size: 1.35rem;
}

/* Studietip Widget in sidebar */
#tip-widget {
    padding: 1.1rem !important;
    border-radius: 1rem !important;
}

#tip-widget * {
    font-size: 0.925rem !important;
    line-height: 1.5 !important;
}

#tip-widget .font-bold {
    font-size: 0.95rem !important;
}

#tip-counter {
    font-size: 0.85rem !important;
}

/* ================================================== */
/* 7. Dashboard Kaarten & Statistieken                */
/* ================================================== */
.stat-number, .text-4xl {
    font-size: 2.75rem !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
}

.stat-label {
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em;
}

.roadmap-card, .chapter-card {
    padding: 1.25rem 1.5rem !important;
    border-radius: 1rem !important;
    transition: all 0.2s ease-in-out !important;
}

.roadmap-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06) !important;
}

/* ================================================== */
/* 8. Hangul SVG Karakters & Karakterkaarten          */
/* ================================================== */
.stroke-img {
    width: 6rem !important;
    height: 6rem !important;
    max-width: 100%;
    object-fit: contain;
    margin: 0.5rem auto;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.1));
    transition: transform 0.2s ease, filter 0.2s ease;
}

.stroke-img:hover {
    transform: scale(1.12);
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
}

.hangul-card, .character-card {
    padding: 1.5rem 1rem !important;
    border-radius: 1.15rem !important;
    min-height: 11rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease-in-out !important;
}

.hangul-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08) !important;
}

.hangul-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: #0f172a;
    margin-top: 0.5rem;
}

.hangul-subtext {
    font-size: 0.95rem !important;
    color: #64748b;
    line-height: 1.4;
}

/* Batchim Badges ("Klinkt als: ...") & Voorbeeldpills */
#hangul-container div.rounded-xl,
#hangul-container div.rounded-2xl,
#hangul-container .badge,
#hangul-container span.rounded-full,
#hangul-container span.rounded-lg,
#hangul-container span.rounded-md {
    font-size: 0.95rem !important;
    padding: 0.35rem 0.75rem !important;
}

#hangul-container p,
#hangul-container span,
#hangul-container div {
    font-size: 1rem;
}

#hangul-container .font-mono {
    font-size: 1.05rem !important;
}

/* ================================================== */
/* 9. Dialogen & Flitskaarten                         */
/* ================================================== */
.dialogue-line {
    display: flex;
    align-items: flex-start;
    gap: 1.1rem;
    padding: 1.1rem 1.35rem;
    border-radius: 1rem;
    margin-bottom: 0.85rem;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    font-size: 1rem;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: keep-all;
}

.dialogue-speaker {
    font-weight: 700;
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.perspective-1000 {
    perspective: 1000px;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, 
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 1.25rem;
    padding: 2.25rem;
}

.flashcard-back {
    transform: rotateY(180deg);
}

/* ================================================== */
/* 10. MOBIELE ADAPTIE (SCHERMEN < 768px)            */
/* ================================================== */
/* ================================================== */
/* MOBIELE ADAPTIE (SCHERMEN < 768px)                */
/* ================================================== */
@media (max-width: 767px) {
    /* Header layout compacter op mobiel */
    header .max-w-\[1600px\] {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.4rem;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    header .flex.items-center.space-x-4 {
        width: 100%;
        justify-content: space-between;
        gap: 0.3rem;
        space-x: 0 !important;
    }

    #tts-rate {
        width: 3.2rem !important;
    }

    #tts-gender, #tts-rate-val {
        font-size: 0.75rem !important;
    }

    /* Slanke Horizontale Tabbar (Best practice voor mobiel) */
    aside {
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        padding: 0.35rem 0.5rem !important;
        border-right: none !important;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
        flex-shrink: 0 !important;
        background-color: #ffffff;
    }

    #main-nav {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        gap: 0.35rem !important;
        padding-bottom: 0.1rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    #main-nav::-webkit-scrollbar {
        display: none;
    }

    /* Slanke, lage knoppen die nooit verticaal uitgroeien */
    .nav-btn {
        white-space: nowrap !important;
        padding: 0.4rem 0.75rem !important;
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
        border-radius: 0.6rem !important;
        flex-shrink: 0 !important;
        width: auto !important;
        height: auto !important;
    }

    .nav-btn:hover {
        transform: none !important;
    }

    #tip-widget {
        display: none !important;
    }

    /* Hoofdvenster opvulling sterk verminderd zodat content breed is op mobiel */
    main {
        flex: 1 1 auto !important;
        width: 100% !important;
        padding: 0.5rem !important; /* Minder grijze rand aan zijkanten */
        /* Royale onderruimte zodat knoppen niet achter Android terug/home-knoppen vallen */
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 20px)) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Leesvlak & Kaart opvulling compacter maken */
    #reader-content {
        padding: 0.85rem !important;
    }

    .block-container {
        padding: 0.85rem 0.75rem !important;
        margin: 0.85rem 0 !important;
    }

    /* Feedbackbalk ("Begrijp je dit onderdeel?") onder elkaar stapelen */
    .block-feedback-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.6rem !important;
    }

    .block-feedback-bar > div,
    .block-feedback-bar button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Dashboard Roadmap Mobiel Fix */
    #dashboard-roadmap {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    .stat-number, .text-4xl {
        font-size: 1.85rem !important;
    }
}

/* Touch Safety Padding onderaan iPhones / Android Gesture Bar */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    main {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    }
}