/* ==========================================================
   ثيم سبايدرمان (Spider-Man 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: #0b0f19; /* Dark Night Sky */
    --primary: #E23636; /* Spidey Red */
    --primary-dark: #B11313;
    --secondary: #0D47A1; /* Spidey Blue */
    --secondary-dark: #002171;
    --accent: #FFFFFF; /* White Webs */
    --accent-dark: #B0BEC5;
    --success: #69F0AE; /* Bright Green */
    --rose: #E23636; /* Red Highlight */
    
    --text-dark: #FFFFFF; /* White for dark mode */
    --white: #FFFFFF;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.5); 
    --border-dark: 2px solid rgba(255, 255, 255, 0.2);

    /* Legacy colors mapped to Spidey theme for lesson readability */
    --candy-purple: #002171; /* Dark Blue */
    --candy-blue: #0D47A1; /* Blue */
    --candy-pink: #E23636; /* Red */
    --candy-green: #2E7D32; /* Green */
    --candy-orange: #B11313; /* Dark Red */
    --shadow-pink: rgba(226, 54, 54, 0.5);
    --shadow-blue: rgba(13, 71, 161, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Baloo Bhaijaan 2', 'Tajawal', 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 {
    background: linear-gradient(135deg, #0b0f19, #001a33, #330000);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-dark);
    overflow-x: hidden;
    padding-bottom: 120px;
    position: relative;
    font-size: 26px;
    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(255, 255, 255, 0.4);
    opacity: 0.15 !important;
    animation: none !important;
}

/* ================== العناوين ================== */
.welcome-msg h2, .sosawy-logo, .lesson-overlay h2 {
    color: var(--text-dark);
    font-size: 4.5rem;
    font-weight: 900;
    text-align: center;
    text-shadow: 0 4px 10px rgba(226, 54, 54, 0.5);
    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 rgba(226, 54, 54, 0.6);
    border-radius: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(226, 54, 54, 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: 4px solid var(--white);
    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: 4px 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: #0B192C;
    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"><path d="M50 0 L50 100 M0 50 L100 50 M15 15 L85 85 M15 85 L85 15" stroke="rgba(255,255,255,0.1)" stroke-width="1.5" fill="none"/><circle cx="50" cy="50" r="20" stroke="rgba(255,255,255,0.1)" stroke-width="1.5" fill="none"/><circle cx="50" cy="50" r="40" stroke="rgba(255,255,255,0.1)" stroke-width="1.5" fill="none"/></svg>');
    background-size: cover;
    border: 4px solid var(--primary);
    border-radius: 50%;
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 20px rgba(226, 54, 54, 0.6), inset 0 0 15px rgba(226, 54, 54, 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: 260px;
    height: 260px;
    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: 15px;
}

.chapter-icon img {
    width: 120px !important;
    height: 120px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    border: 4px solid var(--primary) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8), 0 0 15px rgba(226, 54, 54, 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.5rem; 
    font-weight: 900; 
    margin-bottom: 5px;
    color: var(--white);
}

.chapter-card p, .lesson-card p { 
    font-size: 1.3rem; 
    font-weight: 800; 
    color: var(--accent-dark); 
    opacity: 0.8;
}

.chapter-card:hover, .lesson-card:hover, .mode-card:hover {
    animation: softPulse 1.5s infinite;
    border-color: #FFCA28;
    box-shadow: 0 0 15px rgba(226, 54, 54, 0.6), inset 0 0 10px rgba(255,255,255,0.2);
    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, #0D47A1, #002171); 
    color: var(--white); 
    border: 4px solid var(--primary); 
    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(255,255,255,0.2); 
    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, #2E7D32, #1B5E20);
    border-color: #69F0AE;
}

.btn-action:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 25px rgba(226, 54, 54, 0.6), inset 0 0 20px rgba(255,255,255,0.4); 
    border-color: #FFCA28; 
}

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

/* ================== نافذة الدروس ================== */
.sosawy-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.95);
    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: var(--primary);
    color: var(--white);
    border: 4px solid var(--white);
    border-radius: 50%;
    width: 70px;
    height: 70px;
    font-size: 2.5rem;
    font-weight: 900;
    box-shadow: 0 6px 0 var(--primary-dark);
    cursor: pointer;
    align-self: flex-start;
    margin-bottom: 20px;
    transition: all 0.2s;
}
.close-btn:hover { transform: scale(1.1) translateY(-5px); }
.close-btn:active { transform: translateY(6px); box-shadow: 0 0 0 var(--primary-dark); }

/* ================== الحركات ================== */
@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 gentleSwing {
    0% { transform: rotate(-2deg); }
    100% { transform: rotate(2deg); }
}

@keyframes softPulse {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(226, 54, 54, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 25px rgba(226, 54, 54, 0.8); }
    100% { transform: scale(1); box-shadow: 0 0 10px rgba(226, 54, 54, 0.4); }
}

/* ================== زر الرئيسية ================== */
.home-btn-sea {
    background: linear-gradient(135deg, #0D47A1, #002171);
    color: var(--white);
    padding: 10px 25px;
    border: 3px solid var(--white);
    border-radius: 30px;
    text-decoration: none;
    font-weight: 900;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(13, 71, 161, 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 6px 15px rgba(226, 54, 54, 0.8);
}
.home-btn-sea:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* ================== الفوتر ================== */
.sosawy-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    width: 100%;
    position: relative;
    z-index: 10;
}

.sosawy-footer a {
    color: var(--accent-dark);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    transition: color 0.2s;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 20px;
    display: inline-block;
}

.sosawy-footer a:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--primary);
}

@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.8rem; }
    .btn-action { font-size: 1.8rem !important; padding: 15px 20px !important; }
    .sosawy-overlay { padding: 15px; }
    .chapter-card, .lesson-card, .mode-card { padding: 20px 10px; }
}

@media (max-width: 480px) {
    .welcome-msg h2, .sosawy-logo, .lesson-overlay h2 { font-size: 2.2rem; }
    .chapter-card, .lesson-card, .mode-card { padding: 15px 10px; }
    .chapter-icon { font-size: 3.5rem; }
}
