/* =============================================
   قضايا بسيطة — واجهة تيك توك (سوايب عمودي)
   Approach: one slide visible at a time (display toggle)
   ============================================= */

/* ===== قفل الصفحة ===== */
html, body, .qmf-body {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    height: 100% !important;
    width: 100% !important;
    background: #0a0a0a !important;
    touch-action: none;
    overscroll-behavior: none;
}

/* ===== الحاوية الرئيسية ===== */
.qmf {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    background: #0a0a0a;
    overflow: hidden;
    direction: rtl;
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.qmf * { box-sizing: border-box; margin: 0; padding: 0; }

.qmf-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ===== شريحة القضية الواحدة ===== */
.qmf-slide {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;               /* مخفية بالافتراض */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 20px 80px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.qmf-slide.active {
    display: flex;               /* الشريحة الحالية فقط مرئية */
}

/* انتقال الظهور */
.qmf-slide.slide-in-up {
    animation: qmf-slideInUp 0.35s ease forwards;
}
.qmf-slide.slide-in-down {
    animation: qmf-slideInDown 0.35s ease forwards;
}

@keyframes qmf-slideInUp {
    from { transform: translateY(60px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
@keyframes qmf-slideInDown {
    from { transform: translateY(-60px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

.qmf-slide-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 0;
}

/* خلفيات متنوعة */
.qmf-slide[data-theme="0"] .qmf-slide-bg { background: linear-gradient(160deg, #0f172a 0%, #1e1b4b 40%, #312e81 100%); }
.qmf-slide[data-theme="1"] .qmf-slide-bg { background: linear-gradient(160deg, #0c0a09 0%, #292524 40%, #44403c 100%); }
.qmf-slide[data-theme="2"] .qmf-slide-bg { background: linear-gradient(160deg, #0f172a 0%, #0f766e 40%, #134e4a 100%); }
.qmf-slide[data-theme="3"] .qmf-slide-bg { background: linear-gradient(160deg, #18181b 0%, #3f3f46 40%, #27272a 100%); }
.qmf-slide[data-theme="4"] .qmf-slide-bg { background: linear-gradient(160deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%); }
.qmf-slide[data-theme="5"] .qmf-slide-bg { background: linear-gradient(160deg, #0d0d0d 0%, #1a0000 40%, #330000 100%); }
.qmf-slide[data-theme="6"] .qmf-slide-bg { background: linear-gradient(160deg, #0a0a23 0%, #1b1b3a 40%, #2d2d5e 100%); }
.qmf-slide[data-theme="7"] .qmf-slide-bg { background: linear-gradient(160deg, #0f0f0f 0%, #1a1a2e 40%, #0f3443 100%); }

.qmf-slide-bg::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.03) 0%, transparent 60%),
                radial-gradient(circle at 80% 80%, rgba(255,255,255,0.02) 0%, transparent 50%);
}

/* ===== المحتوى ===== */
.qmf-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.qmf-emoji {
    font-size: 48px;
    margin-bottom: 12px;
    animation: qmf-float 3s ease-in-out infinite;
}

@keyframes qmf-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.qmf-type-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
    margin-bottom: 12px;
}

.qmf-title {
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.4;
    text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.qmf-text {
    font-size: 15px;
    line-height: 1.7;
    color: rgba(255,255,255,0.85);
    margin-bottom: 24px;
    padding: 0 8px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* ===== الخيارات ===== */
.qmf-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.qmf-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 14px;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.12);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.qmf-option:active { transform: scale(0.97); }

.qmf-option-letter {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.qmf-option-text {
    flex: 1;
    text-align: right;
}

.qmf-option.disabled { pointer-events: none; cursor: default; }

.qmf-option.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
}
.qmf-option.correct .qmf-option-letter {
    background: #10b981;
    color: #fff;
}

.qmf-option.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}
.qmf-option.wrong .qmf-option-letter {
    background: #ef4444;
    color: #fff;
}

.qmf-option.not-selected { opacity: 0.4; }

/* ===== التعليل ===== */
.qmf-explanation {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    line-height: 1.7;
    color: rgba(255,255,255,0.75);
    text-align: right;
    display: none;
    animation: qmf-fadeUp 0.4s ease;
}

.qmf-explanation.show { display: block; }

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

/* ===== شريط الأكشنز السفلي ===== */
.qmf-actions {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 36px;
    align-items: center;
    padding: 10px 20px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.3) 60%, transparent 100%);
}

.qmf-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.7);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 4px;
}

.qmf-action-btn:active { transform: scale(0.85); }

.qmf-action-btn svg {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    transition: all 0.2s ease;
}

.qmf-like.active { color: #ef4444; }
.qmf-like.active svg { fill: #ef4444; stroke: #ef4444; }

.qmf-dislike.active { color: #60a5fa; }
.qmf-dislike.active svg { fill: #60a5fa; stroke: #60a5fa; }

.qmf-action-count {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.6);
}

/* ===== عداد التقدم ===== */
.qmf-progress {
    position: fixed;
    top: 12px; right: 12px;
    z-index: 100;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    font-weight: 600;
}

/* ===== زر الخروج ===== */
.qmf-close {
    position: fixed;
    top: 12px; left: 12px;
    z-index: 100;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== شاشة التحميل ===== */
.qmf-loader {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    z-index: 50;
    transition: opacity 0.4s ease;
}

.qmf-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.qmf-loader-icon {
    font-size: 48px;
    animation: qmf-pulse 1.5s ease-in-out infinite;
}

.qmf-loader-text {
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    margin-top: 12px;
}

@keyframes qmf-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}

/* ===== مؤشر السوايب ===== */
.qmf-swipe-hint {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: rgba(255,255,255,0.35);
    font-size: 11px;
    animation: qmf-hintBounce 2s ease-in-out infinite;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.qmf-swipe-hint.hidden { opacity: 0; }

@keyframes qmf-hintBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-8px); }
}

/* ===== بوب-أب النقاط ===== */
.qmf-points-popup {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 200;
    font-size: 48px;
    font-weight: 800;
    color: #34d399;
    text-shadow: 0 4px 20px rgba(16, 185, 129, 0.5);
    pointer-events: none;
    opacity: 0;
}

.qmf-points-popup.show {
    animation: qmf-pointsIn 1s ease forwards;
}

@keyframes qmf-pointsIn {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    30%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    60%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -60%) scale(0.8); opacity: 0; }
}

/* ===== شاشة انتهاء القضايا ===== */
.qmf-end {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    padding: 40px;
}

.qmf-end-emoji { font-size: 64px; margin-bottom: 16px; }
.qmf-end-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.qmf-end-stats { color: rgba(255,255,255,0.6); font-size: 14px; line-height: 1.8; margin-bottom: 24px; }
.qmf-end-btn {
    padding: 12px 32px;
    border-radius: 30px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

/* ===== ريسبونسف ===== */
@media (min-width: 768px) {
    .qmf-content { max-width: 480px; }
    .qmf-title { font-size: 22px; }
    .qmf-text { font-size: 16px; }
    .qmf-option { padding: 16px 22px; font-size: 16px; }
    .qmf-actions { gap: 48px; }
}

/* =============================================
   نظام التحفيز (Gamification)
   ============================================= */

/* ===== شريط HUD العلوي ===== */
.qmf-hud {
    position: fixed;
    top: 12px;
    left: 54px;
    right: 54px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 24px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    transition: opacity 0.4s ease;
}

.qmf-hud.hidden { opacity: 0; pointer-events: none; }

.qmf-hud-rank {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.qmf-rank-icon { font-size: 18px; }
.qmf-rank-name {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
}

.qmf-hud-bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    overflow: hidden;
    min-width: 40px;
}

.qmf-hud-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899);
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.qmf-hud-points {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 1px 4px rgba(251, 191, 36, 0.3);
}

/* ===== عداد السلسلة ===== */
.qmf-streak {
    position: fixed;
    top: 54px;
    right: 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    font-weight: 700;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.qmf-streak.active {
    opacity: 1;
    color: #fb923c;
    background: rgba(251, 146, 60, 0.15);
    border: 1px solid rgba(251, 146, 60, 0.25);
}

.qmf-streak.hot {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

.qmf-streak.fire {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.3);
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.25);
    animation: qmf-fireGlow 1s ease-in-out infinite alternate;
}

@keyframes qmf-fireGlow {
    from { box-shadow: 0 0 12px rgba(251, 191, 36, 0.2); }
    to   { box-shadow: 0 0 20px rgba(251, 191, 36, 0.4); }
}

.qmf-streak.bump {
    animation: qmf-streakBump 0.35s ease;
}

@keyframes qmf-streakBump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.qmf-streak.lost {
    animation: qmf-streakLost 0.6s ease;
    color: #ef4444;
}

@keyframes qmf-streakLost {
    0%   { transform: scale(1); opacity: 1; }
    30%  { transform: scale(1.2) rotate(-5deg); opacity: 1; }
    60%  { transform: scale(0.9) rotate(3deg); opacity: 0.6; }
    100% { transform: scale(1) rotate(0); opacity: 0.5; }
}

.qmf-streak-fire { font-size: 16px; }
.qmf-streak.hidden { opacity: 0; pointer-events: none; }

/* ===== المضاعف ===== */
.qmf-multiplier {
    position: fixed;
    top: 54px;
    left: 12px;
    z-index: 100;
    padding: 5px 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
    border: 1px solid rgba(168, 85, 247, 0.3);
    font-size: 15px;
    font-weight: 800;
    color: #c084fc;
    text-shadow: 0 0 8px rgba(192, 132, 252, 0.4);
    transition: all 0.3s ease;
}

.qmf-multiplier.hidden { opacity: 0; pointer-events: none; }

.qmf-multiplier.bump {
    animation: qmf-multiBump 0.4s ease;
}

@keyframes qmf-multiBump {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35) rotate(-3deg); }
    100% { transform: scale(1); }
}

/* ===== احتفال الترقية ===== */
.qmf-levelup {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 36px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(251, 191, 36, 0.4);
    pointer-events: none;
    opacity: 0;
}

.qmf-levelup.hidden { display: none; }

.qmf-levelup.animate {
    display: flex;
    animation: qmf-levelUpIn 2.5s ease forwards;
}

@keyframes qmf-levelUpIn {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    15%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    25%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    75%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

.qmf-levelup-icon { font-size: 44px; }
.qmf-levelup-text {
    font-size: 18px;
    font-weight: 800;
    color: #fbbf24;
    text-shadow: 0 2px 10px rgba(251, 191, 36, 0.5);
}
.qmf-levelup-rank {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

/* ===== شاشة النهاية المحسّنة ===== */
.qmf-end-rank {
    font-size: 18px;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 20px;
    text-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.qmf-end-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 16px;
}

.qmf-stat-card {
    padding: 14px 10px;
    border-radius: 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}

.qmf-stat-value {
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.qmf-stat-label {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

.qmf-end-total {
    font-size: 13px;
    color: rgba(255,255,255,0.45);
    margin-bottom: 20px;
}

/* تكيّف عداد التقدم مع HUD */
.qmf-progress {
    top: auto;
    bottom: 65px;
    right: 12px;
}
