/* ==========================================================
   ثيم المتسابق المحترف أنس - رياضيات (Hero Racing Champion Theme)
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@400;600;800&family=Tajawal:wght@500;700;800;900&display=swap');

:root {
    --bg-color: #0a192f;
    --bg-color-top: #0a192f;
    --bg-color-bottom: #112240;
    --primary: #0f172a;
    --primary-color: #0f172a;
    --primary-dark: #020617;
    --secondary: #1e293b;
    --secondary-dark: #0f172a;
    --accent: #ffca28;
    --accent-dark: #d97706;
    --success: #10b981;
    --rose: #ef4444;
    --text: #f8fafc;
    --text-color: #f8fafc;
    --text-light: #e2e8f0;
    --text-dark: #ffffff;
    --white: #ffffff;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
    --border-dark: 2px solid rgba(255, 255, 255, 0.2);
    --car-red: #ef4444;
    --car-blue: #ffd700;
    --car-green: #10b981;
    --car-purple: #8b5cf6;
    --card-bg: rgba(30, 41, 59, 0.85);

    /* Legacy color compatibility */
    --candy-purple: #1e293b;
    --candy-blue: #f59e0b;
    --candy-pink: #ef4444;
    --candy-green: #10b981;
    --candy-orange: #f59e0b;
    --shadow-pink: rgba(239, 68, 68, 0.5);
    --shadow-blue: rgba(255, 202, 40, 0.7);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Baloo Bhaijaan 2', 'Tajawal', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background: linear-gradient(135deg, #0b0f19, #001a33, #330000);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text);
    overflow-x: hidden;
    padding-bottom: 120px;
    position: relative;
    font-size: 26px; /* Increased font size for better readability of diacritics */
    line-height: 1.8;
}

/* ================== خلفية التطبيق الحركية ================== */
.enchanted-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.magic-sparkle {
    position: absolute;
    color: #FFCA28;
    opacity: 0.15 !important;
    animation: none !important;
}

.bg-shell {
    position: absolute;
    font-size: 2.5rem;
    color: rgba(129, 212, 250, 0.4);
    opacity: 0.15 !important;
    animation: none !important;
}

/* ================== العناوين والنصوص المتوهجة ================== */
.welcome-msg h2, .sosawy-logo, .lesson-overlay h2 {
    color: var(--white);
    font-size: 4.5rem;
    font-weight: 900;
    text-align: center;
    text-shadow: 0 0 10px var(--accent), 0 0 20px var(--car-blue);
    margin: 20px 0;
    animation: float-wave 3s ease-in-out infinite alternate;
    position: relative;
    z-index: 10;
}

/* ================== الهيدر العلوي ================== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px 30px;
    background: rgba(15, 23, 42, 0.85);
    border: 2px solid var(--accent);
    border-radius: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.4);
    margin: 20px auto 40px;
    max-width: 1100px;
    position: relative;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.stars-panel {
    background: var(--secondary);
    padding: 10px 30px;
    border-radius: 50px;
    border: 3px solid var(--accent);
    box-shadow: 0 6px 0 var(--secondary-dark);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s;
}

.stars-panel:hover {
    transform: translateY(-5px) scale(1.05);
}

.sosawy-tool-btn {
    background: linear-gradient(135deg, #E23636, #8B0000);
    border: 3px solid var(--white);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    font-size: 2rem;
    color: var(--white);
    box-shadow: 0 6px 0 #8B0000;
    cursor: pointer;
    transition: all 0.2s;
}

.sosawy-tool-btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #8B0000;
}

/* ================== البطاقات (سلسلة إطارات السيارات والعقد المضيئة) ================== */
.sosawy-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

.sosawy-grid, .sosawy-lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
    padding: 20px 0;
}

.chapter-card, .lesson-card, .mode-card {
    background-color: transparent;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="48" fill="%23222" stroke="%23111" stroke-width="2"/><circle cx="50" cy="50" r="42" fill="none" stroke="%23333" stroke-width="8" stroke-dasharray="10,4"/><circle cx="50" cy="50" r="25" fill="%23ddd" stroke="%23999" stroke-width="4"/><circle cx="50" cy="50" r="18" fill="%23bbb"/><circle cx="50" cy="50" r="8" fill="%23888"/><circle cx="50" cy="50" r="3" fill="%23444"/></svg>');
    background-size: cover;
    border: 4px solid var(--accent);
    border-radius: 50%;
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.6), inset 0 0 15px rgba(56, 189, 248, 0.3);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 270px;
    height: 270px;
    margin: 0 auto;
    z-index: 2;
}

.chapter-card::before, .lesson-card::before, .mode-card::before {
    display: none;
}

.chapter-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
}

.chapter-icon img {
    width: 120px !important;
    height: 120px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 4px solid var(--accent) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8), 0 0 15px rgba(56, 189, 248, 0.5) !important;
    background: #0B192C !important;
    transition: transform 0.3s;
}

.chapter-card:hover .chapter-icon img {
    transform: scale(1.1) rotate(5deg);
}

.chapter-card h3, .lesson-card h3 { 
    font-size: 1.6rem; 
    font-weight: 900; 
    margin-bottom: 5px;
    color: var(--white);
    text-shadow: 1px 1px 4px rgba(0,0,0,0.8);
}

.chapter-card p, .lesson-card p { 
    font-size: 1.2rem; 
    font-weight: 800; 
    color: var(--accent); 
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.chapter-card:hover, .lesson-card:hover, .mode-card:hover {
    animation: softPulse 1.5s infinite;
    border-color: #FFFFFF;
    box-shadow: 0 0 30px rgba(226, 54, 54, 0.9), inset 0 0 20px rgba(255,255,255,0.5);
    transform: scale(1.05);
}

.chapter-card:active, .lesson-card:active, .mode-card:active {
    transform: translateY(5px);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

/* ================== أزرار التفاعل والإجراءات ================== */
.btn-action {
    background: linear-gradient(135deg, #0B192C, #0D47A1); 
    color: var(--white); 
    border: 4px solid #E23636; 
    border-radius: 30px; 
    padding: 15px 35px;
    font-size: 2.2rem;
    font-weight: 900;
    box-shadow: 0 5px 15px rgba(13, 71, 161, 0.5), inset 0 0 10px rgba(226,54,54,0.4); 
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.btn-action.success {
    background: linear-gradient(135deg, #10b981, #065f46);
    border-color: #69F0AE;
}

.btn-action:hover {
    transform: translateY(-5px);
    background: linear-gradient(135deg, #E23636, #8B0000);
    box-shadow: 0 15px 25px rgba(226, 54, 54, 0.7), inset 0 0 20px rgba(255,255,255,0.4); 
    border-color: #FFFFFF; 
}

.btn-action:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* ================== نافذة الدروس (Lesson Overlay) ================== */
.sosawy-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 25, 47, 0.96);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 30px;
    overflow-y: auto;
    backdrop-filter: blur(10px);
}

.sosawy-overlay.hidden {
    display: none;
}

.close-btn {
    background: linear-gradient(135deg, #E23636, #8B0000);
    color: var(--white);
    border: 3px solid var(--white);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    font-size: 2.5rem;
    font-weight: 900;
    box-shadow: 0 6px 15px rgba(226, 54, 54, 0.5);
    cursor: pointer;
    align-self: flex-start;
    margin-bottom: 20px;
    transition: all 0.2s;
}
.close-btn:hover { transform: scale(1.1) translateY(-5px); box-shadow: 0 10px 25px rgba(226, 54, 54, 0.8); }
.close-btn:active { transform: translateY(6px); box-shadow: none; }

/* ================== الحركات والانتقالات ================== */
@keyframes float-wave {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-8px) rotate(2deg); }
    100% { transform: translateY(0px) rotate(-2deg); }
}

@keyframes pop {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

.bounce-in {
    animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes softPulse {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(56, 189, 248, 0.6), inset 0 0 15px rgba(56, 189, 248, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 0 35px rgba(226, 54, 54, 0.9), inset 0 0 25px rgba(255,255,255,0.6); }
    100% { transform: scale(1); box-shadow: 0 0 20px rgba(56, 189, 248, 0.6), inset 0 0 15px rgba(56, 189, 248, 0.3); }
}

/* ================== زر عودة للمنصة ================== */
.home-btn-sea {
    background: linear-gradient(135deg, var(--primary-color), var(--bg-color-bottom));
    color: var(--white);
    padding: 10px 25px;
    border: 3px solid var(--accent);
    border-radius: 30px;
    text-decoration: none;
    font-weight: 900;
    font-size: 1.5rem;
    box-shadow: 0 6px 15px rgba(56, 189, 248, 0.6);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.home-btn-sea:hover {
    transform: translateY(-5px) scale(1.05);
    background: linear-gradient(135deg, #E23636, #8B0000);
    box-shadow: 0 10px 20px rgba(226, 54, 54, 0.8);
    border-color: #FFFFFF;
}
.home-btn-sea:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* ================== التذييل (Footer) ================== */
.sosawy-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    width: 100%;
    position: relative;
    z-index: 10;
}

.sosawy-footer a {
    color: var(--accent);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.2s;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--accent);
    padding: 10px 25px;
    border-radius: 20px;
    display: inline-block;
}

.sosawy-footer a:hover {
    background: var(--accent);
    color: #0f172a;
    box-shadow: 0 0 15px var(--accent);
}

@media (max-width: 768px) {
    .welcome-msg h2, .sosawy-logo, .lesson-overlay h2 { font-size: 2.2rem !important; }
    .main-header { flex-direction: column; gap: 15px; border-radius: 30px; padding: 20px 15px;}
    .chapter-icon { font-size: 4.5rem; }
    .chapter-card h3 { font-size: 1.4rem; }
    .btn-action { font-size: 1.8rem !important; padding: 15px 20px !important; }
    .sosawy-overlay { padding: 15px; }
    .chapter-card, .lesson-card, .mode-card { width: 220px; height: 220px; padding: 15px 10px; }
}


@media (max-width: 480px) {
    .welcome-msg h2, .sosawy-logo, .lesson-overlay h2 { font-size: 2rem; }
    .chapter-card, .lesson-card, .mode-card { width: 190px; height: 190px; padding: 10px; }
    .chapter-icon img { width: 90px !important; height: 90px !important; }
}

/* ==========================================================
   تصميم الهيدر الاحترافي الفائق (Ultra-Professional Header)
   ========================================================== */
.app-header {
    max-width: 1050px;
    margin: 20px auto 35px;
    padding: 1.25rem 2rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-radius: 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 255, 255, 0.1),
                0 0 25px rgba(255, 202, 40, 0.4);
    border: 1.5px solid rgba(255, 202, 40, 0.5);
    position: relative;
    overflow: hidden;
    direction: rtl;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), var(--car-red), transparent);
    animation: header-shimmer 4s infinite linear;
}

@keyframes header-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 2;
}

/* صورة الملف الشخصي / الأفاتار */
.header-profile-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile-icon {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a192f, #ffd700);
    padding: 3px;
    box-shadow: 0 0 20px rgba(255, 202, 40, 0.7);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.user-profile-icon::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 202, 40, 0.8);
    animation: spin-slow 15s linear infinite;
    pointer-events: none;
}

@keyframes spin-slow {
    100% { transform: rotate(360deg); }
}

.user-profile-icon:hover {
    transform: scale(1.1) rotate(6deg);
    box-shadow: 0 0 30px rgba(255, 202, 40, 0.9), 0 0 10px rgba(239, 68, 68, 0.6);
}

.user-profile-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background: #0f172a;
}

.profile-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.profile-tag {
    background: linear-gradient(135deg, rgba(255, 202, 40, 0.25), rgba(239, 68, 68, 0.2));
    border: 1px solid rgba(255, 202, 40, 0.5);
    color: #ffd700;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 3px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* العنوان الرئيسي للمنصة */
.header-title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
}

.header-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    margin: 0;
    font-size: clamp(1.8rem, 3.5vw, 2.4rem);
    font-weight: 900;
    background: linear-gradient(135deg, #ffffff 30%, #ffd700 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(255, 202, 40, 0.6);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.header-subtitle {
    margin-top: 4px;
    font-size: 0.95rem;
    color: rgba(248, 250, 252, 0.9);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 16px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.speaker-icon-btn {
    cursor: pointer;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 202, 40, 0.2);
    border: 1.5px solid rgba(255, 202, 40, 0.6);
    color: #ffd700;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 202, 40, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.speaker-icon-btn:hover {
    background: #ffd700;
    color: #0f172a;
    transform: scale(1.15) rotate(-10deg);
    box-shadow: 0 0 25px rgba(255, 202, 40, 0.9);
}

/* زر المنصة الرئيسية */
.header-nav-btn {
    text-decoration: none;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 25px;
    padding: 12px 24px;
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.6), 0 0 20px rgba(255, 202, 40, 0.5);
    font-weight: 800;
    font-size: 1.1rem;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-nav-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(60deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: rotate(30deg);
    transition: all 0.6s ease;
}

.header-nav-btn:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 25px rgba(245, 158, 11, 0.8), 0 0 25px rgba(255, 202, 40, 0.8);
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.header-nav-btn:hover::after {
    left: 100%;
}

@media (max-width: 850px) {
    .app-header {
        padding: 1rem 1.2rem;
        margin: 15px 12px 25px;
        border-radius: 24px;
    }
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    .header-title-container {
        order: 1;
    }
    .header-profile-box {
        order: 2;
    }
    .header-nav-btn {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================
   مؤثر التوهج والوميض الأصفر المتوهج عند انطلاق السباق
   ========================================================== */
@keyframes yellow-pulse-glow {
    0% {
        box-shadow: 0 0 20px rgba(255, 202, 40, 0.6), 0 0 40px rgba(245, 158, 11, 0.4);
        border-color: rgba(255, 215, 0, 0.8);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 50px rgba(255, 215, 0, 1), 0 0 90px rgba(255, 202, 40, 0.9), 0 0 130px rgba(245, 158, 11, 0.9);
        border-color: #ffffff;
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 30px rgba(255, 202, 40, 0.8), 0 0 60px rgba(255, 215, 0, 0.6);
        border-color: rgba(255, 215, 0, 0.9);
        transform: scale(1.02);
    }
}

.flashing-white-glow {
    animation: yellow-pulse-glow 0.4s ease-in-out infinite alternate !important;
    z-index: 10 !important;
}


