/**
 * Eduplayify Template: reading_comprehension (الفهم القرائي / نصوص وأسئلة)
 * متوافق تماماً مع المتصفحات القديمة والأجهزة الضعيفة (§10).
 * يدعم 5 أنماط مهام: استخراج وتظليل، كشف وتصحيح خطأ، اختيار من متعدد، صح وخطأ، وإكمال الفراغ.
 */

.th-wrap, .rc-wrap {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    text-align: center;
    padding: 8px 12px 20px;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

/* شريط رأس القالب والمهمة الحالية */
.th-header-box, .rc-header-box {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

/* شريط تعقّب المراحل والأسئلة المتتالية */
.th-progress-bar-wrap, .rc-progress-bar-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 650px;
    margin: 0 auto 6px;
    padding: 6px 12px;
    background: #ffffff;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.th-task-badge, .rc-task-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-size: clamp(0.8rem, 1.8vw, 0.95rem);
    font-weight: 800;
    color: #0284c7;
    background: #e0f2fe;
    padding: 3px 10px;
    border-radius: 9999px;
}

.th-steps-dots, .rc-steps-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}

.th-step-dot, .rc-step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: all 0.25s ease;
}

.th-step-dot.active, .rc-step-dot.active {
    background: #0284c7;
    transform: scale(1.3);
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.5);
}

.th-step-dot.done, .rc-step-dot.done {
    background: #10b981;
}

/* عداد المتبقي ومقياس المحاولات */
.th-meta-pills, .rc-meta-pills {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.th-counter-pill, .rc-counter-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #475569;
    background: #f1f5f9;
    padding: 3px 10px;
    border-radius: 9999px;
}

.th-counter-num, .rc-counter-num {
    font-weight: 800;
    color: #0f172a;
}

/* بطاقة صيغة السؤال الحالية */
.th-prompt-card, .rc-prompt-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    padding: 10px 18px;
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
    border: 2px solid #e2e8f0;
    width: 100%;
    box-sizing: border-box;
}

.th-prompt-icon, .rc-prompt-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.th-prompt-text, .rc-prompt-text {
    margin: 0;
    font-size: 1.15rem;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 800;
    color: #1e293b;
    line-height: 1.4;
}

/* بطاقة الفقرة القرائية */
.th-passage-card, .rc-passage-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    padding: 20px 24px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
    margin: 0 auto 16px;
    position: relative;
    max-width: 860px;
    box-sizing: border-box;
    text-align: right;
}

html[dir="ltr"] .th-passage-card, html[dir="ltr"] .rc-passage-card {
    text-align: left;
}

.th-passage-text, .rc-passage-text {
    margin: 0;
    font-size: 1.35rem;
    font-size: clamp(1.15rem, 2.8vw, 1.55rem);
    line-height: 2.3;
    line-height: clamp(2.1, 4.5vw, 2.5);
    word-spacing: 0.35rem;
    color: #1e293b;
    font-weight: 600;
    direction: auto;
}

/* الكلمات التفاعلية داخل النص */
.th-word, .rc-word {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 1px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: transparent;
    color: inherit;
    text-decoration: none;
}

.th-word:hover:not(.th-highlighted):not(.th-spotted):not(.th-corrected),
.rc-word:hover:not(.rc-highlighted):not(.rc-spotted):not(.rc-corrected) {
    background: #f1f5f9;
    color: #0284c7;
    transform: translateY(-1px);
}

/* تأثير التظليل الفسفوري للإجابات الصحيحة */
.th-word.th-highlighted, .rc-word.rc-highlighted {
    background: linear-gradient(135deg, #fef08a 0%, #facc15 100%);
    color: #854d0e;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(234, 179, 8, 0.4);
    animation: th-highlighter-glow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: default;
}

@keyframes th-highlighter-glow {
    0% { transform: scale(0.95); opacity: 0.7; }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); opacity: 1; }
}

/* الكلمة الخطأ المكتشفة في نمط spot_error */
.th-word.th-spotted, .rc-word.rc-spotted {
    background: #fee2e2;
    color: #b91c1c;
    border-bottom: 3px dashed #ef4444;
    font-weight: 800;
    cursor: default;
}

/* الكلمة بعد تصحيحها بنجاح */
.th-word.th-corrected, .rc-word.rc-corrected {
    background: #dcfce7;
    color: #15803d;
    border-bottom: 3px solid #22c55e;
    font-weight: 800;
    cursor: default;
    animation: th-correct-pulse 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes th-correct-pulse {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* تأثير الهز عند اختيار كلمة خاطئة */
.th-word.th-wrong-shake, .rc-word.rc-wrong-shake {
    background: #fee2e2 !important;
    color: #dc2626 !important;
    animation: th-shake 0.4s ease-in-out;
}

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

/* نافذة التصحيح المنبثقة لنمط spot_error */
.th-modal-overlay, .rc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 16px;
    box-sizing: border-box;
}

.th-modal-card, .rc-modal-card {
    position: relative;
    background: #ffffff;
    border-radius: 20px;
    padding: 24px 22px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
    border: 2px solid #e2e8f0;
    text-align: center;
    box-sizing: border-box;
    animation: th-pop-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.th-modal-close-btn, .rc-modal-close-btn {
    position: absolute;
    top: 12px;
    inset-inline-end: 14px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.th-modal-close-btn:hover, .rc-modal-close-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.th-modal-cancel-btn, .rc-modal-cancel-btn {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 10px 18px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.th-modal-cancel-btn:hover, .rc-modal-cancel-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

@keyframes th-pop-in {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.th-modal-title, .rc-modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 12px;
}

.th-modal-word-preview, .rc-modal-word-preview {
    font-size: 1.4rem;
    font-weight: 800;
    color: #dc2626;
    background: #fef2f2;
    padding: 6px 14px;
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 16px;
    text-decoration: line-through;
}

.th-modal-input, .rc-modal-input {
    width: 100%;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    padding: 10px 14px;
    border-radius: 12px;
    border: 2px solid #cbd5e1;
    margin-bottom: 16px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.th-modal-input:focus, .rc-modal-input:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.th-modal-submit-btn, .rc-modal-submit-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    border: none;
    padding: 10px 24px;
    font-size: 1.05rem;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.th-modal-submit-btn:hover, .rc-modal-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* ========================================================
   أنماط المهام الإضافية (Multiple Choice, True/False, Blank)
   ======================================================== */

/* نمط الاختيار من متعدد Multiple Choice */
.rc-mcq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 700px;
    margin: 14px auto 8px;
}

.rc-choice-btn {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    outline: none;
}

.rc-choice-btn:hover:not(:disabled) {
    border-color: #0284c7;
    background: #f0f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.15);
}

.rc-choice-btn.rc-correct {
    background: #dcfce7 !important;
    border-color: #22c55e !important;
    color: #15803d !important;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25) !important;
}

.rc-choice-btn.rc-wrong {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #b91c1c !important;
    animation: th-shake 0.4s ease-in-out;
}

/* نمط صح وخطأ True / False */
.rc-tf-grid {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 480px;
    margin: 16px auto 8px;
}

.rc-tf-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 20px;
    border-radius: 16px;
    border: 2px solid #e2e8f0;
    background: #ffffff;
    font-size: 1.25rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.rc-tf-btn .rc-tf-icon {
    font-size: 2rem;
    line-height: 1;
}

.rc-tf-btn.rc-tf-true:hover:not(:disabled) {
    border-color: #10b981;
    background: #f0fdf4;
    color: #047857;
    transform: translateY(-2px);
}

.rc-tf-btn.rc-tf-false:hover:not(:disabled) {
    border-color: #ef4444;
    background: #fef2f2;
    color: #b91c1c;
    transform: translateY(-2px);
}

.rc-tf-btn.rc-correct {
    background: #dcfce7 !important;
    border-color: #22c55e !important;
    color: #15803d !important;
}

.rc-tf-btn.rc-wrong {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #b91c1c !important;
    animation: th-shake 0.4s ease-in-out;
}

/* نمط إكمال الفراغ Fill Blank */
.rc-blank-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 520px;
    margin: 16px auto 8px;
    background: #ffffff;
    padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
}

.rc-blank-input {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 8px 14px;
    border: 2px solid #cbd5e1;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.2s ease;
    text-align: center;
}

.rc-blank-input:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.rc-blank-submit {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    font-size: 1.05rem;
    font-weight: 800;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.rc-blank-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
}

/* شريط الإجراءات السفلي (التلميح، زر السؤال التالي) */
.th-actions-bar, .rc-actions-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.th-next-task-btn, .rc-next-task-btn {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    border: none;
    padding: 10px 22px;
    font-size: 1.05rem;
    font-weight: 800;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.th-next-task-btn:hover, .rc-next-task-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

.th-hint-bubble, .rc-hint-bubble {
    background: #fefce8;
    border: 1px solid #fef08a;
    color: #854d0e;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    max-width: 600px;
    margin: 8px auto 0;
}

/* دعم الحركة المخفضة (§10) */
@media (prefers-reduced-motion: reduce) {
    .th-word, .rc-word,
    .th-step-dot, .rc-step-dot,
    .th-modal-card, .rc-modal-card,
    .th-next-task-btn, .rc-next-task-btn,
    .rc-choice-btn, .rc-tf-btn {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
}

/* التجاوب مع شاشات الهواتف والأجهزة الصغيرة */
@media (max-width: 640px) {
    .th-wrap, .rc-wrap {
        padding: 6px 8px 14px;
    }
    .th-passage-card, .rc-passage-card {
        padding: 14px 12px;
        border-radius: 14px;
    }
    .th-passage-text, .rc-passage-text {
        font-size: 1.15rem;
        line-height: 2.1;
        word-spacing: 0.2rem;
    }
    .th-prompt-card, .rc-prompt-card {
        padding: 8px 12px;
    }
    .th-prompt-text, .rc-prompt-text {
        font-size: 1rem;
    }
    .th-word, .rc-word {
        padding: 1px 4px;
    }
    .rc-mcq-grid {
        grid-template-columns: 1fr;
    }
    .rc-tf-grid {
        gap: 12px;
    }
    .rc-tf-btn {
        padding: 12px 14px;
        font-size: 1.1rem;
    }
}

