/* c:\Users\moham\OneDrive\Desktop\Projects\MohammedSa-protofolio\assets\Responsive.css */

/* 
   Responsive Design Styles
   Breakpoints:
   - Extra Small: < 576px (Mobile Portrait)
   - Small: >= 576px (Mobile Landscape)
   - Medium: >= 768px (Tablets)
   - Large: >= 992px (Laptops)
   - Extra Large: >= 1200px (Desktops)
   - Huge: >= 1400px (Wide Screens)
*/

/* =========================================
   1. Extra Small Screens (Mobile - Portrait - Less than 576px)
   ========================================= */

/* Container Adjustment */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

/* Navbar - Mobile View */
.main-header .container {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.nav-toggle {
    display: flex; /* Visible on mobile */
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-light);
    padding: 0;
    width: 44px;
    height: 44px;
    order: 2; /* ترتيب الزر بعد مبدل اللغة */
    z-index: 1001; /* ضمان ظهوره فوق القائمة المنسدلة */
    transition: color 0.3s ease;
}

.nav-toggle:hover {
    color: var(--primary-blue);
}

.nav-toggle:focus {
    outline: none;
    color: var(--primary-blue);
}

/* Ensure Lang Switcher is next to toggle on mobile */
.lang-switcher-wrapper {
    display: flex !important; /* Override style.css display: contents */
    align-items: center;
    order: 1;
    margin-left: auto; /* Push to right */
    margin-right: 10px; /* Adjusted spacing for English view */
}

.main-nav {
    /* Mobile Side Drawer Style */
    display: block;
    position: fixed;
    top: 0;
    right: -100%; /* Start off-screen */
    width: 75%;
    max-width: 300px;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(15px);
    z-index: 999;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
    box-shadow: -5px 0 30px rgba(0,0,0,0.5);
    padding-top: 80px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    overflow-y: auto;
    visibility: hidden;
}

.main-nav.active {
    right: 0;
    visibility: visible;
}

.nav-list {
    display: flex;
    flex-direction: column;
    text-align: center;
    gap: 0;
    padding: 1.5rem;
    margin: 0;
    list-style: none;
}

/* Staggered animation for menu items to appear one by one */
.main-nav.active .nav-list li {
    opacity: 0;
    animation: fadeInItem 0.4s ease forwards;
}

.nav-list li:nth-child(1) { animation-delay: 0.1s; }
.nav-list li:nth-child(2) { animation-delay: 0.2s; }
.nav-list li:nth-child(3) { animation-delay: 0.3s; }
.nav-list li:nth-child(4) { animation-delay: 0.4s; }
.nav-list li:nth-child(5) { animation-delay: 0.5s; }

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

.nav-link {
    display: block;
    padding: 1rem;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.5rem;
    border-radius: 12px; /* جعل الروابط كأزرار منفصلة */
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.nav-list li:last-child .nav-link {
    border-bottom: none;
}

.nav-link:hover {
    background-color: rgba(14, 165, 233, 0.15);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    transform: translateX(5px);
}

/* Layouts - Stacked on Mobile */
.hero-content,
.about-content,
.contact-form-wrapper,
.teachhive-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.steps-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column */
    gap: 1.5rem;
}

/* Skills Section - Mobile Horizontal Scroll with Arrows */
.skills-wrapper-mobile {
    position: relative;
    width: 100%;
}

.skill-scroll-btn, .project-scroll-btn {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    color: var(--primary-blue);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.skill-scroll-btn.prev, .project-scroll-btn.prev {
    left: 0;
}

.skill-scroll-btn.next, .project-scroll-btn.next {
    right: 0;
}

.skills-grid-cards {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1rem;
    padding-bottom: 1.5rem; /* مساحة للتمرير */
    margin: 0;
    width: 100%;
    scrollbar-width: none; /* إخفاء شريط التمرير لفايرفوكس */
    scroll-behavior: smooth;
}
.skills-grid-cards::-webkit-scrollbar { display: none; } /* لكروم وسفاري */

/* Projects Section - Mobile Horizontal Scroll (Carousel) */
.projects-wrapper-mobile {
    position: relative;
    width: 100%;
}

.projects-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1.5rem;
    scrollbar-width: none;
    scroll-behavior: smooth;
    padding-bottom: 1rem;
    margin: 0;
    width: 100%;
}
.projects-grid::-webkit-scrollbar { display: none; }

.form-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Hide Code Block on Mobile */
.about-code-block {
    display: none;
}

/* Image Responsiveness */
img {
    max-width: 100%;
    height: auto;
}

/* Typography Adjustments */
h1 { font-size: 1.8rem; }
h2 { font-size: 1.5rem; }

/* Skills Card - Mobile Adjustments */
.skill-card {
    padding: 1rem;
    min-width: 160px; /* عرض أصغر وأكثر تناسقاً للهاتف */
    scroll-snap-align: center; /* التركيز في المنتصف */
    scroll-snap-stop: always;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    background: rgba(30, 41, 59, 0.6);
    display: flex;
    flex-direction: column;
}

.skill-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.skill-title {
    font-size: 1rem;
}

/* Projects Card - Mobile Adjustments */
.project-card {
    min-width: 82vw; /* عرض يسمح برؤية حواف البطاقات المجاورة */
    scroll-snap-align: center;
    scroll-snap-stop: always;
    flex-shrink: 0;
}

.project-image {
    height: 200px; /* ارتفاع متناسق للصورة */
}

.project-info {
    padding: 1rem; /* تقليل الحواف الداخلية */
}

.project-info h3 {
    font-size: 1.2rem;
}

/* Services Grid - Mobile */
.services-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

/* Timeline - Mobile View */
.timeline {
    max-width: 100%;
    padding-left: 0;
}

.timeline::before {
    left: 15px; /* تقريب الخط للحافة لتوفير مساحة */
    transform: none;
}

.timeline-item {
    flex-direction: column !important;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-left: 40px; /* تقليل الهامش الداخلي */
    position: relative;
}

.timeline-item:nth-child(even) {
    flex-direction: column !important;
}

.timeline-date {
    margin-bottom: 0.5rem;
    text-align: left;
    padding: 0;
    display: block; /* Ensure visible on mobile if needed, or hide if preferred */
}

.timeline-content {
    width: 100%;
}

.timeline-content::before {
    left: -32px !important; /* ضبط موقع النقطة */
    right: auto !important;
    top: 24px; /* محاذاة مع عنوان المحتوى */
    width: 12px;
    height: 12px;
    transform: none;
}

/* Footer - Mobile View */
.footer-content {
    display: flex;
    flex-direction: column;
    text-align: center;
    gap: 2rem;
}

.footer-social-links {
    justify-content: center;
}

.footer-bottom {
    flex-direction: column;
    gap: 1rem;
}

/* Contact Page - Mobile View */
.contact-info-sidebar {
    position: static;
    width: 100%;
}

.contact-actions,
.contact-direct,
.about-actions,
.hero-actions,
.project-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.action-btn,
.direct-contact,
.project-btn {
    width: 100%;
    justify-content: center;
}

/* Hero Section - Mobile Adjustments */
.hero {
    padding: 120px 0 60px; /* Reduce padding on mobile */
    background-attachment: scroll; /* Better mobile performance */
}

.hero-text h1 {
    font-size: 2rem;
    margin-bottom: 15px;
}

.hero-text .subtitle {
    font-size: 1.2rem;
}

.hero-text p {
    font-size: 1rem;
}

/* RTL Adjustments for Mobile */
body[dir="rtl"] .timeline::before { right: 20px; left: auto; }
body[dir="rtl"] .timeline-item { padding-left: 0; padding-right: 40px; }
body[dir="rtl"] .timeline-date { text-align: right; }
body[dir="rtl"] .timeline-content::before { right: -32px !important; left: auto !important; }
body[dir="rtl"] .nav-list { padding-right: 0; }

/* Force Header to keep LTR layout (Logo Left, Toggle Right) in Arabic Mobile */
body[dir="rtl"] .main-header .container { flex-direction: row-reverse; }
body[dir="rtl"] .lang-switcher-wrapper { 
    margin-left: auto; 
    margin-right: 10px; 
}


/* =========================================
   2. Small Screens (Mobile Landscape - >= 576px)
   ========================================= */   
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }

    .steps-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Forms side-by-side */
    .form-row {
        flex-direction: row;
        gap: 20px;
    }
    
    .form-row .form-group {
        flex: 1;
    }

    /* Footer Grid on Tablet */
    .footer-content {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        text-align: left;
    }
    .footer-social-links {
        justify-content: flex-start;
    }

    h1 { font-size: 2.2rem; }

    /* Hero Adjustments */
    .hero {
        padding: 150px 0 80px;
    }

    .hero-text h1 {
        font-size: 2.8rem;
    }

    /* Adjust Cards for Mobile Landscape */
    .skill-card {
        min-width: 180px; /* أصغر قليلاً في الوضع الأفقي لعرض المزيد */
    }

    .project-card {
        min-width: 340px; /* عرض ثابت ومناسب للوضع الأفقي */
    }
    
    .project-image {
        height: 180px;
    }
    
    /* Services Grid - Tablet */
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =========================================
   3. Medium Screens (Tablets - >= 768px)
   ========================================= */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }

    /* Navbar - Desktop View */
    .nav-toggle {
        display: none !important; /* إخفاء زر القائمة بشكل قاطع في الديسك توب */
    }
    
    /* Hide Scroll Buttons on Desktop */
    .skill-scroll-btn, .project-scroll-btn {
        display: none;
    }
    
    /* Reset Wrappers to Block */
    .skills-wrapper-mobile,
    .projects-wrapper-mobile {
        display: block;
    }
    
    .skills-grid-cards {
        display: grid; /* Override flex */
        grid-template-columns: repeat(3, 1fr); /* 3 columns default */
        gap: 2rem;
        margin: 0;
        overflow-x: visible;
        width: auto; /* Reset width from 0 */
        flex: none; /* Reset flex */
        padding-bottom: 0;
        scroll-snap-type: none; /* Disable snap */
    }

    .lang-switcher-wrapper {
        margin-right: 0;
    }
    body[dir="rtl"] .lang-switcher-wrapper { margin-left: 0; }

    .main-nav {
        display: flex;
        width: auto;
        height: auto;
        position: static;
        background-color: transparent;
        box-shadow: none;
        padding: 0;
        max-height: none;
        overflow: visible;
        border: none;
        backdrop-filter: none;
        margin-left: auto;
        margin-right: 1.5rem;
        visibility: visible;
    }

    .main-nav.active {
        animation: none;
    }

    .nav-list {
        flex-direction: row;
        gap: 2rem; /* زيادة المسافة بين الروابط في الديسك توب */
    }

    .nav-link {
        padding: 0.5rem 1rem;
        border-bottom: none;
        font-size: 1rem;
        /* إلغاء أنماط الخلفية الخاصة بالموبايل ليكون التصميم أنظف */
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* تأثير الخط السفلي المتحرك */
    .nav-link::after {
        content: '';
        position: absolute;
        bottom: 5px;
        left: 50%;
        width: 0;
        height: 2px;
        background-color: var(--primary-blue);
        transition: all 0.3s ease;
        transform: translateX(-50%);
    }

    .nav-link:hover::after,
    .nav-link.active::after {
        width: 80%;
    }

    .nav-link:hover,
    .nav-link.active {
        color: var(--primary-blue);
        transform: translateY(-2px); /* رفعة بسيطة للنص */
        background: transparent !important;
    }

    /* RTL Adjustments for Desktop Nav */
    body[dir="rtl"] .main-nav {
        margin-left: 2rem;
        margin-right: auto;
    }

    /* Layouts - Horizontal */
    .hero-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .hero-text {
        width: 50%;
        padding-right: 2rem;
    }
    
    .hero-image-wrapper {
        width: 45%;
    }
    
    /* TeachHive Grid */
    .teachhive-content {
        display: grid;
        grid-template-columns: 2fr 3fr;
        align-items: start;
    }

    .about-code-block {
        display: flex;
    }
    
    .about-code-block code {
        font-size: 0.85rem; /* Slightly smaller font for tablets to fit better */
    }

    .about-code-block pre {
        white-space: pre-wrap;       /* يجعل النص يلتف للسطر التالي بدلاً من التمرير */
        word-wrap: break-word;       /* يكسر الكلمات الطويلة إذا لزم الأمر */
        overflow-x: visible;         /* يلغي شريط التمرير الأفقي */
    }

    .about-content {
        flex-direction: row;
        align-items: center;
    }
    
    /* If about has image, adjust widths. Assuming text is full width if no image div present in HTML structure provided, 
       but keeping flex-row for future proofing or if image is added */
    
    .contact-form-wrapper {
        flex-direction: row;
        gap: 4rem;
    }
    
    .contact-info-sidebar {
        width: 35%;
        position: sticky;
        top: 100px;
    }
    
    .contact-actions, 
    .contact-direct, 
    .about-actions, 
    .hero-actions, 
    .project-links {
        flex-direction: row;
    }
    
    .contact-form-wrapper form {
        width: 65%;
    }

    .skills-grid-cards {
        grid-template-columns: repeat(3, 1fr); /* 3 أعمدة للشاشات المتوسطة */
        gap: 2rem;
    }
    
    .projects-grid {
        grid-template-columns: repeat(2, 1fr); /* عمودين للشاشات المتوسطة لتجنب الازدحام */
        display: grid; /* Restore grid layout for desktop */
        overflow-x: visible;
        padding-bottom: 0;
        margin: 0;
        width: auto; /* Reset width from 0 */
        flex: none; /* Reset flex */
        scroll-snap-type: none;
    }

    /* Restore larger card styles for desktop */
    .skill-card {
        padding: 2.5rem 2rem;
        min-width: 0; /* Reset min-width to allow grid sizing */
    }

    .skill-icon {
        font-size: 4rem;
        margin-bottom: 1.5rem;
    }

    .project-card {
        min-width: 0; /* Reset min-width to allow grid sizing */
    }

    .skill-title {
        font-size: 1.5rem;
    }
    
    /* Footer Distribution - Desktop */
    .footer-content {
        grid-template-columns: 1.5fr 1fr 1fr; /* تحسين نسب أعمدة الفوتر */
        gap: 3rem;
    }

    /* Align Connect section to the end */
    .footer-section:last-child {
        text-align: end;
    }
    
    .footer-section:last-child .footer-social-links {
        justify-content: flex-end;
    }
    
    /* Timeline - Desktop View (Alternating) */
    .timeline::before {
        left: 50%;
        transform: translateX(-50%);
    }

    .timeline-item {
        flex-direction: row !important;
        align-items: center;
        padding-left: 0;
    }

    .timeline-item:nth-child(even) {
        flex-direction: row-reverse !important;
    }

    .timeline-date {
        text-align: center;
        padding: 0 2rem;
        margin-bottom: 0;
    }

    .timeline-content {
        width: auto;
    }
    
    .timeline-content::before {
        top: 50%;
        transform: translateY(-50%);
    }

    .timeline-item:nth-child(odd) .timeline-content::before {
        left: auto !important;
        right: -7.5px !important;
    }

    .timeline-item:nth-child(even) .timeline-content::before {
        left: -7.5px !important;
        right: auto !important;
    }
    
    /* RTL Desktop Adjustments */
    body[dir="rtl"] .timeline::before { right: 50%; left: auto; transform: translateX(50%); }
    body[dir="rtl"] .timeline-item { padding-right: 0; }
    body[dir="rtl"] .timeline-content::before { right: -7.5px !important; left: auto !important; }
    body[dir="rtl"] .timeline-item:nth-child(even) .timeline-content::before { right: auto !important; left: -7.5px !important; }
    
    .action-btn, 
    .direct-contact, 
    .project-btn {
        width: auto;
    }

    /* Services Grid - Desktop */
    .services-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Hero Adjustments */
    .hero {
        padding: 180px 0 100px;
        background-attachment: fixed;
    }

    .hero-text h1 {
        font-size: 3.5rem;
    }
}

/* =========================================
   4. Large Screens (Laptops - >= 992px)
   ========================================= */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }

    .hero-content {
        max-width: 960px;
    }

    .skills-grid-cards {
        grid-template-columns: repeat(4, 1fr); /* 4 أعمدة للمهارات في الشاشات الكبيرة */
    }

    .projects-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 أعمدة للمشاريع في الشاشات الكبيرة */
    }

    h1 { font-size: 3.5rem; }
}

/* =========================================
   5. Extra Large Screens (Desktops - >= 1200px)
   ========================================= */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* =========================================
   6. Huge Screens (Wide Screens - >= 1400px)
   ========================================= */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}
