/* ==========================================================
   الستايل الكرتوني: تصميم يحاكي عالم الرسوم المتحركة
   ========================================================== */

:root {
    /* ألوان زاهية وساطعة */
    --candy-pink: #FF3366;
    --candy-blue: #00C3FF;
    --candy-yellow: #FFDE00;
    --candy-green: #00E676;
    --candy-purple: #D500F9;
    --candy-red: #FF3D00;
    
    /* الألوان الأساسية */
    --text-dark: #000000; /* خطوط سوداء عريضة للرسوم المتحركة */
    --white: #FFFFFF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    /* مؤشر ماوس مرح (قلم تلوين أو يد كرتونية) */
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" style="font-size:30px"><text y="30">🖍️</text></svg>') 10 30, auto !important;
}

body {
    /* خلفية شعاع الشمس الكرتوني (Sunburst) */
    background: repeating-conic-gradient(
        from 0deg,
        #33B5FF 0deg 15deg,
        #0099FF 15deg 30deg
    );
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-dark);
    overflow-x: hidden;
    padding-bottom: 120px; /* مساحة للقائمة السفلية */
}

/* ================== العناوين ================== */
.welcome-msg h2, .sosawy-logo, .lesson-overlay h2 {
    color: var(--candy-yellow);
    font-size: 4.5rem;
    font-weight: 900;
    text-align: center;
    /* حد أسود سميك حول النص (Stroke Effect) يشبه الكوميكس */
    text-shadow: 
        -4px -4px 0 #000,  
         4px -4px 0 #000,
        -4px  4px 0 #000,
         4px  4px 0 #000,
         10px 10px 0 #000;
    margin: 20px 0;
    animation: floating 2s ease-in-out infinite alternate, pop 0.5s ease-out;
}

/* ================== الهيدر العلوي ================== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: var(--white);
    border-bottom: 8px solid var(--text-dark);
    border-radius: 0 0 40px 40px;
    box-shadow: 0 12px 0 var(--text-dark);
    margin-bottom: 40px;
    position: relative;
    z-index: 10;
}

.stars-panel {
    background: var(--candy-yellow);
    padding: 10px 30px;
    border-radius: 50px;
    border: 6px solid var(--text-dark);
    box-shadow: 6px 6px 0 var(--text-dark);
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 15px;
    transform: rotate(-4deg);
    transition: transform 0.2s;
}

.stars-panel:hover {
    transform: rotate(4deg) scale(1.1);
}

.sosawy-tool-btn {
    background: var(--candy-pink);
    border: 6px solid var(--text-dark);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    font-size: 2rem;
    box-shadow: 6px 6px 0 var(--text-dark);
    cursor: pointer;
    transition: all 0.1s;
}

.sosawy-tool-btn:active {
    transform: translate(6px, 6px);
    box-shadow: 0 0 0 var(--text-dark);
}

/* ================== نظام البطاقات الكرتونية ================== */
.sosawy-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

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

/* تصميم البطاقة كصندوق كرتوني (Cell Shading) */
.chapter-card, .lesson-card, .mode-card {
    background: var(--white);
    border: 8px solid var(--text-dark);
    border-radius: 30px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 12px 12px 0 var(--text-dark); /* ظل صلب غير مموه */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

/* ألوان ساطعة للبطاقات */
.chapter-card:nth-child(4n+1) { background: var(--candy-pink); color: var(--white); }
.chapter-card:nth-child(4n+2) { background: var(--candy-yellow); color: var(--text-dark); }
.chapter-card:nth-child(4n+3) { background: var(--candy-green); color: var(--text-dark); }
.chapter-card:nth-child(4n+4) { background: var(--candy-purple); color: var(--white); }

/* إضاءة بيضاء صغيرة في الزاوية للمعان كرتوني (Highlight) */
.chapter-card::after, .lesson-card::after, .btn-action::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 30px;
    height: 15px;
    background: rgba(255,255,255,0.7);
    border-radius: 20px;
    transform: rotate(-30deg);
    pointer-events: none;
}

.chapter-icon {
    font-size: 6.5rem;
    margin-bottom: 20px;
    display: block;
    filter: drop-shadow(5px 5px 0px #000); /* ظل صلب للأيقونات */
}

.chapter-card h3 { 
    font-size: 2.2rem; 
    font-weight: 900; 
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    color: var(--white);
}

.chapter-card:nth-child(4n+2) h3, .chapter-card:nth-child(4n+3) h3 {
    text-shadow: none;
    color: var(--text-dark);
}

.chapter-card p { font-size: 1.4rem; font-weight: 900; opacity: 0.9; }

/* التفاعل */
.chapter-card:hover, .lesson-card:hover, .mode-card:hover {
    transform: translate(-5px, -5px) scale(1.03);
    box-shadow: 18px 18px 0 var(--text-dark);
}

.chapter-card:active, .lesson-card:active, .mode-card:active {
    transform: translate(12px, 12px);
    box-shadow: 0 0 0 var(--text-dark);
}

/* ================== أزرار الأكشن ================== */
.btn-action {
    background: var(--candy-blue);
    color: white;
    border: 8px solid var(--text-dark);
    border-radius: 20px; /* أقل دائرية لتشبه الصناديق الكرتونية */
    padding: 20px 40px;
    font-size: 2.5rem;
    font-weight: 900;
    box-shadow: 8px 8px 0 var(--text-dark);
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    display: inline-block;
    position: relative;
    text-shadow: 2px 2px 0 #000;
}

.btn-action.success {
    background: var(--candy-green);
}

.btn-action:active {
    transform: translate(8px, 8px);
    box-shadow: 0 0 0 var(--text-dark);
}

/* ================== نافذة الدروس (Overlay) ================== */
.sosawy-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* خلفية مخططة تشبه كتب الكوميكس */
    background: repeating-linear-gradient(45deg, var(--candy-pink), var(--candy-pink) 30px, #FF5080 30px, #FF5080 60px);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 30px;
    overflow-y: auto;
}

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

.close-btn {
    background: var(--candy-red);
    color: white;
    border: 8px solid var(--text-dark);
    border-radius: 50%;
    width: 75px;
    height: 75px;
    font-size: 2.5rem;
    font-weight: 900;
    box-shadow: 8px 8px 0 var(--text-dark);
    cursor: pointer;
    align-self: flex-start;
    margin-bottom: 20px;
}
.close-btn:active { transform: translate(8px, 8px); box-shadow: 0 0 0 var(--text-dark); }

/* ================== القائمة السفلية ================== */
.sosawy-nav {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    padding: 15px 80px; /* مسافة أوسع لتطابق الصورة */
    border-radius: 60px;
    border: 10px solid var(--text-dark); /* حدود سميكة جداً */
    box-shadow: 12px 12px 0 var(--text-dark);
    display: flex;
    gap: 100px; /* تباعد كبير بين الأزرار */
    z-index: 1500;
    width: max-content;
    max-width: 95%; /* حتى لا تخرج عن الشاشة في الهواتف */
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 2.8rem;
    cursor: pointer;
    transition: transform 0.2s;
    color: var(--text-dark);
}
.nav-btn span { font-size: 1.8rem; font-weight: 900; margin-top: 5px; }
.nav-btn:hover { transform: scale(1.2) translateY(-10px) rotate(-5deg); }
.nav-btn.active { color: #00A3FF; } /* لون أزرق ساطع كما في الصورة */

/* ================== الحركات ================== */
@keyframes floating {
    0% { transform: translateY(0px) rotate(0deg); }
    100% { transform: translateY(-15px) rotate(4deg); }
}

@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;
}

/* ================== Media Queries ================== */
@media (max-width: 768px) {
    .welcome-msg h2, .sosawy-logo, .lesson-overlay h2 { font-size: 3rem; }
    .main-header { flex-direction: column; gap: 15px; border-radius: 0 0 25px 25px;}
    .chapter-icon { font-size: 4.5rem; }
    .chapter-card h3 { font-size: 1.8rem; }
    .btn-action { font-size: 1.8rem !important; padding: 15px 20px !important; }
    .sosawy-nav { width: 95%; justify-content: space-around; padding: 10px; gap: 10px; }
    .nav-btn { font-size: 2rem; }
    .sosawy-overlay { padding: 15px; }
    
    /* Override large inline fonts from app.js */
    [style*="font-size: 8rem"], [style*="font-size:8rem"] { font-size: 5rem !important; }
    [style*="font-size: 6rem"], [style*="font-size:6rem"] { font-size: 4rem !important; }
    [style*="font-size: 5rem"], [style*="font-size:5rem"] { font-size: 3rem !important; }
    [style*="font-size: 4rem"], [style*="font-size:4rem"] { font-size: 2.5rem !important; }
    [style*="font-size: 3rem"], [style*="font-size:3rem"] { font-size: 2rem !important; }
    [style*="font-size: 2.5rem"], [style*="font-size:2.5rem"] { font-size: 1.8rem !important; }
    
    /* Override large inline boxes */
    [style*="width: 120px"], [style*="width:120px"] { width: 80px !important; height: 80px !important; }
    [style*="width: 100px"], [style*="width:100px"] { width: 70px !important; height: 70px !important; }
    [style*="width: 90px"], [style*="width:90px"] { width: 60px !important; height: 60px !important; }
    [style*="width: 70px"], [style*="width:70px"] { width: 50px !important; height: 50px !important; }
    
    /* Override flex gaps if they are too large */
    [style*="gap: 20px"], [style*="gap:20px"] { gap: 10px !important; }
    [style*="gap: 30px"], [style*="gap:30px"] { gap: 15px !important; }
}

@media (max-width: 480px) {
    .welcome-msg h2, .sosawy-logo, .lesson-overlay h2 { font-size: 2.2rem; }
    .chapter-card, .lesson-card, .mode-card { padding: 20px 15px; }
    .chapter-icon { font-size: 4rem; }
    
    /* Further scale down for very small screens */
    [style*="font-size: 8rem"], [style*="font-size:8rem"] { font-size: 4rem !important; }
    [style*="font-size: 6rem"], [style*="font-size:6rem"] { font-size: 3rem !important; }
    [style*="font-size: 5rem"], [style*="font-size:5rem"] { font-size: 2.5rem !important; }
    [style*="font-size: 4rem"], [style*="font-size:4rem"] { font-size: 2rem !important; }
    [style*="font-size: 3rem"], [style*="font-size:3rem"] { font-size: 1.5rem !important; }
    
    [style*="width: 120px"], [style*="width:120px"] { width: 60px !important; height: 60px !important; }
    [style*="width: 100px"], [style*="width:100px"] { width: 50px !important; height: 50px !important; }
    [style*="width: 90px"], [style*="width:90px"] { width: 45px !important; height: 45px !important; }
    [style*="width: 70px"], [style*="width:70px"] { width: 35px !important; height: 35px !important; }
    
    /* Adjust paddings */
    [style*="padding: 40px"], [style*="padding:40px"] { padding: 20px !important; }
    [style*="padding: 30px"], [style*="padding:30px"] { padding: 15px !important; }
    [style*="padding: 20px"], [style*="padding:20px"] { padding: 10px !important; }
}
