@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');
/* ===== Reset & Base ===== */
/* تنسيق عام للموقع */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll/gaps */
    overscroll-behavior-x: none; /* Prevent horizontal overscroll bounce */
}

/* Paint same background on html and body to avoid gutter flash on first paint */
html, body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
}

/* Page transition wrapper */
.page {
    opacity: 0;
    transform: translateY(10px);
    transition: 0.6s ease-out;
}

.loaded .page {
    opacity: 1;
    transform: none;
}

/* Only reserve a gutter for LTR; let RTL use the default (no left gap flash) */
@supports (scrollbar-gutter: stable) {
  html[dir="ltr"] { scrollbar-gutter: stable; }
  html[dir="rtl"] { scrollbar-gutter: auto; }
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow-x: hidden;
    padding-top: 80px; /* مساحة للشريط العلوي */
}

/* تحسين الخطوط */
/* CSS Variables (tokens) */
:root {
    --color-prep: #16A34A;
    --color-electrical: #F59E0B;
    --color-electronics: #06B6D4;
    --color-cs: #3B82F6;
    --color-mech-power: #EF4444;
    --color-mech-production: #F97316;
    --color-civil: #10B981;
    --color-arch: #A855F7;
}

/* ===== Navbar ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-text {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Brand logo image */
.logo-img {
    height: 40px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: transform 0.2s ease, filter 0.2s ease;
}

.nav-logo:hover .logo-img {
    transform: scale(1.03);
}

.logo-subtitle {
    font-size: 1rem;
    color: #2c3e50;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    color: #2c3e50;
    text-decoration: none;
    font-weight: 600;
    border-radius: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-link:hover,
.nav-link.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
}

.nav-icon {
    font-size: 1.2rem;
}

/* TODO: Replace text glyph icons used in markup with inline SVGs for consistency (no visual change today). */

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 10px;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.hamburger {
    width: 25px;
    height: 3px;
    background: #2c3e50;
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

/* ===== Footer ===== */
.footer {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    margin-top: 60px;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 50px 20px 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
}

.footer-section h3 {
    color: #ecf0f1;
    margin-bottom: 20px;
    font-size: 1.3rem;
    position: relative;
    padding-bottom: 10px;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 50px;
    height: 3px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-radius: 2px;
}

.footer-logo .logo-text {
    font-size: 2.5rem;
    margin-bottom: 10px;
    display: block;
}

.footer-logo .logo-img {
    height: 48px;
    width: auto;
    display: block;
    margin-bottom: 10px;
}

.footer-description {
    color: #bdc3c7;
    line-height: 1.8;
    margin-top: 15px;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 12px;
}

.footer-links a {
    color: #bdc3c7;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-links a:hover {
    color: #667eea;
    transform: translateX(-5px);
}

.footer-links a::before {
    content: '←';
    opacity: 0;
    transition: all 0.3s ease;
}

.footer-links a:hover::before {
    opacity: 1;
}

.contact-info p {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    color: #bdc3c7;
}

.contact-icon {
    font-size: 1.2rem;
    width: 25px;
}

.social-links {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    transition: all 0.3s ease;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.social-link:hover {
    background: linear-gradient(45deg, #667eea, #764ba2);
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 25px 0;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
}

.footer-bottom p {
    color: #bdc3c7;
    margin-bottom: 5px;
}

.footer-tech {
    font-size: 0.9rem;
    opacity: 0.8;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* ===== Effects: background ===== */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="2" fill="rgba(255,255,255,0.1)"/></svg>') repeat;
    background-size: 50px 50px;
    animation: bg-float 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes bg-float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    text-align: center;
    padding: 80px 30px;
    border-radius: 25px;
    margin-bottom: 50px;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    animation: slideInDown 0.8s ease-out;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

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

.hero h1 {
    font-size: 3.2rem;
    margin-bottom: 15px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
    position: relative;
    z-index: 2;
}

.hero p {
    font-size: 1.4rem;
    opacity: 0.95;
    font-weight: 300;
    position: relative;
    z-index: 2;
    margin-top: 10px;
}

/* ===== Grids: Departments ===== */
.departments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
    margin-bottom: 50px;
    animation: fadeInUp 1s ease-out 0.3s both;
}

@keyframes fadeInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.department-card {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 35px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

.department-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.department-card:hover::before {
    opacity: 1;
}

.department-card:hover {
    transform: translateY(-10px) rotateX(5deg);
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    border-color: var(--dept-color, #667eea);
}

.department-card:active {
    transform: translateY(-5px) scale(0.98);
}

.department-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: transform 0.3s ease;
}

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

.department-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: #2c3e50;
    transition: color 0.3s ease;
}

.department-card:hover .department-name {
    color: var(--dept-color, #667eea);
}

.department-description {
    font-size: 1rem;
    color: #7f8c8d;
    margin-bottom: 0;
    line-height: 1.6;
    font-weight: 400;
}

/* ===== Cards & Headers ===== */
.major-header, .year-header, .week-header, .prep-header, .quizzes-header {
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 40px;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: slideInUp 0.6s ease-out;
    border: 2px solid rgba(26, 32, 44, 0.1);
}

@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.major-header::before,
.year-header::before,
.week-header::before,
.prep-header::before,
.quizzes-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--dept-color, #667eea) 0%, rgba(255, 255, 255, 0.2) 100%);
    border-radius: 20px 20px 0 0;
}

.major-title, .prep-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.major-icon, .prep-icon {
    font-size: 3rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.major-title h1, .year-header h1, .week-header h1, .prep-header h1, .quizzes-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
    line-height: 1.2;
}

/* تحسين النصوص العربية في العناوين */
.week-header h1, .prep-header h1 {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: 800;
    color: #0f172a;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.25),
        0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ===== Year Buttons ===== */
.year-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.year-btn {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 15px;
    padding: 30px;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 10px 25px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    display: block;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.year-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.year-btn:hover::before {
    left: 100%;
}

.year-btn:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.3);
}

.year-btn:active {
    transform: translateY(-4px) scale(0.98);
}

/* ===== Quizzes: Alerts Button ===== */
.quiz-alerts-section {
    text-align: center;
    animation: fadeInUp 1s ease-out 0.6s both;
}

.quiz-alerts-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 25px 50px;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 10px 25px rgba(40, 167, 69, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.quiz-alerts-btn::before {
    content: '📋';
    margin-left: 10px;
}

.quiz-alerts-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
    transform: translate(-50%, -50%);
}

.quiz-alerts-btn:hover::after {
    width: 300px;
    height: 300px;
}

.quiz-alerts-btn:hover {
    background: linear-gradient(135deg, #218838 0%, #1e7e34 100%);
    transform: translateY(-5px);
    box-shadow: 
        0 15px 35px rgba(40, 167, 69, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* ===== Grids: Weeks ===== */
.weeks-grid, .prep-weeks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
    animation: fadeInUp 1s ease-out 0.5s both;
}

.week-btn {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 25px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    color: #2c3e50;
    text-align: center;
    display: block;
    position: relative;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.week-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 15px;
}

.week-btn:hover::before {
    opacity: 1;
}

.week-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-5px) scale(1.02);
    box-shadow: 
        0 10px 25px rgba(102, 126, 234, 0.2),
        0 0 0 1px rgba(102, 126, 234, 0.3);
}

.week-btn:active {
    transform: translateY(-2px) scale(0.98);
}

/* ===== Week/Subjects ===== */
.subjects-list {
    display: grid;
    gap: 25px;
    animation: fadeInUp 1.2s ease-out 0.7s both;
}

.subject-card {
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    border-left: 5px solid transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.subject-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 18px;
}

.subject-card:hover::before {
    opacity: 1;
}

.subject-card:hover {
    transform: translateY(-8px);
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    border-left-color: #667eea;
}

.subject-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 18px;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.subject-name::before {
    content: '📚';
    font-size: 1.2rem;
}

.subject-topics {
    color: #0f172a;
    margin-bottom: 20px;
    font-style: normal;
    line-height: 1.8;
    position: relative;
    z-index: 2;
    padding: 20px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    border-left: 4px solid var(--dept-color, #667eea);
    font-size: 1.05rem;
    font-weight: 500;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    font-family: 'Cairo', 'Tajawal', sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* تحسين النصوص الفارغة */
.subject-topics:empty::before,
.subject-topics[data-empty="true"]::before {
    content: "📚 المحتوى قيد التحديث - تابع النشرات الأسبوعية للحصول على آخر المستجدات";
    color: #4a5568;
    font-style: italic;
    opacity: 0.8;
}

.subject-topics.no-content {
    background: rgba(252, 211, 77, 0.1);
    border-left-color: #f59e0b;
    color: #78350f;
    font-style: italic;
}

.subject-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    position: relative;
    z-index: 2;
}

.link-btn {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 22px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.link-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.link-btn:hover::before {
    left: 100%;
}

.link-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.link-btn.notes {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    box-shadow: 0 4px 10px rgba(23, 162, 184, 0.3);
}

.link-btn.lectures {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

.link-btn.assignments {
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #212529;
    box-shadow: 0 4px 10px rgba(255, 193, 7, 0.3);
}

.link-btn.video {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
}

.link-btn.playlist {
    background: linear-gradient(135deg, #6f42c1 0%, #59359a 100%);
    box-shadow: 0 4px 10px rgba(111, 66, 193, 0.3);
}

/* ===== Buttons: Base (no visual change) ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    min-height: 48px;
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.3s ease;
}

/* Demo-only extras used in contrast/responsive tests */
.link-btn.slides {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
}

.link-btn.exercises {
    background: linear-gradient(135deg, #fd7e14 0%, #e8590c 100%);
    box-shadow: 0 4px 10px rgba(253, 126, 20, 0.3);
    color: #212529;
}

.empty-links {
    color: #6c757d;
    font-style: italic;
    padding: 10px 15px;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 8px;
    border: 1px dashed #dee2e6;
}

/* ===== Quizzes: Cards ===== */
.quizzes-list {
    display: grid;
    gap: 25px;
    animation: fadeInUp 1.2s ease-out 0.8s both;
}

.quiz-card {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    border-right: 6px solid #dc3545;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.quiz-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.05) 0%, rgba(220, 53, 69, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 18px;
}

.quiz-card:hover::before {
    opacity: 1;
}

.quiz-card:hover {
    transform: translateY(-8px);
    box-shadow: 
        0 20px 40px rgba(220, 53, 69, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    border-right-width: 8px;
}

.quiz-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #dc3545;
    margin-bottom: 15px;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
}

.quiz-title::before {
    content: '⚠️';
    font-size: 1.3rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.quiz-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    position: relative;
    z-index: 2;
}

.quiz-detail {
    background: rgba(248, 249, 250, 0.9);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(222, 226, 230, 0.8);
    transition: all 0.3s ease;
}

.quiz-detail:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.quiz-detail strong {
    color: #2c3e50;
    font-weight: 700;
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.quiz-link {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 15px 30px;
    border-radius: 12px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 600;
    position: relative;
    overflow: hidden;
    z-index: 2;
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

.quiz-link::before {
    content: '🔗';
}

.quiz-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.quiz-link:hover::after {
    left: 100%;
}

.quiz-link:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0, 123, 255, 0.4);
}

/* ===== Buttons: Back ===== */
.back-btn {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.3);
    position: relative;
    overflow: hidden;
}

.back-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.back-btn:hover::before {
    left: 100%;
}

.back-btn:hover {
    background: linear-gradient(135deg, #5a6268 0%, #343a40 100%);
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(108, 117, 125, 0.4);
}

.back-btn:active {
    transform: translateY(-1px);
}

/* رسالة فارغة */
.empty-message {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 50px 30px;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    font-size: 1.2rem;
    position: relative;
    overflow: hidden;
}

.empty-message::before {
    content: '🔍';
    display: block;
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.7;
}

/* تحسينات إضافية للـ navbar والـ footer */

/* ظل للـ navbar عند التمرير */
.navbar.scrolled {
    box-shadow: 0 4px 18px rgba(102, 126, 234, 0.13);
    background: rgba(255,255,255,0.99);
}

/* ضمان ظهور قائمة التنقل في الهواتف عند الكلاس open */
.nav-menu.open {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
    z-index: 9999;
}

/* إخفاء افتراضي للقائمة في الهواتف */
@media (max-width: 900px) {
    .nav-menu {
        display: none !important;
        opacity: 0;
        pointer-events: none;
    }
}

@media (max-width: 900px) {
    .nav-toggle {
        display: flex;
    }
    .nav-menu {
        position: fixed;
        top: 64px;
        right: 0;
        left: 0;
        background: rgba(255,255,255,0.99);
        box-shadow: 0 8px 24px rgba(102,126,234,0.13);
        flex-direction: column;
        gap: 0;
        padding: 0;
        z-index: 999;
        display: none;
        border-bottom-left-radius: 18px;
        border-bottom-right-radius: 18px;
        animation: fadeInDown 0.3s;
    }
    .nav-menu.open {
        display: flex !important;
        opacity: 1;
        pointer-events: auto;
        z-index: 9999;
    }
    .nav-link {
        width: 100%;
        border-radius: 0;
        padding: 18px 0;
        justify-content: flex-start;
        font-size: 1.13rem;
        border-bottom: 1px solid rgba(102,126,234,0.09);
        color: #1a237e;
        background: none;
    }
    .nav-link:last-child {
        border-bottom: none;
    }
    @keyframes fadeInDown {
        from { opacity: 0; transform: translateY(-20px); }
        to { opacity: 1; transform: translateY(0); }
    }
}

/* تحسين الفوتر وإضافة رموز تواصل اجتماعي */
.footer-social {
    display: flex;
    gap: 18px;
    margin-top: 18px;
    justify-content: flex-start;
}
.footer-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 1.3rem;
    transition: background 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px rgba(102,126,234,0.10);
    text-decoration: none;
}
.footer-social a:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: scale(1.12) rotate(-3deg);
}

/* تحسين تباين نصوص الفوتر */
.footer-section h4, .footer-section h3, .footer-description, .footer-links a, .footer-bottom p {
    text-shadow: 0 1px 4px rgba(44,62,80,0.10);
}

/* تحسين استجابة الفوتر للهواتف */
@media (max-width: 600px) {
    .footer-container {
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 30px 8px 18px;
    }
    .footer-social {
        justify-content: center;
    }
}

/* تصميم متجاوب */
@media (max-width: 768px) {
    .hero {
        padding: 50px 20px;
    }
    
    .hero h1 {
        font-size: 2.2rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .departments-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .year-buttons {
        grid-template-columns: 1fr;
    }

    .weeks-grid, .prep-weeks-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
    }

    .quiz-details {
        grid-template-columns: 1fr;
    }

    .subject-links {
        flex-direction: column;
    }
    
    .major-title h1, .year-header h1, .week-header h1, .prep-header h1, .quizzes-header h1 {
        font-size: 1.8rem;
    }
    
    .major-icon, .prep-icon {
        font-size: 2.5rem;
    }
    
    .container {
        padding: 15px;
    }
    .hero {
        padding: 50px 20px;
    }
    .year-buttons {
        grid-template-columns: 1fr;
    }
    .weeks-grid, .prep-weeks-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
    }
    .quiz-details {
        grid-template-columns: 1fr;
    }
    .subject-links {
        flex-direction: column;
    }
    .major-title h1, .year-header h1, .week-header h1, .prep-header h1, .quizzes-header h1 {
        font-size: 1.8rem;
    }
    .major-icon, .prep-icon {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .weeks-grid, .prep-weeks-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .department-card {
        padding: 25px;
    }
    
    .subject-card, .quiz-card {
        padding: 20px;
    }
    
    .major-title, .prep-title {
        flex-direction: column;
        gap: 10px;
    }
}

/* تحسينات الأداء */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    /* Soften heavy hover effects for motion-reduced users */
    .department-card:hover,
    .subject-card:hover,
    .quiz-card:hover,
    .year-btn:hover,
    .week-btn:hover,
    .quiz-alerts-btn:hover,
    .back-btn:hover,
    .link-btn:hover {
        transform: none !important;
        box-shadow: 0 6px 16px rgba(0,0,0,0.12) !important;
    }
    .glow-effect:hover::after {
        opacity: 0 !important;
    }
}

/* دعم الوضع المظلم (مجمّع) */
@media (prefers-color-scheme: dark) {
    html, body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    .department-card, .subject-card, .quiz-card,
    .major-header, .year-header, .week-header, .prep-header, .quizzes-header,
    .empty-message {
        background: rgba(52, 73, 94, 0.95);
        color: #ecf0f1;
    }
    .department-name, .major-title h1, .year-header h1, .week-header h1, .prep-header h1, .quizzes-header h1 {
        color: #ecf0f1;
    }
    /* Keep subject-specific overrides as in final cascade */
    .subject-card {
        background: rgba(45, 55, 72, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
    .subject-name {
        color: #f7fafc;
    }
    .subject-topics {
        color: #e2e8f0;
        background: rgba(26, 32, 44, 0.8);
        border-left-color: var(--dept-color, #667eea);
    }
    .quiz-detail {
        background: rgba(44, 62, 80, 0.8);
        color: #bdc3c7;
    }
}

/* ألوان محددة للأقسام مع متغيرات CSS */
.department-card.prep {
    --dept-color: var(--color-prep);
    border-color: var(--dept-color);
}

.department-card.electrical {
    --dept-color: var(--color-electrical);
    border-color: var(--dept-color);
}

.department-card.electronics {
    --dept-color: var(--color-electronics);
    border-color: var(--dept-color);
}

.department-card.cs {
    --dept-color: var(--color-cs);
    border-color: var(--dept-color);
}

.department-card.mechanical-power {
    --dept-color: var(--color-mech-power);
    border-color: var(--dept-color);
}

.department-card.mechanical-production {
    --dept-color: var(--color-mech-production);
    border-color: var(--dept-color);
}

.department-card.civil {
    --dept-color: var(--color-civil);
    border-color: var(--dept-color);
}

.department-card.architecture {
    --dept-color: var(--color-arch);
    border-color: var(--dept-color);
}

/* تحسينات إضافية للتفاعل */
.department-card:focus-visible,
.year-btn:focus-visible,
.week-btn:focus-visible,
.quiz-alerts-btn:focus-visible,
.back-btn:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* تأثيرات تحميل */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* تأثيرات متقدمة ومايكرو-إنتراكشن */

/* تأثير الريبل للأزرار */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease-out, height 0.6s ease-out;
    z-index: 1;
    pointer-events: none;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
}

/* تأثيرات المورفولوجي */
.morph {
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.morph:hover {
    transform: scale(1.02) rotate(1deg);
    filter: brightness(1.1);
}

/* تأثيرات الجسيمات */
.particles {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    top: 0;
    left: 0;
    z-index: -1;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    pointer-events: none;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100vh) rotate(360deg); opacity: 0; }
}

/* تأثيرات الانعكاس */
.reflection {
    position: relative;
}

.reflection::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 100%
    );
    transform: scaleY(-1);
    opacity: 0.3;
    z-index: -1;
}

/* تأثيرات النمو الديناميكي */
.grow {
    animation: grow 2s ease-in-out infinite alternate;
}

@keyframes grow {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

/* تأثيرات الضوء المتحرك */
.light-beam {
    position: relative;
    overflow: hidden;
}

.light-beam::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    animation: light-sweep 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes light-sweep {
    0% { left: -100%; }
    50% { left: 100%; }
    100% { left: 100%; }
}

/* تأثيرات البولس المتقدمة */
.pulse-advanced {
    animation: pulse-advanced 2s ease-in-out infinite;
}

@keyframes pulse-advanced {
    0% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% { 
        transform: scale(1.05) rotate(2deg);
        box-shadow: 0 0 0 20px rgba(102, 126, 234, 0);
    }
    100% { 
        transform: scale(1) rotate(0deg);
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

/* تحسينات الاستجابة */
@media (max-width: 768px) {
    .morph:hover {
        transform: scale(1.01);
    }
    
    .ripple:active::before {
        width: 200px;
        height: 200px;
    }
    
    .pulse-advanced {
        animation-duration: 3s;
    }
}

/* تأثيرات الإضاءة الخلفية */
.glow-effect {
    position: relative;
}

.glow-effect::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, #667eea, #764ba2, #667eea);
    background-size: 200% 200%;
    border-radius: inherit;
    z-index: -1;
    animation: glow-rotate 4s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glow-effect:hover::after {
    opacity: 0.7;
}

@keyframes glow-rotate {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* تحسينات الاستجابة للهواتف والأجهزة اللوحية */

/* تابلت وشاشات متوسطة */
@media (max-width: 1024px) {
    .nav-container {
        padding: 0 15px;
    }
    
    .nav-menu {
        gap: 20px;
    }
    
    .nav-link {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .footer-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
        padding: 40px 15px 25px;
    }
}

/* هواتف وشاشات صغيرة */
@media (max-width: 768px) {
    body {
        padding-top: 70px;
    }
    
    .nav-container {
        height: 70px;
        padding: 0 15px;
    }
    
    .logo-text {
        font-size: 1.5rem;
    }
    
    .logo-subtitle {
        font-size: 0.8rem;
    }
    
    .nav-toggle {
        display: flex;
        z-index: 1001;
    }
    
    .nav-menu {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.98);
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
        flex-direction: column;
        padding: 20px;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-link {
        width: 100%;
        justify-content: center;
        padding: 15px;
        margin-bottom: 10px;
        border-radius: 15px;
        font-size: 1rem;
    }
    
    .nav-toggle.active .hamburger:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }
    
    .nav-toggle.active .hamburger:nth-child(2) {
        opacity: 0;
    }
    
    .nav-toggle.active .hamburger:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
    
    /* تحسينات الحاوي الرئيسي */
    .container {
        padding: 15px;
    }
    
    .hero h1 {
        font-size: 2.2rem;
        line-height: 1.3;
    }
    
    .hero p {
        font-size: 1.1rem;
    }
    
    /* تحسينات شبكة الأقسام */
    .departments-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .department-card {
        padding: 20px;
        margin-bottom: 10px;
    }
    
    .department-card h2 {
        font-size: 1.3rem;
    }
    
    .department-card p {
        font-size: 0.9rem;
    }
    
    /* تحسينات الأزرار */
    .btn {
        padding: 12px 20px;
        font-size: 0.9rem;
        min-height: 48px; /* لضمان سهولة النقر */
    }
    
    .year-btn, .week-btn {
        padding: 15px;
        font-size: 1rem;
        min-height: 50px;
    }
    
    /* تحسينات المواد للهواتف */
    .subject-card {
        padding: 25px 20px;
        margin-bottom: 15px;
    }
    
    .subject-name {
        font-size: 1.3rem;
        line-height: 1.4;
        color: #1a202c;
    }
    
    .subject-topics {
        font-size: 1rem;
        line-height: 1.7;
        padding: 18px;
        color: #1a202c;
        font-weight: 500;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid rgba(255, 255, 255, 0.4);
    }
    
    .subject-topics.no-content {
        background: rgba(252, 211, 77, 0.15);
        color: #78350f;
        font-weight: 600;
    }
    
    .link-btn {
        padding: 16px 20px;
        font-size: 1rem;
        min-height: 52px;
        font-weight: 600;
    }
    
    /* تحسينات التذييل */
    .footer-container {
        grid-template-columns: 1fr;
        gap: 25px;
        padding: 30px 15px 20px;
        text-align: center;
    }
    
    .footer-section h3::after {
        left: 50%;
        transform: translateX(-50%);
        right: auto;
    }
    
    .social-links {
        justify-content: center;
    }
    
    .social-link {
        width: 50px;
        height: 50px;
        font-size: 1.8rem;
    }
}

/* هواتف صغيرة جداً */
@media (max-width: 480px) {
    body {
        padding-top: 60px;
    }
    
    .nav-container {
        height: 60px;
        padding: 0 10px;
    }
    
    .logo-text {
        font-size: 1.2rem;
    }
    
    .logo-subtitle {
        display: none;
    }
    
    .nav-menu {
        top: 60px;
        padding: 15px;
    }
    
    .nav-link {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .container {
        padding: 10px;
    }
    
    .hero {
        padding: 20px 15px;
    }
    
    .hero h1 {
        font-size: 1.5rem;
    }
    
    .hero p {
        font-size: 0.9rem;
    }
    
    .department-card {
        padding: 15px;
    }
    
    .department-card h2 {
        font-size: 1.1rem;
    }
    
    .btn {
        padding: 10px 15px;
        font-size: 0.8rem;
        min-height: 44px;
    }
    
    .footer-container {
        padding: 25px 10px 15px;
    }
    
    .social-link {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }
}

/* تحسينات الأداء والحركة للهواتف */
@media (max-width: 768px) {
    /* تقليل التأثيرات المعقدة على الهواتف */
    .morph:hover {
        transform: scale(1.02);
    }
    .ripple:active::before {
        width: 150px;
        height: 150px;
    }
    .pulse-advanced {
        animation-duration: 3s;
    }
}

/* إزالة التأثيرات المكثفة (شرط مركّب بلا تعشيش) */
@media (max-width: 768px) and (orientation: portrait) {
    .light-beam::before,
    .glow-effect::after {
        display: none;
    }
    .backdrop-blur {
        backdrop-filter: none;
        background: rgba(255, 255, 255, 0.9);
    }
}

/* تحسينات إضافية للمس */
@media (hover: none) and (pointer: coarse) {
    .nav-link:hover,
    .department-card:hover,
    .btn:hover {
        transform: none;
    }
    
    .nav-link:active,
    .department-card:active,
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* تحسينات التباين وإمكانية الوصول */
/* A11y note: This block only raises contrast for users explicitly opting into high contrast. It does not change default visuals. */
@media (prefers-contrast: high) {
    .subject-topics {
        color: #000000;
        background: rgba(255, 255, 255, 1);
        border-left-color: #000000;
        border-left-width: 5px;
        border: 2px solid #000000;
    }
    
    .subject-topics.no-content {
        background: #fff3cd;
        color: #664d03;
        border: 2px solid #664d03;
    }
    
    .subject-name {
        color: #000000;
        text-shadow: none;
    }
    
    .subject-card {
        background: rgba(255, 255, 255, 1);
        border: 2px solid #000000;
    }
    
    .link-btn {
        background: #000000;
        border: 2px solid #ffffff;
        color: #ffffff;
    }
}

/* (Merged dark-mode subject overrides above) */

/* (Merged into single prefers-reduced-motion block above) */

/* Media safety: prevent wide content from causing side gaps */
img, video, svg, canvas {
    max-width: 100%;
    height: auto;
}

/* Wrap long words/URLs to avoid overflow in tight layouts */
.subject-topics,
.quiz-detail,
.footer-description {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* --- Layout safety overrides to prevent side gaps and overflow --- */
.container,
.nav-container,
.footer-container {
    width: 100%;
}

/* Respect device safe areas on small screens (iOS notch, etc.) */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .nav-container {
            padding-left: max(15px, env(safe-area-inset-left));
            padding-right: max(15px, env(safe-area-inset-right));
        }
        .container,
        .footer-container {
            padding-left: max(10px, env(safe-area-inset-left));
            padding-right: max(10px, env(safe-area-inset-right));
        }
    }
}

/* ===== A11y Mobile Nav Utilities ===== */
/* Screen-reader only utility */
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* Body scroll lock when nav is open */
body.nav-open { overflow: hidden; }

/* Backdrop behind mobile menu */
.nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 998; }
[hidden] { display: none !important; }

/* Skip link */
.skip-link { position:absolute; inset-inline-end:1rem; top:-40px; background:#fff; color:#000; padding:.5rem 1rem; border-radius:8px; box-shadow:0 4px 12px rgba(0,0,0,.15); transition:top .2s; z-index:1001; text-decoration:none; }
.skip-link:focus { top:10px }

/* Prevent headings hidden under fixed navbar when using #anchors */
:target { scroll-margin-top: 90px; }
