/* ==========================================================================
   FLASHCARDS - Styles
   Design: Grid paper background, sketch-style borders, stabilo highlights
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. GRID PAPER BACKGROUND
   -------------------------------------------------------------------------- */

.mqa-flashcard-container {
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 16px 16px;
    background-color: #ffffff;
    padding: clamp(20px, 4vw, 40px);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
}

/* --------------------------------------------------------------------------
   2. SECTION TITLES WITH STABILO EFFECT
   -------------------------------------------------------------------------- */

.mqa-flashcard-section-title {
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 900;
    color: #000;
    margin-bottom: clamp(16px, 3vw, 28px);
    position: relative;
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.mqa-flashcard-section-title::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: -6px;
    right: -6px;
    height: 0.45em;
    background: #fde047;
    opacity: 0.85;
    z-index: -1;
    transform: skewX(-4deg) rotate(-1.5deg);
    /* Forme irrégulière style surlignage fait à la main */
    clip-path: polygon(
        0% 35%, 2% 15%, 4% 5%, 7% 0%, 12% 3%, 18% 0%, 24% 4%,
        30% 1%, 36% 0%, 42% 5%, 48% 2%, 54% 0%, 60% 3%, 66% 1%,
        72% 4%, 78% 0%, 84% 2%, 88% 6%, 92% 3%, 95% 8%, 97% 12%,
        99% 18%, 100% 25%, 100% 75%, 99% 82%, 97% 88%, 95% 92%,
        92% 97%, 88% 94%, 84% 98%, 78% 100%, 72% 96%, 66% 99%,
        60% 97%, 54% 100%, 48% 98%, 42% 95%, 36% 100%, 30% 99%,
        24% 96%, 18% 100%, 12% 97%, 7% 100%, 4% 95%, 2% 85%, 0% 65%
    );
}

/* --------------------------------------------------------------------------
   3. CHAPTER CARDS (selection grid)
   -------------------------------------------------------------------------- */

.mqa-flashcard-chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: clamp(16px, 3vw, 24px);
    margin-bottom: clamp(24px, 4vw, 40px);
}

.mqa-flashcard-chapter-card {
    background: #ffffff;
    border: 2px solid #000;
    border-radius: 12px;
    box-shadow: 8px 8px 0px rgba(0, 0, 0, 1);
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
    overflow: hidden;
}

.mqa-flashcard-chapter-card:hover {
    transform: translateY(-4px);
    box-shadow: 10px 12px 0px rgba(0, 0, 0, 1);
}

.mqa-flashcard-chapter-card:active {
    transform: translateY(0);
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 1);
}

.mqa-flashcard-chapter-title {
    font-size: clamp(1rem, 2vw, 1.15rem);
    font-weight: 800;
    color: #000;
    margin-bottom: 8px;
    line-height: 1.3;
}

.mqa-flashcard-chapter-count {
    font-size: 0.875rem;
    color: #555;
    font-weight: 500;
}

.mqa-flashcard-chapter-card.mqa-flashcard-chapter-active {
    border-color: #3b82f6;
    box-shadow: 8px 8px 0px rgba(59, 130, 246, 0.6);
}

/* --------------------------------------------------------------------------
   4. FLIP CARD ANIMATION
   -------------------------------------------------------------------------- */

.mqa-flashcard-flip {
    perspective: 1000px;
    width: 100%;
    max-width: 640px;
    margin: 0 auto clamp(20px, 3vw, 32px);
}

.mqa-flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 300px;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
    cursor: pointer;
}

.mqa-flashcard-inner.flipped {
    transform: rotateY(180deg);
}

.mqa-flashcard-front,
.mqa-flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 300px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: #ffffff;
    border: 3px solid #000;
    border-radius: 12px;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 4vw, 40px);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}

.mqa-flashcard-back {
    transform: rotateY(180deg);
    background: #fefce8;
}

.mqa-flashcard-label {
    position: absolute;
    top: 16px;
    left: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
}

.mqa-flashcard-question-text,
.mqa-flashcard-answer-text {
    font-size: clamp(1.05rem, 2.2vw, 1.3rem);
    font-weight: 600;
    color: #000;
    text-align: center;
    line-height: 1.6;
}

.mqa-flashcard-hint {
    position: absolute;
    bottom: 16px;
    font-size: 0.8rem;
    color: #aaa;
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   5. ACTION BUTTONS (A revoir / En cours / Acquis)
   -------------------------------------------------------------------------- */

.mqa-flashcard-actions {
    display: flex;
    gap: clamp(8px, 2vw, 16px);
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: clamp(20px, 3vw, 32px);
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.mqa-flashcard-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: clamp(10px, 2vw, 14px) clamp(18px, 3vw, 28px);
    font-weight: 800;
    font-size: clamp(0.8rem, 1.5vw, 0.95rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 2px solid #000;
    border-radius: 12px;
    box-shadow: 4px 4px 0 #000;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    flex: 1;
    min-width: 120px;
}

.mqa-flashcard-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

.mqa-flashcard-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0 #000;
}

/* A revoir (red) */
.mqa-flashcard-btn-revoir {
    background: #ef4444;
    color: #fff;
}

.mqa-flashcard-btn-revoir:hover {
    background: #dc2626;
}

/* En cours (yellow) */
.mqa-flashcard-btn-encours {
    background: #fde047;
    color: #000;
}

.mqa-flashcard-btn-encours:hover {
    background: #facc15;
}

/* Acquis (green) */
.mqa-flashcard-btn-acquis {
    background: #22c55e;
    color: #fff;
}

.mqa-flashcard-btn-acquis:hover {
    background: #16a34a;
}

/* --------------------------------------------------------------------------
   6. NAVIGATION CONTROLS
   -------------------------------------------------------------------------- */

.mqa-flashcard-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(12px, 2vw, 20px);
    margin-bottom: clamp(20px, 3vw, 32px);
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.mqa-flashcard-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 12px;
    box-shadow: 4px 4px 0 #000;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 1.2rem;
    font-weight: 800;
    color: #000;
}

.mqa-flashcard-nav-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

.mqa-flashcard-nav-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0 #000;
}

.mqa-flashcard-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: 4px 4px 0 #000;
}

.mqa-flashcard-counter {
    font-size: clamp(0.9rem, 1.8vw, 1.05rem);
    font-weight: 700;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   7. PROGRESS BARS (sketch style with stabilo effect)
   -------------------------------------------------------------------------- */

.mqa-flashcard-progress-container {
    max-width: 640px;
    margin: 0 auto clamp(24px, 4vw, 40px);
}

.mqa-flashcard-progress-bar {
    border: 2px solid #000;
    border-radius: 12px;
    overflow: hidden;
    height: 24px;
    background: #f5f5f5;
    display: flex;
    position: relative;
}

.mqa-flashcard-progress-fill {
    height: 100%;
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    /* Style stabilo - bordure irrégulière */
    clip-path: polygon(
        0% 40%, 1% 30%, 3% 25%, 6% 22%, 10% 20%, 14% 22%, 18% 20%,
        22% 22%, 26% 20%, 30% 22%, 34% 20%, 38% 22%, 42% 20%, 46% 22%,
        50% 20%, 54% 22%, 58% 20%, 62% 22%, 66% 20%, 70% 22%, 74% 20%,
        78% 22%, 82% 20%, 86% 22%, 90% 25%, 94% 30%, 97% 35%, 100% 40%,
        100% 60%, 97% 65%, 94% 70%, 90% 75%, 86% 78%, 82% 80%, 78% 78%,
        74% 80%, 70% 78%, 66% 80%, 62% 78%, 58% 80%, 54% 78%, 50% 80%,
        46% 78%, 42% 80%, 38% 78%, 34% 80%, 30% 78%, 26% 80%, 22% 78%,
        18% 80%, 14% 78%, 10% 75%, 6% 70%, 3% 65%, 1% 60%, 0% 60%
    );
    opacity: 0.85;
}

.mqa-flashcard-progress-fill-acquis {
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
    box-shadow:
        0 2px 6px rgba(34, 197, 94, 0.3),
        inset 0 -2px 3px rgba(0, 0, 0, 0.1),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.mqa-flashcard-progress-fill-encours {
    background: linear-gradient(90deg, #fde047 0%, #facc15 100%);
    box-shadow:
        0 2px 6px rgba(253, 224, 71, 0.3),
        inset 0 -2px 3px rgba(0, 0, 0, 0.1),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.mqa-flashcard-progress-fill-revoir {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
    box-shadow:
        0 2px 6px rgba(239, 68, 68, 0.3),
        inset 0 -2px 3px rgba(0, 0, 0, 0.1),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.mqa-flashcard-progress-legend {
    display: flex;
    gap: clamp(12px, 2vw, 20px);
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
}

.mqa-flashcard-progress-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mqa-flashcard-progress-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    border: 1.5px solid #000;
}

.mqa-flashcard-progress-legend-dot-acquis {
    background: #22c55e;
}

.mqa-flashcard-progress-legend-dot-encours {
    background: #fde047;
}

.mqa-flashcard-progress-legend-dot-revoir {
    background: #ef4444;
}

/* --------------------------------------------------------------------------
   8. DASHBOARD STATS
   -------------------------------------------------------------------------- */

.mqa-flashcard-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: clamp(12px, 2vw, 20px);
    margin-bottom: clamp(24px, 4vw, 40px);
}

.mqa-flashcard-stat-card {
    background: #ffffff;
    border: 2px solid #000;
    border-radius: 12px;
    box-shadow: 8px 8px 0px rgba(0, 0, 0, 1);
    padding: clamp(16px, 3vw, 24px);
    text-align: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mqa-flashcard-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 10px 12px 0px rgba(0, 0, 0, 1);
}

.mqa-flashcard-stat-number {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 900;
    color: #000;
    line-height: 1.1;
    margin-bottom: 4px;
}

.mqa-flashcard-stat-number-green {
    color: #22c55e;
}

.mqa-flashcard-stat-number-yellow {
    color: #ca8a04;
}

.mqa-flashcard-stat-number-red {
    color: #ef4444;
}

.mqa-flashcard-stat-label {
    font-size: clamp(0.75rem, 1.3vw, 0.875rem);
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   9. FILTER / MODE BUTTONS
   -------------------------------------------------------------------------- */

.mqa-flashcard-filters {
    display: flex;
    gap: clamp(8px, 1.5vw, 12px);
    flex-wrap: wrap;
    margin-bottom: clamp(16px, 3vw, 24px);
    justify-content: center;
}

.mqa-flashcard-filter-btn {
    padding: clamp(8px, 1.5vw, 10px) clamp(14px, 2.5vw, 20px);
    background: #fff;
    border: 2px solid #000;
    border-radius: 12px;
    box-shadow: 4px 4px 0 #000;
    font-weight: 700;
    font-size: clamp(0.78rem, 1.3vw, 0.88rem);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #000;
}

.mqa-flashcard-filter-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

.mqa-flashcard-filter-btn.mqa-flashcard-filter-active {
    background: #000;
    color: #fff;
}

/* --------------------------------------------------------------------------
   10. EMPTY / COMPLETION STATES
   -------------------------------------------------------------------------- */

.mqa-flashcard-empty-state {
    text-align: center;
    padding: clamp(40px, 6vw, 60px) clamp(20px, 4vw, 40px);
    max-width: 480px;
    margin: 0 auto;
}

.mqa-flashcard-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}

.mqa-flashcard-empty-title {
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    font-weight: 800;
    color: #000;
    margin-bottom: 8px;
}

.mqa-flashcard-empty-text {
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    color: #666;
    line-height: 1.5;
}

.mqa-flashcard-completion {
    text-align: center;
    padding: clamp(30px, 5vw, 50px);
    background: #fff;
    border: 3px solid #000;
    border-radius: 12px;
    box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.15);
    max-width: 480px;
    margin: 0 auto;
}

.mqa-flashcard-completion-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
    display: block;
}

.mqa-flashcard-completion-title {
    font-size: clamp(1.2rem, 2.5vw, 1.5rem);
    font-weight: 900;
    color: #000;
    margin-bottom: 8px;
}

.mqa-flashcard-completion-text {
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    color: #555;
    margin-bottom: 20px;
    line-height: 1.5;
}

.mqa-flashcard-restart-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: clamp(12px, 2vw, 16px) clamp(24px, 4vw, 36px);
    background: #000;
    color: #fff;
    border: 2px solid #000;
    border-radius: 12px;
    box-shadow: 4px 4px 0 #000;
    font-weight: 800;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.mqa-flashcard-restart-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
    background: #222;
}

/* --------------------------------------------------------------------------
   11. SHUFFLE BUTTON
   -------------------------------------------------------------------------- */

.mqa-flashcard-shuffle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #fff;
    border: 2px solid #000;
    border-radius: 12px;
    box-shadow: 4px 4px 0 #000;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #000;
}

.mqa-flashcard-shuffle-btn:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 #000;
}

/* --------------------------------------------------------------------------
   12. TOOLBAR (top bar with filters, shuffle, counter)
   -------------------------------------------------------------------------- */

.mqa-flashcard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: clamp(8px, 2vw, 16px);
    margin-bottom: clamp(16px, 3vw, 24px);
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

/* --------------------------------------------------------------------------
   13. RESPONSIVE - Mobile first
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .mqa-flashcard-chapters-grid {
        grid-template-columns: 1fr;
    }

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

    .mqa-flashcard-actions {
        flex-direction: column;
    }

    .mqa-flashcard-btn {
        width: 100%;
        flex: unset;
    }

    .mqa-flashcard-flip {
        max-width: 100%;
    }

    .mqa-flashcard-front,
    .mqa-flashcard-back {
        min-height: 250px;
        padding: clamp(20px, 4vw, 30px);
    }

    .mqa-flashcard-inner {
        min-height: 250px;
    }

    .mqa-flashcard-nav {
        gap: 10px;
    }

    .mqa-flashcard-toolbar {
        justify-content: center;
    }

    .mqa-flashcard-filters {
        width: 100%;
        justify-content: center;
    }

    .mqa-flashcard-chapter-card {
        box-shadow: 6px 6px 0px rgba(0, 0, 0, 1);
    }

    .mqa-flashcard-stat-card {
        box-shadow: 6px 6px 0px rgba(0, 0, 0, 1);
    }
}

@media (max-width: 480px) {
    .mqa-flashcard-container {
        padding: clamp(12px, 3vw, 20px);
    }

    .mqa-flashcard-dashboard {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .mqa-flashcard-stat-number {
        font-size: 1.6rem;
    }

    .mqa-flashcard-front,
    .mqa-flashcard-back {
        min-height: 220px;
    }

    .mqa-flashcard-inner {
        min-height: 220px;
    }

    .mqa-flashcard-chapter-card {
        padding: 18px;
        box-shadow: 5px 5px 0px rgba(0, 0, 0, 1);
    }

    .mqa-flashcard-progress-legend {
        justify-content: center;
    }
}

/* --------------------------------------------------------------------------
   14. ANIMATIONS
   -------------------------------------------------------------------------- */

@keyframes mqa-flashcard-fadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mqa-flashcard-animate-in {
    animation: mqa-flashcard-fadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.mqa-flashcard-shake {
    animation: mqa-flashcard-shake 0.5s ease-in-out;
}

/* --------------------------------------------------------------------------
   15. BACK TO CHAPTERS LINK
   -------------------------------------------------------------------------- */

.mqa-flashcard-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: clamp(16px, 3vw, 24px);
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
    font-weight: 700;
    color: #000;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.mqa-flashcard-back-link:hover {
    opacity: 0.7;
}
