/* ==============================
   HOME PROJECTS SECTION - MAIN PAGE
   ============================== */


/* القسم الرئيسي */

.home-projects {
    padding: clamp(60px, 10vw, 140px) 0;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    position: relative;
    overflow: hidden;
}


/* ضبط الهوامش الداخلية للحاوية لتقليل المسافة البيضاء */

.home-projects .container {
    padding-left: max(15px, 3vw);
    padding-right: max(15px, 3vw);
    max-width: 1400px;
    /* زيادة الحد الأقصى قليلاً لاستغلال المساحة */
}

@media (min-width: 1600px) {
    .home-projects .container {
        padding-left: 0;
        /* على الشاشات الكبيرة جداً نريد أن تتمدد الشبكة */
        padding-right: 0;
    }
}

.home-projects::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(0, 86, 179, 0.03) 0%, rgba(40, 167, 69, 0.03) 100%);
    pointer-events: none;
}


/* شبكة المشاريع - 3 أعمدة للشاشات الكبيرة، عمود واحد للجوال */

.home-projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
    gap: clamp(15px, 3vw, 20px);
    margin-bottom: clamp(30px, 5vw, 40px);
}


/* بطاقة المشروع */

.home-project-item {
    position: relative;
    overflow: hidden;
    border-radius: clamp(15px, 2vw, 20px);
    aspect-ratio: 16 / 9;
    min-height: 240px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    background: #ffffff;
    cursor: pointer;
    width: 100%;
    /* التأكد من أن البطاقة تأخذ العرض الكامل */
}


/* تحسين التفاعل مع البطاقة (لأجهزة اللمس) */

@media (hover: hover) {
    .home-project-item:hover {
        transform: translateY(-10px) scale(1.02);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    }
    .home-project-item:hover img {
        transform: scale(1.1);
    }
    .home-project-item:hover .home-video-icon {
        color: #28a745;
        transform: translate(-50%, -50%) scale(1.2);
        text-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
}


/* للجوال: تأثير اللمس */

@media (max-width: 768px) {
    .home-project-item:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}


/* الصورة */

.home-project-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}


/* معلومات المشروع (الوصف) */

.home-project-info {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    background: linear-gradient(135deg, rgba(0, 86, 179, 0.95) 0%, rgba(40, 167, 69, 0.95) 100%);
    color: #ffffff;
    padding: clamp(15px, 3vw, 30px);
    transform: translateY(0);
    transition: all 0.3s ease;
    border-top: 2px solid rgba(255, 215, 0, 0.3);
    backdrop-filter: blur(2px);
}


/* تحسين ظهور النص على الجوال */

@media (max-width: 480px) {
    .home-project-info {
        padding: 12px;
    }
}

.home-project-info h3 {
    font-size: clamp(1rem, 4vw, 1.4rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.3;
}

.home-project-description {
    font-size: clamp(0.8rem, 3vw, 1rem);
    line-height: 1.5;
    margin-bottom: 0.8rem;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}


/* تفاصيل إضافية (مثل المساحة ودرجة الحرارة) */

.home-project-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0.5rem;
}

.home-detail-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: clamp(0.7rem, 2.5vw, 0.85rem);
    font-weight: 600;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}


/* للجوال: تكبير منطقة اللمس للتفاصيل */

@media (max-width: 768px) {
    .home-detail-item {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}


/* أيقونة الفيديو - مثلث نبّاض */

.home-video-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(50px, 15vw, 80px);
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 2;
    animation: homePulseTriangle 2s infinite;
}


/* تأثير النبض للمثلث */

@keyframes homePulseTriangle {
    0% {
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1);
        text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.15);
        text-shadow: 0 0 40px rgba(255, 255, 255, 0.8), 0 0 20px rgba(0, 0, 0, 0.5);
    }
    100% {
        opacity: 0.9;
        transform: translate(-50%, -50%) scale(1);
        text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    }
}


/* للجوال: تقليل شدة النبض */

@media (max-width: 768px) {
    @keyframes homePulseTriangle {
        50% {
            transform: translate(-50%, -50%) scale(1.1);
        }
    }
}


/* المشاريع المخفية */

.home-project-item.hidden {
    display: none;
}

.home-project-item.show {
    display: block;
}


/* أزرار التحكم - محسنة للجوال */

.home-projects-buttons {
    text-align: center;
    margin-top: 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.home-projects-buttons button {
    background: #0056b3;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(0, 86, 179, 0.3);
    min-width: 140px;
    touch-action: manipulation;
}


/* تحسين حجم الأزرار للجوال */

@media (max-width: 768px) {
    .home-projects-buttons {
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    .home-projects-buttons button {
        width: 100%;
        max-width: 280px;
        padding: 14px 20px;
        font-size: 1.1rem;
        margin: 0;
    }
}

.home-projects-buttons button:hover {
    background: #004494;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 86, 179, 0.4);
}

.home-projects-buttons button:active {
    transform: translateY(0);
    transition: transform 0.1s;
}

.home-projects-buttons button.hide-btn {
    background: #555;
}

.home-projects-buttons button.hide-btn:hover {
    background: #333;
}


/* مودال الفيديو - محسن للجوال */

.home-video-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
    padding: 10px;
}

.home-video-modal-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: auto;
    aspect-ratio: 9 / 16;
    max-height: 80vh;
    background: #000;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.home-video-modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 14px;
}

.home-close-video {
    position: absolute;
    top: -45px;
    right: 0;
    font-size: 36px;
    color: #fff;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 10px 15px;
    line-height: 1;
    transition: all 0.2s ease;
    z-index: 10000;
    touch-action: manipulation;
}


/* تكبير منطقة إغلاق المودال للجوال */

@media (max-width: 768px) {
    .home-close-video {
        top: -50px;
        font-size: 42px;
        padding: 10px 20px;
    }
}

.home-close-video:active {
    color: #28a745;
    transform: scale(0.95);
}


/* رسالة خطأ الفيديو */

.home-video-error {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 14px;
}

.home-video-error p {
    margin-bottom: 20px;
    font-size: 1rem;
}

.home-video-error a {
    color: #28a745;
    text-decoration: underline;
    font-weight: 600;
    font-size: 1rem;
    padding: 8px 16px;
    touch-action: manipulation;
}


/* تحسينات إضافية للشاشات الصغيرة جداً */

@media (max-width: 380px) {
    .home-project-info h3 {
        font-size: 0.95rem;
    }
    .home-project-description {
        font-size: 0.75rem;
    }
    .home-detail-item {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
    .home-video-icon {
        font-size: 45px;
    }
}


/* تحسين الوصولية */

.home-project-item:focus-visible,
.home-projects-buttons button:focus-visible,
.home-close-video:focus-visible {
    outline: 3px solid #28a745;
    outline-offset: 3px;
}


/* تفضيلات الحركة المخفضة */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}