/* 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; /* Distribute items evenly (Logo Left, Toggle Right) */
    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;
    margin: 0; /* Let justify-content handle spacing */
}

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

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

.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; }
.nav-list li:nth-child(6) { animation-delay: 0.6s; }
.nav-list li:nth-child(7) { animation-delay: 0.7s; } /* For Lang Switcher */

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    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);
}

/* Language Button - Mobile Specific */
.lang-btn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
    border-radius: 12px;
}

/* 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: none;
    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: grid;
    grid-template-columns: repeat(2, 1fr);
    overflow-x: visible;
    scroll-snap-type: none; /* Remove snap as we control scroll via JS */
    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: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    overflow: visible;
    padding-bottom: 1rem;
    margin: 0;
    width: 100%;
}

/* Show only 2 project cards on mobile and small screens */
.projects-grid .project-card:nth-child(n+3) {
    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: 0;
    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 {
    width: 100%;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.project-image {
    height: auto;
    aspect-ratio: 1/1; /* نسبة مربعة (1:1) لتتناسق مع باقي الموقع */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.project-info {
    padding: 1.5rem; /* مساحة مريحة للنص */
}

.project-info h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

/* 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: 20px; /* محاذاة مع منتصف عمود الأيقونة (40px) */
    transform: none;
}

.timeline-item {
    display: grid;
    grid-template-columns: 40px 1fr; /* الأيقونة يسار، المحتوى يمين */
    grid-template-rows: auto auto;
    gap: 0 15px;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    padding-left: 0;
    position: relative;
}

.timeline-item:nth-child(even) {
    /* Resetting flex direction for mobile grid layout */
}

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

.timeline-icon {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    top: 0;
    justify-self: center; /* Center horizontally in the grid column */
    width: 40px;
    height: 40px;
    font-size: 1rem;
    margin-top: 0;
    z-index: 2;
}

.timeline-item:hover .timeline-icon {
    transform: scale(1.1);
}

.timeline-content {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
}

/* 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;
}

/* Logo Wrapper Adjustment */
.logo-wrapper {
    margin: 0;
}

/* Small Mobile Adjustment */
@media (max-width: 380px) {
    .logo { font-size: 1.4rem; }
}

/* RTL Adjustments for Mobile */
body[dir="rtl"] .timeline::before { right: 20px; left: auto; }
body[dir="rtl"] .timeline-item { padding-left: 0; padding-right: 0; }
body[dir="rtl"] .timeline-date { text-align: right; }
body[dir="rtl"] .timeline-icon { right: auto; left: auto; justify-self: center; transform: none; }
body[dir="rtl"] .timeline-item:hover .timeline-icon {
    transform: scale(1.1);
}

body[dir="rtl"] .nav-list { padding-right: 0; }

body[dir="rtl"] .nav-toggle {
    margin: 0;
}


/* =========================================
   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: auto;
        aspect-ratio: 1/1;
    }
    
    /* 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 */
    .main-header .container {
        justify-content: flex-start;
        gap: 3rem;
    }
    .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 */
    }


    .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: 0;
        margin-right: 0;
        visibility: visible;
    }

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

    .nav-list {
        flex-direction: row;
        gap: 0.5rem;
    }

    .nav-link {
        padding: 0.5rem 0.8rem;
        border-bottom: none;
        font-size: 0.95rem;
        background: transparent;
        box-shadow: none;
        border: 1px solid transparent;
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: 0.6rem;
        border-radius: 50px;
        transition: all 0.3s ease;
    }

    .nav-link::after {
        display: none;
    }

    .nav-link:hover,
    .nav-link.active {
        color: var(--primary-blue);
        background: rgba(14, 165, 233, 0.1);
        border-color: rgba(14, 165, 233, 0.2);
        box-shadow: 0 0 15px rgba(14, 165, 233, 0.15);
        transform: translateY(-2px);
    }

    /* Language Button - Desktop Specific */
    .lang-btn {
        width: auto;
        margin-top: 0;
        padding: 0.5rem 1rem;
        margin-left: 1.5rem; /* Added spacing for desktop */
        border-radius: 50px;
    }

    /* RTL Adjustments for Desktop Nav */
    body[dir="rtl"] .main-nav {
        margin: 0;
    }
    /* RTL spacing for lang btn */
    body[dir="rtl"] .lang-btn { margin-left: 0; margin-right: 1.5rem; }

    /* 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;
    }

    /* Show all project cards on larger screens */
    .projects-grid .project-card:nth-child(n+3) {
        display: flex;
    }

    /* 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 {
        display: none; /* إخفاء الخط الأوسط لأن الأيقونات أصبحت على البطاقات */
    }

    .timeline-item {
        display: flex;
        flex-direction: row !important;
        align-items: flex-start;
        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-icon {
        position: absolute;
        top: -15px;
        transform: none;
    }

    /* Connector Line */
    .timeline-icon::after {
        content: '';
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        width: 2px;
        height: 15px;
        background: var(--primary-blue);
        z-index: -1;
    }

    /* LTR Positioning */
    .timeline-item:nth-child(odd) .timeline-icon { right: 2rem; left: auto; }
    .timeline-item:nth-child(even) .timeline-icon { left: 2rem; right: auto; }

    .timeline-item:hover .timeline-icon {
        transform: scale(1.1);
    }

    
    /* RTL Desktop Adjustments */
    body[dir="rtl"] .timeline::before { right: 50%; left: auto; transform: translateX(50%); }
    body[dir="rtl"] .timeline-item { padding-right: 0; }
    
    /* RTL Positioning */
    body[dir="rtl"] .timeline-item:nth-child(odd) .timeline-icon { left: 2rem; right: auto; }
    body[dir="rtl"] .timeline-item:nth-child(even) .timeline-icon { right: 2rem; left: auto; }
    
    body[dir="rtl"] .timeline-item:hover .timeline-icon { transform: scale(1.1); }
    
    .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;
    }
}
